blob: bc17a96a7945b33c26934f56dd0a5e97c7a6d971 [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 Avdoninbab282b2006-08-22 13:31:58 +0200218 ALC883_ACER,
Tobin Davis2880a8672007-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,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200223 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200224 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200225 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100226 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200227 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200228 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200229 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200230 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200231 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200232 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100233 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100234 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100235 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100236 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800237 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200238 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200239 ALC889A_INTEL,
240 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200241 ALC888_ASUS_M90V,
242 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200243 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100244 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200245 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200246 ALC882_AUTO,
247 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200248};
249
Kailang Yangdf694da2005-12-05 19:42:22 +0100250/* for GPIO Poll */
251#define GPIO_MASK 0x03
252
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200253/* extra amp-initialization sequence types */
254enum {
255 ALC_INIT_NONE,
256 ALC_INIT_DEFAULT,
257 ALC_INIT_GPIO1,
258 ALC_INIT_GPIO2,
259 ALC_INIT_GPIO3,
260};
261
Takashi Iwai6c819492009-08-10 18:47:44 +0200262struct alc_mic_route {
263 hda_nid_t pin;
264 unsigned char mux_idx;
265 unsigned char amix_idx;
266};
267
268#define MUX_IDX_UNDEF ((unsigned char)-1)
269
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270struct alc_spec {
271 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100272 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100274 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100275 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276
Kailang Yangdf694da2005-12-05 19:42:22 +0100277 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200278 * don't forget NULL
279 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200280 */
281 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200283 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284 struct hda_pcm_stream *stream_analog_playback;
285 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100286 struct hda_pcm_stream *stream_analog_alt_playback;
287 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200289 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290 struct hda_pcm_stream *stream_digital_playback;
291 struct hda_pcm_stream *stream_digital_capture;
292
293 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200294 struct hda_multi_out multiout; /* playback set-up
295 * max_channels, dacs must be set
296 * dig_out_nid and hp_nid are optional
297 */
Takashi Iwai63300792008-01-24 15:31:36 +0100298 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100299 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100300 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301
302 /* capture */
303 unsigned int num_adc_nids;
304 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100305 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200306 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307
308 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200309 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310 const struct hda_input_mux *input_mux;
311 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200312 struct alc_mic_route ext_mic;
313 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314
315 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100316 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200318 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200319 int const_channel_count;
320 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321
322 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100323 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200324
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200325 /* dynamic controls, init_verbs and input_mux */
326 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200327 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200328 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200329 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200330 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
331 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100332
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100333 /* hooks */
334 void (*init_hook)(struct hda_codec *codec);
335 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
336
Takashi Iwai834be882006-03-01 14:16:17 +0100337 /* for pin sensing */
338 unsigned int sense_updated: 1;
339 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100340 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200341 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200342
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100343 /* other flags */
344 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200345 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100346
Takashi Iwai2134ea42008-01-10 16:53:55 +0100347 /* for virtual master */
348 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200349#ifdef CONFIG_SND_HDA_POWER_SAVE
350 struct hda_loopback_check loopback;
351#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200352
353 /* for PLL fix */
354 hda_nid_t pll_nid;
355 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100356};
357
358/*
359 * configuration template - to be copied to the spec instance
360 */
361struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200362 struct snd_kcontrol_new *mixers[5]; /* should be identical size
363 * with spec
364 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100365 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100366 const struct hda_verb *init_verbs[5];
367 unsigned int num_dacs;
368 hda_nid_t *dac_nids;
369 hda_nid_t dig_out_nid; /* optional */
370 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800371 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100372 unsigned int num_adc_nids;
373 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100374 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100375 hda_nid_t dig_in_nid;
376 unsigned int num_channel_mode;
377 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200378 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200379 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200380 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100381 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100382 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200383 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100384 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200385#ifdef CONFIG_SND_HDA_POWER_SAVE
386 struct hda_amp_list *loopbacks;
387#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388};
389
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390
391/*
392 * input MUX handling
393 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200394static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
395 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396{
397 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
398 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200399 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
400 if (mux_idx >= spec->num_mux_defs)
401 mux_idx = 0;
402 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403}
404
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200405static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
406 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407{
408 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
409 struct alc_spec *spec = codec->spec;
410 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
411
412 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
413 return 0;
414}
415
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200416static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
417 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418{
419 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
420 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100421 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100423 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100424 hda_nid_t nid = spec->capsrc_nids ?
425 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200426 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427
Takashi Iwaicd896c32008-11-18 12:36:33 +0100428 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
429 imux = &spec->input_mux[mux_idx];
430
Takashi Iwaia22d5432009-07-27 12:54:26 +0200431 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200432 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100433 /* Matrix-mixer style (e.g. ALC882) */
434 unsigned int *cur_val = &spec->cur_mux[adc_idx];
435 unsigned int i, idx;
436
437 idx = ucontrol->value.enumerated.item[0];
438 if (idx >= imux->num_items)
439 idx = imux->num_items - 1;
440 if (*cur_val == idx)
441 return 0;
442 for (i = 0; i < imux->num_items; i++) {
443 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
444 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
445 imux->items[i].index,
446 HDA_AMP_MUTE, v);
447 }
448 *cur_val = idx;
449 return 1;
450 } else {
451 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100452 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100453 &spec->cur_mux[adc_idx]);
454 }
455}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200456
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457/*
458 * channel mode setting
459 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200460static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
461 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462{
463 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
464 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100465 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
466 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467}
468
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200469static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
470 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471{
472 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
473 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100474 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200475 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200476 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477}
478
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200479static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
480 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481{
482 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
483 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200484 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
485 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200486 &spec->ext_channel_count);
487 if (err >= 0 && !spec->const_channel_count) {
488 spec->multiout.max_channels = spec->ext_channel_count;
489 if (spec->need_dac_fix)
490 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
491 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200492 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493}
494
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100496 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200497 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100498 * being part of a format specifier. Maximum allowed length of a value is
499 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100500 *
501 * Note: some retasking pin complexes seem to ignore requests for input
502 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
503 * are requested. Therefore order this list so that this behaviour will not
504 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200505 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
506 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200507 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100508static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100509 "Mic 50pc bias", "Mic 80pc bias",
510 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100511};
512static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100513 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100514};
515/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200516 * in the pin being assumed to be exclusively an input or an output pin. In
517 * addition, "input" pins may or may not process the mic bias option
518 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
519 * accept requests for bias as of chip versions up to March 2006) and/or
520 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100521 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200522#define ALC_PIN_DIR_IN 0x00
523#define ALC_PIN_DIR_OUT 0x01
524#define ALC_PIN_DIR_INOUT 0x02
525#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
526#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100527
Kailang Yangea1fb292008-08-26 12:58:38 +0200528/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100529 * For each direction the minimum and maximum values are given.
530 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200531static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100532 { 0, 2 }, /* ALC_PIN_DIR_IN */
533 { 3, 4 }, /* ALC_PIN_DIR_OUT */
534 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200535 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
536 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100537};
538#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
539#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
540#define alc_pin_mode_n_items(_dir) \
541 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
542
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200543static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
544 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200545{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100546 unsigned int item_num = uinfo->value.enumerated.item;
547 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
548
549 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200550 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100551 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
552
553 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
554 item_num = alc_pin_mode_min(dir);
555 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200556 return 0;
557}
558
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200559static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
560 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200561{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100562 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200563 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
564 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100565 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200566 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200567 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
568 AC_VERB_GET_PIN_WIDGET_CONTROL,
569 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200570
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100571 /* Find enumerated value for current pinctl setting */
572 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200573 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100574 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200575 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100576 return 0;
577}
578
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200579static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
580 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100581{
582 signed int change;
583 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
584 hda_nid_t nid = kcontrol->private_value & 0xffff;
585 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
586 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200587 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
588 AC_VERB_GET_PIN_WIDGET_CONTROL,
589 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100590
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200591 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100592 val = alc_pin_mode_min(dir);
593
594 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100595 if (change) {
596 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200597 snd_hda_codec_write_cache(codec, nid, 0,
598 AC_VERB_SET_PIN_WIDGET_CONTROL,
599 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100600
Kailang Yangea1fb292008-08-26 12:58:38 +0200601 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100602 * for the requested pin mode. Enum values of 2 or less are
603 * input modes.
604 *
605 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200606 * reduces noise slightly (particularly on input) so we'll
607 * do it. However, having both input and output buffers
608 * enabled simultaneously doesn't seem to be problematic if
609 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100610 */
611 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200612 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
613 HDA_AMP_MUTE, HDA_AMP_MUTE);
614 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
615 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100616 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200617 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
618 HDA_AMP_MUTE, HDA_AMP_MUTE);
619 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
620 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100621 }
622 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200623 return change;
624}
625
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100626#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200627 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100628 .info = alc_pin_mode_info, \
629 .get = alc_pin_mode_get, \
630 .put = alc_pin_mode_put, \
631 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100632
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100633/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
634 * together using a mask with more than one bit set. This control is
635 * currently used only by the ALC260 test model. At this stage they are not
636 * needed for any "production" models.
637 */
638#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200639#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200640
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200641static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
642 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100643{
644 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
645 hda_nid_t nid = kcontrol->private_value & 0xffff;
646 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
647 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200648 unsigned int val = snd_hda_codec_read(codec, nid, 0,
649 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100650
651 *valp = (val & mask) != 0;
652 return 0;
653}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200654static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
655 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100656{
657 signed int change;
658 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
659 hda_nid_t nid = kcontrol->private_value & 0xffff;
660 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
661 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200662 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
663 AC_VERB_GET_GPIO_DATA,
664 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100665
666 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200667 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
668 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100669 gpio_data &= ~mask;
670 else
671 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200672 snd_hda_codec_write_cache(codec, nid, 0,
673 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100674
675 return change;
676}
677#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
678 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
679 .info = alc_gpio_data_info, \
680 .get = alc_gpio_data_get, \
681 .put = alc_gpio_data_put, \
682 .private_value = nid | (mask<<16) }
683#endif /* CONFIG_SND_DEBUG */
684
Jonathan Woithe92621f12006-02-28 11:47:47 +0100685/* A switch control to allow the enabling of the digital IO pins on the
686 * ALC260. This is incredibly simplistic; the intention of this control is
687 * to provide something in the test model allowing digital outputs to be
688 * identified if present. If models are found which can utilise these
689 * outputs a more complete mixer control can be devised for those models if
690 * necessary.
691 */
692#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200693#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200694
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200695static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
696 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100697{
698 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
699 hda_nid_t nid = kcontrol->private_value & 0xffff;
700 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
701 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200702 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100703 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100704
705 *valp = (val & mask) != 0;
706 return 0;
707}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200708static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
709 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100710{
711 signed int change;
712 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
713 hda_nid_t nid = kcontrol->private_value & 0xffff;
714 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
715 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200716 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100717 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200718 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100719
720 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200721 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100722 if (val==0)
723 ctrl_data &= ~mask;
724 else
725 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200726 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
727 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100728
729 return change;
730}
731#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
732 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
733 .info = alc_spdif_ctrl_info, \
734 .get = alc_spdif_ctrl_get, \
735 .put = alc_spdif_ctrl_put, \
736 .private_value = nid | (mask<<16) }
737#endif /* CONFIG_SND_DEBUG */
738
Jonathan Woithef8225f62008-01-08 12:16:54 +0100739/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
740 * Again, this is only used in the ALC26x test models to help identify when
741 * the EAPD line must be asserted for features to work.
742 */
743#ifdef CONFIG_SND_DEBUG
744#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
745
746static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
747 struct snd_ctl_elem_value *ucontrol)
748{
749 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
750 hda_nid_t nid = kcontrol->private_value & 0xffff;
751 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
752 long *valp = ucontrol->value.integer.value;
753 unsigned int val = snd_hda_codec_read(codec, nid, 0,
754 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
755
756 *valp = (val & mask) != 0;
757 return 0;
758}
759
760static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
761 struct snd_ctl_elem_value *ucontrol)
762{
763 int change;
764 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
765 hda_nid_t nid = kcontrol->private_value & 0xffff;
766 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
767 long val = *ucontrol->value.integer.value;
768 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
769 AC_VERB_GET_EAPD_BTLENABLE,
770 0x00);
771
772 /* Set/unset the masked control bit(s) as needed */
773 change = (!val ? 0 : mask) != (ctrl_data & mask);
774 if (!val)
775 ctrl_data &= ~mask;
776 else
777 ctrl_data |= mask;
778 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
779 ctrl_data);
780
781 return change;
782}
783
784#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
785 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
786 .info = alc_eapd_ctrl_info, \
787 .get = alc_eapd_ctrl_get, \
788 .put = alc_eapd_ctrl_put, \
789 .private_value = nid | (mask<<16) }
790#endif /* CONFIG_SND_DEBUG */
791
Kailang Yangdf694da2005-12-05 19:42:22 +0100792/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100793 * set up the input pin config (depending on the given auto-pin type)
794 */
795static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
796 int auto_pin_type)
797{
798 unsigned int val = PIN_IN;
799
800 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
801 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100802 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100803 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
804 if (pincap & AC_PINCAP_VREF_80)
805 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200806 else if (pincap & AC_PINCAP_VREF_50)
807 val = PIN_VREF50;
808 else if (pincap & AC_PINCAP_VREF_100)
809 val = PIN_VREF100;
810 else if (pincap & AC_PINCAP_VREF_GRD)
811 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100812 }
813 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
814}
815
816/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100817 */
818static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
819{
820 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
821 return;
822 spec->mixers[spec->num_mixers++] = mix;
823}
824
825static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
826{
827 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
828 return;
829 spec->init_verbs[spec->num_init_verbs++] = verb;
830}
831
Takashi Iwaidaead532008-11-28 12:55:36 +0100832#ifdef CONFIG_PROC_FS
833/*
834 * hook for proc
835 */
836static void print_realtek_coef(struct snd_info_buffer *buffer,
837 struct hda_codec *codec, hda_nid_t nid)
838{
839 int coeff;
840
841 if (nid != 0x20)
842 return;
843 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
844 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
845 coeff = snd_hda_codec_read(codec, nid, 0,
846 AC_VERB_GET_COEF_INDEX, 0);
847 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
848}
849#else
850#define print_realtek_coef NULL
851#endif
852
Takashi Iwaid88897e2008-10-31 15:01:37 +0100853/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100854 * set up from the preset table
855 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200856static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200857 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100858{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200859 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100860 int i;
861
862 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100863 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100864 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200865 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
866 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100867 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200868
Kailang Yangdf694da2005-12-05 19:42:22 +0100869 spec->channel_mode = preset->channel_mode;
870 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200871 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200872 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100873
Hector Martin3b315d72009-06-02 10:54:19 +0200874 if (preset->const_channel_count)
875 spec->multiout.max_channels = preset->const_channel_count;
876 else
877 spec->multiout.max_channels = spec->channel_mode[0].channels;
878 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100879
880 spec->multiout.num_dacs = preset->num_dacs;
881 spec->multiout.dac_nids = preset->dac_nids;
882 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800883 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100884 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200885
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200886 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200887 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200888 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100889 spec->input_mux = preset->input_mux;
890
891 spec->num_adc_nids = preset->num_adc_nids;
892 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100893 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100894 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100895
896 spec->unsol_event = preset->unsol_event;
897 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200898#ifdef CONFIG_SND_HDA_POWER_SAVE
899 spec->loopback.amplist = preset->loopbacks;
900#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200901
902 if (preset->setup)
903 preset->setup(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100904}
905
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200906/* Enable GPIO mask and set output */
907static struct hda_verb alc_gpio1_init_verbs[] = {
908 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
909 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
910 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
911 { }
912};
913
914static struct hda_verb alc_gpio2_init_verbs[] = {
915 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
916 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
917 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
918 { }
919};
920
Kailang Yangbdd148a2007-05-08 15:19:08 +0200921static struct hda_verb alc_gpio3_init_verbs[] = {
922 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
923 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
924 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
925 { }
926};
927
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200928/*
929 * Fix hardware PLL issue
930 * On some codecs, the analog PLL gating control must be off while
931 * the default value is 1.
932 */
933static void alc_fix_pll(struct hda_codec *codec)
934{
935 struct alc_spec *spec = codec->spec;
936 unsigned int val;
937
938 if (!spec->pll_nid)
939 return;
940 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
941 spec->pll_coef_idx);
942 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
943 AC_VERB_GET_PROC_COEF, 0);
944 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
945 spec->pll_coef_idx);
946 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
947 val & ~(1 << spec->pll_coef_bit));
948}
949
950static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
951 unsigned int coef_idx, unsigned int coef_bit)
952{
953 struct alc_spec *spec = codec->spec;
954 spec->pll_nid = nid;
955 spec->pll_coef_idx = coef_idx;
956 spec->pll_coef_bit = coef_bit;
957 alc_fix_pll(codec);
958}
959
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200960static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200961{
962 struct alc_spec *spec = codec->spec;
Takashi Iwai261c2402009-06-25 08:13:40 +0200963 unsigned int present, pincap;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200964 unsigned int nid = spec->autocfg.hp_pins[0];
965 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200966
Takashi Iwai261c2402009-06-25 08:13:40 +0200967 pincap = snd_hda_query_pin_caps(codec, nid);
968 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
969 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200970 present = snd_hda_codec_read(codec, nid, 0,
Kailang Yangc9b58002007-10-16 14:30:01 +0200971 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200972 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
973 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
974 nid = spec->autocfg.speaker_pins[i];
975 if (!nid)
976 break;
977 snd_hda_codec_write(codec, nid, 0,
978 AC_VERB_SET_PIN_WIDGET_CONTROL,
979 spec->jack_present ? 0 : PIN_OUT);
980 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200981}
982
Takashi Iwai6c819492009-08-10 18:47:44 +0200983static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
984 hda_nid_t nid)
985{
986 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
987 int i, nums;
988
989 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
990 for (i = 0; i < nums; i++)
991 if (conn[i] == nid)
992 return i;
993 return -1;
994}
995
Kailang Yang7fb0d782008-10-15 11:12:35 +0200996static void alc_mic_automute(struct hda_codec *codec)
997{
998 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +0200999 struct alc_mic_route *dead, *alive;
1000 unsigned int present, type;
1001 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001002
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001003 if (!spec->auto_mic)
1004 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001005 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1006 return;
1007 if (snd_BUG_ON(!spec->adc_nids))
1008 return;
1009
1010 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1011
1012 present = snd_hda_codec_read(codec, spec->ext_mic.pin, 0,
1013 AC_VERB_GET_PIN_SENSE, 0);
1014 present &= AC_PINSENSE_PRESENCE;
1015 if (present) {
1016 alive = &spec->ext_mic;
1017 dead = &spec->int_mic;
1018 } else {
1019 alive = &spec->int_mic;
1020 dead = &spec->ext_mic;
1021 }
1022
Takashi Iwai6c819492009-08-10 18:47:44 +02001023 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1024 if (type == AC_WID_AUD_MIX) {
1025 /* Matrix-mixer style (e.g. ALC882) */
1026 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1027 alive->mux_idx,
1028 HDA_AMP_MUTE, 0);
1029 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1030 dead->mux_idx,
1031 HDA_AMP_MUTE, HDA_AMP_MUTE);
1032 } else {
1033 /* MUX style (e.g. ALC880) */
1034 snd_hda_codec_write_cache(codec, cap_nid, 0,
1035 AC_VERB_SET_CONNECT_SEL,
1036 alive->mux_idx);
1037 }
1038
1039 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001040}
1041
Kailang Yangc9b58002007-10-16 14:30:01 +02001042/* unsolicited event for HP jack sensing */
1043static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1044{
1045 if (codec->vendor_id == 0x10ec0880)
1046 res >>= 28;
1047 else
1048 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001049 switch (res) {
1050 case ALC880_HP_EVENT:
1051 alc_automute_pin(codec);
1052 break;
1053 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001054 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001055 break;
1056 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001057}
1058
1059static void alc_inithook(struct hda_codec *codec)
1060{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001061 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001062 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001063}
1064
Kailang Yangf9423e72008-05-27 12:32:25 +02001065/* additional initialization for ALC888 variants */
1066static void alc888_coef_init(struct hda_codec *codec)
1067{
1068 unsigned int tmp;
1069
1070 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1071 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1072 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001073 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001074 /* alc888S-VC */
1075 snd_hda_codec_read(codec, 0x20, 0,
1076 AC_VERB_SET_PROC_COEF, 0x830);
1077 else
1078 /* alc888-VB */
1079 snd_hda_codec_read(codec, 0x20, 0,
1080 AC_VERB_SET_PROC_COEF, 0x3030);
1081}
1082
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001083static void alc889_coef_init(struct hda_codec *codec)
1084{
1085 unsigned int tmp;
1086
1087 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1088 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1089 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1090 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1091}
1092
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001093static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001094{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001095 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001096
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001097 switch (type) {
1098 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001099 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1100 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001101 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001102 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1103 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001104 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001105 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1106 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001107 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001108 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001109 case 0x10ec0260:
1110 snd_hda_codec_write(codec, 0x0f, 0,
1111 AC_VERB_SET_EAPD_BTLENABLE, 2);
1112 snd_hda_codec_write(codec, 0x10, 0,
1113 AC_VERB_SET_EAPD_BTLENABLE, 2);
1114 break;
1115 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001116 case 0x10ec0267:
1117 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001118 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001119 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001120 case 0x10ec0660:
1121 case 0x10ec0662:
1122 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001123 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001124 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001125 snd_hda_codec_write(codec, 0x14, 0,
1126 AC_VERB_SET_EAPD_BTLENABLE, 2);
1127 snd_hda_codec_write(codec, 0x15, 0,
1128 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001129 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001130 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001131 switch (codec->vendor_id) {
1132 case 0x10ec0260:
1133 snd_hda_codec_write(codec, 0x1a, 0,
1134 AC_VERB_SET_COEF_INDEX, 7);
1135 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1136 AC_VERB_GET_PROC_COEF, 0);
1137 snd_hda_codec_write(codec, 0x1a, 0,
1138 AC_VERB_SET_COEF_INDEX, 7);
1139 snd_hda_codec_write(codec, 0x1a, 0,
1140 AC_VERB_SET_PROC_COEF,
1141 tmp | 0x2010);
1142 break;
1143 case 0x10ec0262:
1144 case 0x10ec0880:
1145 case 0x10ec0882:
1146 case 0x10ec0883:
1147 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001148 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001149 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001150 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001151 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001152 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001153 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001154 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001155 case 0x10ec0267:
1156 case 0x10ec0268:
1157 snd_hda_codec_write(codec, 0x20, 0,
1158 AC_VERB_SET_COEF_INDEX, 7);
1159 tmp = snd_hda_codec_read(codec, 0x20, 0,
1160 AC_VERB_GET_PROC_COEF, 0);
1161 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001162 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001163 snd_hda_codec_write(codec, 0x20, 0,
1164 AC_VERB_SET_PROC_COEF,
1165 tmp | 0x3000);
1166 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001167 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001168 break;
1169 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001170}
Kailang Yangea1fb292008-08-26 12:58:38 +02001171
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001172static void alc_init_auto_hp(struct hda_codec *codec)
1173{
1174 struct alc_spec *spec = codec->spec;
1175
1176 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001177 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001178
Kailang Yangc9b58002007-10-16 14:30:01 +02001179 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001180 if (spec->autocfg.line_out_pins[0] &&
1181 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001182 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001183 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001184 else
1185 return;
1186 }
1187
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001188 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1189 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001190 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1191 AC_VERB_SET_UNSOLICITED_ENABLE,
1192 AC_USRSP_EN | ALC880_HP_EVENT);
1193 spec->unsol_event = alc_sku_unsol_event;
1194}
1195
Takashi Iwai6c819492009-08-10 18:47:44 +02001196static void alc_init_auto_mic(struct hda_codec *codec)
1197{
1198 struct alc_spec *spec = codec->spec;
1199 struct auto_pin_cfg *cfg = &spec->autocfg;
1200 hda_nid_t fixed, ext;
1201 int i;
1202
1203 /* there must be only two mic inputs exclusively */
1204 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1205 if (cfg->input_pins[i])
1206 return;
1207
1208 fixed = ext = 0;
1209 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1210 hda_nid_t nid = cfg->input_pins[i];
1211 unsigned int defcfg;
1212 if (!nid)
1213 return;
1214 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1215 switch (get_defcfg_connect(defcfg)) {
1216 case AC_JACK_PORT_FIXED:
1217 if (fixed)
1218 return; /* already occupied */
1219 fixed = nid;
1220 break;
1221 case AC_JACK_PORT_COMPLEX:
1222 if (ext)
1223 return; /* already occupied */
1224 ext = nid;
1225 break;
1226 default:
1227 return; /* invalid entry */
1228 }
1229 }
1230 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1231 return; /* no unsol support */
1232 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1233 ext, fixed);
1234 spec->ext_mic.pin = ext;
1235 spec->int_mic.pin = fixed;
1236 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1237 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1238 spec->auto_mic = 1;
1239 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1240 AC_VERB_SET_UNSOLICITED_ENABLE,
1241 AC_USRSP_EN | ALC880_MIC_EVENT);
1242 spec->unsol_event = alc_sku_unsol_event;
1243}
1244
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001245/* check subsystem ID and set up device-specific initialization;
1246 * return 1 if initialized, 0 if invalid SSID
1247 */
1248/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1249 * 31 ~ 16 : Manufacture ID
1250 * 15 ~ 8 : SKU ID
1251 * 7 ~ 0 : Assembly ID
1252 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1253 */
1254static int alc_subsystem_id(struct hda_codec *codec,
1255 hda_nid_t porta, hda_nid_t porte,
1256 hda_nid_t portd)
1257{
1258 unsigned int ass, tmp, i;
1259 unsigned nid;
1260 struct alc_spec *spec = codec->spec;
1261
1262 ass = codec->subsystem_id & 0xffff;
1263 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1264 goto do_sku;
1265
1266 /* invalid SSID, check the special NID pin defcfg instead */
1267 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001268 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001269 * 29~21 : reserve
1270 * 20 : PCBEEP input
1271 * 19~16 : Check sum (15:1)
1272 * 15~1 : Custom
1273 * 0 : override
1274 */
1275 nid = 0x1d;
1276 if (codec->vendor_id == 0x10ec0260)
1277 nid = 0x17;
1278 ass = snd_hda_codec_get_pincfg(codec, nid);
1279 snd_printd("realtek: No valid SSID, "
1280 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001281 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001282 if (!(ass & 1) && !(ass & 0x100000))
1283 return 0;
1284 if ((ass >> 30) != 1) /* no physical connection */
1285 return 0;
1286
1287 /* check sum */
1288 tmp = 0;
1289 for (i = 1; i < 16; i++) {
1290 if ((ass >> i) & 1)
1291 tmp++;
1292 }
1293 if (((ass >> 16) & 0xf) != tmp)
1294 return 0;
1295do_sku:
1296 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1297 ass & 0xffff, codec->vendor_id);
1298 /*
1299 * 0 : override
1300 * 1 : Swap Jack
1301 * 2 : 0 --> Desktop, 1 --> Laptop
1302 * 3~5 : External Amplifier control
1303 * 7~6 : Reserved
1304 */
1305 tmp = (ass & 0x38) >> 3; /* external Amp control */
1306 switch (tmp) {
1307 case 1:
1308 spec->init_amp = ALC_INIT_GPIO1;
1309 break;
1310 case 3:
1311 spec->init_amp = ALC_INIT_GPIO2;
1312 break;
1313 case 7:
1314 spec->init_amp = ALC_INIT_GPIO3;
1315 break;
1316 case 5:
1317 spec->init_amp = ALC_INIT_DEFAULT;
1318 break;
1319 }
1320
1321 /* is laptop or Desktop and enable the function "Mute internal speaker
1322 * when the external headphone out jack is plugged"
1323 */
1324 if (!(ass & 0x8000))
1325 return 1;
1326 /*
1327 * 10~8 : Jack location
1328 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1329 * 14~13: Resvered
1330 * 15 : 1 --> enable the function "Mute internal speaker
1331 * when the external headphone out jack is plugged"
1332 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001333 if (!spec->autocfg.hp_pins[0]) {
1334 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1335 if (tmp == 0)
1336 spec->autocfg.hp_pins[0] = porta;
1337 else if (tmp == 1)
1338 spec->autocfg.hp_pins[0] = porte;
1339 else if (tmp == 2)
1340 spec->autocfg.hp_pins[0] = portd;
1341 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001342 return 1;
Kailang Yangc9b58002007-10-16 14:30:01 +02001343 }
1344
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001345 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001346 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001347 return 1;
1348}
Kailang Yangea1fb292008-08-26 12:58:38 +02001349
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001350static void alc_ssid_check(struct hda_codec *codec,
1351 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1352{
1353 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1354 struct alc_spec *spec = codec->spec;
1355 snd_printd("realtek: "
1356 "Enable default setup for auto mode as fallback\n");
1357 spec->init_amp = ALC_INIT_DEFAULT;
1358 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001359 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001360 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001361}
1362
Takashi Iwai41e41f12005-06-08 14:48:49 +02001363/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001364 * Fix-up pin default configurations
1365 */
1366
1367struct alc_pincfg {
1368 hda_nid_t nid;
1369 u32 val;
1370};
1371
1372static void alc_fix_pincfg(struct hda_codec *codec,
1373 const struct snd_pci_quirk *quirk,
1374 const struct alc_pincfg **pinfix)
1375{
1376 const struct alc_pincfg *cfg;
1377
1378 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1379 if (!quirk)
1380 return;
1381
1382 cfg = pinfix[quirk->value];
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001383 for (; cfg->nid; cfg++)
1384 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001385}
1386
1387/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001388 * ALC888
1389 */
1390
1391/*
1392 * 2ch mode
1393 */
1394static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1395/* Mic-in jack as mic in */
1396 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1397 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1398/* Line-in jack as Line in */
1399 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1400 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1401/* Line-Out as Front */
1402 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1403 { } /* end */
1404};
1405
1406/*
1407 * 4ch mode
1408 */
1409static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1410/* Mic-in jack as mic in */
1411 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1412 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1413/* Line-in jack as Surround */
1414 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1415 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1416/* Line-Out as Front */
1417 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1418 { } /* end */
1419};
1420
1421/*
1422 * 6ch mode
1423 */
1424static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1425/* Mic-in jack as CLFE */
1426 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1427 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1428/* Line-in jack as Surround */
1429 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1430 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1431/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1432 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1433 { } /* end */
1434};
1435
1436/*
1437 * 8ch mode
1438 */
1439static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1440/* Mic-in jack as CLFE */
1441 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1442 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1443/* Line-in jack as Surround */
1444 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1445 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1446/* Line-Out as Side */
1447 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1448 { } /* end */
1449};
1450
1451static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1452 { 2, alc888_4ST_ch2_intel_init },
1453 { 4, alc888_4ST_ch4_intel_init },
1454 { 6, alc888_4ST_ch6_intel_init },
1455 { 8, alc888_4ST_ch8_intel_init },
1456};
1457
1458/*
1459 * ALC888 Fujitsu Siemens Amillo xa3530
1460 */
1461
1462static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1463/* Front Mic: set to PIN_IN (empty by default) */
1464 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1465/* Connect Internal HP to Front */
1466 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1467 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1468 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1469/* Connect Bass HP to Front */
1470 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1471 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1472 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1473/* Connect Line-Out side jack (SPDIF) to Side */
1474 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1475 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1476 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1477/* Connect Mic jack to CLFE */
1478 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1479 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1480 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1481/* Connect Line-in jack to Surround */
1482 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1483 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1484 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1485/* Connect HP out jack to Front */
1486 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1487 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1488 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1489/* Enable unsolicited event for HP jack and Line-out jack */
1490 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1491 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1492 {}
1493};
1494
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001495static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001496{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001497 struct alc_spec *spec = codec->spec;
Takashi Iwai261c2402009-06-25 08:13:40 +02001498 unsigned int val, mute, pincap;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001499 hda_nid_t nid;
1500 int i;
1501
1502 spec->jack_present = 0;
1503 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1504 nid = spec->autocfg.hp_pins[i];
1505 if (!nid)
1506 break;
Takashi Iwai261c2402009-06-25 08:13:40 +02001507 pincap = snd_hda_query_pin_caps(codec, nid);
1508 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
1509 snd_hda_codec_read(codec, nid, 0,
1510 AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001511 val = snd_hda_codec_read(codec, nid, 0,
1512 AC_VERB_GET_PIN_SENSE, 0);
1513 if (val & AC_PINSENSE_PRESENCE) {
1514 spec->jack_present = 1;
1515 break;
1516 }
1517 }
1518
1519 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001520 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001521 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1522 nid = spec->autocfg.speaker_pins[i];
1523 if (!nid)
1524 break;
1525 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1526 HDA_AMP_MUTE, mute);
1527 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001528}
1529
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001530static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1531 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001532{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001533 if (codec->vendor_id == 0x10ec0880)
1534 res >>= 28;
1535 else
1536 res >>= 26;
1537 if (res == ALC880_HP_EVENT)
1538 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001539}
1540
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001541static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001542{
1543 struct alc_spec *spec = codec->spec;
1544
1545 spec->autocfg.hp_pins[0] = 0x15;
1546 spec->autocfg.speaker_pins[0] = 0x14;
1547 spec->autocfg.speaker_pins[1] = 0x16;
1548 spec->autocfg.speaker_pins[2] = 0x17;
1549 spec->autocfg.speaker_pins[3] = 0x19;
1550 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001551}
1552
1553static void alc889_intel_init_hook(struct hda_codec *codec)
1554{
1555 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001556 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001557}
1558
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001559static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001560{
1561 struct alc_spec *spec = codec->spec;
1562
1563 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1564 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1565 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1566 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001567}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001568
1569/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001570 * ALC888 Acer Aspire 4930G model
1571 */
1572
1573static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1574/* Front Mic: set to PIN_IN (empty by default) */
1575 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1576/* Unselect Front Mic by default in input mixer 3 */
1577 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001578/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001579 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1580/* Connect Internal HP to front */
1581 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1582 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1583 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1584/* Connect HP out to front */
1585 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1586 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1587 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1588 { }
1589};
1590
Hector Martin3b315d72009-06-02 10:54:19 +02001591/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001592 * ALC888 Acer Aspire 6530G model
1593 */
1594
1595static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1596/* Bias voltage on for external mic port */
1597 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001598/* Front Mic: set to PIN_IN (empty by default) */
1599 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1600/* Unselect Front Mic by default in input mixer 3 */
1601 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001602/* Enable unsolicited event for HP jack */
1603 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1604/* Enable speaker output */
1605 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1606 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1607/* Enable headphone output */
1608 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1609 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1610 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1611 { }
1612};
1613
1614/*
Hector Martin018df412009-06-04 00:13:40 +02001615 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001616 */
1617
Hector Martin018df412009-06-04 00:13:40 +02001618static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001619/* Front Mic: set to PIN_IN (empty by default) */
1620 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1621/* Unselect Front Mic by default in input mixer 3 */
1622 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1623/* Enable unsolicited event for HP jack */
1624 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1625/* Connect Internal Front to Front */
1626 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1627 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1628 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1629/* Connect Internal Rear to Rear */
1630 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1631 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1632 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1633/* Connect Internal CLFE to CLFE */
1634 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1635 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1636 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1637/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001638 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001639 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1640 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1641/* Enable all DACs */
1642/* DAC DISABLE/MUTE 1? */
1643/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1644 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1645 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1646/* DAC DISABLE/MUTE 2? */
1647/* some bit here disables the other DACs. Init=0x4900 */
1648 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1649 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1650/* Enable amplifiers */
1651 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1652 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
Hector Martin018df412009-06-04 00:13:40 +02001653/* DMIC fix
1654 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1655 * which makes the stereo useless. However, either the mic or the ALC889
1656 * makes the signal become a difference/sum signal instead of standard
1657 * stereo, which is annoying. So instead we flip this bit which makes the
1658 * codec replicate the sum signal to both channels, turning it into a
1659 * normal mono mic.
1660 */
1661/* DMIC_CONTROL? Init value = 0x0001 */
1662 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1663 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001664 { }
1665};
1666
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001667static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001668 /* Front mic only available on one ADC */
1669 {
1670 .num_items = 4,
1671 .items = {
1672 { "Mic", 0x0 },
1673 { "Line", 0x2 },
1674 { "CD", 0x4 },
1675 { "Front Mic", 0xb },
1676 },
1677 },
1678 {
1679 .num_items = 3,
1680 .items = {
1681 { "Mic", 0x0 },
1682 { "Line", 0x2 },
1683 { "CD", 0x4 },
1684 },
1685 }
1686};
1687
Tony Vroond2fd4b02009-06-21 00:40:10 +01001688static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1689 /* Interal mic only available on one ADC */
1690 {
Tony Vroon684a8842009-06-26 09:27:50 +01001691 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001692 .items = {
1693 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001694 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001695 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001696 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001697 { "Int Mic", 0xb },
1698 },
1699 },
1700 {
Tony Vroon684a8842009-06-26 09:27:50 +01001701 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001702 .items = {
1703 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001704 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001705 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001706 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001707 },
1708 }
1709};
1710
Hector Martin018df412009-06-04 00:13:40 +02001711static struct hda_input_mux alc889_capture_sources[3] = {
1712 /* Digital mic only available on first "ADC" */
1713 {
1714 .num_items = 5,
1715 .items = {
1716 { "Mic", 0x0 },
1717 { "Line", 0x2 },
1718 { "CD", 0x4 },
1719 { "Front Mic", 0xb },
1720 { "Input Mix", 0xa },
1721 },
1722 },
1723 {
1724 .num_items = 4,
1725 .items = {
1726 { "Mic", 0x0 },
1727 { "Line", 0x2 },
1728 { "CD", 0x4 },
1729 { "Input Mix", 0xa },
1730 },
1731 },
1732 {
1733 .num_items = 4,
1734 .items = {
1735 { "Mic", 0x0 },
1736 { "Line", 0x2 },
1737 { "CD", 0x4 },
1738 { "Input Mix", 0xa },
1739 },
1740 }
1741};
1742
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001743static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001744 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1745 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1746 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1747 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1748 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1749 HDA_OUTPUT),
1750 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1751 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1752 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1753 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1754 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1755 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1756 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1757 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1758 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1759 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1760 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1761 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001762 { } /* end */
1763};
1764
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001765static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001766{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001767 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001768
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001769 spec->autocfg.hp_pins[0] = 0x15;
1770 spec->autocfg.speaker_pins[0] = 0x14;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001771}
1772
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001773static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001774{
1775 struct alc_spec *spec = codec->spec;
1776
1777 spec->autocfg.hp_pins[0] = 0x15;
1778 spec->autocfg.speaker_pins[0] = 0x14;
1779 spec->autocfg.speaker_pins[1] = 0x16;
1780 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001781}
1782
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001783static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001784{
1785 struct alc_spec *spec = codec->spec;
1786
1787 spec->autocfg.hp_pins[0] = 0x15;
1788 spec->autocfg.speaker_pins[0] = 0x14;
1789 spec->autocfg.speaker_pins[1] = 0x16;
1790 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001791}
1792
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001793/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001794 * ALC880 3-stack model
1795 *
1796 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001797 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1798 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001799 */
1800
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001801static hda_nid_t alc880_dac_nids[4] = {
1802 /* front, rear, clfe, rear_surr */
1803 0x02, 0x05, 0x04, 0x03
1804};
1805
1806static hda_nid_t alc880_adc_nids[3] = {
1807 /* ADC0-2 */
1808 0x07, 0x08, 0x09,
1809};
1810
1811/* The datasheet says the node 0x07 is connected from inputs,
1812 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001813 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001814 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001815static hda_nid_t alc880_adc_nids_alt[2] = {
1816 /* ADC1-2 */
1817 0x08, 0x09,
1818};
1819
1820#define ALC880_DIGOUT_NID 0x06
1821#define ALC880_DIGIN_NID 0x0a
1822
1823static struct hda_input_mux alc880_capture_source = {
1824 .num_items = 4,
1825 .items = {
1826 { "Mic", 0x0 },
1827 { "Front Mic", 0x3 },
1828 { "Line", 0x2 },
1829 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001830 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001831};
1832
1833/* channel source setting (2/6 channel selection for 3-stack) */
1834/* 2ch mode */
1835static struct hda_verb alc880_threestack_ch2_init[] = {
1836 /* set line-in to input, mute it */
1837 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1838 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1839 /* set mic-in to input vref 80%, mute it */
1840 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1841 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001842 { } /* end */
1843};
1844
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001845/* 6ch mode */
1846static struct hda_verb alc880_threestack_ch6_init[] = {
1847 /* set line-in to output, unmute it */
1848 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1849 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1850 /* set mic-in to output, unmute it */
1851 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1852 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1853 { } /* end */
1854};
1855
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001856static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001857 { 2, alc880_threestack_ch2_init },
1858 { 6, alc880_threestack_ch6_init },
1859};
1860
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001861static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001862 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001863 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001864 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001865 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001866 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1867 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001868 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1869 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001870 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1871 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1872 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1873 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1874 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1875 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1876 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1877 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001878 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001879 {
1880 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1881 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001882 .info = alc_ch_mode_info,
1883 .get = alc_ch_mode_get,
1884 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001885 },
1886 { } /* end */
1887};
1888
1889/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001890static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1891 struct snd_ctl_elem_info *uinfo)
1892{
1893 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1894 struct alc_spec *spec = codec->spec;
1895 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001896
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001897 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001898 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1899 HDA_INPUT);
1900 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001901 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001902 return err;
1903}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001904
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001905static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1906 unsigned int size, unsigned int __user *tlv)
1907{
1908 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1909 struct alc_spec *spec = codec->spec;
1910 int err;
1911
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001912 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001913 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1914 HDA_INPUT);
1915 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001916 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001917 return err;
1918}
1919
1920typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1921 struct snd_ctl_elem_value *ucontrol);
1922
1923static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1924 struct snd_ctl_elem_value *ucontrol,
1925 getput_call_t func)
1926{
1927 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1928 struct alc_spec *spec = codec->spec;
1929 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1930 int err;
1931
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001932 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001933 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1934 3, 0, HDA_INPUT);
1935 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001936 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001937 return err;
1938}
1939
1940static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1941 struct snd_ctl_elem_value *ucontrol)
1942{
1943 return alc_cap_getput_caller(kcontrol, ucontrol,
1944 snd_hda_mixer_amp_volume_get);
1945}
1946
1947static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1948 struct snd_ctl_elem_value *ucontrol)
1949{
1950 return alc_cap_getput_caller(kcontrol, ucontrol,
1951 snd_hda_mixer_amp_volume_put);
1952}
1953
1954/* capture mixer elements */
1955#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1956
1957static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1958 struct snd_ctl_elem_value *ucontrol)
1959{
1960 return alc_cap_getput_caller(kcontrol, ucontrol,
1961 snd_hda_mixer_amp_switch_get);
1962}
1963
1964static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1965 struct snd_ctl_elem_value *ucontrol)
1966{
1967 return alc_cap_getput_caller(kcontrol, ucontrol,
1968 snd_hda_mixer_amp_switch_put);
1969}
1970
Takashi Iwaia23b6882009-03-23 15:21:36 +01001971#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001972 { \
1973 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1974 .name = "Capture Switch", \
1975 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1976 .count = num, \
1977 .info = alc_cap_sw_info, \
1978 .get = alc_cap_sw_get, \
1979 .put = alc_cap_sw_put, \
1980 }, \
1981 { \
1982 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1983 .name = "Capture Volume", \
1984 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1985 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1986 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1987 .count = num, \
1988 .info = alc_cap_vol_info, \
1989 .get = alc_cap_vol_get, \
1990 .put = alc_cap_vol_put, \
1991 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001992 }
1993
1994#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001995 { \
1996 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1997 /* .name = "Capture Source", */ \
1998 .name = "Input Source", \
1999 .count = num, \
2000 .info = alc_mux_enum_info, \
2001 .get = alc_mux_enum_get, \
2002 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002003 }
2004
2005#define DEFINE_CAPMIX(num) \
2006static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2007 _DEFINE_CAPMIX(num), \
2008 _DEFINE_CAPSRC(num), \
2009 { } /* end */ \
2010}
2011
2012#define DEFINE_CAPMIX_NOSRC(num) \
2013static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2014 _DEFINE_CAPMIX(num), \
2015 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002016}
2017
2018/* up to three ADCs */
2019DEFINE_CAPMIX(1);
2020DEFINE_CAPMIX(2);
2021DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002022DEFINE_CAPMIX_NOSRC(1);
2023DEFINE_CAPMIX_NOSRC(2);
2024DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002025
2026/*
2027 * ALC880 5-stack model
2028 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002029 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2030 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002031 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2032 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2033 */
2034
2035/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002036static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002037 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002038 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002039 { } /* end */
2040};
2041
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002042/* channel source setting (6/8 channel selection for 5-stack) */
2043/* 6ch mode */
2044static struct hda_verb alc880_fivestack_ch6_init[] = {
2045 /* set line-in to input, mute it */
2046 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2047 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002048 { } /* end */
2049};
2050
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002051/* 8ch mode */
2052static struct hda_verb alc880_fivestack_ch8_init[] = {
2053 /* set line-in to output, unmute it */
2054 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2055 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2056 { } /* end */
2057};
2058
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002059static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002060 { 6, alc880_fivestack_ch6_init },
2061 { 8, alc880_fivestack_ch8_init },
2062};
2063
2064
2065/*
2066 * ALC880 6-stack model
2067 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002068 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2069 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002070 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2071 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2072 */
2073
2074static hda_nid_t alc880_6st_dac_nids[4] = {
2075 /* front, rear, clfe, rear_surr */
2076 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002077};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002078
2079static struct hda_input_mux alc880_6stack_capture_source = {
2080 .num_items = 4,
2081 .items = {
2082 { "Mic", 0x0 },
2083 { "Front Mic", 0x1 },
2084 { "Line", 0x2 },
2085 { "CD", 0x4 },
2086 },
2087};
2088
2089/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002090static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002091 { 8, NULL },
2092};
2093
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002094static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002095 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002096 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002097 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002098 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002099 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2100 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002101 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2102 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002103 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002104 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002105 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2106 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2107 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2108 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2109 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2110 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2111 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2112 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002113 {
2114 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2115 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002116 .info = alc_ch_mode_info,
2117 .get = alc_ch_mode_get,
2118 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002119 },
2120 { } /* end */
2121};
2122
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002123
2124/*
2125 * ALC880 W810 model
2126 *
2127 * W810 has rear IO for:
2128 * Front (DAC 02)
2129 * Surround (DAC 03)
2130 * Center/LFE (DAC 04)
2131 * Digital out (06)
2132 *
2133 * The system also has a pair of internal speakers, and a headphone jack.
2134 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002135 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002136 * There is a variable resistor to control the speaker or headphone
2137 * volume. This is a hardware-only device without a software API.
2138 *
2139 * Plugging headphones in will disable the internal speakers. This is
2140 * implemented in hardware, not via the driver using jack sense. In
2141 * a similar fashion, plugging into the rear socket marked "front" will
2142 * disable both the speakers and headphones.
2143 *
2144 * For input, there's a microphone jack, and an "audio in" jack.
2145 * These may not do anything useful with this driver yet, because I
2146 * haven't setup any initialization verbs for these yet...
2147 */
2148
2149static hda_nid_t alc880_w810_dac_nids[3] = {
2150 /* front, rear/surround, clfe */
2151 0x02, 0x03, 0x04
2152};
2153
2154/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002155static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002156 { 6, NULL }
2157};
2158
2159/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002160static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002161 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002162 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002163 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002164 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002165 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2166 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002167 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2168 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002169 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2170 { } /* end */
2171};
2172
2173
2174/*
2175 * Z710V model
2176 *
2177 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002178 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2179 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002180 */
2181
2182static hda_nid_t alc880_z71v_dac_nids[1] = {
2183 0x02
2184};
2185#define ALC880_Z71V_HP_DAC 0x03
2186
2187/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002188static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002189 { 2, NULL }
2190};
2191
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002192static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002193 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002194 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002195 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002196 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002197 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2198 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2199 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2200 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2201 { } /* end */
2202};
2203
2204
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002205/*
2206 * ALC880 F1734 model
2207 *
2208 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2209 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2210 */
2211
2212static hda_nid_t alc880_f1734_dac_nids[1] = {
2213 0x03
2214};
2215#define ALC880_F1734_HP_DAC 0x02
2216
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002217static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002218 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002219 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002220 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2221 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002222 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2223 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002224 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2225 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002226 { } /* end */
2227};
2228
Takashi Iwai937b4162008-02-11 14:52:36 +01002229static struct hda_input_mux alc880_f1734_capture_source = {
2230 .num_items = 2,
2231 .items = {
2232 { "Mic", 0x1 },
2233 { "CD", 0x4 },
2234 },
2235};
2236
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002237
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002238/*
2239 * ALC880 ASUS model
2240 *
2241 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2242 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2243 * Mic = 0x18, Line = 0x1a
2244 */
2245
2246#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2247#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2248
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002249static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002250 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002251 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002252 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002253 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002254 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2255 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002256 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2257 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002258 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2259 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2260 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2261 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2262 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2263 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002264 {
2265 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2266 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002267 .info = alc_ch_mode_info,
2268 .get = alc_ch_mode_get,
2269 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002270 },
2271 { } /* end */
2272};
2273
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002274/*
2275 * ALC880 ASUS W1V model
2276 *
2277 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2278 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2279 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2280 */
2281
2282/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002283static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002284 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2285 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002286 { } /* end */
2287};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002288
Kailang Yangdf694da2005-12-05 19:42:22 +01002289/* TCL S700 */
2290static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2291 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2292 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2293 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2294 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2295 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2296 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2297 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2298 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2299 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002300 { } /* end */
2301};
2302
Kailang Yangccc656c2006-10-17 12:32:26 +02002303/* Uniwill */
2304static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002305 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2306 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2307 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2308 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002309 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2310 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2311 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2312 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2313 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2314 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2315 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2316 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2317 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2318 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2319 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2320 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002321 {
2322 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2323 .name = "Channel Mode",
2324 .info = alc_ch_mode_info,
2325 .get = alc_ch_mode_get,
2326 .put = alc_ch_mode_put,
2327 },
2328 { } /* end */
2329};
2330
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002331static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2332 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2333 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2334 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2335 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2336 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2337 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2338 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2339 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2340 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2341 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2342 { } /* end */
2343};
2344
Kailang Yangccc656c2006-10-17 12:32:26 +02002345static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002346 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2347 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2348 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2349 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002350 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2351 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2352 { } /* end */
2353};
2354
Linus Torvalds1da177e2005-04-16 15:20:36 -07002355/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002356 * virtual master controls
2357 */
2358
2359/*
2360 * slave controls for virtual master
2361 */
2362static const char *alc_slave_vols[] = {
2363 "Front Playback Volume",
2364 "Surround Playback Volume",
2365 "Center Playback Volume",
2366 "LFE Playback Volume",
2367 "Side Playback Volume",
2368 "Headphone Playback Volume",
2369 "Speaker Playback Volume",
2370 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002371 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002372 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002373 NULL,
2374};
2375
2376static const char *alc_slave_sws[] = {
2377 "Front Playback Switch",
2378 "Surround Playback Switch",
2379 "Center Playback Switch",
2380 "LFE Playback Switch",
2381 "Side Playback Switch",
2382 "Headphone Playback Switch",
2383 "Speaker Playback Switch",
2384 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002385 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002386 NULL,
2387};
2388
2389/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002390 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002391 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002392
2393static void alc_free_kctls(struct hda_codec *codec);
2394
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002395/* additional beep mixers; the actual parameters are overwritten at build */
2396static struct snd_kcontrol_new alc_beep_mixer[] = {
2397 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2398 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2399 { } /* end */
2400};
2401
Linus Torvalds1da177e2005-04-16 15:20:36 -07002402static int alc_build_controls(struct hda_codec *codec)
2403{
2404 struct alc_spec *spec = codec->spec;
2405 int err;
2406 int i;
2407
2408 for (i = 0; i < spec->num_mixers; i++) {
2409 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2410 if (err < 0)
2411 return err;
2412 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002413 if (spec->cap_mixer) {
2414 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2415 if (err < 0)
2416 return err;
2417 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002418 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002419 err = snd_hda_create_spdif_out_ctls(codec,
2420 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002421 if (err < 0)
2422 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002423 if (!spec->no_analog) {
2424 err = snd_hda_create_spdif_share_sw(codec,
2425 &spec->multiout);
2426 if (err < 0)
2427 return err;
2428 spec->multiout.share_spdif = 1;
2429 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002430 }
2431 if (spec->dig_in_nid) {
2432 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2433 if (err < 0)
2434 return err;
2435 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002436
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002437 /* create beep controls if needed */
2438 if (spec->beep_amp) {
2439 struct snd_kcontrol_new *knew;
2440 for (knew = alc_beep_mixer; knew->name; knew++) {
2441 struct snd_kcontrol *kctl;
2442 kctl = snd_ctl_new1(knew, codec);
2443 if (!kctl)
2444 return -ENOMEM;
2445 kctl->private_value = spec->beep_amp;
2446 err = snd_hda_ctl_add(codec, kctl);
2447 if (err < 0)
2448 return err;
2449 }
2450 }
2451
Takashi Iwai2134ea42008-01-10 16:53:55 +01002452 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002453 if (!spec->no_analog &&
2454 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002455 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002456 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002457 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002458 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002459 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002460 if (err < 0)
2461 return err;
2462 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002463 if (!spec->no_analog &&
2464 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002465 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2466 NULL, alc_slave_sws);
2467 if (err < 0)
2468 return err;
2469 }
2470
Takashi Iwai603c4012008-07-30 15:01:44 +02002471 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002472 return 0;
2473}
2474
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002475
Linus Torvalds1da177e2005-04-16 15:20:36 -07002476/*
2477 * initialize the codec volumes, etc
2478 */
2479
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002480/*
2481 * generic initialization of ADC, input mixers and output mixers
2482 */
2483static struct hda_verb alc880_volume_init_verbs[] = {
2484 /*
2485 * Unmute ADC0-2 and set the default input to mic-in
2486 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002487 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002488 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002489 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002490 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002491 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002492 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002493
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002494 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2495 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002496 * Note: PASD motherboards uses the Line In 2 as the input for front
2497 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002498 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002499 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002500 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2501 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2502 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2503 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2504 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2505 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2506 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002507
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002508 /*
2509 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002510 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002511 /* set vol=0 to output mixers */
2512 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2513 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2514 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2515 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2516 /* set up input amps for analog loopback */
2517 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002518 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2519 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002520 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2521 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002522 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2523 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002524 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2525 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002526
2527 { }
2528};
2529
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002530/*
2531 * 3-stack pin configuration:
2532 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2533 */
2534static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2535 /*
2536 * preset connection lists of input pins
2537 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2538 */
2539 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2540 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2541 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2542
2543 /*
2544 * Set pin mode and muting
2545 */
2546 /* set front pin widgets 0x14 for output */
2547 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2548 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2549 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2550 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2551 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2552 /* Mic2 (as headphone out) for HP output */
2553 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2554 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2555 /* Line In pin widget for input */
2556 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2557 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2558 /* Line2 (as front mic) pin widget for input and vref at 80% */
2559 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2560 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2561 /* CD pin widget for input */
2562 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2563
2564 { }
2565};
2566
2567/*
2568 * 5-stack pin configuration:
2569 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2570 * line-in/side = 0x1a, f-mic = 0x1b
2571 */
2572static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2573 /*
2574 * preset connection lists of input pins
2575 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2576 */
2577 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2578 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2579
2580 /*
2581 * Set pin mode and muting
2582 */
2583 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002584 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2585 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2586 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2587 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002588 /* unmute pins for output (no gain on this amp) */
2589 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2590 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2591 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2592 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2593
Linus Torvalds1da177e2005-04-16 15:20:36 -07002594 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002595 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002596 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2597 /* Mic2 (as headphone out) for HP output */
2598 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002599 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002600 /* Line In pin widget for input */
2601 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2602 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2603 /* Line2 (as front mic) pin widget for input and vref at 80% */
2604 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2605 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2606 /* CD pin widget for input */
2607 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002608
2609 { }
2610};
2611
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002612/*
2613 * W810 pin configuration:
2614 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2615 */
2616static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002617 /* hphone/speaker input selector: front DAC */
2618 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2619
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002620 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2621 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2622 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2623 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2624 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2625 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2626
2627 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002628 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002629
Linus Torvalds1da177e2005-04-16 15:20:36 -07002630 { }
2631};
2632
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002633/*
2634 * Z71V pin configuration:
2635 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2636 */
2637static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002638 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002639 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002640 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002641 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002642
Takashi Iwai16ded522005-06-10 19:58:24 +02002643 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002644 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002645 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002646 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002647
2648 { }
2649};
2650
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002651/*
2652 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002653 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2654 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002655 */
2656static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2657 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2658
Takashi Iwai16ded522005-06-10 19:58:24 +02002659 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002660 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002661 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002662 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002663 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002664 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002665 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002666 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2667
Takashi Iwai16ded522005-06-10 19:58:24 +02002668 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002669 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002670 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002671 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002672 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002673 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002674 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002675 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002676 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002677
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002678 { }
2679};
Takashi Iwai16ded522005-06-10 19:58:24 +02002680
Kailang Yangccc656c2006-10-17 12:32:26 +02002681/*
2682 * Uniwill pin configuration:
2683 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2684 * line = 0x1a
2685 */
2686static struct hda_verb alc880_uniwill_init_verbs[] = {
2687 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2688
2689 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2690 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2691 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2692 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2693 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2694 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2695 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2696 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2697 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2698 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2699 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2700 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2701 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2702 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2703
2704 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2705 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2706 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2707 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2708 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2709 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2710 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2711 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2712 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2713
2714 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2715 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2716
2717 { }
2718};
2719
2720/*
2721* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002722* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002723 */
2724static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2725 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2726
2727 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2728 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2729 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2730 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2731 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2732 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2733 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2734 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2735 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2736 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2737 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2738 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2739
2740 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2741 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2742 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2743 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2744 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2745 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2746
2747 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2748 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2749
2750 { }
2751};
2752
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002753static struct hda_verb alc880_beep_init_verbs[] = {
2754 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2755 { }
2756};
2757
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002758/* auto-toggle front mic */
2759static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2760{
2761 unsigned int present;
2762 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002763
2764 present = snd_hda_codec_read(codec, 0x18, 0,
2765 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002766 bits = present ? HDA_AMP_MUTE : 0;
2767 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002768}
2769
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002770static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002771{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002772 struct alc_spec *spec = codec->spec;
2773
2774 spec->autocfg.hp_pins[0] = 0x14;
2775 spec->autocfg.speaker_pins[0] = 0x15;
2776 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002777}
2778
2779static void alc880_uniwill_init_hook(struct hda_codec *codec)
2780{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002781 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002782 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002783}
2784
2785static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2786 unsigned int res)
2787{
2788 /* Looks like the unsol event is incompatible with the standard
2789 * definition. 4bit tag is placed at 28 bit!
2790 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002791 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002792 case ALC880_MIC_EVENT:
2793 alc880_uniwill_mic_automute(codec);
2794 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002795 default:
2796 alc_automute_amp_unsol_event(codec, res);
2797 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002798 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002799}
2800
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002801static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002802{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002803 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002804
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002805 spec->autocfg.hp_pins[0] = 0x14;
2806 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02002807}
2808
2809static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2810{
2811 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002812
Kailang Yangccc656c2006-10-17 12:32:26 +02002813 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002814 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2815 present &= HDA_AMP_VOLMASK;
2816 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2817 HDA_AMP_VOLMASK, present);
2818 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2819 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002820}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002821
Kailang Yangccc656c2006-10-17 12:32:26 +02002822static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2823 unsigned int res)
2824{
2825 /* Looks like the unsol event is incompatible with the standard
2826 * definition. 4bit tag is placed at 28 bit!
2827 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002828 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002829 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002830 else
2831 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002832}
2833
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002834/*
2835 * F1734 pin configuration:
2836 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2837 */
2838static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002839 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002840 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2841 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2842 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2843 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2844
2845 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2846 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2847 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2848 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2849
2850 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2851 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002852 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002853 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2854 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2855 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2856 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2857 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2858 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002859
Takashi Iwai937b4162008-02-11 14:52:36 +01002860 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2861 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2862
Takashi Iwai16ded522005-06-10 19:58:24 +02002863 { }
2864};
2865
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002866/*
2867 * ASUS pin configuration:
2868 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2869 */
2870static struct hda_verb alc880_pin_asus_init_verbs[] = {
2871 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2872 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2873 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2874 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2875
2876 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2877 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2878 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2879 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2880 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2881 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2882 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2883 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2884
2885 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2886 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2887 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2888 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2889 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2890 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2891 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2892 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2893 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002894
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002895 { }
2896};
2897
2898/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002899#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2900#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02002901#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002902
Kailang Yangdf694da2005-12-05 19:42:22 +01002903/* Clevo m520g init */
2904static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2905 /* headphone output */
2906 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2907 /* line-out */
2908 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2909 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2910 /* Line-in */
2911 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2912 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2913 /* CD */
2914 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2915 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2916 /* Mic1 (rear panel) */
2917 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2918 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2919 /* Mic2 (front panel) */
2920 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2921 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2922 /* headphone */
2923 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2924 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2925 /* change to EAPD mode */
2926 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2927 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2928
2929 { }
2930};
2931
2932static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002933 /* change to EAPD mode */
2934 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2935 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2936
Kailang Yangdf694da2005-12-05 19:42:22 +01002937 /* Headphone output */
2938 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2939 /* Front output*/
2940 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2941 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2942
2943 /* Line In pin widget for input */
2944 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2945 /* CD pin widget for input */
2946 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2947 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2948 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2949
2950 /* change to EAPD mode */
2951 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2952 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2953
2954 { }
2955};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002956
2957/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002958 * LG m1 express dual
2959 *
2960 * Pin assignment:
2961 * Rear Line-In/Out (blue): 0x14
2962 * Build-in Mic-In: 0x15
2963 * Speaker-out: 0x17
2964 * HP-Out (green): 0x1b
2965 * Mic-In/Out (red): 0x19
2966 * SPDIF-Out: 0x1e
2967 */
2968
2969/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2970static hda_nid_t alc880_lg_dac_nids[3] = {
2971 0x05, 0x02, 0x03
2972};
2973
2974/* seems analog CD is not working */
2975static struct hda_input_mux alc880_lg_capture_source = {
2976 .num_items = 3,
2977 .items = {
2978 { "Mic", 0x1 },
2979 { "Line", 0x5 },
2980 { "Internal Mic", 0x6 },
2981 },
2982};
2983
2984/* 2,4,6 channel modes */
2985static struct hda_verb alc880_lg_ch2_init[] = {
2986 /* set line-in and mic-in to input */
2987 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2988 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2989 { }
2990};
2991
2992static struct hda_verb alc880_lg_ch4_init[] = {
2993 /* set line-in to out and mic-in to input */
2994 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2995 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2996 { }
2997};
2998
2999static struct hda_verb alc880_lg_ch6_init[] = {
3000 /* set line-in and mic-in to output */
3001 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3002 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3003 { }
3004};
3005
3006static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3007 { 2, alc880_lg_ch2_init },
3008 { 4, alc880_lg_ch4_init },
3009 { 6, alc880_lg_ch6_init },
3010};
3011
3012static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003013 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3014 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003015 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3016 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3017 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3018 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3019 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3020 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3021 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3022 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3023 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3024 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3025 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3026 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3027 {
3028 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3029 .name = "Channel Mode",
3030 .info = alc_ch_mode_info,
3031 .get = alc_ch_mode_get,
3032 .put = alc_ch_mode_put,
3033 },
3034 { } /* end */
3035};
3036
3037static struct hda_verb alc880_lg_init_verbs[] = {
3038 /* set capture source to mic-in */
3039 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3040 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3041 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3042 /* mute all amp mixer inputs */
3043 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003044 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3045 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003046 /* line-in to input */
3047 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3048 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3049 /* built-in mic */
3050 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3051 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3052 /* speaker-out */
3053 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3054 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3055 /* mic-in to input */
3056 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3057 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3058 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3059 /* HP-out */
3060 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3061 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3062 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3063 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003064 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003065 { }
3066};
3067
3068/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003069static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003070{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003071 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003072
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003073 spec->autocfg.hp_pins[0] = 0x1b;
3074 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003075}
3076
3077/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003078 * LG LW20
3079 *
3080 * Pin assignment:
3081 * Speaker-out: 0x14
3082 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003083 * Built-in Mic-In: 0x19
3084 * Line-In: 0x1b
3085 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003086 * SPDIF-Out: 0x1e
3087 */
3088
Takashi Iwaid6815182006-03-23 16:06:23 +01003089static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003090 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003091 .items = {
3092 { "Mic", 0x0 },
3093 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003094 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003095 },
3096};
3097
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003098#define alc880_lg_lw_modes alc880_threestack_modes
3099
Takashi Iwaid6815182006-03-23 16:06:23 +01003100static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003101 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3102 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3103 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3104 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3105 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3106 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3107 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3108 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3109 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3110 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003111 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3112 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3113 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3114 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003115 {
3116 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3117 .name = "Channel Mode",
3118 .info = alc_ch_mode_info,
3119 .get = alc_ch_mode_get,
3120 .put = alc_ch_mode_put,
3121 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003122 { } /* end */
3123};
3124
3125static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003126 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3127 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3128 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3129
Takashi Iwaid6815182006-03-23 16:06:23 +01003130 /* set capture source to mic-in */
3131 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3132 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3133 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003134 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003135 /* speaker-out */
3136 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3137 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3138 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003139 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3140 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3141 /* mic-in to input */
3142 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3143 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3144 /* built-in mic */
3145 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3146 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3147 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003148 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003149 { }
3150};
3151
3152/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003153static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003154{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003155 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003156
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003157 spec->autocfg.hp_pins[0] = 0x1b;
3158 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003159}
3160
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003161static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3162 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3163 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3164 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3165 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3166 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3167 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3168 { } /* end */
3169};
3170
3171static struct hda_input_mux alc880_medion_rim_capture_source = {
3172 .num_items = 2,
3173 .items = {
3174 { "Mic", 0x0 },
3175 { "Internal Mic", 0x1 },
3176 },
3177};
3178
3179static struct hda_verb alc880_medion_rim_init_verbs[] = {
3180 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3181
3182 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3183 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3184
3185 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3186 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3187 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3188 /* Mic2 (as headphone out) for HP output */
3189 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3190 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3191 /* Internal Speaker */
3192 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3193 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3194
3195 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3196 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3197
3198 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3199 { }
3200};
3201
3202/* toggle speaker-output according to the hp-jack state */
3203static void alc880_medion_rim_automute(struct hda_codec *codec)
3204{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003205 struct alc_spec *spec = codec->spec;
3206 alc_automute_amp(codec);
3207 /* toggle EAPD */
3208 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003209 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3210 else
3211 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3212}
3213
3214static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3215 unsigned int res)
3216{
3217 /* Looks like the unsol event is incompatible with the standard
3218 * definition. 4bit tag is placed at 28 bit!
3219 */
3220 if ((res >> 28) == ALC880_HP_EVENT)
3221 alc880_medion_rim_automute(codec);
3222}
3223
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003224static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003225{
3226 struct alc_spec *spec = codec->spec;
3227
3228 spec->autocfg.hp_pins[0] = 0x14;
3229 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003230}
3231
Takashi Iwaicb53c622007-08-10 17:21:45 +02003232#ifdef CONFIG_SND_HDA_POWER_SAVE
3233static struct hda_amp_list alc880_loopbacks[] = {
3234 { 0x0b, HDA_INPUT, 0 },
3235 { 0x0b, HDA_INPUT, 1 },
3236 { 0x0b, HDA_INPUT, 2 },
3237 { 0x0b, HDA_INPUT, 3 },
3238 { 0x0b, HDA_INPUT, 4 },
3239 { } /* end */
3240};
3241
3242static struct hda_amp_list alc880_lg_loopbacks[] = {
3243 { 0x0b, HDA_INPUT, 1 },
3244 { 0x0b, HDA_INPUT, 6 },
3245 { 0x0b, HDA_INPUT, 7 },
3246 { } /* end */
3247};
3248#endif
3249
Takashi Iwaid6815182006-03-23 16:06:23 +01003250/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003251 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003252 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003253
Linus Torvalds1da177e2005-04-16 15:20:36 -07003254static int alc_init(struct hda_codec *codec)
3255{
3256 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003257 unsigned int i;
3258
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003259 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003260 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003261
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003262 for (i = 0; i < spec->num_init_verbs; i++)
3263 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003264
3265 if (spec->init_hook)
3266 spec->init_hook(codec);
3267
Linus Torvalds1da177e2005-04-16 15:20:36 -07003268 return 0;
3269}
3270
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003271static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3272{
3273 struct alc_spec *spec = codec->spec;
3274
3275 if (spec->unsol_event)
3276 spec->unsol_event(codec, res);
3277}
3278
Takashi Iwaicb53c622007-08-10 17:21:45 +02003279#ifdef CONFIG_SND_HDA_POWER_SAVE
3280static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3281{
3282 struct alc_spec *spec = codec->spec;
3283 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3284}
3285#endif
3286
Linus Torvalds1da177e2005-04-16 15:20:36 -07003287/*
3288 * Analog playback callbacks
3289 */
3290static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3291 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003292 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003293{
3294 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003295 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3296 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003297}
3298
3299static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3300 struct hda_codec *codec,
3301 unsigned int stream_tag,
3302 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003303 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003304{
3305 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003306 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3307 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003308}
3309
3310static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3311 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003312 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003313{
3314 struct alc_spec *spec = codec->spec;
3315 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3316}
3317
3318/*
3319 * Digital out
3320 */
3321static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3322 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003323 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003324{
3325 struct alc_spec *spec = codec->spec;
3326 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3327}
3328
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003329static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3330 struct hda_codec *codec,
3331 unsigned int stream_tag,
3332 unsigned int format,
3333 struct snd_pcm_substream *substream)
3334{
3335 struct alc_spec *spec = codec->spec;
3336 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3337 stream_tag, format, substream);
3338}
3339
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003340static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3341 struct hda_codec *codec,
3342 struct snd_pcm_substream *substream)
3343{
3344 struct alc_spec *spec = codec->spec;
3345 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3346}
3347
Linus Torvalds1da177e2005-04-16 15:20:36 -07003348static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3349 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003350 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003351{
3352 struct alc_spec *spec = codec->spec;
3353 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3354}
3355
3356/*
3357 * Analog capture
3358 */
Takashi Iwai63300792008-01-24 15:31:36 +01003359static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003360 struct hda_codec *codec,
3361 unsigned int stream_tag,
3362 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003363 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003364{
3365 struct alc_spec *spec = codec->spec;
3366
Takashi Iwai63300792008-01-24 15:31:36 +01003367 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003368 stream_tag, 0, format);
3369 return 0;
3370}
3371
Takashi Iwai63300792008-01-24 15:31:36 +01003372static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003373 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003374 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003375{
3376 struct alc_spec *spec = codec->spec;
3377
Takashi Iwai888afa12008-03-18 09:57:50 +01003378 snd_hda_codec_cleanup_stream(codec,
3379 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003380 return 0;
3381}
3382
3383
3384/*
3385 */
3386static struct hda_pcm_stream alc880_pcm_analog_playback = {
3387 .substreams = 1,
3388 .channels_min = 2,
3389 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003390 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003391 .ops = {
3392 .open = alc880_playback_pcm_open,
3393 .prepare = alc880_playback_pcm_prepare,
3394 .cleanup = alc880_playback_pcm_cleanup
3395 },
3396};
3397
3398static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003399 .substreams = 1,
3400 .channels_min = 2,
3401 .channels_max = 2,
3402 /* NID is set in alc_build_pcms */
3403};
3404
3405static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3406 .substreams = 1,
3407 .channels_min = 2,
3408 .channels_max = 2,
3409 /* NID is set in alc_build_pcms */
3410};
3411
3412static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3413 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003414 .channels_min = 2,
3415 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003416 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003417 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003418 .prepare = alc880_alt_capture_pcm_prepare,
3419 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003420 },
3421};
3422
3423static struct hda_pcm_stream alc880_pcm_digital_playback = {
3424 .substreams = 1,
3425 .channels_min = 2,
3426 .channels_max = 2,
3427 /* NID is set in alc_build_pcms */
3428 .ops = {
3429 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003430 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003431 .prepare = alc880_dig_playback_pcm_prepare,
3432 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003433 },
3434};
3435
3436static struct hda_pcm_stream alc880_pcm_digital_capture = {
3437 .substreams = 1,
3438 .channels_min = 2,
3439 .channels_max = 2,
3440 /* NID is set in alc_build_pcms */
3441};
3442
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003443/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003444static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003445 .substreams = 0,
3446 .channels_min = 0,
3447 .channels_max = 0,
3448};
3449
Linus Torvalds1da177e2005-04-16 15:20:36 -07003450static int alc_build_pcms(struct hda_codec *codec)
3451{
3452 struct alc_spec *spec = codec->spec;
3453 struct hda_pcm *info = spec->pcm_rec;
3454 int i;
3455
3456 codec->num_pcms = 1;
3457 codec->pcm_info = info;
3458
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003459 if (spec->no_analog)
3460 goto skip_analog;
3461
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003462 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3463 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003464 info->name = spec->stream_name_analog;
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003465
Takashi Iwai4a471b72005-12-07 13:56:29 +01003466 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003467 if (snd_BUG_ON(!spec->multiout.dac_nids))
3468 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003469 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3470 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3471 }
3472 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003473 if (snd_BUG_ON(!spec->adc_nids))
3474 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003475 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3476 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3477 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003478
Takashi Iwai4a471b72005-12-07 13:56:29 +01003479 if (spec->channel_mode) {
3480 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3481 for (i = 0; i < spec->num_channel_mode; i++) {
3482 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3483 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3484 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003485 }
3486 }
3487
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003488 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003489 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003490 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003491 snprintf(spec->stream_name_digital,
3492 sizeof(spec->stream_name_digital),
3493 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003494 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003495 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003496 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003497 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003498 if (spec->dig_out_type)
3499 info->pcm_type = spec->dig_out_type;
3500 else
3501 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003502 if (spec->multiout.dig_out_nid &&
3503 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003504 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3505 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3506 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003507 if (spec->dig_in_nid &&
3508 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003509 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3510 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3511 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003512 /* FIXME: do we need this for all Realtek codec models? */
3513 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003514 }
3515
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003516 if (spec->no_analog)
3517 return 0;
3518
Takashi Iwaie08a0072006-09-07 17:52:14 +02003519 /* If the use of more than one ADC is requested for the current
3520 * model, configure a second analog capture-only PCM.
3521 */
3522 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003523 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3524 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003525 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003526 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003527 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003528 if (spec->alt_dac_nid) {
3529 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3530 *spec->stream_analog_alt_playback;
3531 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3532 spec->alt_dac_nid;
3533 } else {
3534 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3535 alc_pcm_null_stream;
3536 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3537 }
3538 if (spec->num_adc_nids > 1) {
3539 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3540 *spec->stream_analog_alt_capture;
3541 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3542 spec->adc_nids[1];
3543 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3544 spec->num_adc_nids - 1;
3545 } else {
3546 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3547 alc_pcm_null_stream;
3548 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003549 }
3550 }
3551
Linus Torvalds1da177e2005-04-16 15:20:36 -07003552 return 0;
3553}
3554
Takashi Iwai603c4012008-07-30 15:01:44 +02003555static void alc_free_kctls(struct hda_codec *codec)
3556{
3557 struct alc_spec *spec = codec->spec;
3558
3559 if (spec->kctls.list) {
3560 struct snd_kcontrol_new *kctl = spec->kctls.list;
3561 int i;
3562 for (i = 0; i < spec->kctls.used; i++)
3563 kfree(kctl[i].name);
3564 }
3565 snd_array_free(&spec->kctls);
3566}
3567
Linus Torvalds1da177e2005-04-16 15:20:36 -07003568static void alc_free(struct hda_codec *codec)
3569{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003570 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003571
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003572 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003573 return;
3574
Takashi Iwai603c4012008-07-30 15:01:44 +02003575 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003576 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003577 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003578}
3579
Takashi Iwaie044c392008-10-27 16:56:24 +01003580#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003581static int alc_resume(struct hda_codec *codec)
3582{
Takashi Iwaie044c392008-10-27 16:56:24 +01003583 codec->patch_ops.init(codec);
3584 snd_hda_codec_resume_amp(codec);
3585 snd_hda_codec_resume_cache(codec);
3586 return 0;
3587}
Takashi Iwaie044c392008-10-27 16:56:24 +01003588#endif
3589
Linus Torvalds1da177e2005-04-16 15:20:36 -07003590/*
3591 */
3592static struct hda_codec_ops alc_patch_ops = {
3593 .build_controls = alc_build_controls,
3594 .build_pcms = alc_build_pcms,
3595 .init = alc_init,
3596 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003597 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003598#ifdef SND_HDA_NEEDS_RESUME
3599 .resume = alc_resume,
3600#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003601#ifdef CONFIG_SND_HDA_POWER_SAVE
3602 .check_power_status = alc_check_power_status,
3603#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003604};
3605
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003606
3607/*
3608 * Test configuration for debugging
3609 *
3610 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3611 * enum controls.
3612 */
3613#ifdef CONFIG_SND_DEBUG
3614static hda_nid_t alc880_test_dac_nids[4] = {
3615 0x02, 0x03, 0x04, 0x05
3616};
3617
3618static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003619 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003620 .items = {
3621 { "In-1", 0x0 },
3622 { "In-2", 0x1 },
3623 { "In-3", 0x2 },
3624 { "In-4", 0x3 },
3625 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003626 { "Front", 0x5 },
3627 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003628 },
3629};
3630
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003631static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003632 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003633 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003634 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003635 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003636};
3637
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003638static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3639 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003640{
3641 static char *texts[] = {
3642 "N/A", "Line Out", "HP Out",
3643 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3644 };
3645 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3646 uinfo->count = 1;
3647 uinfo->value.enumerated.items = 8;
3648 if (uinfo->value.enumerated.item >= 8)
3649 uinfo->value.enumerated.item = 7;
3650 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3651 return 0;
3652}
3653
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003654static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3655 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003656{
3657 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3658 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3659 unsigned int pin_ctl, item = 0;
3660
3661 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3662 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3663 if (pin_ctl & AC_PINCTL_OUT_EN) {
3664 if (pin_ctl & AC_PINCTL_HP_EN)
3665 item = 2;
3666 else
3667 item = 1;
3668 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3669 switch (pin_ctl & AC_PINCTL_VREFEN) {
3670 case AC_PINCTL_VREF_HIZ: item = 3; break;
3671 case AC_PINCTL_VREF_50: item = 4; break;
3672 case AC_PINCTL_VREF_GRD: item = 5; break;
3673 case AC_PINCTL_VREF_80: item = 6; break;
3674 case AC_PINCTL_VREF_100: item = 7; break;
3675 }
3676 }
3677 ucontrol->value.enumerated.item[0] = item;
3678 return 0;
3679}
3680
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003681static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3682 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003683{
3684 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3685 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3686 static unsigned int ctls[] = {
3687 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3688 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3689 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3690 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3691 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3692 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3693 };
3694 unsigned int old_ctl, new_ctl;
3695
3696 old_ctl = snd_hda_codec_read(codec, nid, 0,
3697 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3698 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3699 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003700 int val;
3701 snd_hda_codec_write_cache(codec, nid, 0,
3702 AC_VERB_SET_PIN_WIDGET_CONTROL,
3703 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003704 val = ucontrol->value.enumerated.item[0] >= 3 ?
3705 HDA_AMP_MUTE : 0;
3706 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3707 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003708 return 1;
3709 }
3710 return 0;
3711}
3712
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003713static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3714 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003715{
3716 static char *texts[] = {
3717 "Front", "Surround", "CLFE", "Side"
3718 };
3719 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3720 uinfo->count = 1;
3721 uinfo->value.enumerated.items = 4;
3722 if (uinfo->value.enumerated.item >= 4)
3723 uinfo->value.enumerated.item = 3;
3724 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3725 return 0;
3726}
3727
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003728static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3729 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003730{
3731 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3732 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3733 unsigned int sel;
3734
3735 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3736 ucontrol->value.enumerated.item[0] = sel & 3;
3737 return 0;
3738}
3739
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003740static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3741 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003742{
3743 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3744 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3745 unsigned int sel;
3746
3747 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3748 if (ucontrol->value.enumerated.item[0] != sel) {
3749 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003750 snd_hda_codec_write_cache(codec, nid, 0,
3751 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003752 return 1;
3753 }
3754 return 0;
3755}
3756
3757#define PIN_CTL_TEST(xname,nid) { \
3758 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3759 .name = xname, \
3760 .info = alc_test_pin_ctl_info, \
3761 .get = alc_test_pin_ctl_get, \
3762 .put = alc_test_pin_ctl_put, \
3763 .private_value = nid \
3764 }
3765
3766#define PIN_SRC_TEST(xname,nid) { \
3767 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3768 .name = xname, \
3769 .info = alc_test_pin_src_info, \
3770 .get = alc_test_pin_src_get, \
3771 .put = alc_test_pin_src_put, \
3772 .private_value = nid \
3773 }
3774
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003775static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003776 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3777 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3778 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3779 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003780 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3781 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3782 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3783 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003784 PIN_CTL_TEST("Front Pin Mode", 0x14),
3785 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3786 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3787 PIN_CTL_TEST("Side Pin Mode", 0x17),
3788 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3789 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3790 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3791 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3792 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3793 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3794 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3795 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3796 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3797 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3798 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3799 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3800 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3801 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3802 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3803 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3804 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3805 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003806 {
3807 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3808 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003809 .info = alc_ch_mode_info,
3810 .get = alc_ch_mode_get,
3811 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003812 },
3813 { } /* end */
3814};
3815
3816static struct hda_verb alc880_test_init_verbs[] = {
3817 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003818 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3819 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3820 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3821 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3822 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3823 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3824 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3825 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003826 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003827 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3828 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3829 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3830 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003831 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003832 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3833 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3834 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3835 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003836 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003837 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3838 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3839 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3840 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003841 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003842 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3843 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003844 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3845 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3846 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003847 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003848 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3849 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3850 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3851 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003852 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003853 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003854 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003855 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003856 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003857 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003858 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003859 /* Analog input/passthru */
3860 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3861 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3862 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3863 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3864 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003865 { }
3866};
3867#endif
3868
Linus Torvalds1da177e2005-04-16 15:20:36 -07003869/*
3870 */
3871
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003872static const char *alc880_models[ALC880_MODEL_LAST] = {
3873 [ALC880_3ST] = "3stack",
3874 [ALC880_TCL_S700] = "tcl",
3875 [ALC880_3ST_DIG] = "3stack-digout",
3876 [ALC880_CLEVO] = "clevo",
3877 [ALC880_5ST] = "5stack",
3878 [ALC880_5ST_DIG] = "5stack-digout",
3879 [ALC880_W810] = "w810",
3880 [ALC880_Z71V] = "z71v",
3881 [ALC880_6ST] = "6stack",
3882 [ALC880_6ST_DIG] = "6stack-digout",
3883 [ALC880_ASUS] = "asus",
3884 [ALC880_ASUS_W1V] = "asus-w1v",
3885 [ALC880_ASUS_DIG] = "asus-dig",
3886 [ALC880_ASUS_DIG2] = "asus-dig2",
3887 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003888 [ALC880_UNIWILL_P53] = "uniwill-p53",
3889 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003890 [ALC880_F1734] = "F1734",
3891 [ALC880_LG] = "lg",
3892 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003893 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003894#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003895 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003896#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003897 [ALC880_AUTO] = "auto",
3898};
3899
3900static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003901 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003902 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3903 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3904 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3905 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3906 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3907 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3908 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3909 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003910 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3911 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003912 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3913 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3914 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3915 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3916 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3917 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3918 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3919 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3920 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3921 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003922 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003923 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3924 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3925 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003926 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003927 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003928 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3929 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003930 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3931 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003932 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3933 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3934 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3935 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003936 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3937 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003938 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003939 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003940 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003941 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003942 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3943 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003944 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003945 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003946 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003947 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003948 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003949 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003950 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003951 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003952 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003953 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3954 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003955 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003956 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3957 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3958 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3959 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003960 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3961 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003962 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003963 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003964 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3965 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003966 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3967 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3968 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003969 /* default Intel */
3970 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003971 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3972 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003973 {}
3974};
3975
Takashi Iwai16ded522005-06-10 19:58:24 +02003976/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003977 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003978 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003979static struct alc_config_preset alc880_presets[] = {
3980 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003981 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003982 .init_verbs = { alc880_volume_init_verbs,
3983 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003984 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003985 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003986 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3987 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003988 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003989 .input_mux = &alc880_capture_source,
3990 },
3991 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003992 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003993 .init_verbs = { alc880_volume_init_verbs,
3994 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003995 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003996 .dac_nids = alc880_dac_nids,
3997 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003998 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3999 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004000 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004001 .input_mux = &alc880_capture_source,
4002 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004003 [ALC880_TCL_S700] = {
4004 .mixers = { alc880_tcl_s700_mixer },
4005 .init_verbs = { alc880_volume_init_verbs,
4006 alc880_pin_tcl_S700_init_verbs,
4007 alc880_gpio2_init_verbs },
4008 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4009 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004010 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4011 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004012 .hp_nid = 0x03,
4013 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4014 .channel_mode = alc880_2_jack_modes,
4015 .input_mux = &alc880_capture_source,
4016 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004017 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004018 .mixers = { alc880_three_stack_mixer,
4019 alc880_five_stack_mixer},
4020 .init_verbs = { alc880_volume_init_verbs,
4021 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004022 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4023 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004024 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4025 .channel_mode = alc880_fivestack_modes,
4026 .input_mux = &alc880_capture_source,
4027 },
4028 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004029 .mixers = { alc880_three_stack_mixer,
4030 alc880_five_stack_mixer },
4031 .init_verbs = { alc880_volume_init_verbs,
4032 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004033 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4034 .dac_nids = alc880_dac_nids,
4035 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004036 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4037 .channel_mode = alc880_fivestack_modes,
4038 .input_mux = &alc880_capture_source,
4039 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004040 [ALC880_6ST] = {
4041 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004042 .init_verbs = { alc880_volume_init_verbs,
4043 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004044 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4045 .dac_nids = alc880_6st_dac_nids,
4046 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4047 .channel_mode = alc880_sixstack_modes,
4048 .input_mux = &alc880_6stack_capture_source,
4049 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004050 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004051 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004052 .init_verbs = { alc880_volume_init_verbs,
4053 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004054 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4055 .dac_nids = alc880_6st_dac_nids,
4056 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004057 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4058 .channel_mode = alc880_sixstack_modes,
4059 .input_mux = &alc880_6stack_capture_source,
4060 },
4061 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004062 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004063 .init_verbs = { alc880_volume_init_verbs,
4064 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004065 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004066 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4067 .dac_nids = alc880_w810_dac_nids,
4068 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004069 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4070 .channel_mode = alc880_w810_modes,
4071 .input_mux = &alc880_capture_source,
4072 },
4073 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004074 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004075 .init_verbs = { alc880_volume_init_verbs,
4076 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004077 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4078 .dac_nids = alc880_z71v_dac_nids,
4079 .dig_out_nid = ALC880_DIGOUT_NID,
4080 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004081 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4082 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004083 .input_mux = &alc880_capture_source,
4084 },
4085 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004086 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004087 .init_verbs = { alc880_volume_init_verbs,
4088 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004089 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4090 .dac_nids = alc880_f1734_dac_nids,
4091 .hp_nid = 0x02,
4092 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4093 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004094 .input_mux = &alc880_f1734_capture_source,
4095 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004096 .setup = alc880_uniwill_p53_setup,
4097 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004098 },
4099 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004100 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004101 .init_verbs = { alc880_volume_init_verbs,
4102 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004103 alc880_gpio1_init_verbs },
4104 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4105 .dac_nids = alc880_asus_dac_nids,
4106 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4107 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004108 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004109 .input_mux = &alc880_capture_source,
4110 },
4111 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004112 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004113 .init_verbs = { alc880_volume_init_verbs,
4114 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004115 alc880_gpio1_init_verbs },
4116 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4117 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004118 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004119 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4120 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004121 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004122 .input_mux = &alc880_capture_source,
4123 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004124 [ALC880_ASUS_DIG2] = {
4125 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004126 .init_verbs = { alc880_volume_init_verbs,
4127 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004128 alc880_gpio2_init_verbs }, /* use GPIO2 */
4129 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4130 .dac_nids = alc880_asus_dac_nids,
4131 .dig_out_nid = ALC880_DIGOUT_NID,
4132 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4133 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004134 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004135 .input_mux = &alc880_capture_source,
4136 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004137 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004138 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004139 .init_verbs = { alc880_volume_init_verbs,
4140 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004141 alc880_gpio1_init_verbs },
4142 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4143 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004144 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004145 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4146 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004147 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004148 .input_mux = &alc880_capture_source,
4149 },
4150 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004151 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004152 .init_verbs = { alc880_volume_init_verbs,
4153 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004154 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4155 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004156 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004157 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4158 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004159 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004160 .input_mux = &alc880_capture_source,
4161 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004162 [ALC880_UNIWILL] = {
4163 .mixers = { alc880_uniwill_mixer },
4164 .init_verbs = { alc880_volume_init_verbs,
4165 alc880_uniwill_init_verbs },
4166 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4167 .dac_nids = alc880_asus_dac_nids,
4168 .dig_out_nid = ALC880_DIGOUT_NID,
4169 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4170 .channel_mode = alc880_threestack_modes,
4171 .need_dac_fix = 1,
4172 .input_mux = &alc880_capture_source,
4173 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004174 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004175 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004176 },
4177 [ALC880_UNIWILL_P53] = {
4178 .mixers = { alc880_uniwill_p53_mixer },
4179 .init_verbs = { alc880_volume_init_verbs,
4180 alc880_uniwill_p53_init_verbs },
4181 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4182 .dac_nids = alc880_asus_dac_nids,
4183 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004184 .channel_mode = alc880_threestack_modes,
4185 .input_mux = &alc880_capture_source,
4186 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004187 .setup = alc880_uniwill_p53_setup,
4188 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004189 },
4190 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004191 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004192 .init_verbs = { alc880_volume_init_verbs,
4193 alc880_uniwill_p53_init_verbs,
4194 alc880_beep_init_verbs },
4195 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4196 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004197 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004198 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4199 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004200 .input_mux = &alc880_capture_source,
4201 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004202 .setup = alc880_uniwill_p53_setup,
4203 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004204 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004205 [ALC880_CLEVO] = {
4206 .mixers = { alc880_three_stack_mixer },
4207 .init_verbs = { alc880_volume_init_verbs,
4208 alc880_pin_clevo_init_verbs },
4209 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4210 .dac_nids = alc880_dac_nids,
4211 .hp_nid = 0x03,
4212 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4213 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004214 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004215 .input_mux = &alc880_capture_source,
4216 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004217 [ALC880_LG] = {
4218 .mixers = { alc880_lg_mixer },
4219 .init_verbs = { alc880_volume_init_verbs,
4220 alc880_lg_init_verbs },
4221 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4222 .dac_nids = alc880_lg_dac_nids,
4223 .dig_out_nid = ALC880_DIGOUT_NID,
4224 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4225 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004226 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004227 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004228 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004229 .setup = alc880_lg_setup,
4230 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004231#ifdef CONFIG_SND_HDA_POWER_SAVE
4232 .loopbacks = alc880_lg_loopbacks,
4233#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004234 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004235 [ALC880_LG_LW] = {
4236 .mixers = { alc880_lg_lw_mixer },
4237 .init_verbs = { alc880_volume_init_verbs,
4238 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004239 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004240 .dac_nids = alc880_dac_nids,
4241 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004242 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4243 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004244 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004245 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004246 .setup = alc880_lg_lw_setup,
4247 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004248 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004249 [ALC880_MEDION_RIM] = {
4250 .mixers = { alc880_medion_rim_mixer },
4251 .init_verbs = { alc880_volume_init_verbs,
4252 alc880_medion_rim_init_verbs,
4253 alc_gpio2_init_verbs },
4254 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4255 .dac_nids = alc880_dac_nids,
4256 .dig_out_nid = ALC880_DIGOUT_NID,
4257 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4258 .channel_mode = alc880_2_jack_modes,
4259 .input_mux = &alc880_medion_rim_capture_source,
4260 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004261 .setup = alc880_medion_rim_setup,
4262 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004263 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004264#ifdef CONFIG_SND_DEBUG
4265 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004266 .mixers = { alc880_test_mixer },
4267 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004268 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4269 .dac_nids = alc880_test_dac_nids,
4270 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004271 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4272 .channel_mode = alc880_test_modes,
4273 .input_mux = &alc880_test_capture_source,
4274 },
4275#endif
4276};
4277
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004278/*
4279 * Automatic parse of I/O pins from the BIOS configuration
4280 */
4281
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004282enum {
4283 ALC_CTL_WIDGET_VOL,
4284 ALC_CTL_WIDGET_MUTE,
4285 ALC_CTL_BIND_MUTE,
4286};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004287static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004288 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4289 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004290 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004291};
4292
4293/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004294static int add_control(struct alc_spec *spec, int type, const char *name,
4295 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004296{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004297 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004298
Takashi Iwai603c4012008-07-30 15:01:44 +02004299 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4300 knew = snd_array_new(&spec->kctls);
4301 if (!knew)
4302 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004303 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004304 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004305 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004306 return -ENOMEM;
4307 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004308 return 0;
4309}
4310
4311#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4312#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4313#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4314#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004315#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4316#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4317#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4318#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4319#define ALC880_PIN_CD_NID 0x1c
4320
4321/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004322static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4323 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004324{
4325 hda_nid_t nid;
4326 int assigned[4];
4327 int i, j;
4328
4329 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004330 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004331
4332 /* check the pins hardwired to audio widget */
4333 for (i = 0; i < cfg->line_outs; i++) {
4334 nid = cfg->line_out_pins[i];
4335 if (alc880_is_fixed_pin(nid)) {
4336 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004337 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004338 assigned[idx] = 1;
4339 }
4340 }
4341 /* left pins can be connect to any audio widget */
4342 for (i = 0; i < cfg->line_outs; i++) {
4343 nid = cfg->line_out_pins[i];
4344 if (alc880_is_fixed_pin(nid))
4345 continue;
4346 /* search for an empty channel */
4347 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004348 if (!assigned[j]) {
4349 spec->multiout.dac_nids[i] =
4350 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004351 assigned[j] = 1;
4352 break;
4353 }
4354 }
4355 }
4356 spec->multiout.num_dacs = cfg->line_outs;
4357 return 0;
4358}
4359
4360/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004361static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4362 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004363{
4364 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004365 static const char *chname[4] = {
4366 "Front", "Surround", NULL /*CLFE*/, "Side"
4367 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004368 hda_nid_t nid;
4369 int i, err;
4370
4371 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004372 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004373 continue;
4374 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4375 if (i == 2) {
4376 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004377 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4378 "Center Playback Volume",
4379 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4380 HDA_OUTPUT));
4381 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004382 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004383 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4384 "LFE Playback Volume",
4385 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4386 HDA_OUTPUT));
4387 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004388 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004389 err = add_control(spec, ALC_CTL_BIND_MUTE,
4390 "Center Playback Switch",
4391 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4392 HDA_INPUT));
4393 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004394 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004395 err = add_control(spec, ALC_CTL_BIND_MUTE,
4396 "LFE Playback Switch",
4397 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4398 HDA_INPUT));
4399 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004400 return err;
4401 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004402 const char *pfx;
4403 if (cfg->line_outs == 1 &&
4404 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4405 pfx = "Speaker";
4406 else
4407 pfx = chname[i];
4408 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004409 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4410 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4411 HDA_OUTPUT));
4412 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004413 return err;
Takashi Iwaicb162b62009-08-25 16:05:03 +02004414 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004415 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4416 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4417 HDA_INPUT));
4418 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004419 return err;
4420 }
4421 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004422 return 0;
4423}
4424
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004425/* add playback controls for speaker and HP outputs */
4426static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4427 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004428{
4429 hda_nid_t nid;
4430 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004431 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004432
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004433 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004434 return 0;
4435
4436 if (alc880_is_fixed_pin(pin)) {
4437 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004438 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004439 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004440 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004441 else
4442 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004443 /* control HP volume/switch on the output mixer amp */
4444 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004445 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004446 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4447 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4448 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004449 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004450 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004451 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4452 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4453 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004454 return err;
4455 } else if (alc880_is_multi_pin(pin)) {
4456 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004457 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004458 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004459 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4460 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4461 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004462 return err;
4463 }
4464 return 0;
4465}
4466
4467/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004468static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4469 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004470 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004471{
4472 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004473 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004474
4475 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004476 err = add_control(spec, ALC_CTL_WIDGET_VOL, 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 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004481 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4482 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4483 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004484 return err;
4485 return 0;
4486}
4487
Takashi Iwai05f5f472009-08-25 13:10:18 +02004488static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004489{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004490 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4491 return (pincap & AC_PINCAP_IN) != 0;
4492}
4493
4494/* create playback/capture controls for input pins */
4495static int alc_auto_create_input_ctls(struct hda_codec *codec,
4496 const struct auto_pin_cfg *cfg,
4497 hda_nid_t mixer,
4498 hda_nid_t cap1, hda_nid_t cap2)
4499{
4500 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004501 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004502 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004503
4504 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004505 hda_nid_t pin;
4506
4507 pin = cfg->input_pins[i];
4508 if (!alc_is_input_pin(codec, pin))
4509 continue;
4510
4511 if (mixer) {
4512 idx = get_connection_index(codec, mixer, pin);
4513 if (idx >= 0) {
4514 err = new_analog_input(spec, pin,
4515 auto_pin_cfg_labels[i],
4516 idx, mixer);
4517 if (err < 0)
4518 return err;
4519 }
4520 }
4521
4522 if (!cap1)
4523 continue;
4524 idx = get_connection_index(codec, cap1, pin);
4525 if (idx < 0 && cap2)
4526 idx = get_connection_index(codec, cap2, pin);
4527 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004528 imux->items[imux->num_items].label =
4529 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004530 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004531 imux->num_items++;
4532 }
4533 }
4534 return 0;
4535}
4536
Takashi Iwai05f5f472009-08-25 13:10:18 +02004537static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4538 const struct auto_pin_cfg *cfg)
4539{
4540 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4541}
4542
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004543static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4544 unsigned int pin_type)
4545{
4546 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4547 pin_type);
4548 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004549 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4550 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004551}
4552
Kailang Yangdf694da2005-12-05 19:42:22 +01004553static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4554 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004555 int dac_idx)
4556{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004557 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004558 /* need the manual connection? */
4559 if (alc880_is_multi_pin(nid)) {
4560 struct alc_spec *spec = codec->spec;
4561 int idx = alc880_multi_pin_idx(nid);
4562 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4563 AC_VERB_SET_CONNECT_SEL,
4564 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4565 }
4566}
4567
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004568static int get_pin_type(int line_out_type)
4569{
4570 if (line_out_type == AUTO_PIN_HP_OUT)
4571 return PIN_HP;
4572 else
4573 return PIN_OUT;
4574}
4575
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004576static void alc880_auto_init_multi_out(struct hda_codec *codec)
4577{
4578 struct alc_spec *spec = codec->spec;
4579 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004580
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004581 for (i = 0; i < spec->autocfg.line_outs; i++) {
4582 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004583 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4584 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004585 }
4586}
4587
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004588static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004589{
4590 struct alc_spec *spec = codec->spec;
4591 hda_nid_t pin;
4592
Takashi Iwai82bc9552006-03-21 11:24:42 +01004593 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004594 if (pin) /* connect to front */
4595 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004596 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004597 if (pin) /* connect to front */
4598 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4599}
4600
4601static void alc880_auto_init_analog_input(struct hda_codec *codec)
4602{
4603 struct alc_spec *spec = codec->spec;
4604 int i;
4605
4606 for (i = 0; i < AUTO_PIN_LAST; i++) {
4607 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004608 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004609 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004610 if (nid != ALC880_PIN_CD_NID &&
4611 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004612 snd_hda_codec_write(codec, nid, 0,
4613 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004614 AMP_OUT_MUTE);
4615 }
4616 }
4617}
4618
4619/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004620/* return 1 if successful, 0 if the proper config is not found,
4621 * or a negative error code
4622 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004623static int alc880_parse_auto_config(struct hda_codec *codec)
4624{
4625 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004626 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004627 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004628
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004629 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4630 alc880_ignore);
4631 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004632 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004633 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004634 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004635
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004636 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4637 if (err < 0)
4638 return err;
4639 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4640 if (err < 0)
4641 return err;
4642 err = alc880_auto_create_extra_out(spec,
4643 spec->autocfg.speaker_pins[0],
4644 "Speaker");
4645 if (err < 0)
4646 return err;
4647 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4648 "Headphone");
4649 if (err < 0)
4650 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004651 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004652 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004653 return err;
4654
4655 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4656
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004657 /* check multiple SPDIF-out (for recent codecs) */
4658 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4659 hda_nid_t dig_nid;
4660 err = snd_hda_get_connections(codec,
4661 spec->autocfg.dig_out_pins[i],
4662 &dig_nid, 1);
4663 if (err < 0)
4664 continue;
4665 if (!i)
4666 spec->multiout.dig_out_nid = dig_nid;
4667 else {
4668 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4669 spec->slave_dig_outs[i - 1] = dig_nid;
4670 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4671 break;
4672 }
4673 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004674 if (spec->autocfg.dig_in_pin)
4675 spec->dig_in_nid = ALC880_DIGIN_NID;
4676
Takashi Iwai603c4012008-07-30 15:01:44 +02004677 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004678 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004679
Takashi Iwaid88897e2008-10-31 15:01:37 +01004680 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004681
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004682 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004683 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004684
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004685 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4686
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004687 return 1;
4688}
4689
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004690/* additional initialization for auto-configuration model */
4691static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004692{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004693 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004694 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004695 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004696 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004697 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004698 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004699}
4700
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004701/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4702 * one of two digital mic pins, e.g. on ALC272
4703 */
4704static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004705{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004706 struct alc_spec *spec = codec->spec;
4707 int i;
4708
4709 for (i = 0; i < spec->num_adc_nids; i++) {
4710 hda_nid_t cap = spec->capsrc_nids ?
4711 spec->capsrc_nids[i] : spec->adc_nids[i];
4712 int iidx, eidx;
4713
4714 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4715 if (iidx < 0)
4716 continue;
4717 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4718 if (eidx < 0)
4719 continue;
4720 spec->int_mic.mux_idx = iidx;
4721 spec->ext_mic.mux_idx = eidx;
4722 if (spec->capsrc_nids)
4723 spec->capsrc_nids += i;
4724 spec->adc_nids += i;
4725 spec->num_adc_nids = 1;
4726 return;
4727 }
4728 snd_printd(KERN_INFO "hda_codec: %s: "
4729 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4730 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4731 spec->auto_mic = 0; /* disable auto-mic to be sure */
4732}
4733
4734static void set_capture_mixer(struct hda_codec *codec)
4735{
4736 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01004737 static struct snd_kcontrol_new *caps[2][3] = {
4738 { alc_capture_mixer_nosrc1,
4739 alc_capture_mixer_nosrc2,
4740 alc_capture_mixer_nosrc3 },
4741 { alc_capture_mixer1,
4742 alc_capture_mixer2,
4743 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004744 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004745 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4746 int mux;
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004747 if (spec->auto_mic) {
4748 mux = 0;
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004749 fixup_automic_adc(codec);
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004750 } else if (spec->input_mux && spec->input_mux->num_items > 1)
Takashi Iwaia23b6882009-03-23 15:21:36 +01004751 mux = 1;
4752 else
4753 mux = 0;
4754 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4755 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004756}
4757
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004758#define set_beep_amp(spec, nid, idx, dir) \
4759 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4760
4761/*
4762 * OK, here we have finally the patch for ALC880
4763 */
4764
Linus Torvalds1da177e2005-04-16 15:20:36 -07004765static int patch_alc880(struct hda_codec *codec)
4766{
4767 struct alc_spec *spec;
4768 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004769 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004770
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004771 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004772 if (spec == NULL)
4773 return -ENOMEM;
4774
4775 codec->spec = spec;
4776
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004777 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4778 alc880_models,
4779 alc880_cfg_tbl);
4780 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004781 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4782 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004783 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004784 }
4785
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004786 if (board_config == ALC880_AUTO) {
4787 /* automatic parse from the BIOS config */
4788 err = alc880_parse_auto_config(codec);
4789 if (err < 0) {
4790 alc_free(codec);
4791 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004792 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004793 printk(KERN_INFO
4794 "hda_codec: Cannot set up configuration "
4795 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004796 board_config = ALC880_3ST;
4797 }
4798 }
4799
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004800 err = snd_hda_attach_beep_device(codec, 0x1);
4801 if (err < 0) {
4802 alc_free(codec);
4803 return err;
4804 }
4805
Kailang Yangdf694da2005-12-05 19:42:22 +01004806 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02004807 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004808
Linus Torvalds1da177e2005-04-16 15:20:36 -07004809 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4810 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004811 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004812
Linus Torvalds1da177e2005-04-16 15:20:36 -07004813 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4814 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4815
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004816 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004817 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004818 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004819 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02004820 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004821 if (wcap != AC_WID_AUD_IN) {
4822 spec->adc_nids = alc880_adc_nids_alt;
4823 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004824 } else {
4825 spec->adc_nids = alc880_adc_nids;
4826 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004827 }
4828 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004829 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004830 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004831
Takashi Iwai2134ea42008-01-10 16:53:55 +01004832 spec->vmaster_nid = 0x0c;
4833
Linus Torvalds1da177e2005-04-16 15:20:36 -07004834 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004835 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004836 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004837#ifdef CONFIG_SND_HDA_POWER_SAVE
4838 if (!spec->loopback.amplist)
4839 spec->loopback.amplist = alc880_loopbacks;
4840#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004841 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004842
4843 return 0;
4844}
4845
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004846
Linus Torvalds1da177e2005-04-16 15:20:36 -07004847/*
4848 * ALC260 support
4849 */
4850
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004851static hda_nid_t alc260_dac_nids[1] = {
4852 /* front */
4853 0x02,
4854};
4855
4856static hda_nid_t alc260_adc_nids[1] = {
4857 /* ADC0 */
4858 0x04,
4859};
4860
Kailang Yangdf694da2005-12-05 19:42:22 +01004861static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004862 /* ADC1 */
4863 0x05,
4864};
4865
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004866/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4867 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4868 */
4869static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004870 /* ADC0, ADC1 */
4871 0x04, 0x05
4872};
4873
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004874#define ALC260_DIGOUT_NID 0x03
4875#define ALC260_DIGIN_NID 0x06
4876
4877static struct hda_input_mux alc260_capture_source = {
4878 .num_items = 4,
4879 .items = {
4880 { "Mic", 0x0 },
4881 { "Front Mic", 0x1 },
4882 { "Line", 0x2 },
4883 { "CD", 0x4 },
4884 },
4885};
4886
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004887/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004888 * headphone jack and the internal CD lines since these are the only pins at
4889 * which audio can appear. For flexibility, also allow the option of
4890 * recording the mixer output on the second ADC (ADC0 doesn't have a
4891 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004892 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004893static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4894 {
4895 .num_items = 3,
4896 .items = {
4897 { "Mic/Line", 0x0 },
4898 { "CD", 0x4 },
4899 { "Headphone", 0x2 },
4900 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004901 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004902 {
4903 .num_items = 4,
4904 .items = {
4905 { "Mic/Line", 0x0 },
4906 { "CD", 0x4 },
4907 { "Headphone", 0x2 },
4908 { "Mixer", 0x5 },
4909 },
4910 },
4911
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004912};
4913
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004914/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4915 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004916 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004917static struct hda_input_mux alc260_acer_capture_sources[2] = {
4918 {
4919 .num_items = 4,
4920 .items = {
4921 { "Mic", 0x0 },
4922 { "Line", 0x2 },
4923 { "CD", 0x4 },
4924 { "Headphone", 0x5 },
4925 },
4926 },
4927 {
4928 .num_items = 5,
4929 .items = {
4930 { "Mic", 0x0 },
4931 { "Line", 0x2 },
4932 { "CD", 0x4 },
4933 { "Headphone", 0x6 },
4934 { "Mixer", 0x5 },
4935 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004936 },
4937};
Michael Schwingencc959482009-02-22 18:58:45 +01004938
4939/* Maxdata Favorit 100XS */
4940static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4941 {
4942 .num_items = 2,
4943 .items = {
4944 { "Line/Mic", 0x0 },
4945 { "CD", 0x4 },
4946 },
4947 },
4948 {
4949 .num_items = 3,
4950 .items = {
4951 { "Line/Mic", 0x0 },
4952 { "CD", 0x4 },
4953 { "Mixer", 0x5 },
4954 },
4955 },
4956};
4957
Linus Torvalds1da177e2005-04-16 15:20:36 -07004958/*
4959 * This is just place-holder, so there's something for alc_build_pcms to look
4960 * at when it calculates the maximum number of channels. ALC260 has no mixer
4961 * element which allows changing the channel mode, so the verb list is
4962 * never used.
4963 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004964static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004965 { 2, NULL },
4966};
4967
Kailang Yangdf694da2005-12-05 19:42:22 +01004968
4969/* Mixer combinations
4970 *
4971 * basic: base_output + input + pc_beep + capture
4972 * HP: base_output + input + capture_alt
4973 * HP_3013: hp_3013 + input + capture
4974 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004975 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004976 */
4977
4978static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004979 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004980 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004981 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4982 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4983 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4984 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4985 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004986};
Kailang Yangdf694da2005-12-05 19:42:22 +01004987
4988static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004989 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4990 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4991 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4992 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4993 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4994 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4995 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4996 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004997 { } /* end */
4998};
4999
Takashi Iwaibec15c32008-01-28 18:16:30 +01005000/* update HP, line and mono out pins according to the master switch */
5001static void alc260_hp_master_update(struct hda_codec *codec,
5002 hda_nid_t hp, hda_nid_t line,
5003 hda_nid_t mono)
5004{
5005 struct alc_spec *spec = codec->spec;
5006 unsigned int val = spec->master_sw ? PIN_HP : 0;
5007 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005008 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005009 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005010 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005011 val);
5012 /* mono (speaker) depending on the HP jack sense */
5013 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005014 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005015 val);
5016}
5017
5018static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5019 struct snd_ctl_elem_value *ucontrol)
5020{
5021 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5022 struct alc_spec *spec = codec->spec;
5023 *ucontrol->value.integer.value = spec->master_sw;
5024 return 0;
5025}
5026
5027static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5028 struct snd_ctl_elem_value *ucontrol)
5029{
5030 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5031 struct alc_spec *spec = codec->spec;
5032 int val = !!*ucontrol->value.integer.value;
5033 hda_nid_t hp, line, mono;
5034
5035 if (val == spec->master_sw)
5036 return 0;
5037 spec->master_sw = val;
5038 hp = (kcontrol->private_value >> 16) & 0xff;
5039 line = (kcontrol->private_value >> 8) & 0xff;
5040 mono = kcontrol->private_value & 0xff;
5041 alc260_hp_master_update(codec, hp, line, mono);
5042 return 1;
5043}
5044
5045static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5046 {
5047 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5048 .name = "Master Playback Switch",
5049 .info = snd_ctl_boolean_mono_info,
5050 .get = alc260_hp_master_sw_get,
5051 .put = alc260_hp_master_sw_put,
5052 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5053 },
5054 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5055 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5056 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5057 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5058 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5059 HDA_OUTPUT),
5060 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5061 { } /* end */
5062};
5063
5064static struct hda_verb alc260_hp_unsol_verbs[] = {
5065 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5066 {},
5067};
5068
5069static void alc260_hp_automute(struct hda_codec *codec)
5070{
5071 struct alc_spec *spec = codec->spec;
5072 unsigned int present;
5073
5074 present = snd_hda_codec_read(codec, 0x10, 0,
5075 AC_VERB_GET_PIN_SENSE, 0);
5076 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
5077 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5078}
5079
5080static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5081{
5082 if ((res >> 26) == ALC880_HP_EVENT)
5083 alc260_hp_automute(codec);
5084}
5085
Kailang Yangdf694da2005-12-05 19:42:22 +01005086static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005087 {
5088 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5089 .name = "Master Playback Switch",
5090 .info = snd_ctl_boolean_mono_info,
5091 .get = alc260_hp_master_sw_get,
5092 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005093 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005094 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005095 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5096 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5097 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5098 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5099 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5100 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005101 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5102 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005103 { } /* end */
5104};
5105
Kailang Yang3f878302008-08-26 13:02:23 +02005106static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5107 .ops = &snd_hda_bind_vol,
5108 .values = {
5109 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5110 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5111 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5112 0
5113 },
5114};
5115
5116static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5117 .ops = &snd_hda_bind_sw,
5118 .values = {
5119 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5120 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5121 0
5122 },
5123};
5124
5125static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5126 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5127 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5128 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5129 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5130 { } /* end */
5131};
5132
Takashi Iwaibec15c32008-01-28 18:16:30 +01005133static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5134 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5135 {},
5136};
5137
5138static void alc260_hp_3013_automute(struct hda_codec *codec)
5139{
5140 struct alc_spec *spec = codec->spec;
5141 unsigned int present;
5142
5143 present = snd_hda_codec_read(codec, 0x15, 0,
5144 AC_VERB_GET_PIN_SENSE, 0);
5145 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005146 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005147}
5148
5149static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5150 unsigned int res)
5151{
5152 if ((res >> 26) == ALC880_HP_EVENT)
5153 alc260_hp_3013_automute(codec);
5154}
5155
Kailang Yang3f878302008-08-26 13:02:23 +02005156static void alc260_hp_3012_automute(struct hda_codec *codec)
5157{
5158 unsigned int present, bits;
5159
5160 present = snd_hda_codec_read(codec, 0x10, 0,
5161 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
5162
5163 bits = present ? 0 : PIN_OUT;
5164 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5165 bits);
5166 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5167 bits);
5168 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5169 bits);
5170}
5171
5172static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5173 unsigned int res)
5174{
5175 if ((res >> 26) == ALC880_HP_EVENT)
5176 alc260_hp_3012_automute(codec);
5177}
5178
5179/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005180 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5181 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005182static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005183 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005184 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005185 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005186 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5187 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5188 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5189 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005190 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005191 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5192 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005193 { } /* end */
5194};
5195
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005196/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5197 * versions of the ALC260 don't act on requests to enable mic bias from NID
5198 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5199 * datasheet doesn't mention this restriction. At this stage it's not clear
5200 * whether this behaviour is intentional or is a hardware bug in chip
5201 * revisions available in early 2006. Therefore for now allow the
5202 * "Headphone Jack Mode" control to span all choices, but if it turns out
5203 * that the lack of mic bias for this NID is intentional we could change the
5204 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5205 *
5206 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5207 * don't appear to make the mic bias available from the "line" jack, even
5208 * though the NID used for this jack (0x14) can supply it. The theory is
5209 * that perhaps Acer have included blocking capacitors between the ALC260
5210 * and the output jack. If this turns out to be the case for all such
5211 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5212 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005213 *
5214 * The C20x Tablet series have a mono internal speaker which is controlled
5215 * via the chip's Mono sum widget and pin complex, so include the necessary
5216 * controls for such models. On models without a "mono speaker" the control
5217 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005218 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005219static struct snd_kcontrol_new alc260_acer_mixer[] = {
5220 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5221 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005222 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005223 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005224 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005225 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005226 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005227 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5228 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5229 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5230 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5231 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5232 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5233 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5234 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005235 { } /* end */
5236};
5237
Michael Schwingencc959482009-02-22 18:58:45 +01005238/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5239 */
5240static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5241 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5242 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5243 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5244 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5245 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5246 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5247 { } /* end */
5248};
5249
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005250/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5251 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5252 */
5253static struct snd_kcontrol_new alc260_will_mixer[] = {
5254 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5255 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5256 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5257 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5258 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5259 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5260 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5261 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5262 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5263 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005264 { } /* end */
5265};
5266
5267/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5268 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5269 */
5270static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5271 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5272 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5273 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5274 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5275 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5276 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5277 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5278 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5279 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5280 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5281 { } /* end */
5282};
5283
Kailang Yangdf694da2005-12-05 19:42:22 +01005284/*
5285 * initialization verbs
5286 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005287static struct hda_verb alc260_init_verbs[] = {
5288 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005289 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005290 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005291 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005292 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005293 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005294 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005295 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005296 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005297 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005298 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005299 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005300 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005301 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005302 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005303 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005304 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005305 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5306 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005307 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005308 /* set connection select to line in (default select for this ADC) */
5309 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005310 /* mute capture amp left and right */
5311 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5312 /* set connection select to line in (default select for this ADC) */
5313 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005314 /* set vol=0 Line-Out mixer amp left and right */
5315 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5316 /* unmute pin widget amp left and right (no gain on this amp) */
5317 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5318 /* set vol=0 HP mixer amp left and right */
5319 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5320 /* unmute pin widget amp left and right (no gain on this amp) */
5321 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5322 /* set vol=0 Mono mixer amp left and right */
5323 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5324 /* unmute pin widget amp left and right (no gain on this amp) */
5325 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5326 /* unmute LINE-2 out pin */
5327 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005328 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5329 * Line In 2 = 0x03
5330 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005331 /* mute analog inputs */
5332 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5333 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5334 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5335 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5336 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005337 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005338 /* mute Front out path */
5339 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5340 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5341 /* mute Headphone out path */
5342 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5343 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5344 /* mute Mono out path */
5345 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5346 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005347 { }
5348};
5349
Takashi Iwai474167d2006-05-17 17:17:43 +02005350#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005351static struct hda_verb alc260_hp_init_verbs[] = {
5352 /* Headphone and output */
5353 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5354 /* mono output */
5355 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5356 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5357 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5358 /* Mic2 (front panel) pin widget for input and vref at 80% */
5359 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5360 /* Line In pin widget for input */
5361 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5362 /* Line-2 pin widget for output */
5363 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5364 /* CD pin widget for input */
5365 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5366 /* unmute amp left and right */
5367 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5368 /* set connection select to line in (default select for this ADC) */
5369 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5370 /* unmute Line-Out mixer amp left and right (volume = 0) */
5371 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5372 /* mute pin widget amp left and right (no gain on this amp) */
5373 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5374 /* unmute HP mixer amp left and right (volume = 0) */
5375 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5376 /* mute pin widget amp left and right (no gain on this amp) */
5377 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005378 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5379 * Line In 2 = 0x03
5380 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005381 /* mute analog inputs */
5382 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5383 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5384 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5385 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5386 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005387 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5388 /* Unmute Front out path */
5389 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5390 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5391 /* Unmute Headphone out path */
5392 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5393 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5394 /* Unmute Mono out path */
5395 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5396 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5397 { }
5398};
Takashi Iwai474167d2006-05-17 17:17:43 +02005399#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005400
5401static struct hda_verb alc260_hp_3013_init_verbs[] = {
5402 /* Line out and output */
5403 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5404 /* mono output */
5405 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5406 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5407 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5408 /* Mic2 (front panel) pin widget for input and vref at 80% */
5409 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5410 /* Line In pin widget for input */
5411 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5412 /* Headphone pin widget for output */
5413 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5414 /* CD pin widget for input */
5415 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5416 /* unmute amp left and right */
5417 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5418 /* set connection select to line in (default select for this ADC) */
5419 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5420 /* unmute Line-Out mixer amp left and right (volume = 0) */
5421 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5422 /* mute pin widget amp left and right (no gain on this amp) */
5423 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5424 /* unmute HP mixer amp left and right (volume = 0) */
5425 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5426 /* mute pin widget amp left and right (no gain on this amp) */
5427 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005428 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5429 * Line In 2 = 0x03
5430 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005431 /* mute analog inputs */
5432 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5433 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5434 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5435 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5436 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005437 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5438 /* Unmute Front out path */
5439 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5440 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5441 /* Unmute Headphone out path */
5442 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5443 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5444 /* Unmute Mono out path */
5445 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5446 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5447 { }
5448};
5449
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005450/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005451 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5452 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005453 */
5454static struct hda_verb alc260_fujitsu_init_verbs[] = {
5455 /* Disable all GPIOs */
5456 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5457 /* Internal speaker is connected to headphone pin */
5458 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5459 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5460 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005461 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5462 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5463 /* Ensure all other unused pins are disabled and muted. */
5464 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5465 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005466 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005467 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005468 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005469 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5470 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5471 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005472
Jonathan Woithef7ace402006-02-28 11:46:14 +01005473 /* Disable digital (SPDIF) pins */
5474 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5475 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005476
Kailang Yangea1fb292008-08-26 12:58:38 +02005477 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005478 * when acting as an output.
5479 */
5480 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5481
5482 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005483 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5484 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5485 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5486 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5487 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5488 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5489 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5490 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5491 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005492
Jonathan Woithef7ace402006-02-28 11:46:14 +01005493 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5494 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5495 /* Unmute Line1 pin widget output buffer since it starts as an output.
5496 * If the pin mode is changed by the user the pin mode control will
5497 * take care of enabling the pin's input/output buffers as needed.
5498 * Therefore there's no need to enable the input buffer at this
5499 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005500 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005501 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005502 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005503 * mixer ctrl)
5504 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005505 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005506
Jonathan Woithef7ace402006-02-28 11:46:14 +01005507 /* Mute capture amp left and right */
5508 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005509 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005510 * in (on mic1 pin)
5511 */
5512 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005513
Jonathan Woithef7ace402006-02-28 11:46:14 +01005514 /* Do the same for the second ADC: mute capture input amp and
5515 * set ADC connection to line in (on mic1 pin)
5516 */
5517 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5518 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005519
Jonathan Woithef7ace402006-02-28 11:46:14 +01005520 /* Mute all inputs to mixer widget (even unconnected ones) */
5521 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5522 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5523 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5524 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5525 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5526 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5527 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5528 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005529
5530 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005531};
5532
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005533/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5534 * similar laptops (adapted from Fujitsu init verbs).
5535 */
5536static struct hda_verb alc260_acer_init_verbs[] = {
5537 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5538 * the headphone jack. Turn this on and rely on the standard mute
5539 * methods whenever the user wants to turn these outputs off.
5540 */
5541 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5542 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5543 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5544 /* Internal speaker/Headphone jack is connected to Line-out pin */
5545 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5546 /* Internal microphone/Mic jack is connected to Mic1 pin */
5547 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5548 /* Line In jack is connected to Line1 pin */
5549 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005550 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5551 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005552 /* Ensure all other unused pins are disabled and muted. */
5553 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5554 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005555 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5556 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5557 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5558 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5559 /* Disable digital (SPDIF) pins */
5560 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5561 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5562
Kailang Yangea1fb292008-08-26 12:58:38 +02005563 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005564 * bus when acting as outputs.
5565 */
5566 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5567 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5568
5569 /* Start with output sum widgets muted and their output gains at min */
5570 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5571 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5572 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5573 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5574 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5575 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5576 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5577 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5578 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5579
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005580 /* Unmute Line-out pin widget amp left and right
5581 * (no equiv mixer ctrl)
5582 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005583 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005584 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5585 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005586 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5587 * inputs. If the pin mode is changed by the user the pin mode control
5588 * will take care of enabling the pin's input/output buffers as needed.
5589 * Therefore there's no need to enable the input buffer at this
5590 * stage.
5591 */
5592 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5593 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5594
5595 /* Mute capture amp left and right */
5596 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5597 /* Set ADC connection select to match default mixer setting - mic
5598 * (on mic1 pin)
5599 */
5600 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5601
5602 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005603 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005604 */
5605 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005606 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005607
5608 /* Mute all inputs to mixer widget (even unconnected ones) */
5609 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5610 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5611 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5612 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5613 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5614 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5615 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5616 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5617
5618 { }
5619};
5620
Michael Schwingencc959482009-02-22 18:58:45 +01005621/* Initialisation sequence for Maxdata Favorit 100XS
5622 * (adapted from Acer init verbs).
5623 */
5624static struct hda_verb alc260_favorit100_init_verbs[] = {
5625 /* GPIO 0 enables the output jack.
5626 * Turn this on and rely on the standard mute
5627 * methods whenever the user wants to turn these outputs off.
5628 */
5629 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5630 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5631 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5632 /* Line/Mic input jack is connected to Mic1 pin */
5633 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5634 /* Ensure all other unused pins are disabled and muted. */
5635 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5636 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5637 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5638 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5639 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5640 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5641 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5642 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5643 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5644 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5645 /* Disable digital (SPDIF) pins */
5646 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5647 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5648
5649 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5650 * bus when acting as outputs.
5651 */
5652 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5653 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5654
5655 /* Start with output sum widgets muted and their output gains at min */
5656 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5657 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5658 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5659 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5660 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5661 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5662 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5663 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5664 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5665
5666 /* Unmute Line-out pin widget amp left and right
5667 * (no equiv mixer ctrl)
5668 */
5669 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5670 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5671 * inputs. If the pin mode is changed by the user the pin mode control
5672 * will take care of enabling the pin's input/output buffers as needed.
5673 * Therefore there's no need to enable the input buffer at this
5674 * stage.
5675 */
5676 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5677
5678 /* Mute capture amp left and right */
5679 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5680 /* Set ADC connection select to match default mixer setting - mic
5681 * (on mic1 pin)
5682 */
5683 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5684
5685 /* Do similar with the second ADC: mute capture input amp and
5686 * set ADC connection to mic to match ALSA's default state.
5687 */
5688 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5689 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5690
5691 /* Mute all inputs to mixer widget (even unconnected ones) */
5692 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5693 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5694 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5695 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5696 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5697 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5698 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5699 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5700
5701 { }
5702};
5703
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005704static struct hda_verb alc260_will_verbs[] = {
5705 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5706 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5707 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5708 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5709 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5710 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5711 {}
5712};
5713
5714static struct hda_verb alc260_replacer_672v_verbs[] = {
5715 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5716 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5717 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5718
5719 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5720 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5721 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5722
5723 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5724 {}
5725};
5726
5727/* toggle speaker-output according to the hp-jack state */
5728static void alc260_replacer_672v_automute(struct hda_codec *codec)
5729{
5730 unsigned int present;
5731
5732 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5733 present = snd_hda_codec_read(codec, 0x0f, 0,
5734 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5735 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005736 snd_hda_codec_write_cache(codec, 0x01, 0,
5737 AC_VERB_SET_GPIO_DATA, 1);
5738 snd_hda_codec_write_cache(codec, 0x0f, 0,
5739 AC_VERB_SET_PIN_WIDGET_CONTROL,
5740 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005741 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005742 snd_hda_codec_write_cache(codec, 0x01, 0,
5743 AC_VERB_SET_GPIO_DATA, 0);
5744 snd_hda_codec_write_cache(codec, 0x0f, 0,
5745 AC_VERB_SET_PIN_WIDGET_CONTROL,
5746 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005747 }
5748}
5749
5750static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5751 unsigned int res)
5752{
5753 if ((res >> 26) == ALC880_HP_EVENT)
5754 alc260_replacer_672v_automute(codec);
5755}
5756
Kailang Yang3f878302008-08-26 13:02:23 +02005757static struct hda_verb alc260_hp_dc7600_verbs[] = {
5758 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5759 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5760 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5761 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5762 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5763 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5764 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5765 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5766 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5767 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5768 {}
5769};
5770
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005771/* Test configuration for debugging, modelled after the ALC880 test
5772 * configuration.
5773 */
5774#ifdef CONFIG_SND_DEBUG
5775static hda_nid_t alc260_test_dac_nids[1] = {
5776 0x02,
5777};
5778static hda_nid_t alc260_test_adc_nids[2] = {
5779 0x04, 0x05,
5780};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005781/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005782 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005783 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005784 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005785static struct hda_input_mux alc260_test_capture_sources[2] = {
5786 {
5787 .num_items = 7,
5788 .items = {
5789 { "MIC1 pin", 0x0 },
5790 { "MIC2 pin", 0x1 },
5791 { "LINE1 pin", 0x2 },
5792 { "LINE2 pin", 0x3 },
5793 { "CD pin", 0x4 },
5794 { "LINE-OUT pin", 0x5 },
5795 { "HP-OUT pin", 0x6 },
5796 },
5797 },
5798 {
5799 .num_items = 8,
5800 .items = {
5801 { "MIC1 pin", 0x0 },
5802 { "MIC2 pin", 0x1 },
5803 { "LINE1 pin", 0x2 },
5804 { "LINE2 pin", 0x3 },
5805 { "CD pin", 0x4 },
5806 { "Mixer", 0x5 },
5807 { "LINE-OUT pin", 0x6 },
5808 { "HP-OUT pin", 0x7 },
5809 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005810 },
5811};
5812static struct snd_kcontrol_new alc260_test_mixer[] = {
5813 /* Output driver widgets */
5814 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5815 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5816 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5817 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5818 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5819 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5820
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005821 /* Modes for retasking pin widgets
5822 * Note: the ALC260 doesn't seem to act on requests to enable mic
5823 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5824 * mention this restriction. At this stage it's not clear whether
5825 * this behaviour is intentional or is a hardware bug in chip
5826 * revisions available at least up until early 2006. Therefore for
5827 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5828 * choices, but if it turns out that the lack of mic bias for these
5829 * NIDs is intentional we could change their modes from
5830 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5831 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005832 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5833 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5834 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5835 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5836 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5837 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5838
5839 /* Loopback mixer controls */
5840 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5841 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5842 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5843 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5844 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5845 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5846 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5847 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5848 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5849 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005850 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5851 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5852 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5853 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005854
5855 /* Controls for GPIO pins, assuming they are configured as outputs */
5856 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5857 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5858 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5859 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5860
Jonathan Woithe92621f12006-02-28 11:47:47 +01005861 /* Switches to allow the digital IO pins to be enabled. The datasheet
5862 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005863 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005864 */
5865 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5866 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5867
Jonathan Woithef8225f62008-01-08 12:16:54 +01005868 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5869 * this output to turn on an external amplifier.
5870 */
5871 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5872 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5873
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005874 { } /* end */
5875};
5876static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005877 /* Enable all GPIOs as outputs with an initial value of 0 */
5878 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5879 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5880 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5881
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005882 /* Enable retasking pins as output, initially without power amp */
5883 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5884 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5885 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5886 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5887 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5888 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5889
Jonathan Woithe92621f12006-02-28 11:47:47 +01005890 /* Disable digital (SPDIF) pins initially, but users can enable
5891 * them via a mixer switch. In the case of SPDIF-out, this initverb
5892 * payload also sets the generation to 0, output to be in "consumer"
5893 * PCM format, copyright asserted, no pre-emphasis and no validity
5894 * control.
5895 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005896 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5897 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5898
Kailang Yangea1fb292008-08-26 12:58:38 +02005899 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005900 * OUT1 sum bus when acting as an output.
5901 */
5902 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5903 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5904 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5905 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5906
5907 /* Start with output sum widgets muted and their output gains at min */
5908 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5909 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5910 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5911 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5912 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5913 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5914 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5915 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5916 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5917
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005918 /* Unmute retasking pin widget output buffers since the default
5919 * state appears to be output. As the pin mode is changed by the
5920 * user the pin mode control will take care of enabling the pin's
5921 * input/output buffers as needed.
5922 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005923 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5924 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5925 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5926 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5927 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5928 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5929 /* Also unmute the mono-out pin widget */
5930 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5931
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005932 /* Mute capture amp left and right */
5933 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005934 /* Set ADC connection select to match default mixer setting (mic1
5935 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005936 */
5937 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5938
5939 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005940 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005941 */
5942 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5943 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5944
5945 /* Mute all inputs to mixer widget (even unconnected ones) */
5946 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5947 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5948 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5949 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5950 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5951 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5952 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5953 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5954
5955 { }
5956};
5957#endif
5958
Takashi Iwai63300792008-01-24 15:31:36 +01005959#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5960#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005961
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005962#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5963#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5964
Kailang Yangdf694da2005-12-05 19:42:22 +01005965/*
5966 * for BIOS auto-configuration
5967 */
5968
5969static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005970 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005971{
5972 hda_nid_t nid_vol;
5973 unsigned long vol_val, sw_val;
5974 char name[32];
5975 int err;
5976
5977 if (nid >= 0x0f && nid < 0x11) {
5978 nid_vol = nid - 0x7;
5979 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5980 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5981 } else if (nid == 0x11) {
5982 nid_vol = nid - 0x7;
5983 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5984 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5985 } else if (nid >= 0x12 && nid <= 0x15) {
5986 nid_vol = 0x08;
5987 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5988 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5989 } else
5990 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005991
Takashi Iwai863b4512008-10-21 17:01:47 +02005992 if (!(*vol_bits & (1 << nid_vol))) {
5993 /* first control for the volume widget */
5994 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5995 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5996 if (err < 0)
5997 return err;
5998 *vol_bits |= (1 << nid_vol);
5999 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006000 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006001 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
6002 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006003 return err;
6004 return 1;
6005}
6006
6007/* add playback controls from the parsed DAC table */
6008static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6009 const struct auto_pin_cfg *cfg)
6010{
6011 hda_nid_t nid;
6012 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006013 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006014
6015 spec->multiout.num_dacs = 1;
6016 spec->multiout.dac_nids = spec->private_dac_nids;
6017 spec->multiout.dac_nids[0] = 0x02;
6018
6019 nid = cfg->line_out_pins[0];
6020 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006021 const char *pfx;
6022 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6023 pfx = "Master";
6024 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6025 pfx = "Speaker";
6026 else
6027 pfx = "Front";
6028 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006029 if (err < 0)
6030 return err;
6031 }
6032
Takashi Iwai82bc9552006-03-21 11:24:42 +01006033 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006034 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006035 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006036 if (err < 0)
6037 return err;
6038 }
6039
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006040 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006041 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006042 err = alc260_add_playback_controls(spec, nid, "Headphone",
6043 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006044 if (err < 0)
6045 return err;
6046 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006047 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006048}
6049
6050/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006051static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006052 const struct auto_pin_cfg *cfg)
6053{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006054 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006055}
6056
6057static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6058 hda_nid_t nid, int pin_type,
6059 int sel_idx)
6060{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006061 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006062 /* need the manual connection? */
6063 if (nid >= 0x12) {
6064 int idx = nid - 0x12;
6065 snd_hda_codec_write(codec, idx + 0x0b, 0,
6066 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006067 }
6068}
6069
6070static void alc260_auto_init_multi_out(struct hda_codec *codec)
6071{
6072 struct alc_spec *spec = codec->spec;
6073 hda_nid_t nid;
6074
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006075 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006076 if (nid) {
6077 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6078 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6079 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006080
Takashi Iwai82bc9552006-03-21 11:24:42 +01006081 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006082 if (nid)
6083 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6084
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006085 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006086 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006087 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006088}
Kailang Yangdf694da2005-12-05 19:42:22 +01006089
6090#define ALC260_PIN_CD_NID 0x16
6091static void alc260_auto_init_analog_input(struct hda_codec *codec)
6092{
6093 struct alc_spec *spec = codec->spec;
6094 int i;
6095
6096 for (i = 0; i < AUTO_PIN_LAST; i++) {
6097 hda_nid_t nid = spec->autocfg.input_pins[i];
6098 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006099 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006100 if (nid != ALC260_PIN_CD_NID &&
6101 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006102 snd_hda_codec_write(codec, nid, 0,
6103 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006104 AMP_OUT_MUTE);
6105 }
6106 }
6107}
6108
6109/*
6110 * generic initialization of ADC, input mixers and output mixers
6111 */
6112static struct hda_verb alc260_volume_init_verbs[] = {
6113 /*
6114 * Unmute ADC0-1 and set the default input to mic-in
6115 */
6116 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6117 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6118 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6119 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006120
Kailang Yangdf694da2005-12-05 19:42:22 +01006121 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6122 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006123 * Note: PASD motherboards uses the Line In 2 as the input for
6124 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006125 */
6126 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006127 /* mute analog inputs */
6128 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6129 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6130 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6131 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6132 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006133
6134 /*
6135 * Set up output mixers (0x08 - 0x0a)
6136 */
6137 /* set vol=0 to output mixers */
6138 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6139 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6140 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6141 /* set up input amps for analog loopback */
6142 /* Amp Indices: DAC = 0, mixer = 1 */
6143 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6144 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6145 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6146 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6147 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6148 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006149
Kailang Yangdf694da2005-12-05 19:42:22 +01006150 { }
6151};
6152
6153static int alc260_parse_auto_config(struct hda_codec *codec)
6154{
6155 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006156 int err;
6157 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6158
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006159 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6160 alc260_ignore);
6161 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006162 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006163 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6164 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006165 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006166 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006167 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006168 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006169 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006170 return err;
6171
6172 spec->multiout.max_channels = 2;
6173
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006174 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006175 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006176 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006177 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006178
Takashi Iwaid88897e2008-10-31 15:01:37 +01006179 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006180
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006181 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006182 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006183
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006184 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6185
Kailang Yangdf694da2005-12-05 19:42:22 +01006186 return 1;
6187}
6188
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006189/* additional initialization for auto-configuration model */
6190static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006191{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006192 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006193 alc260_auto_init_multi_out(codec);
6194 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006195 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006196 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006197}
6198
Takashi Iwaicb53c622007-08-10 17:21:45 +02006199#ifdef CONFIG_SND_HDA_POWER_SAVE
6200static struct hda_amp_list alc260_loopbacks[] = {
6201 { 0x07, HDA_INPUT, 0 },
6202 { 0x07, HDA_INPUT, 1 },
6203 { 0x07, HDA_INPUT, 2 },
6204 { 0x07, HDA_INPUT, 3 },
6205 { 0x07, HDA_INPUT, 4 },
6206 { } /* end */
6207};
6208#endif
6209
Kailang Yangdf694da2005-12-05 19:42:22 +01006210/*
6211 * ALC260 configurations
6212 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006213static const char *alc260_models[ALC260_MODEL_LAST] = {
6214 [ALC260_BASIC] = "basic",
6215 [ALC260_HP] = "hp",
6216 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006217 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006218 [ALC260_FUJITSU_S702X] = "fujitsu",
6219 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006220 [ALC260_WILL] = "will",
6221 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006222 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006223#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006224 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006225#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006226 [ALC260_AUTO] = "auto",
6227};
6228
6229static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006230 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006231 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006232 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006233 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01006234 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006235 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006236 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006237 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006238 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6239 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6240 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6241 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6242 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6243 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6244 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6245 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6246 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006247 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006248 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006249 {}
6250};
6251
Kailang Yangdf694da2005-12-05 19:42:22 +01006252static struct alc_config_preset alc260_presets[] = {
6253 [ALC260_BASIC] = {
6254 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006255 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006256 .init_verbs = { alc260_init_verbs },
6257 .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_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006260 .adc_nids = alc260_adc_nids,
6261 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6262 .channel_mode = alc260_modes,
6263 .input_mux = &alc260_capture_source,
6264 },
6265 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006266 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006267 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006268 .init_verbs = { alc260_init_verbs,
6269 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006270 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6271 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006272 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6273 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006274 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6275 .channel_mode = alc260_modes,
6276 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006277 .unsol_event = alc260_hp_unsol_event,
6278 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006279 },
Kailang Yang3f878302008-08-26 13:02:23 +02006280 [ALC260_HP_DC7600] = {
6281 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006282 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006283 .init_verbs = { alc260_init_verbs,
6284 alc260_hp_dc7600_verbs },
6285 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6286 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006287 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6288 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006289 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6290 .channel_mode = alc260_modes,
6291 .input_mux = &alc260_capture_source,
6292 .unsol_event = alc260_hp_3012_unsol_event,
6293 .init_hook = alc260_hp_3012_automute,
6294 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006295 [ALC260_HP_3013] = {
6296 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006297 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006298 .init_verbs = { alc260_hp_3013_init_verbs,
6299 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006300 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6301 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006302 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6303 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006304 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6305 .channel_mode = alc260_modes,
6306 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006307 .unsol_event = alc260_hp_3013_unsol_event,
6308 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006309 },
6310 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006311 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006312 .init_verbs = { alc260_fujitsu_init_verbs },
6313 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6314 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006315 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6316 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006317 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6318 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006319 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6320 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006321 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006322 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006323 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006324 .init_verbs = { alc260_acer_init_verbs },
6325 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6326 .dac_nids = alc260_dac_nids,
6327 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6328 .adc_nids = alc260_dual_adc_nids,
6329 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6330 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006331 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6332 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006333 },
Michael Schwingencc959482009-02-22 18:58:45 +01006334 [ALC260_FAVORIT100] = {
6335 .mixers = { alc260_favorit100_mixer },
6336 .init_verbs = { alc260_favorit100_init_verbs },
6337 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6338 .dac_nids = alc260_dac_nids,
6339 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6340 .adc_nids = alc260_dual_adc_nids,
6341 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6342 .channel_mode = alc260_modes,
6343 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6344 .input_mux = alc260_favorit100_capture_sources,
6345 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006346 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006347 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006348 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6349 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6350 .dac_nids = alc260_dac_nids,
6351 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6352 .adc_nids = alc260_adc_nids,
6353 .dig_out_nid = ALC260_DIGOUT_NID,
6354 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6355 .channel_mode = alc260_modes,
6356 .input_mux = &alc260_capture_source,
6357 },
6358 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006359 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006360 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6361 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6362 .dac_nids = alc260_dac_nids,
6363 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6364 .adc_nids = alc260_adc_nids,
6365 .dig_out_nid = ALC260_DIGOUT_NID,
6366 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6367 .channel_mode = alc260_modes,
6368 .input_mux = &alc260_capture_source,
6369 .unsol_event = alc260_replacer_672v_unsol_event,
6370 .init_hook = alc260_replacer_672v_automute,
6371 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006372#ifdef CONFIG_SND_DEBUG
6373 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006374 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006375 .init_verbs = { alc260_test_init_verbs },
6376 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6377 .dac_nids = alc260_test_dac_nids,
6378 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6379 .adc_nids = alc260_test_adc_nids,
6380 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6381 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006382 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6383 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006384 },
6385#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006386};
6387
Linus Torvalds1da177e2005-04-16 15:20:36 -07006388static int patch_alc260(struct hda_codec *codec)
6389{
6390 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006391 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006392
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006393 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006394 if (spec == NULL)
6395 return -ENOMEM;
6396
6397 codec->spec = spec;
6398
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006399 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6400 alc260_models,
6401 alc260_cfg_tbl);
6402 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006403 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006404 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006405 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006406 }
6407
Kailang Yangdf694da2005-12-05 19:42:22 +01006408 if (board_config == ALC260_AUTO) {
6409 /* automatic parse from the BIOS config */
6410 err = alc260_parse_auto_config(codec);
6411 if (err < 0) {
6412 alc_free(codec);
6413 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006414 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006415 printk(KERN_INFO
6416 "hda_codec: Cannot set up configuration "
6417 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006418 board_config = ALC260_BASIC;
6419 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006420 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006421
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006422 err = snd_hda_attach_beep_device(codec, 0x1);
6423 if (err < 0) {
6424 alc_free(codec);
6425 return err;
6426 }
6427
Kailang Yangdf694da2005-12-05 19:42:22 +01006428 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006429 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006430
Linus Torvalds1da177e2005-04-16 15:20:36 -07006431 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6432 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6433
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006434 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6435 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6436
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006437 if (!spec->adc_nids && spec->input_mux) {
6438 /* check whether NID 0x04 is valid */
6439 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006440 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006441 /* get type */
6442 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6443 spec->adc_nids = alc260_adc_nids_alt;
6444 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6445 } else {
6446 spec->adc_nids = alc260_adc_nids;
6447 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6448 }
6449 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006450 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006451 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006452
Takashi Iwai2134ea42008-01-10 16:53:55 +01006453 spec->vmaster_nid = 0x08;
6454
Linus Torvalds1da177e2005-04-16 15:20:36 -07006455 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006456 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006457 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006458#ifdef CONFIG_SND_HDA_POWER_SAVE
6459 if (!spec->loopback.amplist)
6460 spec->loopback.amplist = alc260_loopbacks;
6461#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006462 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006463
6464 return 0;
6465}
6466
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006467
Linus Torvalds1da177e2005-04-16 15:20:36 -07006468/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006469 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006470 *
6471 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6472 * configuration. Each pin widget can choose any input DACs and a mixer.
6473 * Each ADC is connected from a mixer of all inputs. This makes possible
6474 * 6-channel independent captures.
6475 *
6476 * In addition, an independent DAC for the multi-playback (not used in this
6477 * driver yet).
6478 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006479#define ALC882_DIGOUT_NID 0x06
6480#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006481#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6482#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6483#define ALC1200_DIGOUT_NID 0x10
6484
Linus Torvalds1da177e2005-04-16 15:20:36 -07006485
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006486static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006487 { 8, NULL }
6488};
6489
Takashi Iwai4953550a2009-06-30 15:28:30 +02006490/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006491static hda_nid_t alc882_dac_nids[4] = {
6492 /* front, rear, clfe, rear_surr */
6493 0x02, 0x03, 0x04, 0x05
6494};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006495#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006496
Takashi Iwai4953550a2009-06-30 15:28:30 +02006497/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006498#define alc882_adc_nids alc880_adc_nids
6499#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006500#define alc883_adc_nids alc882_adc_nids_alt
6501static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6502static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6503#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006504
Takashi Iwaie1406342008-02-11 18:32:32 +01006505static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6506static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006507#define alc883_capsrc_nids alc882_capsrc_nids_alt
6508static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6509#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006510
Linus Torvalds1da177e2005-04-16 15:20:36 -07006511/* input MUX */
6512/* FIXME: should be a matrix-type input source selection */
6513
6514static struct hda_input_mux alc882_capture_source = {
6515 .num_items = 4,
6516 .items = {
6517 { "Mic", 0x0 },
6518 { "Front Mic", 0x1 },
6519 { "Line", 0x2 },
6520 { "CD", 0x4 },
6521 },
6522};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006523
Takashi Iwai4953550a2009-06-30 15:28:30 +02006524#define alc883_capture_source alc882_capture_source
6525
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006526static struct hda_input_mux alc889_capture_source = {
6527 .num_items = 3,
6528 .items = {
6529 { "Front Mic", 0x0 },
6530 { "Mic", 0x3 },
6531 { "Line", 0x2 },
6532 },
6533};
6534
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006535static struct hda_input_mux mb5_capture_source = {
6536 .num_items = 3,
6537 .items = {
6538 { "Mic", 0x1 },
6539 { "Line", 0x2 },
6540 { "CD", 0x4 },
6541 },
6542};
6543
Takashi Iwai4953550a2009-06-30 15:28:30 +02006544static struct hda_input_mux alc883_3stack_6ch_intel = {
6545 .num_items = 4,
6546 .items = {
6547 { "Mic", 0x1 },
6548 { "Front Mic", 0x0 },
6549 { "Line", 0x2 },
6550 { "CD", 0x4 },
6551 },
6552};
6553
6554static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6555 .num_items = 2,
6556 .items = {
6557 { "Mic", 0x1 },
6558 { "Line", 0x2 },
6559 },
6560};
6561
6562static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6563 .num_items = 4,
6564 .items = {
6565 { "Mic", 0x0 },
6566 { "iMic", 0x1 },
6567 { "Line", 0x2 },
6568 { "CD", 0x4 },
6569 },
6570};
6571
6572static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6573 .num_items = 2,
6574 .items = {
6575 { "Mic", 0x0 },
6576 { "Int Mic", 0x1 },
6577 },
6578};
6579
6580static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6581 .num_items = 3,
6582 .items = {
6583 { "Mic", 0x0 },
6584 { "Front Mic", 0x1 },
6585 { "Line", 0x4 },
6586 },
6587};
6588
6589static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6590 .num_items = 2,
6591 .items = {
6592 { "Mic", 0x0 },
6593 { "Line", 0x2 },
6594 },
6595};
6596
6597static struct hda_input_mux alc889A_mb31_capture_source = {
6598 .num_items = 2,
6599 .items = {
6600 { "Mic", 0x0 },
6601 /* Front Mic (0x01) unused */
6602 { "Line", 0x2 },
6603 /* Line 2 (0x03) unused */
6604 /* CD (0x04) unsused? */
6605 },
6606};
6607
6608/*
6609 * 2ch mode
6610 */
6611static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6612 { 2, NULL }
6613};
6614
Kailang Yangdf694da2005-12-05 19:42:22 +01006615/*
Kailang Yang272a5272007-05-14 11:00:38 +02006616 * 2ch mode
6617 */
6618static struct hda_verb alc882_3ST_ch2_init[] = {
6619 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6620 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6621 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6622 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6623 { } /* end */
6624};
6625
6626/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006627 * 4ch mode
6628 */
6629static struct hda_verb alc882_3ST_ch4_init[] = {
6630 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6631 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
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
6638/*
Kailang Yang272a5272007-05-14 11:00:38 +02006639 * 6ch mode
6640 */
6641static struct hda_verb alc882_3ST_ch6_init[] = {
6642 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6643 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6644 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6645 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6646 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6647 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6648 { } /* end */
6649};
6650
Takashi Iwai4953550a2009-06-30 15:28:30 +02006651static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006652 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006653 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006654 { 6, alc882_3ST_ch6_init },
6655};
6656
Takashi Iwai4953550a2009-06-30 15:28:30 +02006657#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6658
Kailang Yang272a5272007-05-14 11:00:38 +02006659/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006660 * 6ch mode
6661 */
6662static struct hda_verb alc882_sixstack_ch6_init[] = {
6663 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6664 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6665 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6666 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6667 { } /* end */
6668};
6669
6670/*
6671 * 8ch mode
6672 */
6673static struct hda_verb alc882_sixstack_ch8_init[] = {
6674 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6675 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6676 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6677 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6678 { } /* end */
6679};
6680
6681static struct hda_channel_mode alc882_sixstack_modes[2] = {
6682 { 6, alc882_sixstack_ch6_init },
6683 { 8, alc882_sixstack_ch8_init },
6684};
6685
Takashi Iwai87350ad2007-08-16 18:19:38 +02006686/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006687 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006688 */
6689
6690/*
6691 * 2ch mode
6692 */
6693static struct hda_verb alc885_mbp_ch2_init[] = {
6694 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6695 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6696 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6697 { } /* end */
6698};
6699
6700/*
6701 * 6ch mode
6702 */
6703static struct hda_verb alc885_mbp_ch6_init[] = {
6704 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6705 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6706 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6707 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6708 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6709 { } /* end */
6710};
6711
6712static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6713 { 2, alc885_mbp_ch2_init },
6714 { 6, alc885_mbp_ch6_init },
6715};
6716
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006717/*
6718 * 2ch
6719 * Speakers/Woofer/HP = Front
6720 * LineIn = Input
6721 */
6722static struct hda_verb alc885_mb5_ch2_init[] = {
6723 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6724 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6725 { } /* end */
6726};
6727
6728/*
6729 * 6ch mode
6730 * Speakers/HP = Front
6731 * Woofer = LFE
6732 * LineIn = Surround
6733 */
6734static struct hda_verb alc885_mb5_ch6_init[] = {
6735 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6736 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6737 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6738 { } /* end */
6739};
6740
6741static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6742 { 2, alc885_mb5_ch2_init },
6743 { 6, alc885_mb5_ch6_init },
6744};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006745
Takashi Iwai4953550a2009-06-30 15:28:30 +02006746
6747/*
6748 * 2ch mode
6749 */
6750static struct hda_verb alc883_4ST_ch2_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_IN },
6756 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6757 { } /* end */
6758};
6759
6760/*
6761 * 4ch mode
6762 */
6763static struct hda_verb alc883_4ST_ch4_init[] = {
6764 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6765 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6766 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6767 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6768 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6769 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6770 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6771 { } /* end */
6772};
6773
6774/*
6775 * 6ch mode
6776 */
6777static struct hda_verb alc883_4ST_ch6_init[] = {
6778 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6779 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6780 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6781 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6782 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6783 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6784 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6785 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6786 { } /* end */
6787};
6788
6789/*
6790 * 8ch mode
6791 */
6792static struct hda_verb alc883_4ST_ch8_init[] = {
6793 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6794 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6795 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6796 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6797 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6798 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6799 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6800 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6801 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6802 { } /* end */
6803};
6804
6805static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6806 { 2, alc883_4ST_ch2_init },
6807 { 4, alc883_4ST_ch4_init },
6808 { 6, alc883_4ST_ch6_init },
6809 { 8, alc883_4ST_ch8_init },
6810};
6811
6812
6813/*
6814 * 2ch mode
6815 */
6816static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6817 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6818 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6819 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6820 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6821 { } /* end */
6822};
6823
6824/*
6825 * 4ch mode
6826 */
6827static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6828 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6829 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
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
6836/*
6837 * 6ch mode
6838 */
6839static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6840 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6841 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6842 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6843 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6844 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6845 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6846 { } /* end */
6847};
6848
6849static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6850 { 2, alc883_3ST_ch2_intel_init },
6851 { 4, alc883_3ST_ch4_intel_init },
6852 { 6, alc883_3ST_ch6_intel_init },
6853};
6854
6855/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006856 * 2ch mode
6857 */
6858static struct hda_verb alc889_ch2_intel_init[] = {
6859 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6860 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
6861 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
6862 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
6863 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6864 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6865 { } /* end */
6866};
6867
6868/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006869 * 6ch mode
6870 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006871static struct hda_verb alc889_ch6_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_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006877 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6878 { } /* end */
6879};
6880
6881/*
6882 * 8ch mode
6883 */
6884static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006885 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6886 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6887 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6888 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6889 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006890 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6891 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006892 { } /* end */
6893};
6894
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006895static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
6896 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006897 { 6, alc889_ch6_intel_init },
6898 { 8, alc889_ch8_intel_init },
6899};
6900
6901/*
6902 * 6ch mode
6903 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006904static struct hda_verb alc883_sixstack_ch6_init[] = {
6905 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6906 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6907 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6908 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6909 { } /* end */
6910};
6911
6912/*
6913 * 8ch mode
6914 */
6915static struct hda_verb alc883_sixstack_ch8_init[] = {
6916 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6917 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6918 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6919 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6920 { } /* end */
6921};
6922
6923static struct hda_channel_mode alc883_sixstack_modes[2] = {
6924 { 6, alc883_sixstack_ch6_init },
6925 { 8, alc883_sixstack_ch8_init },
6926};
6927
6928
Linus Torvalds1da177e2005-04-16 15:20:36 -07006929/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6930 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6931 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006932static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006933 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006934 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006935 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006936 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006937 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6938 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006939 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6940 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006941 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006942 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006943 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6944 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6945 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6946 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6947 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6948 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006949 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006950 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6951 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006952 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006953 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006954 { } /* end */
6955};
6956
Takashi Iwai87350ad2007-08-16 18:19:38 +02006957static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006958 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6959 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6960 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6961 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6962 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6963 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006964 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6965 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006966 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006967 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6968 { } /* end */
6969};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006970
6971static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006972 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6973 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6974 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6975 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
6976 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
6977 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
6978 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
6979 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006980 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6981 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6982 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6983 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6984 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
6985 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
6986 { } /* end */
6987};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006988
Kailang Yangbdd148a2007-05-08 15:19:08 +02006989static struct snd_kcontrol_new alc882_w2jc_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_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6993 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6994 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6995 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6996 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6997 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6998 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006999 { } /* end */
7000};
7001
Kailang Yang272a5272007-05-14 11:00:38 +02007002static struct snd_kcontrol_new alc882_targa_mixer[] = {
7003 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7004 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7005 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7006 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7007 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7008 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7009 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7010 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7011 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007012 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007013 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7014 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007015 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007016 { } /* end */
7017};
7018
7019/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7020 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7021 */
7022static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7023 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7024 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7025 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7026 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7027 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7028 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7029 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7030 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7031 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7032 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7033 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7034 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007035 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007036 { } /* end */
7037};
7038
Takashi Iwai914759b2007-09-06 14:52:04 +02007039static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7040 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7041 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7042 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7043 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7044 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7045 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7046 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7047 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7048 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7049 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007050 { } /* end */
7051};
7052
Kailang Yangdf694da2005-12-05 19:42:22 +01007053static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7054 {
7055 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7056 .name = "Channel Mode",
7057 .info = alc_ch_mode_info,
7058 .get = alc_ch_mode_get,
7059 .put = alc_ch_mode_put,
7060 },
7061 { } /* end */
7062};
7063
Takashi Iwai4953550a2009-06-30 15:28:30 +02007064static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007065 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007066 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7067 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7068 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007069 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007070 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7071 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7072 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007073 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007074 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7075 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7076 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007077 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007078 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7079 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7080 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007081
Takashi Iwaicb638122009-07-03 10:56:10 +02007082 /* mute analog input loopbacks */
7083 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7084 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7085 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7086 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7087 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7088
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007089 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007090 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007091 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007092 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007093 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007094 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007095 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007096 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007097 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007098 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007099 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007100 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007101 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007102 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007103 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007104 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007105 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007106 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007107 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7108 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007109 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007110 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7111 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007112 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007113 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7114 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7115 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7116 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7117 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007118 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007119 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007120
7121 /* FIXME: use matrix-type input source selection */
7122 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007123 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007124 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7125 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7126 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7127 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007128 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007129 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7130 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7131 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7132 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007133 /* ADC2: mute amp left and right */
7134 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007135 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007136 /* ADC3: mute amp left and right */
7137 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007138 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007139
7140 { }
7141};
7142
Takashi Iwai4953550a2009-06-30 15:28:30 +02007143static struct hda_verb alc882_adc1_init_verbs[] = {
7144 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7145 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7146 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7147 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7148 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7149 /* ADC1: mute amp left and right */
7150 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7151 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7152 { }
7153};
7154
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007155static struct hda_verb alc882_eapd_verbs[] = {
7156 /* change to EAPD mode */
7157 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007158 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007159 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007160};
7161
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007162static struct hda_verb alc889_eapd_verbs[] = {
7163 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7164 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7165 { }
7166};
7167
Wu Fengguang6732bd02009-07-30 09:19:14 +02007168static struct hda_verb alc_hp15_unsol_verbs[] = {
7169 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7170 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7171 {}
7172};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007173
7174static struct hda_verb alc885_init_verbs[] = {
7175 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7176 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7177 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7178 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7179 /* Rear mixer */
7180 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7181 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7182 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7183 /* CLFE mixer */
7184 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7185 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7186 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7187 /* Side mixer */
7188 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7189 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7190 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7191
7192 /* mute analog input loopbacks */
7193 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7194 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7195 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7196
7197 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007198 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007199 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7200 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7201 /* Front Pin: output 0 (0x0c) */
7202 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7203 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7204 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7205 /* Rear Pin: output 1 (0x0d) */
7206 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7207 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7208 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7209 /* CLFE Pin: output 2 (0x0e) */
7210 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7211 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7212 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7213 /* Side Pin: output 3 (0x0f) */
7214 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7215 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7216 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7217 /* Mic (rear) pin: input vref at 80% */
7218 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7219 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7220 /* Front Mic pin: input vref at 80% */
7221 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7222 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7223 /* Line In pin: input */
7224 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7225 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7226
7227 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7228 /* Input mixer1 */
7229 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7230 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7231 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7232 /* Input mixer2 */
7233 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7234 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7235 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7236 /* Input mixer3 */
7237 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7238 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7239 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7240 /* ADC2: mute amp left and right */
7241 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7242 /* ADC3: mute amp left and right */
7243 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7244
7245 { }
7246};
7247
7248static struct hda_verb alc885_init_input_verbs[] = {
7249 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7250 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7251 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7252 { }
7253};
7254
7255
7256/* Unmute Selector 24h and set the default input to front mic */
7257static struct hda_verb alc889_init_input_verbs[] = {
7258 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7259 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7260 { }
7261};
7262
7263
Takashi Iwai4953550a2009-06-30 15:28:30 +02007264#define alc883_init_verbs alc882_base_init_verbs
7265
Tobin Davis9102cd12006-12-15 10:02:12 +01007266/* Mac Pro test */
7267static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7268 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7269 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7270 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7271 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7272 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007273 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01007274 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
7275 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007276 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007277 { } /* end */
7278};
7279
7280static struct hda_verb alc882_macpro_init_verbs[] = {
7281 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7282 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7283 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7284 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7285 /* Front Pin: output 0 (0x0c) */
7286 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7287 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7288 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7289 /* Front Mic pin: input vref at 80% */
7290 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7291 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7292 /* Speaker: output */
7293 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7294 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7295 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7296 /* Headphone output (output 0 - 0x0c) */
7297 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7298 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7299 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7300
7301 /* FIXME: use matrix-type input source selection */
7302 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7303 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7304 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7305 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7306 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7307 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7308 /* Input mixer2 */
7309 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7310 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7311 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7312 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7313 /* Input mixer3 */
7314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7315 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7316 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7317 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7318 /* ADC1: mute amp left and right */
7319 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7320 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7321 /* ADC2: mute amp left and right */
7322 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7323 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7324 /* ADC3: mute amp left and right */
7325 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7326 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7327
7328 { }
7329};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007330
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007331/* Macbook 5,1 */
7332static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007333 /* DACs */
7334 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7335 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7336 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7337 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007338 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007339 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7340 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7341 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007342 /* Surround mixer */
7343 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7344 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7345 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7346 /* LFE mixer */
7347 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7349 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7350 /* HP mixer */
7351 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7352 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7353 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7354 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007355 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7356 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007357 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7358 /* LFE Pin (0x0e) */
7359 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7360 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7361 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7362 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007363 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7364 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007365 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007366 /* Front Mic pin: input vref at 80% */
7367 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7368 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7369 /* Line In pin */
7370 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7371 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7372
7373 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7374 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7375 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7376 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7377 { }
7378};
7379
Takashi Iwai87350ad2007-08-16 18:19:38 +02007380/* Macbook Pro rev3 */
7381static struct hda_verb alc885_mbp3_init_verbs[] = {
7382 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7383 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7384 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7385 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7386 /* Rear mixer */
7387 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7388 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7389 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7390 /* Front Pin: output 0 (0x0c) */
7391 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7392 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7393 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7394 /* HP Pin: output 0 (0x0d) */
7395 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
7396 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7397 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7398 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7399 /* Mic (rear) pin: input vref at 80% */
7400 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7401 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7402 /* Front Mic pin: input vref at 80% */
7403 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7404 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7405 /* Line In pin: use output 1 when in LineOut mode */
7406 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7407 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7408 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7409
7410 /* FIXME: use matrix-type input source selection */
7411 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7412 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7413 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7414 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7415 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7416 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7417 /* Input mixer2 */
7418 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7419 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7420 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7421 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7422 /* Input mixer3 */
7423 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7424 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7425 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7426 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7427 /* ADC1: mute amp left and right */
7428 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7429 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7430 /* ADC2: mute amp left and right */
7431 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7432 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7433 /* ADC3: mute amp left and right */
7434 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7435 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7436
7437 { }
7438};
7439
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007440/* iMac 24 mixer. */
7441static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7442 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7443 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7444 { } /* end */
7445};
7446
7447/* iMac 24 init verbs. */
7448static struct hda_verb alc885_imac24_init_verbs[] = {
7449 /* Internal speakers: output 0 (0x0c) */
7450 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7451 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7452 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7453 /* Internal speakers: output 0 (0x0c) */
7454 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7455 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7456 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7457 /* Headphone: output 0 (0x0c) */
7458 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7459 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7460 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7461 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7462 /* Front Mic: input vref at 80% */
7463 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7464 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7465 { }
7466};
7467
7468/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007469static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007470{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007471 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007472
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007473 spec->autocfg.hp_pins[0] = 0x14;
7474 spec->autocfg.speaker_pins[0] = 0x18;
7475 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007476}
7477
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007478static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007479{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007480 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007481
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007482 spec->autocfg.hp_pins[0] = 0x15;
7483 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02007484}
7485
7486
Kailang Yang272a5272007-05-14 11:00:38 +02007487static struct hda_verb alc882_targa_verbs[] = {
7488 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7489 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7490
7491 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7492 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007493
Kailang Yang272a5272007-05-14 11:00:38 +02007494 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7495 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7496 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7497
7498 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007499 { } /* end */
7500};
7501
7502/* toggle speaker-output according to the hp-jack state */
7503static void alc882_targa_automute(struct hda_codec *codec)
7504{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007505 struct alc_spec *spec = codec->spec;
7506 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007507 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007508 spec->jack_present ? 1 : 3);
7509}
7510
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007511static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007512{
7513 struct alc_spec *spec = codec->spec;
7514
7515 spec->autocfg.hp_pins[0] = 0x14;
7516 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02007517}
7518
7519static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7520{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007521 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007522 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007523}
7524
7525static struct hda_verb alc882_asus_a7j_verbs[] = {
7526 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7527 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7528
7529 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7530 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7531 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007532
Kailang Yang272a5272007-05-14 11:00:38 +02007533 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7534 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7535 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7536
7537 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7538 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7539 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7540 { } /* end */
7541};
7542
Takashi Iwai914759b2007-09-06 14:52:04 +02007543static struct hda_verb alc882_asus_a7m_verbs[] = {
7544 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7545 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7546
7547 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7548 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7549 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007550
Takashi Iwai914759b2007-09-06 14:52:04 +02007551 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7552 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7553 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7554
7555 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7556 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7557 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7558 { } /* end */
7559};
7560
Tobin Davis9102cd12006-12-15 10:02:12 +01007561static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7562{
7563 unsigned int gpiostate, gpiomask, gpiodir;
7564
7565 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7566 AC_VERB_GET_GPIO_DATA, 0);
7567
7568 if (!muted)
7569 gpiostate |= (1 << pin);
7570 else
7571 gpiostate &= ~(1 << pin);
7572
7573 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7574 AC_VERB_GET_GPIO_MASK, 0);
7575 gpiomask |= (1 << pin);
7576
7577 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7578 AC_VERB_GET_GPIO_DIRECTION, 0);
7579 gpiodir |= (1 << pin);
7580
7581
7582 snd_hda_codec_write(codec, codec->afg, 0,
7583 AC_VERB_SET_GPIO_MASK, gpiomask);
7584 snd_hda_codec_write(codec, codec->afg, 0,
7585 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7586
7587 msleep(1);
7588
7589 snd_hda_codec_write(codec, codec->afg, 0,
7590 AC_VERB_SET_GPIO_DATA, gpiostate);
7591}
7592
Takashi Iwai7debbe52007-08-16 15:01:03 +02007593/* set up GPIO at initialization */
7594static void alc885_macpro_init_hook(struct hda_codec *codec)
7595{
7596 alc882_gpio_mute(codec, 0, 0);
7597 alc882_gpio_mute(codec, 1, 0);
7598}
7599
7600/* set up GPIO and update auto-muting at initialization */
7601static void alc885_imac24_init_hook(struct hda_codec *codec)
7602{
7603 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007604 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007605}
7606
Kailang Yangdf694da2005-12-05 19:42:22 +01007607/*
7608 * generic initialization of ADC, input mixers and output mixers
7609 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007610static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007611 /*
7612 * Unmute ADC0-2 and set the default input to mic-in
7613 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007614 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7615 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7616 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7617 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7618
Takashi Iwaicb53c622007-08-10 17:21:45 +02007619 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007620 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007621 * Note: PASD motherboards uses the Line In 2 as the input for
7622 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007623 */
7624 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007625 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7626 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7627 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7628 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7629 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007630
7631 /*
7632 * Set up output mixers (0x0c - 0x0f)
7633 */
7634 /* set vol=0 to output mixers */
7635 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7636 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7637 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7638 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7639 /* set up input amps for analog loopback */
7640 /* Amp Indices: DAC = 0, mixer = 1 */
7641 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7642 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7643 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7644 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7645 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7646 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7647 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7648 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7649 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7650 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7651
7652 /* FIXME: use matrix-type input source selection */
7653 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01007654 /* Input mixer2 */
7655 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7656 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7657 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7658 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7659 /* Input mixer3 */
7660 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7661 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7662 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7663 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7664
7665 { }
7666};
7667
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007668/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7669static struct hda_verb alc889A_mb31_ch2_init[] = {
7670 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7671 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7672 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7673 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7674 { } /* end */
7675};
7676
7677/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7678static struct hda_verb alc889A_mb31_ch4_init[] = {
7679 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7680 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7681 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7682 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7683 { } /* end */
7684};
7685
7686/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7687static struct hda_verb alc889A_mb31_ch5_init[] = {
7688 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7689 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7690 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7691 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7692 { } /* end */
7693};
7694
7695/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7696static struct hda_verb alc889A_mb31_ch6_init[] = {
7697 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7698 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7699 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7700 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7701 { } /* end */
7702};
7703
7704static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7705 { 2, alc889A_mb31_ch2_init },
7706 { 4, alc889A_mb31_ch4_init },
7707 { 5, alc889A_mb31_ch5_init },
7708 { 6, alc889A_mb31_ch6_init },
7709};
7710
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007711static struct hda_verb alc883_medion_eapd_verbs[] = {
7712 /* eanable EAPD on medion laptop */
7713 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7714 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7715 { }
7716};
7717
Takashi Iwai4953550a2009-06-30 15:28:30 +02007718#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007719
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007720static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7721 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7722 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7723 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7724 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7725 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7726 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7727 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7728 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7729 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7730 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7731 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7732 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7733 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007734 { } /* end */
7735};
7736
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007737static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007738 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7739 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7740 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7741 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7742 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7743 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7744 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7745 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7746 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7747 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007748 { } /* end */
7749};
7750
Jiang zhefb97dc62008-03-06 11:07:11 +01007751static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7752 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7753 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7754 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7755 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7756 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7757 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7758 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7759 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7760 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7761 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007762 { } /* end */
7763};
7764
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007765static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7766 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7767 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7768 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7769 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7770 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7771 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7772 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7773 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007774 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007775 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7776 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007777 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007778 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007779 { } /* end */
7780};
7781
7782static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7783 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7784 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7785 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7786 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7787 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7788 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7789 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7790 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7791 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7792 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7793 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7794 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7795 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7796 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007797 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007798 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7799 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007800 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007801 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007802 { } /* end */
7803};
7804
Jiang zhe17bba1b2008-06-04 12:11:07 +02007805static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7806 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7807 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7808 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7809 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7810 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7811 HDA_OUTPUT),
7812 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7813 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7814 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7815 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7816 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7817 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7818 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7819 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7820 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7821 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7822 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7823 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7824 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7825 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007826 { } /* end */
7827};
7828
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007829static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
7830 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7831 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7832 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7833 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7834 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7835 HDA_OUTPUT),
7836 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7837 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7838 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7839 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7840 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
7841 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7842 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7843 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7844 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
7845 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
7846 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
7847 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7848 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7849 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7850 { } /* end */
7851};
7852
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007853static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007854 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007855 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007856 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007857 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007858 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7859 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007860 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7861 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007862 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7863 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7864 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7865 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7866 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7867 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007868 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007869 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7870 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007871 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007872 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007873 { } /* end */
7874};
7875
Sasha Alexandrc2592492009-06-16 14:52:54 -04007876static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007877 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7878 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7879 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7880 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7881 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7882 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7883 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7884 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7885 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7886 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7887 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7888 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7889 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7890 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007891 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007892 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007893 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007894};
Kailang Yangccc656c2006-10-17 12:32:26 +02007895
Sasha Alexandrc2592492009-06-16 14:52:54 -04007896static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007897 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7898 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7899 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7900 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7901 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7902 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007903 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007904 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007905 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7906 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7907 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007908 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007909};
Kailang Yangccc656c2006-10-17 12:32:26 +02007910
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007911static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7912 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7913 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007914 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7915 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007916 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7917 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7918 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7919 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007920 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007921};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007922
Kailang Yang272a5272007-05-14 11:00:38 +02007923static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7924 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7925 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7926 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 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("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7932 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007933 { } /* end */
7934};
7935
7936static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7937 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7938 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7939 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7940 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7941 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7942 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7943 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7944 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7945 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007946 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007947};
Kailang Yang272a5272007-05-14 11:00:38 +02007948
Tobin Davis2880a8672007-08-07 11:50:26 +02007949static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007950 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7951 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02007952 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02007953 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7954 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007955 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7956 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7957 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02007958 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007959};
Tobin Davis2880a8672007-08-07 11:50:26 +02007960
Tony Vroond2fd4b02009-06-21 00:40:10 +01007961static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
7962 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7963 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7964 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7965 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01007966 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7967 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01007968 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7969 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7970 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7971 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7972 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7973 { } /* end */
7974};
7975
Kailang Yange2757d52008-08-26 13:17:46 +02007976static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7977 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7978 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7979 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7980 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7981 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7982 0x0d, 1, 0x0, HDA_OUTPUT),
7983 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7984 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7985 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7986 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7987 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007988 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7989 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7990 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7991 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7992 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7993 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7994 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7995 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7996 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7997 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007998 { } /* end */
7999};
8000
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008001static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8002 /* Output mixers */
8003 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8004 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8005 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8006 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8007 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8008 HDA_OUTPUT),
8009 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8010 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8011 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8012 /* Output switches */
8013 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8014 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8015 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8016 /* Boost mixers */
8017 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8018 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8019 /* Input mixers */
8020 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8021 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8022 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8023 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8024 { } /* end */
8025};
8026
Guido Günther3e1647c2009-06-05 00:47:26 +02008027static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8028 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8029 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8030 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8031 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8032 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8033 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8034 { } /* end */
8035};
8036
Kailang Yange2757d52008-08-26 13:17:46 +02008037static struct hda_bind_ctls alc883_bind_cap_vol = {
8038 .ops = &snd_hda_bind_vol,
8039 .values = {
8040 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8041 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8042 0
8043 },
8044};
8045
8046static struct hda_bind_ctls alc883_bind_cap_switch = {
8047 .ops = &snd_hda_bind_sw,
8048 .values = {
8049 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8050 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8051 0
8052 },
8053};
8054
8055static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8056 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8057 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8058 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8059 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8060 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8061 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8062 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8063 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008064 { } /* end */
8065};
8066
8067static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008068 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8069 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8070 {
8071 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8072 /* .name = "Capture Source", */
8073 .name = "Input Source",
8074 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008075 .info = alc_mux_enum_info,
8076 .get = alc_mux_enum_get,
8077 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008078 },
8079 { } /* end */
8080};
8081
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008082static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8083 {
8084 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8085 .name = "Channel Mode",
8086 .info = alc_ch_mode_info,
8087 .get = alc_ch_mode_get,
8088 .put = alc_ch_mode_put,
8089 },
8090 { } /* end */
8091};
8092
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008093/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008094static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008095{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008096 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008097
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008098 spec->autocfg.hp_pins[0] = 0x15;
8099 spec->autocfg.speaker_pins[0] = 0x14;
8100 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008101}
8102
8103/* auto-toggle front mic */
8104/*
8105static void alc883_mitac_mic_automute(struct hda_codec *codec)
8106{
8107 unsigned int present;
8108 unsigned char bits;
8109
8110 present = snd_hda_codec_read(codec, 0x18, 0,
8111 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8112 bits = present ? HDA_AMP_MUTE : 0;
8113 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8114}
8115*/
8116
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008117static struct hda_verb alc883_mitac_verbs[] = {
8118 /* HP */
8119 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8120 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8121 /* Subwoofer */
8122 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8123 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8124
8125 /* enable unsolicited event */
8126 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8127 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8128
8129 { } /* end */
8130};
8131
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008132static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008133 /* HP */
8134 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8135 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8136 /* Int speaker */
8137 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8138 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8139
8140 /* enable unsolicited event */
8141 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008142 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008143
8144 { } /* end */
8145};
8146
Jiang zhefb97dc62008-03-06 11:07:11 +01008147static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8148 /* HP */
8149 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8150 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8151 /* Subwoofer */
8152 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8153 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8154
8155 /* enable unsolicited event */
8156 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8157
8158 { } /* end */
8159};
8160
Sasha Alexandrc2592492009-06-16 14:52:54 -04008161static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008162 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8163 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8164
8165 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8166 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008167
David Heidelberger64a8be72009-06-08 16:15:18 +02008168/* Connect Line-Out side jack (SPDIF) to Side */
8169 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8170 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8171 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8172/* Connect Mic jack to CLFE */
8173 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8174 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8175 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8176/* Connect Line-in jack to Surround */
8177 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8178 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8179 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8180/* Connect HP out jack to Front */
8181 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8182 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8183 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008184
8185 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008186
8187 { } /* end */
8188};
8189
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008190static struct hda_verb alc883_lenovo_101e_verbs[] = {
8191 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8192 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8193 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8194 { } /* end */
8195};
8196
Kailang Yang272a5272007-05-14 11:00:38 +02008197static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8198 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8199 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8200 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8201 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8202 { } /* end */
8203};
8204
8205static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8206 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8207 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8208 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8209 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8210 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8211 { } /* end */
8212};
8213
Kailang Yang189609a2007-08-20 11:31:23 +02008214static struct hda_verb alc883_haier_w66_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
8218 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8219
8220 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8221 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8222 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8223 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8224 { } /* end */
8225};
8226
Kailang Yange2757d52008-08-26 13:17:46 +02008227static struct hda_verb alc888_lenovo_sky_verbs[] = {
8228 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8229 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8230 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8231 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8232 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8233 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8234 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8235 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8236 { } /* end */
8237};
8238
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008239static struct hda_verb alc888_6st_dell_verbs[] = {
8240 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8241 { }
8242};
8243
Guido Günther3e1647c2009-06-05 00:47:26 +02008244static struct hda_verb alc883_vaiott_verbs[] = {
8245 /* HP */
8246 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8247 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8248
8249 /* enable unsolicited event */
8250 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8251
8252 { } /* end */
8253};
8254
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008255static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008256{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008257 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008258
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008259 spec->autocfg.hp_pins[0] = 0x1b;
8260 spec->autocfg.speaker_pins[0] = 0x14;
8261 spec->autocfg.speaker_pins[1] = 0x16;
8262 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008263}
8264
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008265static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008266 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008267 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8268 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008269 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008270 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008271};
8272
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008273/*
8274 * 2ch mode
8275 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008276static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008277 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8278 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8279 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8280 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008281 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008282};
8283
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008284/*
8285 * 4ch mode
8286 */
8287static struct hda_verb alc888_3st_hp_4ch_init[] = {
8288 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8289 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8290 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8291 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8292 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8293 { } /* end */
8294};
8295
8296/*
8297 * 6ch mode
8298 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008299static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008300 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8301 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008302 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008303 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8304 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008305 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8306 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008307};
8308
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008309static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008310 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008311 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008312 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008313};
8314
Kailang Yang272a5272007-05-14 11:00:38 +02008315/* toggle front-jack and RCA according to the hp-jack state */
8316static void alc888_lenovo_ms7195_front_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, 0x1b, 0,
8321 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008322 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8323 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8324 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8325 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008326}
8327
8328/* toggle RCA according to the front-jack state */
8329static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8330{
8331 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008332
Kailang Yang272a5272007-05-14 11:00:38 +02008333 present = snd_hda_codec_read(codec, 0x14, 0,
8334 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008335 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8336 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008337}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008338
Kailang Yang272a5272007-05-14 11:00:38 +02008339static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8340 unsigned int res)
8341{
8342 if ((res >> 26) == ALC880_HP_EVENT)
8343 alc888_lenovo_ms7195_front_automute(codec);
8344 if ((res >> 26) == ALC880_FRONT_EVENT)
8345 alc888_lenovo_ms7195_rca_automute(codec);
8346}
8347
8348static struct hda_verb alc883_medion_md2_verbs[] = {
8349 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8350 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8351
8352 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8353
8354 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8355 { } /* end */
8356};
8357
8358/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008359static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008360{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008361 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008362
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008363 spec->autocfg.hp_pins[0] = 0x14;
8364 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008365}
8366
Kailang Yangccc656c2006-10-17 12:32:26 +02008367/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008368#define alc883_targa_init_hook alc882_targa_init_hook
8369#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008370
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008371static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8372{
8373 unsigned int present;
8374
8375 present = snd_hda_codec_read(codec, 0x18, 0,
8376 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8377 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8378 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8379}
8380
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008381static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008382{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008383 struct alc_spec *spec = codec->spec;
8384
8385 spec->autocfg.hp_pins[0] = 0x15;
8386 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008387}
8388
8389static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8390{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008391 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008392 alc883_clevo_m720_mic_automute(codec);
8393}
8394
8395static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008396 unsigned int res)
8397{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008398 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008399 case ALC880_MIC_EVENT:
8400 alc883_clevo_m720_mic_automute(codec);
8401 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008402 default:
8403 alc_automute_amp_unsol_event(codec, res);
8404 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008405 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008406}
8407
Jiang zhefb97dc62008-03-06 11:07:11 +01008408/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008409static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008410{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008411 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008412
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008413 spec->autocfg.hp_pins[0] = 0x14;
8414 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01008415}
8416
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008417static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008418{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008419 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008420
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008421 spec->autocfg.hp_pins[0] = 0x1b;
8422 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02008423}
8424
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008425static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8426{
8427 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008428 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008429
David Heidelberger64a8be72009-06-08 16:15:18 +02008430 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8431 & AC_PINSENSE_PRESENCE;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008432 bits = present ? HDA_AMP_MUTE : 0;
8433 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8434 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008435}
8436
8437static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8438{
8439 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008440 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008441
8442 present = snd_hda_codec_read(codec, 0x1b, 0,
8443 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008444 bits = present ? HDA_AMP_MUTE : 0;
8445 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8446 HDA_AMP_MUTE, bits);
8447 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8448 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008449}
8450
8451static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8452 unsigned int res)
8453{
8454 if ((res >> 26) == ALC880_HP_EVENT)
8455 alc883_lenovo_101e_all_automute(codec);
8456 if ((res >> 26) == ALC880_FRONT_EVENT)
8457 alc883_lenovo_101e_ispeaker_automute(codec);
8458}
8459
Takashi Iwai676a9b52007-08-16 15:23:35 +02008460/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008461static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008462{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008463 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008464
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008465 spec->autocfg.hp_pins[0] = 0x14;
8466 spec->autocfg.speaker_pins[0] = 0x15;
8467 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02008468}
8469
Kailang Yangd1a991a2007-08-15 16:21:59 +02008470static struct hda_verb alc883_acer_eapd_verbs[] = {
8471 /* HP Pin: output 0 (0x0c) */
8472 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8473 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8474 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8475 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008476 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8477 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008478 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008479 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8480 /* eanable EAPD on medion laptop */
8481 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8482 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008483 /* enable unsolicited event */
8484 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008485 { }
8486};
8487
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008488static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8489 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8490 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8491 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8492 { } /* end */
8493};
8494
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008495static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008496{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008497 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008498
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008499 spec->autocfg.hp_pins[0] = 0x1b;
8500 spec->autocfg.speaker_pins[0] = 0x14;
8501 spec->autocfg.speaker_pins[1] = 0x15;
8502 spec->autocfg.speaker_pins[2] = 0x16;
8503 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008504}
8505
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008506static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008507{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008508 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008509
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008510 spec->autocfg.hp_pins[0] = 0x1b;
8511 spec->autocfg.speaker_pins[0] = 0x14;
8512 spec->autocfg.speaker_pins[1] = 0x15;
8513 spec->autocfg.speaker_pins[2] = 0x16;
8514 spec->autocfg.speaker_pins[3] = 0x17;
8515 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02008516}
8517
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008518static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02008519{
8520 struct alc_spec *spec = codec->spec;
8521
8522 spec->autocfg.hp_pins[0] = 0x15;
8523 spec->autocfg.speaker_pins[0] = 0x14;
8524 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02008525}
8526
Kailang Yange2757d52008-08-26 13:17:46 +02008527static struct hda_verb alc888_asus_m90v_verbs[] = {
8528 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8529 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8530 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8531 /* enable unsolicited event */
8532 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8533 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8534 { } /* end */
8535};
8536
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008537static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008538{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008539 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008540
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008541 spec->autocfg.hp_pins[0] = 0x1b;
8542 spec->autocfg.speaker_pins[0] = 0x14;
8543 spec->autocfg.speaker_pins[1] = 0x15;
8544 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008545 spec->ext_mic.pin = 0x18;
8546 spec->int_mic.pin = 0x19;
8547 spec->ext_mic.mux_idx = 0;
8548 spec->int_mic.mux_idx = 1;
8549 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02008550}
8551
8552static struct hda_verb alc888_asus_eee1601_verbs[] = {
8553 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8554 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8555 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8556 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8557 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8558 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8559 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8560 /* enable unsolicited event */
8561 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8562 { } /* end */
8563};
8564
Kailang Yange2757d52008-08-26 13:17:46 +02008565static void alc883_eee1601_inithook(struct hda_codec *codec)
8566{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008567 struct alc_spec *spec = codec->spec;
8568
8569 spec->autocfg.hp_pins[0] = 0x14;
8570 spec->autocfg.speaker_pins[0] = 0x1b;
8571 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008572}
8573
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008574static struct hda_verb alc889A_mb31_verbs[] = {
8575 /* Init rear pin (used as headphone output) */
8576 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8577 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8578 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8579 /* Init line pin (used as output in 4ch and 6ch mode) */
8580 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8581 /* Init line 2 pin (used as headphone out by default) */
8582 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8583 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8584 { } /* end */
8585};
8586
8587/* Mute speakers according to the headphone jack state */
8588static void alc889A_mb31_automute(struct hda_codec *codec)
8589{
8590 unsigned int present;
8591
8592 /* Mute only in 2ch or 4ch mode */
8593 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8594 == 0x00) {
8595 present = snd_hda_codec_read(codec, 0x15, 0,
8596 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
8597 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8598 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8599 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8600 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8601 }
8602}
8603
8604static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8605{
8606 if ((res >> 26) == ALC880_HP_EVENT)
8607 alc889A_mb31_automute(codec);
8608}
8609
Takashi Iwai4953550a2009-06-30 15:28:30 +02008610
Takashi Iwaicb53c622007-08-10 17:21:45 +02008611#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02008612#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02008613#endif
8614
Sasha Alexandrdef319f2009-06-16 16:00:15 -04008615/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008616#define alc882_pcm_analog_playback alc880_pcm_analog_playback
8617#define alc882_pcm_analog_capture alc880_pcm_analog_capture
8618#define alc882_pcm_digital_playback alc880_pcm_digital_playback
8619#define alc882_pcm_digital_capture alc880_pcm_digital_capture
8620
8621static hda_nid_t alc883_slave_dig_outs[] = {
8622 ALC1200_DIGOUT_NID, 0,
8623};
8624
8625static hda_nid_t alc1200_slave_dig_outs[] = {
8626 ALC883_DIGOUT_NID, 0,
8627};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008628
8629/*
8630 * configuration and preset
8631 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008632static const char *alc882_models[ALC882_MODEL_LAST] = {
8633 [ALC882_3ST_DIG] = "3stack-dig",
8634 [ALC882_6ST_DIG] = "6stack-dig",
8635 [ALC882_ARIMA] = "arima",
8636 [ALC882_W2JC] = "w2jc",
8637 [ALC882_TARGA] = "targa",
8638 [ALC882_ASUS_A7J] = "asus-a7j",
8639 [ALC882_ASUS_A7M] = "asus-a7m",
8640 [ALC885_MACPRO] = "macpro",
8641 [ALC885_MB5] = "mb5",
8642 [ALC885_MBP3] = "mbp3",
8643 [ALC885_IMAC24] = "imac24",
8644 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008645 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8646 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008647 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008648 [ALC883_TARGA_DIG] = "targa-dig",
8649 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02008650 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008651 [ALC883_ACER] = "acer",
Tobin Davis2880a8672007-08-07 11:50:26 +02008652 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008653 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02008654 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02008655 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008656 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008657 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008658 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008659 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008660 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008661 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8662 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008663 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008664 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008665 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008666 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008667 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008668 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008669 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008670 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008671 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008672 [ALC889A_INTEL] = "intel-alc889a",
8673 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008674 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008675 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02008676 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008677 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008678};
8679
Takashi Iwai4953550a2009-06-30 15:28:30 +02008680static struct snd_pci_quirk alc882_cfg_tbl[] = {
8681 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8682
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008683 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008684 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008685 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008686 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8687 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008688 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008689 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8690 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008691 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8692 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02008693 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8694 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02008695 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
8696 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008697 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
8698 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008699 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02008700 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008701 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01008702 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008703 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
8704 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02008705 /* default Acer -- disabled as it causes more problems.
8706 * model=auto should work fine now
8707 */
8708 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008709
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008710 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008711
Tobin Davisfebe3372007-06-12 11:27:46 +02008712 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008713 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8714 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008715 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008716 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008717 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008718
8719 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8720 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8721 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008722 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008723 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8724 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8725 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008726 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008727 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008728 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008729 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008730
8731 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02008732 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008733 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008734 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008735 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8736 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008737 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008738 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008739 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8740
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008741 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8742 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8743 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008744 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Jiang zhe4383fae2008-04-14 12:58:57 +02008745 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008746 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008747 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008748 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008749 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8750 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8751 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8752 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8753 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8754 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008755 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008756 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8757 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8758 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02008759 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008760 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8761 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008762 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008763 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008764 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008765 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008766 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04008767 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008768 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008769 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008770
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008771 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008772 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8773 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008774 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008775 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008776 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008777 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008778 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008779 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008780 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008781 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008782 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008783 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008784 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8785 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008786 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008787 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008788 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008789 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008790 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008791
Jiang zhe17bba1b2008-06-04 12:11:07 +02008792 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8793 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008794 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008795 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
8796 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
8797 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008798 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008799
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008800 {}
8801};
8802
Takashi Iwai4953550a2009-06-30 15:28:30 +02008803/* codec SSID table for Intel Mac */
8804static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
8805 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
8806 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
8807 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
8808 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
8809 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
8810 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
8811 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
8812 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
8813 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
8814 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
8815 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
8816 /* FIXME: HP jack sense seems not working for MBP 5,1, so apparently
8817 * no perfect solution yet
8818 */
8819 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
8820 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008821};
8822
Takashi Iwai4953550a2009-06-30 15:28:30 +02008823static struct alc_config_preset alc882_presets[] = {
8824 [ALC882_3ST_DIG] = {
8825 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008826 .init_verbs = { alc882_base_init_verbs,
8827 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008828 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8829 .dac_nids = alc882_dac_nids,
8830 .dig_out_nid = ALC882_DIGOUT_NID,
8831 .dig_in_nid = ALC882_DIGIN_NID,
8832 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8833 .channel_mode = alc882_ch_modes,
8834 .need_dac_fix = 1,
8835 .input_mux = &alc882_capture_source,
8836 },
8837 [ALC882_6ST_DIG] = {
8838 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008839 .init_verbs = { alc882_base_init_verbs,
8840 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008841 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8842 .dac_nids = alc882_dac_nids,
8843 .dig_out_nid = ALC882_DIGOUT_NID,
8844 .dig_in_nid = ALC882_DIGIN_NID,
8845 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8846 .channel_mode = alc882_sixstack_modes,
8847 .input_mux = &alc882_capture_source,
8848 },
8849 [ALC882_ARIMA] = {
8850 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008851 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8852 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008853 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8854 .dac_nids = alc882_dac_nids,
8855 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8856 .channel_mode = alc882_sixstack_modes,
8857 .input_mux = &alc882_capture_source,
8858 },
8859 [ALC882_W2JC] = {
8860 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008861 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8862 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008863 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8864 .dac_nids = alc882_dac_nids,
8865 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8866 .channel_mode = alc880_threestack_modes,
8867 .need_dac_fix = 1,
8868 .input_mux = &alc882_capture_source,
8869 .dig_out_nid = ALC882_DIGOUT_NID,
8870 },
8871 [ALC885_MBP3] = {
8872 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
8873 .init_verbs = { alc885_mbp3_init_verbs,
8874 alc880_gpio1_init_verbs },
8875 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8876 .dac_nids = alc882_dac_nids,
8877 .channel_mode = alc885_mbp_6ch_modes,
8878 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
8879 .input_mux = &alc882_capture_source,
8880 .dig_out_nid = ALC882_DIGOUT_NID,
8881 .dig_in_nid = ALC882_DIGIN_NID,
8882 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008883 .setup = alc885_mbp3_setup,
8884 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008885 },
8886 [ALC885_MB5] = {
8887 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
8888 .init_verbs = { alc885_mb5_init_verbs,
8889 alc880_gpio1_init_verbs },
8890 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8891 .dac_nids = alc882_dac_nids,
8892 .channel_mode = alc885_mb5_6ch_modes,
8893 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
8894 .input_mux = &mb5_capture_source,
8895 .dig_out_nid = ALC882_DIGOUT_NID,
8896 .dig_in_nid = ALC882_DIGIN_NID,
8897 },
8898 [ALC885_MACPRO] = {
8899 .mixers = { alc882_macpro_mixer },
8900 .init_verbs = { alc882_macpro_init_verbs },
8901 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8902 .dac_nids = alc882_dac_nids,
8903 .dig_out_nid = ALC882_DIGOUT_NID,
8904 .dig_in_nid = ALC882_DIGIN_NID,
8905 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8906 .channel_mode = alc882_ch_modes,
8907 .input_mux = &alc882_capture_source,
8908 .init_hook = alc885_macpro_init_hook,
8909 },
8910 [ALC885_IMAC24] = {
8911 .mixers = { alc885_imac24_mixer },
8912 .init_verbs = { alc885_imac24_init_verbs },
8913 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8914 .dac_nids = alc882_dac_nids,
8915 .dig_out_nid = ALC882_DIGOUT_NID,
8916 .dig_in_nid = ALC882_DIGIN_NID,
8917 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8918 .channel_mode = alc882_ch_modes,
8919 .input_mux = &alc882_capture_source,
8920 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008921 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008922 .init_hook = alc885_imac24_init_hook,
8923 },
8924 [ALC882_TARGA] = {
8925 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008926 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02008927 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02008928 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8929 .dac_nids = alc882_dac_nids,
8930 .dig_out_nid = ALC882_DIGOUT_NID,
8931 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
8932 .adc_nids = alc882_adc_nids,
8933 .capsrc_nids = alc882_capsrc_nids,
8934 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
8935 .channel_mode = alc882_3ST_6ch_modes,
8936 .need_dac_fix = 1,
8937 .input_mux = &alc882_capture_source,
8938 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008939 .setup = alc882_targa_setup,
8940 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008941 },
8942 [ALC882_ASUS_A7J] = {
8943 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008944 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8945 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02008946 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8947 .dac_nids = alc882_dac_nids,
8948 .dig_out_nid = ALC882_DIGOUT_NID,
8949 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
8950 .adc_nids = alc882_adc_nids,
8951 .capsrc_nids = alc882_capsrc_nids,
8952 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
8953 .channel_mode = alc882_3ST_6ch_modes,
8954 .need_dac_fix = 1,
8955 .input_mux = &alc882_capture_source,
8956 },
8957 [ALC882_ASUS_A7M] = {
8958 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008959 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8960 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008961 alc882_asus_a7m_verbs },
8962 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8963 .dac_nids = alc882_dac_nids,
8964 .dig_out_nid = ALC882_DIGOUT_NID,
8965 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8966 .channel_mode = alc880_threestack_modes,
8967 .need_dac_fix = 1,
8968 .input_mux = &alc882_capture_source,
8969 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008970 [ALC883_3ST_2ch_DIG] = {
8971 .mixers = { alc883_3ST_2ch_mixer },
8972 .init_verbs = { alc883_init_verbs },
8973 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8974 .dac_nids = alc883_dac_nids,
8975 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008976 .dig_in_nid = ALC883_DIGIN_NID,
8977 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8978 .channel_mode = alc883_3ST_2ch_modes,
8979 .input_mux = &alc883_capture_source,
8980 },
8981 [ALC883_3ST_6ch_DIG] = {
8982 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8983 .init_verbs = { alc883_init_verbs },
8984 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8985 .dac_nids = alc883_dac_nids,
8986 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008987 .dig_in_nid = ALC883_DIGIN_NID,
8988 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8989 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008990 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008991 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008992 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008993 [ALC883_3ST_6ch] = {
8994 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8995 .init_verbs = { alc883_init_verbs },
8996 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8997 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008998 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8999 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009000 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009001 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009002 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009003 [ALC883_3ST_6ch_INTEL] = {
9004 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9005 .init_verbs = { alc883_init_verbs },
9006 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9007 .dac_nids = alc883_dac_nids,
9008 .dig_out_nid = ALC883_DIGOUT_NID,
9009 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009010 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009011 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9012 .channel_mode = alc883_3ST_6ch_intel_modes,
9013 .need_dac_fix = 1,
9014 .input_mux = &alc883_3stack_6ch_intel,
9015 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009016 [ALC889A_INTEL] = {
9017 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009018 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9019 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009020 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9021 .dac_nids = alc883_dac_nids,
9022 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9023 .adc_nids = alc889_adc_nids,
9024 .dig_out_nid = ALC883_DIGOUT_NID,
9025 .dig_in_nid = ALC883_DIGIN_NID,
9026 .slave_dig_outs = alc883_slave_dig_outs,
9027 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9028 .channel_mode = alc889_8ch_intel_modes,
9029 .capsrc_nids = alc889_capsrc_nids,
9030 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009031 .setup = alc889_automute_setup,
9032 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009033 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009034 .need_dac_fix = 1,
9035 },
9036 [ALC889_INTEL] = {
9037 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9038 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009039 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009040 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9041 .dac_nids = alc883_dac_nids,
9042 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9043 .adc_nids = alc889_adc_nids,
9044 .dig_out_nid = ALC883_DIGOUT_NID,
9045 .dig_in_nid = ALC883_DIGIN_NID,
9046 .slave_dig_outs = alc883_slave_dig_outs,
9047 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9048 .channel_mode = alc889_8ch_intel_modes,
9049 .capsrc_nids = alc889_capsrc_nids,
9050 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009051 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009052 .init_hook = alc889_intel_init_hook,
9053 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009054 .need_dac_fix = 1,
9055 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009056 [ALC883_6ST_DIG] = {
9057 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9058 .init_verbs = { alc883_init_verbs },
9059 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9060 .dac_nids = alc883_dac_nids,
9061 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009062 .dig_in_nid = ALC883_DIGIN_NID,
9063 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9064 .channel_mode = alc883_sixstack_modes,
9065 .input_mux = &alc883_capture_source,
9066 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009067 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009068 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009069 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9070 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009071 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9072 .dac_nids = alc883_dac_nids,
9073 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009074 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9075 .channel_mode = alc883_3ST_6ch_modes,
9076 .need_dac_fix = 1,
9077 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009078 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009079 .setup = alc882_targa_setup,
9080 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009081 },
9082 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009083 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009084 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9085 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009086 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9087 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009088 .adc_nids = alc883_adc_nids_alt,
9089 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02009090 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009091 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9092 .channel_mode = alc883_3ST_2ch_modes,
9093 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009094 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009095 .setup = alc882_targa_setup,
9096 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009097 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009098 [ALC883_TARGA_8ch_DIG] = {
9099 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9100 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009101 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009102 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9103 .dac_nids = alc883_dac_nids,
9104 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9105 .adc_nids = alc883_adc_nids_rev,
9106 .capsrc_nids = alc883_capsrc_nids_rev,
9107 .dig_out_nid = ALC883_DIGOUT_NID,
9108 .dig_in_nid = ALC883_DIGIN_NID,
9109 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9110 .channel_mode = alc883_4ST_8ch_modes,
9111 .need_dac_fix = 1,
9112 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009113 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009114 .setup = alc882_targa_setup,
9115 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009116 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009117 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009118 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009119 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9120 * and the headphone jack. Turn this on and rely on the
9121 * standard mute methods whenever the user wants to turn
9122 * these outputs off.
9123 */
9124 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9125 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9126 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009127 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9128 .channel_mode = alc883_3ST_2ch_modes,
9129 .input_mux = &alc883_capture_source,
9130 },
Tobin Davis2880a8672007-08-07 11:50:26 +02009131 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009132 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009133 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a8672007-08-07 11:50:26 +02009134 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9135 .dac_nids = alc883_dac_nids,
9136 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a8672007-08-07 11:50:26 +02009137 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9138 .channel_mode = alc883_3ST_2ch_modes,
9139 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009140 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009141 .setup = alc883_acer_aspire_setup,
9142 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009143 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009144 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009145 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009146 alc883_chmode_mixer },
9147 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9148 alc888_acer_aspire_4930g_verbs },
9149 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9150 .dac_nids = alc883_dac_nids,
9151 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9152 .adc_nids = alc883_adc_nids_rev,
9153 .capsrc_nids = alc883_capsrc_nids_rev,
9154 .dig_out_nid = ALC883_DIGOUT_NID,
9155 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9156 .channel_mode = alc883_3ST_6ch_modes,
9157 .need_dac_fix = 1,
9158 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009159 ARRAY_SIZE(alc888_2_capture_sources),
9160 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009161 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009162 .setup = alc888_acer_aspire_4930g_setup,
9163 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009164 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009165 [ALC888_ACER_ASPIRE_6530G] = {
9166 .mixers = { alc888_acer_aspire_6530_mixer },
9167 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9168 alc888_acer_aspire_6530g_verbs },
9169 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9170 .dac_nids = alc883_dac_nids,
9171 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9172 .adc_nids = alc883_adc_nids_rev,
9173 .capsrc_nids = alc883_capsrc_nids_rev,
9174 .dig_out_nid = ALC883_DIGOUT_NID,
9175 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9176 .channel_mode = alc883_3ST_2ch_modes,
9177 .num_mux_defs =
9178 ARRAY_SIZE(alc888_2_capture_sources),
9179 .input_mux = alc888_acer_aspire_6530_sources,
9180 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009181 .setup = alc888_acer_aspire_6530g_setup,
9182 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009183 },
Hector Martin3b315d72009-06-02 10:54:19 +02009184 [ALC888_ACER_ASPIRE_8930G] = {
9185 .mixers = { alc888_base_mixer,
9186 alc883_chmode_mixer },
9187 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin018df412009-06-04 00:13:40 +02009188 alc889_acer_aspire_8930g_verbs },
Hector Martin3b315d72009-06-02 10:54:19 +02009189 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9190 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009191 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9192 .adc_nids = alc889_adc_nids,
9193 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009194 .dig_out_nid = ALC883_DIGOUT_NID,
9195 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9196 .channel_mode = alc883_3ST_6ch_modes,
9197 .need_dac_fix = 1,
9198 .const_channel_count = 6,
9199 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009200 ARRAY_SIZE(alc889_capture_sources),
9201 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009202 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009203 .setup = alc889_acer_aspire_8930g_setup,
9204 .init_hook = alc_automute_amp,
Hector Martin3b315d72009-06-02 10:54:19 +02009205 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009206 [ALC888_ACER_ASPIRE_7730G] = {
9207 .mixers = { alc883_3ST_6ch_mixer,
9208 alc883_chmode_mixer },
9209 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9210 alc888_acer_aspire_7730G_verbs },
9211 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9212 .dac_nids = alc883_dac_nids,
9213 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9214 .adc_nids = alc883_adc_nids_rev,
9215 .capsrc_nids = alc883_capsrc_nids_rev,
9216 .dig_out_nid = ALC883_DIGOUT_NID,
9217 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9218 .channel_mode = alc883_3ST_6ch_modes,
9219 .need_dac_fix = 1,
9220 .const_channel_count = 6,
9221 .input_mux = &alc883_capture_source,
9222 .unsol_event = alc_automute_amp_unsol_event,
9223 .setup = alc888_acer_aspire_6530g_setup,
9224 .init_hook = alc_automute_amp,
9225 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009226 [ALC883_MEDION] = {
9227 .mixers = { alc883_fivestack_mixer,
9228 alc883_chmode_mixer },
9229 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009230 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009231 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9232 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009233 .adc_nids = alc883_adc_nids_alt,
9234 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02009235 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9236 .channel_mode = alc883_sixstack_modes,
9237 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009238 },
Kailang Yang272a5272007-05-14 11:00:38 +02009239 [ALC883_MEDION_MD2] = {
9240 .mixers = { alc883_medion_md2_mixer},
9241 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9242 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9243 .dac_nids = alc883_dac_nids,
9244 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009245 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9246 .channel_mode = alc883_3ST_2ch_modes,
9247 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009248 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009249 .setup = alc883_medion_md2_setup,
9250 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009251 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009252 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009253 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009254 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9255 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9256 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009257 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9258 .channel_mode = alc883_3ST_2ch_modes,
9259 .input_mux = &alc883_capture_source,
9260 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009261 [ALC883_CLEVO_M720] = {
9262 .mixers = { alc883_clevo_m720_mixer },
9263 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009264 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9265 .dac_nids = alc883_dac_nids,
9266 .dig_out_nid = ALC883_DIGOUT_NID,
9267 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9268 .channel_mode = alc883_3ST_2ch_modes,
9269 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009270 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009271 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009272 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009273 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009274 [ALC883_LENOVO_101E_2ch] = {
9275 .mixers = { alc883_lenovo_101e_2ch_mixer},
9276 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9277 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9278 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009279 .adc_nids = alc883_adc_nids_alt,
9280 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009281 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9282 .channel_mode = alc883_3ST_2ch_modes,
9283 .input_mux = &alc883_lenovo_101e_capture_source,
9284 .unsol_event = alc883_lenovo_101e_unsol_event,
9285 .init_hook = alc883_lenovo_101e_all_automute,
9286 },
Kailang Yang272a5272007-05-14 11:00:38 +02009287 [ALC883_LENOVO_NB0763] = {
9288 .mixers = { alc883_lenovo_nb0763_mixer },
9289 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9290 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9291 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009292 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9293 .channel_mode = alc883_3ST_2ch_modes,
9294 .need_dac_fix = 1,
9295 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009296 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009297 .setup = alc883_medion_md2_setup,
9298 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009299 },
9300 [ALC888_LENOVO_MS7195_DIG] = {
9301 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9302 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9303 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9304 .dac_nids = alc883_dac_nids,
9305 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009306 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9307 .channel_mode = alc883_3ST_6ch_modes,
9308 .need_dac_fix = 1,
9309 .input_mux = &alc883_capture_source,
9310 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9311 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009312 },
9313 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009314 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009315 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9316 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9317 .dac_nids = alc883_dac_nids,
9318 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009319 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9320 .channel_mode = alc883_3ST_2ch_modes,
9321 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009322 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009323 .setup = alc883_haier_w66_setup,
9324 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009325 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009326 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009327 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009328 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009329 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9330 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009331 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9332 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009333 .need_dac_fix = 1,
9334 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009335 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009336 .setup = alc888_3st_hp_setup,
9337 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009338 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009339 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009340 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009341 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9342 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9343 .dac_nids = alc883_dac_nids,
9344 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009345 .dig_in_nid = ALC883_DIGIN_NID,
9346 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9347 .channel_mode = alc883_sixstack_modes,
9348 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009349 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009350 .setup = alc888_6st_dell_setup,
9351 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009352 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009353 [ALC883_MITAC] = {
9354 .mixers = { alc883_mitac_mixer },
9355 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9356 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9357 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009358 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9359 .channel_mode = alc883_3ST_2ch_modes,
9360 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009361 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009362 .setup = alc883_mitac_setup,
9363 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009364 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009365 [ALC883_FUJITSU_PI2515] = {
9366 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9367 .init_verbs = { alc883_init_verbs,
9368 alc883_2ch_fujitsu_pi2515_verbs},
9369 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9370 .dac_nids = alc883_dac_nids,
9371 .dig_out_nid = ALC883_DIGOUT_NID,
9372 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9373 .channel_mode = alc883_3ST_2ch_modes,
9374 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009375 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009376 .setup = alc883_2ch_fujitsu_pi2515_setup,
9377 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +01009378 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009379 [ALC888_FUJITSU_XA3530] = {
9380 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9381 .init_verbs = { alc883_init_verbs,
9382 alc888_fujitsu_xa3530_verbs },
9383 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9384 .dac_nids = alc883_dac_nids,
9385 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9386 .adc_nids = alc883_adc_nids_rev,
9387 .capsrc_nids = alc883_capsrc_nids_rev,
9388 .dig_out_nid = ALC883_DIGOUT_NID,
9389 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9390 .channel_mode = alc888_4ST_8ch_intel_modes,
9391 .num_mux_defs =
9392 ARRAY_SIZE(alc888_2_capture_sources),
9393 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009394 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009395 .setup = alc888_fujitsu_xa3530_setup,
9396 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009397 },
Kailang Yange2757d52008-08-26 13:17:46 +02009398 [ALC888_LENOVO_SKY] = {
9399 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9400 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9401 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9402 .dac_nids = alc883_dac_nids,
9403 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009404 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9405 .channel_mode = alc883_sixstack_modes,
9406 .need_dac_fix = 1,
9407 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009408 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009409 .setup = alc888_lenovo_sky_setup,
9410 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +02009411 },
9412 [ALC888_ASUS_M90V] = {
9413 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9414 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9415 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9416 .dac_nids = alc883_dac_nids,
9417 .dig_out_nid = ALC883_DIGOUT_NID,
9418 .dig_in_nid = ALC883_DIGIN_NID,
9419 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9420 .channel_mode = alc883_3ST_6ch_modes,
9421 .need_dac_fix = 1,
9422 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009423 .unsol_event = alc_sku_unsol_event,
9424 .setup = alc883_mode2_setup,
9425 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +02009426 },
9427 [ALC888_ASUS_EEE1601] = {
9428 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009429 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009430 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9431 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9432 .dac_nids = alc883_dac_nids,
9433 .dig_out_nid = ALC883_DIGOUT_NID,
9434 .dig_in_nid = ALC883_DIGIN_NID,
9435 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9436 .channel_mode = alc883_3ST_2ch_modes,
9437 .need_dac_fix = 1,
9438 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009439 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009440 .init_hook = alc883_eee1601_inithook,
9441 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009442 [ALC1200_ASUS_P5Q] = {
9443 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9444 .init_verbs = { alc883_init_verbs },
9445 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9446 .dac_nids = alc883_dac_nids,
9447 .dig_out_nid = ALC1200_DIGOUT_NID,
9448 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009449 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009450 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9451 .channel_mode = alc883_sixstack_modes,
9452 .input_mux = &alc883_capture_source,
9453 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009454 [ALC889A_MB31] = {
9455 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9456 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9457 alc880_gpio1_init_verbs },
9458 .adc_nids = alc883_adc_nids,
9459 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9460 .dac_nids = alc883_dac_nids,
9461 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9462 .channel_mode = alc889A_mb31_6ch_modes,
9463 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9464 .input_mux = &alc889A_mb31_capture_source,
9465 .dig_out_nid = ALC883_DIGOUT_NID,
9466 .unsol_event = alc889A_mb31_unsol_event,
9467 .init_hook = alc889A_mb31_automute,
9468 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009469 [ALC883_SONY_VAIO_TT] = {
9470 .mixers = { alc883_vaiott_mixer },
9471 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9472 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9473 .dac_nids = alc883_dac_nids,
9474 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9475 .channel_mode = alc883_3ST_2ch_modes,
9476 .input_mux = &alc883_capture_source,
9477 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009478 .setup = alc883_vaiott_setup,
9479 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +02009480 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009481};
9482
9483
9484/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02009485 * Pin config fixes
9486 */
9487enum {
9488 PINFIX_ABIT_AW9D_MAX
9489};
9490
9491static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9492 { 0x15, 0x01080104 }, /* side */
9493 { 0x16, 0x01011012 }, /* rear */
9494 { 0x17, 0x01016011 }, /* clfe */
9495 { }
9496};
9497
9498static const struct alc_pincfg *alc882_pin_fixes[] = {
9499 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
9500};
9501
9502static struct snd_pci_quirk alc882_pinfix_tbl[] = {
9503 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9504 {}
9505};
9506
9507/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009508 * BIOS auto configuration
9509 */
Takashi Iwai05f5f472009-08-25 13:10:18 +02009510static int alc882_auto_create_input_ctls(struct hda_codec *codec,
9511 const struct auto_pin_cfg *cfg)
9512{
9513 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
9514}
9515
Takashi Iwai4953550a2009-06-30 15:28:30 +02009516static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009517 hda_nid_t nid, int pin_type,
9518 int dac_idx)
9519{
9520 /* set as output */
9521 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009522 int idx;
9523
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009524 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009525 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9526 idx = 4;
9527 else
9528 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009529 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9530
9531}
9532
Takashi Iwai4953550a2009-06-30 15:28:30 +02009533static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009534{
9535 struct alc_spec *spec = codec->spec;
9536 int i;
9537
9538 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009539 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009540 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009541 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009542 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009543 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009544 }
9545}
9546
Takashi Iwai4953550a2009-06-30 15:28:30 +02009547static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009548{
9549 struct alc_spec *spec = codec->spec;
9550 hda_nid_t pin;
9551
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009552 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009553 if (pin) /* connect to front */
9554 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009555 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009556 pin = spec->autocfg.speaker_pins[0];
9557 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009558 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009559}
9560
Takashi Iwai4953550a2009-06-30 15:28:30 +02009561static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009562{
9563 struct alc_spec *spec = codec->spec;
9564 int i;
9565
9566 for (i = 0; i < AUTO_PIN_LAST; i++) {
9567 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +02009568 if (!nid)
9569 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +02009570 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009571 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9572 snd_hda_codec_write(codec, nid, 0,
9573 AC_VERB_SET_AMP_GAIN_MUTE,
9574 AMP_OUT_MUTE);
9575 }
9576}
9577
9578static void alc882_auto_init_input_src(struct hda_codec *codec)
9579{
9580 struct alc_spec *spec = codec->spec;
9581 int c;
9582
9583 for (c = 0; c < spec->num_adc_nids; c++) {
9584 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9585 hda_nid_t nid = spec->capsrc_nids[c];
9586 unsigned int mux_idx;
9587 const struct hda_input_mux *imux;
9588 int conns, mute, idx, item;
9589
9590 conns = snd_hda_get_connections(codec, nid, conn_list,
9591 ARRAY_SIZE(conn_list));
9592 if (conns < 0)
9593 continue;
9594 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9595 imux = &spec->input_mux[mux_idx];
9596 for (idx = 0; idx < conns; idx++) {
9597 /* if the current connection is the selected one,
9598 * unmute it as default - otherwise mute it
9599 */
9600 mute = AMP_IN_MUTE(idx);
9601 for (item = 0; item < imux->num_items; item++) {
9602 if (imux->items[item].index == idx) {
9603 if (spec->cur_mux[c] == item)
9604 mute = AMP_IN_UNMUTE(idx);
9605 break;
9606 }
9607 }
9608 /* check if we have a selector or mixer
9609 * we could check for the widget type instead, but
9610 * just check for Amp-In presence (in case of mixer
9611 * without amp-in there is something wrong, this
9612 * function shouldn't be used or capsrc nid is wrong)
9613 */
9614 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009615 snd_hda_codec_write(codec, nid, 0,
9616 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009617 mute);
9618 else if (mute != AMP_IN_MUTE(idx))
9619 snd_hda_codec_write(codec, nid, 0,
9620 AC_VERB_SET_CONNECT_SEL,
9621 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009622 }
9623 }
9624}
9625
Takashi Iwai4953550a2009-06-30 15:28:30 +02009626/* add mic boosts if needed */
9627static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009628{
9629 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009630 int err;
9631 hda_nid_t nid;
9632
9633 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9634 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9635 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9636 "Mic Boost",
9637 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9638 if (err < 0)
9639 return err;
9640 }
9641 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9642 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9643 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9644 "Front Mic Boost",
9645 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9646 if (err < 0)
9647 return err;
9648 }
9649 return 0;
9650}
9651
9652/* almost identical with ALC880 parser... */
9653static int alc882_parse_auto_config(struct hda_codec *codec)
9654{
9655 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009656 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
9657 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009658
Takashi Iwai05f5f472009-08-25 13:10:18 +02009659 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9660 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009661 if (err < 0)
9662 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009663 if (!spec->autocfg.line_outs)
9664 return 0; /* can't find valid BIOS pin config */
9665
9666 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
9667 if (err < 0)
9668 return err;
9669 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
9670 if (err < 0)
9671 return err;
9672 err = alc880_auto_create_extra_out(spec,
9673 spec->autocfg.speaker_pins[0],
9674 "Speaker");
9675 if (err < 0)
9676 return err;
9677 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
9678 "Headphone");
9679 if (err < 0)
9680 return err;
9681 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
9682 if (err < 0)
9683 return err;
9684
9685 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9686
9687 /* check multiple SPDIF-out (for recent codecs) */
9688 for (i = 0; i < spec->autocfg.dig_outs; i++) {
9689 hda_nid_t dig_nid;
9690 err = snd_hda_get_connections(codec,
9691 spec->autocfg.dig_out_pins[i],
9692 &dig_nid, 1);
9693 if (err < 0)
9694 continue;
9695 if (!i)
9696 spec->multiout.dig_out_nid = dig_nid;
9697 else {
9698 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
9699 spec->slave_dig_outs[i - 1] = dig_nid;
9700 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
9701 break;
9702 }
9703 }
9704 if (spec->autocfg.dig_in_pin)
9705 spec->dig_in_nid = ALC880_DIGIN_NID;
9706
9707 if (spec->kctls.list)
9708 add_mixer(spec, spec->kctls.list);
9709
9710 add_verb(spec, alc883_auto_init_verbs);
9711 /* if ADC 0x07 is available, initialize it, too */
9712 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
9713 add_verb(spec, alc882_adc1_init_verbs);
9714
9715 spec->num_mux_defs = 1;
9716 spec->input_mux = &spec->private_imux[0];
9717
9718 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
Takashi Iwai776e1842007-08-29 15:07:11 +02009719
9720 err = alc_auto_add_mic_boost(codec);
9721 if (err < 0)
9722 return err;
9723
Takashi Iwai776e1842007-08-29 15:07:11 +02009724 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009725}
9726
9727/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009728static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009729{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009730 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009731 alc882_auto_init_multi_out(codec);
9732 alc882_auto_init_hp_out(codec);
9733 alc882_auto_init_analog_input(codec);
9734 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009735 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009736 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009737}
9738
Takashi Iwai4953550a2009-06-30 15:28:30 +02009739static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009740{
9741 struct alc_spec *spec;
9742 int err, board_config;
9743
9744 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9745 if (spec == NULL)
9746 return -ENOMEM;
9747
9748 codec->spec = spec;
9749
Takashi Iwai4953550a2009-06-30 15:28:30 +02009750 switch (codec->vendor_id) {
9751 case 0x10ec0882:
9752 case 0x10ec0885:
9753 break;
9754 default:
9755 /* ALC883 and variants */
9756 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9757 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009758 }
9759
Takashi Iwai4953550a2009-06-30 15:28:30 +02009760 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
9761 alc882_models,
9762 alc882_cfg_tbl);
9763
9764 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
9765 board_config = snd_hda_check_board_codec_sid_config(codec,
9766 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
9767
9768 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02009769 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009770 codec->chip_name);
9771 board_config = ALC882_AUTO;
9772 }
9773
9774 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
9775
9776 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009777 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009778 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009779 if (err < 0) {
9780 alc_free(codec);
9781 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009782 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009783 printk(KERN_INFO
9784 "hda_codec: Cannot set up configuration "
9785 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +02009786 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009787 }
9788 }
9789
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009790 err = snd_hda_attach_beep_device(codec, 0x1);
9791 if (err < 0) {
9792 alc_free(codec);
9793 return err;
9794 }
9795
Takashi Iwai4953550a2009-06-30 15:28:30 +02009796 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02009797 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009798
Takashi Iwai4953550a2009-06-30 15:28:30 +02009799 spec->stream_analog_playback = &alc882_pcm_analog_playback;
9800 spec->stream_analog_capture = &alc882_pcm_analog_capture;
9801 /* FIXME: setup DAC5 */
9802 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
9803 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
9804
9805 spec->stream_digital_playback = &alc882_pcm_digital_playback;
9806 spec->stream_digital_capture = &alc882_pcm_digital_capture;
9807
9808 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009809 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009810
9811 if (!spec->adc_nids && spec->input_mux) {
9812 int i;
9813 spec->num_adc_nids = 0;
9814 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
9815 hda_nid_t cap;
9816 hda_nid_t nid = alc882_adc_nids[i];
9817 unsigned int wcap = get_wcaps(codec, nid);
9818 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02009819 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009820 if (wcap != AC_WID_AUD_IN)
9821 continue;
9822 spec->private_adc_nids[spec->num_adc_nids] = nid;
9823 err = snd_hda_get_connections(codec, nid, &cap, 1);
9824 if (err < 0)
9825 continue;
9826 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
9827 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009828 }
Takashi Iwai4953550a2009-06-30 15:28:30 +02009829 spec->adc_nids = spec->private_adc_nids;
9830 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +02009831 }
9832
Takashi Iwaib59bdf32009-08-11 09:47:30 +02009833 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009834 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009835
Takashi Iwai2134ea42008-01-10 16:53:55 +01009836 spec->vmaster_nid = 0x0c;
9837
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009838 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009839 if (board_config == ALC882_AUTO)
9840 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009841#ifdef CONFIG_SND_HDA_POWER_SAVE
9842 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009843 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009844#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009845 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009846
9847 return 0;
9848}
9849
Takashi Iwai4953550a2009-06-30 15:28:30 +02009850
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009851/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009852 * ALC262 support
9853 */
9854
9855#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9856#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9857
9858#define alc262_dac_nids alc260_dac_nids
9859#define alc262_adc_nids alc882_adc_nids
9860#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009861#define alc262_capsrc_nids alc882_capsrc_nids
9862#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009863
9864#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009865#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009866
Kailang Yang4e555fe2008-08-26 13:05:55 +02009867static hda_nid_t alc262_dmic_adc_nids[1] = {
9868 /* ADC0 */
9869 0x09
9870};
9871
9872static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9873
Kailang Yangdf694da2005-12-05 19:42:22 +01009874static struct snd_kcontrol_new alc262_base_mixer[] = {
9875 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9876 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9877 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9878 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9879 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9880 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9881 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9882 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009883 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009884 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9885 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009886 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009887 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9888 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9889 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9890 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009891 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009892};
9893
Takashi Iwaice875f02008-01-28 18:17:43 +01009894/* update HP, line and mono-out pins according to the master switch */
9895static void alc262_hp_master_update(struct hda_codec *codec)
9896{
9897 struct alc_spec *spec = codec->spec;
9898 int val = spec->master_sw;
9899
9900 /* HP & line-out */
9901 snd_hda_codec_write_cache(codec, 0x1b, 0,
9902 AC_VERB_SET_PIN_WIDGET_CONTROL,
9903 val ? PIN_HP : 0);
9904 snd_hda_codec_write_cache(codec, 0x15, 0,
9905 AC_VERB_SET_PIN_WIDGET_CONTROL,
9906 val ? PIN_HP : 0);
9907 /* mono (speaker) depending on the HP jack sense */
9908 val = val && !spec->jack_present;
9909 snd_hda_codec_write_cache(codec, 0x16, 0,
9910 AC_VERB_SET_PIN_WIDGET_CONTROL,
9911 val ? PIN_OUT : 0);
9912}
9913
9914static void alc262_hp_bpc_automute(struct hda_codec *codec)
9915{
9916 struct alc_spec *spec = codec->spec;
9917 unsigned int presence;
9918 presence = snd_hda_codec_read(codec, 0x1b, 0,
9919 AC_VERB_GET_PIN_SENSE, 0);
9920 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9921 alc262_hp_master_update(codec);
9922}
9923
9924static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9925{
9926 if ((res >> 26) != ALC880_HP_EVENT)
9927 return;
9928 alc262_hp_bpc_automute(codec);
9929}
9930
9931static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9932{
9933 struct alc_spec *spec = codec->spec;
9934 unsigned int presence;
9935 presence = snd_hda_codec_read(codec, 0x15, 0,
9936 AC_VERB_GET_PIN_SENSE, 0);
9937 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9938 alc262_hp_master_update(codec);
9939}
9940
9941static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9942 unsigned int res)
9943{
9944 if ((res >> 26) != ALC880_HP_EVENT)
9945 return;
9946 alc262_hp_wildwest_automute(codec);
9947}
9948
Takashi Iwaib72519b2009-05-08 14:31:55 +02009949#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +01009950
9951static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9952 struct snd_ctl_elem_value *ucontrol)
9953{
9954 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9955 struct alc_spec *spec = codec->spec;
9956 int val = !!*ucontrol->value.integer.value;
9957
9958 if (val == spec->master_sw)
9959 return 0;
9960 spec->master_sw = val;
9961 alc262_hp_master_update(codec);
9962 return 1;
9963}
9964
Takashi Iwaib72519b2009-05-08 14:31:55 +02009965#define ALC262_HP_MASTER_SWITCH \
9966 { \
9967 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9968 .name = "Master Playback Switch", \
9969 .info = snd_ctl_boolean_mono_info, \
9970 .get = alc262_hp_master_sw_get, \
9971 .put = alc262_hp_master_sw_put, \
9972 }
9973
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009974static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009975 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009976 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9977 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9978 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009979 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9980 HDA_OUTPUT),
9981 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9982 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009983 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9984 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009985 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009986 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9987 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009988 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009989 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9990 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9991 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9992 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009993 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9994 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9995 { } /* end */
9996};
9997
Kailang Yangcd7509a2007-01-26 18:33:17 +01009998static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009999 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010000 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10001 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10002 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10003 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010004 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10005 HDA_OUTPUT),
10006 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10007 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010008 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10009 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010010 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010011 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10012 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10013 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10014 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010015 { } /* end */
10016};
10017
10018static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10019 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10020 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010021 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010022 { } /* end */
10023};
10024
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010025/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010026static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010027{
10028 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010029
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010030 spec->autocfg.hp_pins[0] = 0x15;
10031 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010032}
10033
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010034static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010035 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10036 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010037 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10038 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10039 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10040 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10041 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10042 { } /* end */
10043};
10044
10045static struct hda_verb alc262_hp_t5735_verbs[] = {
10046 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10047 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10048
10049 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10050 { }
10051};
10052
Kailang Yang8c427222008-01-10 13:03:59 +010010053static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010054 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10055 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010056 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10057 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010058 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10059 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10060 { } /* end */
10061};
10062
10063static struct hda_verb alc262_hp_rp5700_verbs[] = {
10064 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10065 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10066 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10067 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10068 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10069 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10070 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10071 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10072 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10073 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10074 {}
10075};
10076
10077static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10078 .num_items = 1,
10079 .items = {
10080 { "Line", 0x1 },
10081 },
10082};
10083
Takashi Iwai42171c12009-05-08 14:11:43 +020010084/* bind hp and internal speaker mute (with plug check) as master switch */
10085static void alc262_hippo_master_update(struct hda_codec *codec)
10086{
10087 struct alc_spec *spec = codec->spec;
10088 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10089 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10090 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10091 unsigned int mute;
10092
10093 /* HP */
10094 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10095 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10096 HDA_AMP_MUTE, mute);
10097 /* mute internal speaker per jack sense */
10098 if (spec->jack_present)
10099 mute = HDA_AMP_MUTE;
10100 if (line_nid)
10101 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10102 HDA_AMP_MUTE, mute);
10103 if (speaker_nid && speaker_nid != line_nid)
10104 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10105 HDA_AMP_MUTE, mute);
10106}
10107
10108#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10109
10110static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10111 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010112{
10113 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010114 struct alc_spec *spec = codec->spec;
10115 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010116
Takashi Iwai42171c12009-05-08 14:11:43 +020010117 if (val == spec->master_sw)
10118 return 0;
10119 spec->master_sw = val;
10120 alc262_hippo_master_update(codec);
10121 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010122}
Takashi Iwai5b319542007-07-26 11:49:22 +020010123
Takashi Iwai42171c12009-05-08 14:11:43 +020010124#define ALC262_HIPPO_MASTER_SWITCH \
10125 { \
10126 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10127 .name = "Master Playback Switch", \
10128 .info = snd_ctl_boolean_mono_info, \
10129 .get = alc262_hippo_master_sw_get, \
10130 .put = alc262_hippo_master_sw_put, \
10131 }
10132
10133static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10134 ALC262_HIPPO_MASTER_SWITCH,
10135 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10136 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10137 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10138 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10139 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10140 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10141 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10142 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10143 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10144 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10145 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10146 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10147 { } /* end */
10148};
10149
10150static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10151 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10152 ALC262_HIPPO_MASTER_SWITCH,
10153 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10154 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10155 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10156 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10157 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10158 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10159 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10160 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10161 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10162 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10163 { } /* end */
10164};
10165
10166/* mute/unmute internal speaker according to the hp jack and mute state */
10167static void alc262_hippo_automute(struct hda_codec *codec)
10168{
10169 struct alc_spec *spec = codec->spec;
10170 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10171 unsigned int present;
10172
10173 /* need to execute and sync at first */
10174 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
10175 present = snd_hda_codec_read(codec, hp_nid, 0,
10176 AC_VERB_GET_PIN_SENSE, 0);
10177 spec->jack_present = (present & 0x80000000) != 0;
10178 alc262_hippo_master_update(codec);
10179}
10180
10181static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10182{
10183 if ((res >> 26) != ALC880_HP_EVENT)
10184 return;
10185 alc262_hippo_automute(codec);
10186}
10187
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010188static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010189{
10190 struct alc_spec *spec = codec->spec;
10191
10192 spec->autocfg.hp_pins[0] = 0x15;
10193 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010194}
10195
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010196static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010197{
10198 struct alc_spec *spec = codec->spec;
10199
10200 spec->autocfg.hp_pins[0] = 0x1b;
10201 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010202}
10203
10204
Kailang Yang272a5272007-05-14 11:00:38 +020010205static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010206 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010207 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010208 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10209 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10210 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10211 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10212 { } /* end */
10213};
10214
Kailang Yang83c34212007-07-05 11:43:05 +020010215static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010216 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10217 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010218 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10219 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10220 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10221 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10222 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10223 { } /* end */
10224};
Kailang Yang272a5272007-05-14 11:00:38 +020010225
Tony Vroonba340e82009-02-02 19:01:30 +000010226static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10227 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10228 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10229 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10230 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10231 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10232 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10233 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10234 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10235 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10236 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10237 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10238 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10239 { } /* end */
10240};
10241
10242static struct hda_verb alc262_tyan_verbs[] = {
10243 /* Headphone automute */
10244 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10245 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10246 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10247
10248 /* P11 AUX_IN, white 4-pin connector */
10249 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10250 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10251 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10252 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10253
10254 {}
10255};
10256
10257/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010258static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010259{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010260 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010261
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010262 spec->autocfg.hp_pins[0] = 0x1b;
10263 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010264}
10265
Tony Vroonba340e82009-02-02 19:01:30 +000010266
Kailang Yangdf694da2005-12-05 19:42:22 +010010267#define alc262_capture_mixer alc882_capture_mixer
10268#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10269
10270/*
10271 * generic initialization of ADC, input mixers and output mixers
10272 */
10273static struct hda_verb alc262_init_verbs[] = {
10274 /*
10275 * Unmute ADC0-2 and set the default input to mic-in
10276 */
10277 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10278 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10279 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10280 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10281 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10282 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10283
Takashi Iwaicb53c622007-08-10 17:21:45 +020010284 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010285 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010286 * Note: PASD motherboards uses the Line In 2 as the input for
10287 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010288 */
10289 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010290 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10291 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10292 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10293 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10294 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010295
10296 /*
10297 * Set up output mixers (0x0c - 0x0e)
10298 */
10299 /* set vol=0 to output mixers */
10300 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10301 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10302 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10303 /* set up input amps for analog loopback */
10304 /* Amp Indices: DAC = 0, mixer = 1 */
10305 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10306 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10307 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10308 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10309 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10310 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10311
10312 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10313 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10314 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10315 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10316 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10317 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10318
10319 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10320 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10321 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10322 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10323 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010324
Kailang Yangdf694da2005-12-05 19:42:22 +010010325 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10326 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010327
Kailang Yangdf694da2005-12-05 19:42:22 +010010328 /* FIXME: use matrix-type input source selection */
10329 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10330 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10331 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10332 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10333 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10334 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10335 /* Input mixer2 */
10336 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10337 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10338 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10339 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10340 /* Input mixer3 */
10341 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10342 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10343 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010344 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010345
10346 { }
10347};
10348
Kailang Yang4e555fe2008-08-26 13:05:55 +020010349static struct hda_verb alc262_eapd_verbs[] = {
10350 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10351 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10352 { }
10353};
10354
Kailang Yangccc656c2006-10-17 12:32:26 +020010355static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10356 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10357 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10358 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10359
10360 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10361 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10362 {}
10363};
10364
Kailang Yang272a5272007-05-14 11:00:38 +020010365static struct hda_verb alc262_sony_unsol_verbs[] = {
10366 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10367 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10368 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10369
10370 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10371 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010372 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010373};
10374
Kailang Yang4e555fe2008-08-26 13:05:55 +020010375static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10376 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10377 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10378 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10379 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10380 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010381 { } /* end */
10382};
10383
10384static struct hda_verb alc262_toshiba_s06_verbs[] = {
10385 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10386 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10387 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10388 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10389 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10390 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10391 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10392 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10393 {}
10394};
10395
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010396static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020010397{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010398 struct alc_spec *spec = codec->spec;
10399
10400 spec->autocfg.hp_pins[0] = 0x15;
10401 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010402 spec->ext_mic.pin = 0x18;
10403 spec->ext_mic.mux_idx = 0;
10404 spec->int_mic.pin = 0x12;
10405 spec->int_mic.mux_idx = 9;
10406 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020010407}
10408
Takashi Iwai834be882006-03-01 14:16:17 +010010409/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010410 * nec model
10411 * 0x15 = headphone
10412 * 0x16 = internal speaker
10413 * 0x18 = external mic
10414 */
10415
10416static struct snd_kcontrol_new alc262_nec_mixer[] = {
10417 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10418 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10419
10420 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10421 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10422 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10423
10424 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10425 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10426 { } /* end */
10427};
10428
10429static struct hda_verb alc262_nec_verbs[] = {
10430 /* Unmute Speaker */
10431 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10432
10433 /* Headphone */
10434 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10435 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10436
10437 /* External mic to headphone */
10438 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10439 /* External mic to speaker */
10440 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10441 {}
10442};
10443
10444/*
Takashi Iwai834be882006-03-01 14:16:17 +010010445 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010446 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10447 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010448 */
10449
10450#define ALC_HP_EVENT 0x37
10451
10452static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10453 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10454 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010455 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10456 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010457 {}
10458};
10459
Jiang zhe0e31daf2008-03-20 12:12:39 +010010460static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10461 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10462 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10463 {}
10464};
10465
Takashi Iwai834be882006-03-01 14:16:17 +010010466static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010467 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010468 .items = {
10469 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010470 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010471 { "CD", 0x4 },
10472 },
10473};
10474
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010475static struct hda_input_mux alc262_HP_capture_source = {
10476 .num_items = 5,
10477 .items = {
10478 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010479 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010480 { "Line", 0x2 },
10481 { "CD", 0x4 },
10482 { "AUX IN", 0x6 },
10483 },
10484};
10485
zhejiangaccbe492007-08-31 12:36:05 +020010486static struct hda_input_mux alc262_HP_D7000_capture_source = {
10487 .num_items = 4,
10488 .items = {
10489 { "Mic", 0x0 },
10490 { "Front Mic", 0x2 },
10491 { "Line", 0x1 },
10492 { "CD", 0x4 },
10493 },
10494};
10495
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010496/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010497static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10498{
10499 struct alc_spec *spec = codec->spec;
10500 unsigned int mute;
10501
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010502 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010503 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010504 /* need to execute and sync at first */
10505 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010506 /* check laptop HP jack */
10507 present = snd_hda_codec_read(codec, 0x14, 0,
10508 AC_VERB_GET_PIN_SENSE, 0);
10509 /* need to execute and sync at first */
10510 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10511 /* check docking HP jack */
10512 present |= snd_hda_codec_read(codec, 0x1b, 0,
10513 AC_VERB_GET_PIN_SENSE, 0);
10514 if (present & AC_PINSENSE_PRESENCE)
10515 spec->jack_present = 1;
10516 else
10517 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010518 spec->sense_updated = 1;
10519 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010520 /* unmute internal speaker only if both HPs are unplugged and
10521 * master switch is on
10522 */
10523 if (spec->jack_present)
10524 mute = HDA_AMP_MUTE;
10525 else
Takashi Iwai834be882006-03-01 14:16:17 +010010526 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010527 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10528 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010529}
10530
10531/* unsolicited event for HP jack sensing */
10532static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10533 unsigned int res)
10534{
10535 if ((res >> 26) != ALC_HP_EVENT)
10536 return;
10537 alc262_fujitsu_automute(codec, 1);
10538}
10539
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010540static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10541{
10542 alc262_fujitsu_automute(codec, 1);
10543}
10544
Takashi Iwai834be882006-03-01 14:16:17 +010010545/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010546static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10547 .ops = &snd_hda_bind_vol,
10548 .values = {
10549 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10550 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10551 0
10552 },
10553};
Takashi Iwai834be882006-03-01 14:16:17 +010010554
Jiang zhe0e31daf2008-03-20 12:12:39 +010010555/* mute/unmute internal speaker according to the hp jack and mute state */
10556static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10557{
10558 struct alc_spec *spec = codec->spec;
10559 unsigned int mute;
10560
10561 if (force || !spec->sense_updated) {
10562 unsigned int present_int_hp;
10563 /* need to execute and sync at first */
10564 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10565 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10566 AC_VERB_GET_PIN_SENSE, 0);
10567 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10568 spec->sense_updated = 1;
10569 }
10570 if (spec->jack_present) {
10571 /* mute internal speaker */
10572 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10573 HDA_AMP_MUTE, HDA_AMP_MUTE);
10574 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10575 HDA_AMP_MUTE, HDA_AMP_MUTE);
10576 } else {
10577 /* unmute internal speaker if necessary */
10578 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10579 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10580 HDA_AMP_MUTE, mute);
10581 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10582 HDA_AMP_MUTE, mute);
10583 }
10584}
10585
10586/* unsolicited event for HP jack sensing */
10587static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10588 unsigned int res)
10589{
10590 if ((res >> 26) != ALC_HP_EVENT)
10591 return;
10592 alc262_lenovo_3000_automute(codec, 1);
10593}
10594
Takashi Iwai8de56b72009-07-24 16:51:47 +020010595static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10596 int dir, int idx, long *valp)
10597{
10598 int i, change = 0;
10599
10600 for (i = 0; i < 2; i++, valp++)
10601 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10602 HDA_AMP_MUTE,
10603 *valp ? 0 : HDA_AMP_MUTE);
10604 return change;
10605}
10606
Takashi Iwai834be882006-03-01 14:16:17 +010010607/* bind hp and internal speaker mute (with plug check) */
10608static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10609 struct snd_ctl_elem_value *ucontrol)
10610{
10611 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10612 long *valp = ucontrol->value.integer.value;
10613 int change;
10614
Takashi Iwai8de56b72009-07-24 16:51:47 +020010615 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10616 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010617 if (change)
10618 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010619 return change;
10620}
10621
10622static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010623 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010624 {
10625 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10626 .name = "Master Playback Switch",
10627 .info = snd_hda_mixer_amp_switch_info,
10628 .get = snd_hda_mixer_amp_switch_get,
10629 .put = alc262_fujitsu_master_sw_put,
10630 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10631 },
10632 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10633 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10634 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10635 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10636 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010637 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10638 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10639 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010640 { } /* end */
10641};
10642
Jiang zhe0e31daf2008-03-20 12:12:39 +010010643/* bind hp and internal speaker mute (with plug check) */
10644static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10645 struct snd_ctl_elem_value *ucontrol)
10646{
10647 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10648 long *valp = ucontrol->value.integer.value;
10649 int change;
10650
Takashi Iwai8de56b72009-07-24 16:51:47 +020010651 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010652 if (change)
10653 alc262_lenovo_3000_automute(codec, 0);
10654 return change;
10655}
10656
10657static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10658 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10659 {
10660 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10661 .name = "Master Playback Switch",
10662 .info = snd_hda_mixer_amp_switch_info,
10663 .get = snd_hda_mixer_amp_switch_get,
10664 .put = alc262_lenovo_3000_master_sw_put,
10665 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10666 },
10667 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10668 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10669 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10670 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10671 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10672 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10673 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10674 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10675 { } /* end */
10676};
10677
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010678static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10679 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010680 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010681 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10682 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10683 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10684 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10685 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10686 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10687 { } /* end */
10688};
10689
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010690/* additional init verbs for Benq laptops */
10691static struct hda_verb alc262_EAPD_verbs[] = {
10692 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10693 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10694 {}
10695};
10696
Kailang Yang83c34212007-07-05 11:43:05 +020010697static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10698 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10699 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10700
10701 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10702 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10703 {}
10704};
10705
Tobin Davisf651b502007-10-26 12:40:47 +020010706/* Samsung Q1 Ultra Vista model setup */
10707static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010708 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10709 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010710 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10711 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10712 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010713 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010714 { } /* end */
10715};
10716
10717static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010718 /* output mixer */
10719 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10720 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10721 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10722 /* speaker */
10723 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10724 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10725 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10726 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10727 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010728 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010729 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10730 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10731 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10732 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10733 /* internal mic */
10734 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10735 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10736 /* ADC, choose mic */
10737 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10738 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10739 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10740 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10741 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10742 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10743 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10744 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10745 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10746 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010747 {}
10748};
10749
Tobin Davisf651b502007-10-26 12:40:47 +020010750/* mute/unmute internal speaker according to the hp jack and mute state */
10751static void alc262_ultra_automute(struct hda_codec *codec)
10752{
10753 struct alc_spec *spec = codec->spec;
10754 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010755
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010756 mute = 0;
10757 /* auto-mute only when HP is used as HP */
10758 if (!spec->cur_mux[0]) {
10759 unsigned int present;
10760 /* need to execute and sync at first */
10761 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10762 present = snd_hda_codec_read(codec, 0x15, 0,
10763 AC_VERB_GET_PIN_SENSE, 0);
10764 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10765 if (spec->jack_present)
10766 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010767 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010768 /* mute/unmute internal speaker */
10769 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10770 HDA_AMP_MUTE, mute);
10771 /* mute/unmute HP */
10772 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10773 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010774}
10775
10776/* unsolicited event for HP jack sensing */
10777static void alc262_ultra_unsol_event(struct hda_codec *codec,
10778 unsigned int res)
10779{
10780 if ((res >> 26) != ALC880_HP_EVENT)
10781 return;
10782 alc262_ultra_automute(codec);
10783}
10784
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010785static struct hda_input_mux alc262_ultra_capture_source = {
10786 .num_items = 2,
10787 .items = {
10788 { "Mic", 0x1 },
10789 { "Headphone", 0x7 },
10790 },
10791};
10792
10793static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10794 struct snd_ctl_elem_value *ucontrol)
10795{
10796 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10797 struct alc_spec *spec = codec->spec;
10798 int ret;
10799
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010800 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010801 if (!ret)
10802 return 0;
10803 /* reprogram the HP pin as mic or HP according to the input source */
10804 snd_hda_codec_write_cache(codec, 0x15, 0,
10805 AC_VERB_SET_PIN_WIDGET_CONTROL,
10806 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10807 alc262_ultra_automute(codec); /* mute/unmute HP */
10808 return ret;
10809}
10810
10811static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10812 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10813 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10814 {
10815 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10816 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010817 .info = alc_mux_enum_info,
10818 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010819 .put = alc262_ultra_mux_enum_put,
10820 },
10821 { } /* end */
10822};
10823
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010824/* We use two mixers depending on the output pin; 0x16 is a mono output
10825 * and thus it's bound with a different mixer.
10826 * This function returns which mixer amp should be used.
10827 */
10828static int alc262_check_volbit(hda_nid_t nid)
10829{
10830 if (!nid)
10831 return 0;
10832 else if (nid == 0x16)
10833 return 2;
10834 else
10835 return 1;
10836}
10837
10838static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
10839 const char *pfx, int *vbits)
10840{
10841 char name[32];
10842 unsigned long val;
10843 int vbit;
10844
10845 vbit = alc262_check_volbit(nid);
10846 if (!vbit)
10847 return 0;
10848 if (*vbits & vbit) /* a volume control for this mixer already there */
10849 return 0;
10850 *vbits |= vbit;
10851 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
10852 if (vbit == 2)
10853 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
10854 else
10855 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
10856 return add_control(spec, ALC_CTL_WIDGET_VOL, name, val);
10857}
10858
10859static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
10860 const char *pfx)
10861{
10862 char name[32];
10863 unsigned long val;
10864
10865 if (!nid)
10866 return 0;
10867 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
10868 if (nid == 0x16)
10869 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
10870 else
10871 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
10872 return add_control(spec, ALC_CTL_WIDGET_MUTE, name, val);
10873}
10874
Kailang Yangdf694da2005-12-05 19:42:22 +010010875/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010876static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10877 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010878{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010879 const char *pfx;
10880 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010010881 int err;
10882
10883 spec->multiout.num_dacs = 1; /* only use one dac */
10884 spec->multiout.dac_nids = spec->private_dac_nids;
10885 spec->multiout.dac_nids[0] = 2;
10886
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010887 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
10888 pfx = "Master";
10889 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
10890 pfx = "Speaker";
10891 else
10892 pfx = "Front";
10893 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
10894 if (err < 0)
10895 return err;
10896 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
10897 if (err < 0)
10898 return err;
10899 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
10900 if (err < 0)
10901 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010010902
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010903 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
10904 alc262_check_volbit(cfg->speaker_pins[0]) |
10905 alc262_check_volbit(cfg->hp_pins[0]);
10906 if (vbits == 1 || vbits == 2)
10907 pfx = "Master"; /* only one mixer is used */
10908 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
10909 pfx = "Speaker";
10910 else
10911 pfx = "Front";
10912 vbits = 0;
10913 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
10914 if (err < 0)
10915 return err;
10916 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
10917 &vbits);
10918 if (err < 0)
10919 return err;
10920 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
10921 &vbits);
10922 if (err < 0)
10923 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010924 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010925}
10926
Takashi Iwai05f5f472009-08-25 13:10:18 +020010927#define alc262_auto_create_input_ctls \
10928 alc880_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010929
10930/*
10931 * generic initialization of ADC, input mixers and output mixers
10932 */
10933static struct hda_verb alc262_volume_init_verbs[] = {
10934 /*
10935 * Unmute ADC0-2 and set the default input to mic-in
10936 */
10937 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10938 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10939 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10940 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10941 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10942 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10943
Takashi Iwaicb53c622007-08-10 17:21:45 +020010944 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010945 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010946 * Note: PASD motherboards uses the Line In 2 as the input for
10947 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010948 */
10949 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010950 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10951 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10952 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10953 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10954 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010955
10956 /*
10957 * Set up output mixers (0x0c - 0x0f)
10958 */
10959 /* set vol=0 to output mixers */
10960 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10961 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10962 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010963
Kailang Yangdf694da2005-12-05 19:42:22 +010010964 /* set up input amps for analog loopback */
10965 /* Amp Indices: DAC = 0, mixer = 1 */
10966 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10967 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10968 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10969 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10970 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10971 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10972
10973 /* FIXME: use matrix-type input source selection */
10974 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10975 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10976 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10977 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10978 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10979 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10980 /* Input mixer2 */
10981 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10982 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10983 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10984 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10985 /* Input mixer3 */
10986 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10987 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10988 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10989 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10990
10991 { }
10992};
10993
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010994static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10995 /*
10996 * Unmute ADC0-2 and set the default input to mic-in
10997 */
10998 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10999 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11000 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11001 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11002 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11003 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11004
Takashi Iwaicb53c622007-08-10 17:21:45 +020011005 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011006 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011007 * Note: PASD motherboards uses the Line In 2 as the input for
11008 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011009 */
11010 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011011 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11012 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11013 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11014 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11015 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11016 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11017 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011018
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011019 /*
11020 * Set up output mixers (0x0c - 0x0e)
11021 */
11022 /* set vol=0 to output mixers */
11023 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11024 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11025 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11026
11027 /* set up input amps for analog loopback */
11028 /* Amp Indices: DAC = 0, mixer = 1 */
11029 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11030 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11031 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11032 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11033 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11034 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11035
Takashi Iwaice875f02008-01-28 18:17:43 +010011036 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011037 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11038 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11039
11040 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11041 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11042
11043 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11044 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11045
11046 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11047 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11048 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11049 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11050 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11051
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011052 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011053 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11054 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011055 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011056 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11057 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11058
11059
11060 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011061 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11062 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011063 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011064 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11065 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11066 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11067 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11068 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11069 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11070 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11071 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011072 /* Input mixer2 */
11073 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011074 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11075 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11076 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11077 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11078 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11079 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11080 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11081 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011082 /* Input mixer3 */
11083 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011084 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11085 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11086 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11087 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11090 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11091 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011092
Takashi Iwaice875f02008-01-28 18:17:43 +010011093 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11094
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011095 { }
11096};
11097
Kailang Yangcd7509a2007-01-26 18:33:17 +010011098static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11099 /*
11100 * Unmute ADC0-2 and set the default input to mic-in
11101 */
11102 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11103 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11104 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11105 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11106 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11107 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11108
Takashi Iwaicb53c622007-08-10 17:21:45 +020011109 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011110 * mixer widget
11111 * Note: PASD motherboards uses the Line In 2 as the input for front
11112 * panel mic (mic 2)
11113 */
11114 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011115 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11116 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11117 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11118 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11119 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11120 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11121 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11122 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011123 /*
11124 * Set up output mixers (0x0c - 0x0e)
11125 */
11126 /* set vol=0 to output mixers */
11127 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11128 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11129 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11130
11131 /* set up input amps for analog loopback */
11132 /* Amp Indices: DAC = 0, mixer = 1 */
11133 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11134 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11135 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11136 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11137 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11138 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11139
11140
11141 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11142 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11143 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11144 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11145 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11146 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11147 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11148
11149 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11150 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11151
11152 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11153 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11154
11155 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11156 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11157 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11158 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11159 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11160 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11161
11162 /* FIXME: use matrix-type input source selection */
11163 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11164 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11165 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11166 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11167 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11168 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11169 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11170 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11171 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11172 /* Input mixer2 */
11173 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11174 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11175 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11176 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11177 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11178 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11179 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11180 /* Input mixer3 */
11181 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11182 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11183 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11184 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11185 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11186 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11187 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11188
Takashi Iwaice875f02008-01-28 18:17:43 +010011189 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11190
Kailang Yangcd7509a2007-01-26 18:33:17 +010011191 { }
11192};
11193
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011194static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11195
11196 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11197 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11198 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11199
11200 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11201 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11202 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11203 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11204
11205 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11206 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11207 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11208 {}
11209};
11210
11211
Takashi Iwaicb53c622007-08-10 17:21:45 +020011212#ifdef CONFIG_SND_HDA_POWER_SAVE
11213#define alc262_loopbacks alc880_loopbacks
11214#endif
11215
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011216/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011217#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11218#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11219#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11220#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11221
11222/*
11223 * BIOS auto configuration
11224 */
11225static int alc262_parse_auto_config(struct hda_codec *codec)
11226{
11227 struct alc_spec *spec = codec->spec;
11228 int err;
11229 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11230
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011231 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11232 alc262_ignore);
11233 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011234 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011235 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011236 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011237 spec->multiout.max_channels = 2;
11238 spec->no_analog = 1;
11239 goto dig_only;
11240 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011241 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011242 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011243 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11244 if (err < 0)
11245 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011246 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011247 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011248 return err;
11249
11250 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11251
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011252 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011253 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011254 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011255 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011256 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011257 if (spec->autocfg.dig_in_pin)
11258 spec->dig_in_nid = ALC262_DIGIN_NID;
11259
Takashi Iwai603c4012008-07-30 15:01:44 +020011260 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011261 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011262
Takashi Iwaid88897e2008-10-31 15:01:37 +010011263 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011264 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011265 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011266
Takashi Iwai776e1842007-08-29 15:07:11 +020011267 err = alc_auto_add_mic_boost(codec);
11268 if (err < 0)
11269 return err;
11270
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011271 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11272
Kailang Yangdf694da2005-12-05 19:42:22 +010011273 return 1;
11274}
11275
11276#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11277#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11278#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011279#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011280
11281
11282/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011283static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011284{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011285 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011286 alc262_auto_init_multi_out(codec);
11287 alc262_auto_init_hp_out(codec);
11288 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011289 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011290 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011291 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011292}
11293
11294/*
11295 * configuration and preset
11296 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011297static const char *alc262_models[ALC262_MODEL_LAST] = {
11298 [ALC262_BASIC] = "basic",
11299 [ALC262_HIPPO] = "hippo",
11300 [ALC262_HIPPO_1] = "hippo_1",
11301 [ALC262_FUJITSU] = "fujitsu",
11302 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011303 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011304 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011305 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011306 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011307 [ALC262_BENQ_T31] = "benq-t31",
11308 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011309 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011310 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011311 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011312 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011313 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011314 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011315 [ALC262_AUTO] = "auto",
11316};
11317
11318static struct snd_pci_quirk alc262_cfg_tbl[] = {
11319 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011320 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011321 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11322 ALC262_HP_BPC),
11323 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11324 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011325 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11326 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011327 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011328 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011329 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011330 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011331 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011332 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011333 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011334 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011335 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11336 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11337 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011338 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11339 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011340 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011341 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011342 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011343 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011344 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011345 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Takashi Iwaif872a912009-02-26 00:57:01 +010011346 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11347 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090011348 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011349 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011350 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011351 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011352 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011353 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011354 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11355 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011356 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011357 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011358 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011359 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011360 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011361 {}
11362};
11363
11364static struct alc_config_preset alc262_presets[] = {
11365 [ALC262_BASIC] = {
11366 .mixers = { alc262_base_mixer },
11367 .init_verbs = { alc262_init_verbs },
11368 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11369 .dac_nids = alc262_dac_nids,
11370 .hp_nid = 0x03,
11371 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11372 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011373 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011374 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011375 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011376 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011377 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011378 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11379 .dac_nids = alc262_dac_nids,
11380 .hp_nid = 0x03,
11381 .dig_out_nid = ALC262_DIGOUT_NID,
11382 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11383 .channel_mode = alc262_modes,
11384 .input_mux = &alc262_capture_source,
11385 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011386 .setup = alc262_hippo_setup,
11387 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011388 },
11389 [ALC262_HIPPO_1] = {
11390 .mixers = { alc262_hippo1_mixer },
11391 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11392 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11393 .dac_nids = alc262_dac_nids,
11394 .hp_nid = 0x02,
11395 .dig_out_nid = ALC262_DIGOUT_NID,
11396 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11397 .channel_mode = alc262_modes,
11398 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011399 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011400 .setup = alc262_hippo1_setup,
11401 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011402 },
Takashi Iwai834be882006-03-01 14:16:17 +010011403 [ALC262_FUJITSU] = {
11404 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011405 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11406 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011407 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11408 .dac_nids = alc262_dac_nids,
11409 .hp_nid = 0x03,
11410 .dig_out_nid = ALC262_DIGOUT_NID,
11411 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11412 .channel_mode = alc262_modes,
11413 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011414 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011415 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011416 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011417 [ALC262_HP_BPC] = {
11418 .mixers = { alc262_HP_BPC_mixer },
11419 .init_verbs = { alc262_HP_BPC_init_verbs },
11420 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11421 .dac_nids = alc262_dac_nids,
11422 .hp_nid = 0x03,
11423 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11424 .channel_mode = alc262_modes,
11425 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011426 .unsol_event = alc262_hp_bpc_unsol_event,
11427 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011428 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011429 [ALC262_HP_BPC_D7000_WF] = {
11430 .mixers = { alc262_HP_BPC_WildWest_mixer },
11431 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11432 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11433 .dac_nids = alc262_dac_nids,
11434 .hp_nid = 0x03,
11435 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11436 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011437 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011438 .unsol_event = alc262_hp_wildwest_unsol_event,
11439 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011440 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011441 [ALC262_HP_BPC_D7000_WL] = {
11442 .mixers = { alc262_HP_BPC_WildWest_mixer,
11443 alc262_HP_BPC_WildWest_option_mixer },
11444 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11445 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11446 .dac_nids = alc262_dac_nids,
11447 .hp_nid = 0x03,
11448 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11449 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011450 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011451 .unsol_event = alc262_hp_wildwest_unsol_event,
11452 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011453 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011454 [ALC262_HP_TC_T5735] = {
11455 .mixers = { alc262_hp_t5735_mixer },
11456 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11457 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11458 .dac_nids = alc262_dac_nids,
11459 .hp_nid = 0x03,
11460 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11461 .channel_mode = alc262_modes,
11462 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011463 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011464 .setup = alc262_hp_t5735_setup,
11465 .init_hook = alc_automute_amp,
Kailang Yang8c427222008-01-10 13:03:59 +010011466 },
11467 [ALC262_HP_RP5700] = {
11468 .mixers = { alc262_hp_rp5700_mixer },
11469 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11470 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11471 .dac_nids = alc262_dac_nids,
11472 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11473 .channel_mode = alc262_modes,
11474 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011475 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011476 [ALC262_BENQ_ED8] = {
11477 .mixers = { alc262_base_mixer },
11478 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11479 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11480 .dac_nids = alc262_dac_nids,
11481 .hp_nid = 0x03,
11482 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11483 .channel_mode = alc262_modes,
11484 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011485 },
Kailang Yang272a5272007-05-14 11:00:38 +020011486 [ALC262_SONY_ASSAMD] = {
11487 .mixers = { alc262_sony_mixer },
11488 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11489 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11490 .dac_nids = alc262_dac_nids,
11491 .hp_nid = 0x02,
11492 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11493 .channel_mode = alc262_modes,
11494 .input_mux = &alc262_capture_source,
11495 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011496 .setup = alc262_hippo_setup,
11497 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020011498 },
11499 [ALC262_BENQ_T31] = {
11500 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011501 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
11502 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020011503 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11504 .dac_nids = alc262_dac_nids,
11505 .hp_nid = 0x03,
11506 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11507 .channel_mode = alc262_modes,
11508 .input_mux = &alc262_capture_source,
11509 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011510 .setup = alc262_hippo_setup,
11511 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020011512 },
Tobin Davisf651b502007-10-26 12:40:47 +020011513 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011514 .mixers = { alc262_ultra_mixer },
11515 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011516 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011517 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11518 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011519 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11520 .channel_mode = alc262_modes,
11521 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011522 .adc_nids = alc262_adc_nids, /* ADC0 */
11523 .capsrc_nids = alc262_capsrc_nids,
11524 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011525 .unsol_event = alc262_ultra_unsol_event,
11526 .init_hook = alc262_ultra_automute,
11527 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011528 [ALC262_LENOVO_3000] = {
11529 .mixers = { alc262_lenovo_3000_mixer },
11530 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11531 alc262_lenovo_3000_unsol_verbs },
11532 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11533 .dac_nids = alc262_dac_nids,
11534 .hp_nid = 0x03,
11535 .dig_out_nid = ALC262_DIGOUT_NID,
11536 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11537 .channel_mode = alc262_modes,
11538 .input_mux = &alc262_fujitsu_capture_source,
11539 .unsol_event = alc262_lenovo_3000_unsol_event,
11540 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011541 [ALC262_NEC] = {
11542 .mixers = { alc262_nec_mixer },
11543 .init_verbs = { alc262_nec_verbs },
11544 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11545 .dac_nids = alc262_dac_nids,
11546 .hp_nid = 0x03,
11547 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11548 .channel_mode = alc262_modes,
11549 .input_mux = &alc262_capture_source,
11550 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011551 [ALC262_TOSHIBA_S06] = {
11552 .mixers = { alc262_toshiba_s06_mixer },
11553 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11554 alc262_eapd_verbs },
11555 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11556 .capsrc_nids = alc262_dmic_capsrc_nids,
11557 .dac_nids = alc262_dac_nids,
11558 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011559 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011560 .dig_out_nid = ALC262_DIGOUT_NID,
11561 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11562 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011563 .unsol_event = alc_sku_unsol_event,
11564 .setup = alc262_toshiba_s06_setup,
11565 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020011566 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011567 [ALC262_TOSHIBA_RX1] = {
11568 .mixers = { alc262_toshiba_rx1_mixer },
11569 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11570 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11571 .dac_nids = alc262_dac_nids,
11572 .hp_nid = 0x03,
11573 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11574 .channel_mode = alc262_modes,
11575 .input_mux = &alc262_capture_source,
11576 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011577 .setup = alc262_hippo_setup,
11578 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011579 },
Tony Vroonba340e82009-02-02 19:01:30 +000011580 [ALC262_TYAN] = {
11581 .mixers = { alc262_tyan_mixer },
11582 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11583 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11584 .dac_nids = alc262_dac_nids,
11585 .hp_nid = 0x02,
11586 .dig_out_nid = ALC262_DIGOUT_NID,
11587 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11588 .channel_mode = alc262_modes,
11589 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011590 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011591 .setup = alc262_tyan_setup,
11592 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000011593 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011594};
11595
11596static int patch_alc262(struct hda_codec *codec)
11597{
11598 struct alc_spec *spec;
11599 int board_config;
11600 int err;
11601
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011602 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011603 if (spec == NULL)
11604 return -ENOMEM;
11605
11606 codec->spec = spec;
11607#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011608 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11609 * under-run
11610 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011611 {
11612 int tmp;
11613 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11614 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11615 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11616 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11617 }
11618#endif
11619
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011620 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11621
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011622 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11623 alc262_models,
11624 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011625
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011626 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011627 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11628 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011629 board_config = ALC262_AUTO;
11630 }
11631
11632 if (board_config == ALC262_AUTO) {
11633 /* automatic parse from the BIOS config */
11634 err = alc262_parse_auto_config(codec);
11635 if (err < 0) {
11636 alc_free(codec);
11637 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011638 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011639 printk(KERN_INFO
11640 "hda_codec: Cannot set up configuration "
11641 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011642 board_config = ALC262_BASIC;
11643 }
11644 }
11645
Takashi Iwai07eba612009-02-19 08:06:35 +010011646 if (!spec->no_analog) {
11647 err = snd_hda_attach_beep_device(codec, 0x1);
11648 if (err < 0) {
11649 alc_free(codec);
11650 return err;
11651 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011652 }
11653
Kailang Yangdf694da2005-12-05 19:42:22 +010011654 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011655 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011656
Kailang Yangdf694da2005-12-05 19:42:22 +010011657 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11658 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011659
Kailang Yangdf694da2005-12-05 19:42:22 +010011660 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11661 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11662
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011663 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011664 int i;
11665 /* check whether the digital-mic has to be supported */
11666 for (i = 0; i < spec->input_mux->num_items; i++) {
11667 if (spec->input_mux->items[i].index >= 9)
11668 break;
11669 }
11670 if (i < spec->input_mux->num_items) {
11671 /* use only ADC0 */
11672 spec->adc_nids = alc262_dmic_adc_nids;
11673 spec->num_adc_nids = 1;
11674 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011675 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011676 /* all analog inputs */
11677 /* check whether NID 0x07 is valid */
11678 unsigned int wcap = get_wcaps(codec, 0x07);
11679
11680 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011681 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020011682 if (wcap != AC_WID_AUD_IN) {
11683 spec->adc_nids = alc262_adc_nids_alt;
11684 spec->num_adc_nids =
11685 ARRAY_SIZE(alc262_adc_nids_alt);
11686 spec->capsrc_nids = alc262_capsrc_nids_alt;
11687 } else {
11688 spec->adc_nids = alc262_adc_nids;
11689 spec->num_adc_nids =
11690 ARRAY_SIZE(alc262_adc_nids);
11691 spec->capsrc_nids = alc262_capsrc_nids;
11692 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011693 }
11694 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011695 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011696 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011697 if (!spec->no_analog)
11698 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011699
Takashi Iwai2134ea42008-01-10 16:53:55 +010011700 spec->vmaster_nid = 0x0c;
11701
Kailang Yangdf694da2005-12-05 19:42:22 +010011702 codec->patch_ops = alc_patch_ops;
11703 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011704 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011705#ifdef CONFIG_SND_HDA_POWER_SAVE
11706 if (!spec->loopback.amplist)
11707 spec->loopback.amplist = alc262_loopbacks;
11708#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011709 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011710
Kailang Yangdf694da2005-12-05 19:42:22 +010011711 return 0;
11712}
11713
Kailang Yangdf694da2005-12-05 19:42:22 +010011714/*
Kailang Yanga361d842007-06-05 12:30:55 +020011715 * ALC268 channel source setting (2 channel)
11716 */
11717#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11718#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011719
Kailang Yanga361d842007-06-05 12:30:55 +020011720static hda_nid_t alc268_dac_nids[2] = {
11721 /* front, hp */
11722 0x02, 0x03
11723};
11724
11725static hda_nid_t alc268_adc_nids[2] = {
11726 /* ADC0-1 */
11727 0x08, 0x07
11728};
11729
11730static hda_nid_t alc268_adc_nids_alt[1] = {
11731 /* ADC0 */
11732 0x08
11733};
11734
Takashi Iwaie1406342008-02-11 18:32:32 +010011735static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11736
Kailang Yanga361d842007-06-05 12:30:55 +020011737static struct snd_kcontrol_new alc268_base_mixer[] = {
11738 /* output mixer control */
11739 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11740 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11741 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11742 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011743 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11744 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11745 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011746 { }
11747};
11748
Takashi Iwai42171c12009-05-08 14:11:43 +020011749static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11750 /* output mixer control */
11751 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11752 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11753 ALC262_HIPPO_MASTER_SWITCH,
11754 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11755 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11756 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11757 { }
11758};
11759
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011760/* bind Beep switches of both NID 0x0f and 0x10 */
11761static struct hda_bind_ctls alc268_bind_beep_sw = {
11762 .ops = &snd_hda_bind_sw,
11763 .values = {
11764 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11765 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11766 0
11767 },
11768};
11769
11770static struct snd_kcontrol_new alc268_beep_mixer[] = {
11771 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11772 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11773 { }
11774};
11775
Kailang Yangd1a991a2007-08-15 16:21:59 +020011776static struct hda_verb alc268_eapd_verbs[] = {
11777 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11778 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11779 { }
11780};
11781
Takashi Iwaid2738092007-08-16 14:59:45 +020011782/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011783static struct hda_verb alc268_toshiba_verbs[] = {
11784 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11785 { } /* end */
11786};
11787
11788/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011789/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011790static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11791 .ops = &snd_hda_bind_vol,
11792 .values = {
11793 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11794 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11795 0
11796 },
11797};
11798
Takashi Iwai889c4392007-08-23 18:56:52 +020011799/* mute/unmute internal speaker according to the hp jack and mute state */
11800static void alc268_acer_automute(struct hda_codec *codec, int force)
11801{
11802 struct alc_spec *spec = codec->spec;
11803 unsigned int mute;
11804
11805 if (force || !spec->sense_updated) {
11806 unsigned int present;
11807 present = snd_hda_codec_read(codec, 0x14, 0,
11808 AC_VERB_GET_PIN_SENSE, 0);
11809 spec->jack_present = (present & 0x80000000) != 0;
11810 spec->sense_updated = 1;
11811 }
11812 if (spec->jack_present)
11813 mute = HDA_AMP_MUTE; /* mute internal speaker */
11814 else /* unmute internal speaker if necessary */
11815 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11816 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11817 HDA_AMP_MUTE, mute);
11818}
11819
11820
11821/* bind hp and internal speaker mute (with plug check) */
11822static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11823 struct snd_ctl_elem_value *ucontrol)
11824{
11825 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11826 long *valp = ucontrol->value.integer.value;
11827 int change;
11828
Takashi Iwai8de56b72009-07-24 16:51:47 +020011829 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020011830 if (change)
11831 alc268_acer_automute(codec, 0);
11832 return change;
11833}
Takashi Iwaid2738092007-08-16 14:59:45 +020011834
Kailang Yang8ef355d2008-08-26 13:10:22 +020011835static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11836 /* output mixer control */
11837 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11838 {
11839 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11840 .name = "Master Playback Switch",
11841 .info = snd_hda_mixer_amp_switch_info,
11842 .get = snd_hda_mixer_amp_switch_get,
11843 .put = alc268_acer_master_sw_put,
11844 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11845 },
11846 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11847 { }
11848};
11849
Takashi Iwaid2738092007-08-16 14:59:45 +020011850static struct snd_kcontrol_new alc268_acer_mixer[] = {
11851 /* output mixer control */
11852 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11853 {
11854 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11855 .name = "Master Playback Switch",
11856 .info = snd_hda_mixer_amp_switch_info,
11857 .get = snd_hda_mixer_amp_switch_get,
11858 .put = alc268_acer_master_sw_put,
11859 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11860 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011861 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11862 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11863 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011864 { }
11865};
11866
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011867static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11868 /* output mixer control */
11869 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11870 {
11871 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11872 .name = "Master Playback Switch",
11873 .info = snd_hda_mixer_amp_switch_info,
11874 .get = snd_hda_mixer_amp_switch_get,
11875 .put = alc268_acer_master_sw_put,
11876 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11877 },
11878 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11879 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11880 { }
11881};
11882
Kailang Yang8ef355d2008-08-26 13:10:22 +020011883static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11884 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11885 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11886 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11887 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11888 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11889 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11890 { }
11891};
11892
Takashi Iwaid2738092007-08-16 14:59:45 +020011893static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011894 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11895 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011896 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11897 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011898 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11899 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011900 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11901 { }
11902};
11903
11904/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011905#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011906#define alc268_toshiba_setup alc262_hippo_setup
11907#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020011908
11909static void alc268_acer_unsol_event(struct hda_codec *codec,
11910 unsigned int res)
11911{
Takashi Iwai889c4392007-08-23 18:56:52 +020011912 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011913 return;
11914 alc268_acer_automute(codec, 1);
11915}
11916
Takashi Iwai889c4392007-08-23 18:56:52 +020011917static void alc268_acer_init_hook(struct hda_codec *codec)
11918{
11919 alc268_acer_automute(codec, 1);
11920}
11921
Kailang Yang8ef355d2008-08-26 13:10:22 +020011922/* toggle speaker-output according to the hp-jack state */
11923static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11924{
11925 unsigned int present;
11926 unsigned char bits;
11927
11928 present = snd_hda_codec_read(codec, 0x15, 0,
11929 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11930 bits = present ? AMP_IN_MUTE(0) : 0;
11931 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11932 AMP_IN_MUTE(0), bits);
11933 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11934 AMP_IN_MUTE(0), bits);
11935}
11936
Kailang Yang8ef355d2008-08-26 13:10:22 +020011937static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11938 unsigned int res)
11939{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011940 switch (res >> 26) {
11941 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020011942 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011943 break;
11944 case ALC880_MIC_EVENT:
11945 alc_mic_automute(codec);
11946 break;
11947 }
11948}
11949
11950static void alc268_acer_lc_setup(struct hda_codec *codec)
11951{
11952 struct alc_spec *spec = codec->spec;
11953 spec->ext_mic.pin = 0x18;
11954 spec->ext_mic.mux_idx = 0;
11955 spec->int_mic.pin = 0x12;
11956 spec->int_mic.mux_idx = 6;
11957 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020011958}
11959
11960static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11961{
11962 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011963 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020011964}
11965
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011966static struct snd_kcontrol_new alc268_dell_mixer[] = {
11967 /* output mixer control */
11968 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11969 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11970 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11971 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11972 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11973 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11974 { }
11975};
11976
11977static struct hda_verb alc268_dell_verbs[] = {
11978 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11979 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11980 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011981 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011982 { }
11983};
11984
11985/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011986static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011987{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011988 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011989
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011990 spec->autocfg.hp_pins[0] = 0x15;
11991 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011992 spec->ext_mic.pin = 0x18;
11993 spec->ext_mic.mux_idx = 0;
11994 spec->int_mic.pin = 0x19;
11995 spec->int_mic.mux_idx = 1;
11996 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011997}
11998
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011999static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12000 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12001 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12002 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12003 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12004 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12005 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12006 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12007 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12008 { }
12009};
12010
12011static struct hda_verb alc267_quanta_il1_verbs[] = {
12012 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12013 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12014 { }
12015};
12016
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012017static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012018{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012019 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012020 spec->autocfg.hp_pins[0] = 0x15;
12021 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012022 spec->ext_mic.pin = 0x18;
12023 spec->ext_mic.mux_idx = 0;
12024 spec->int_mic.pin = 0x19;
12025 spec->int_mic.mux_idx = 1;
12026 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012027}
12028
Kailang Yanga361d842007-06-05 12:30:55 +020012029/*
12030 * generic initialization of ADC, input mixers and output mixers
12031 */
12032static struct hda_verb alc268_base_init_verbs[] = {
12033 /* Unmute DAC0-1 and set vol = 0 */
12034 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012035 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012036
12037 /*
12038 * Set up output mixers (0x0c - 0x0e)
12039 */
12040 /* set vol=0 to output mixers */
12041 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012042 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12043
12044 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12045 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12046
12047 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12048 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12049 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12050 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12051 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12052 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12053 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12054 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12055
12056 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12057 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12058 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12059 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012060 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012061
12062 /* set PCBEEP vol = 0, mute connections */
12063 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12064 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12065 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012066
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012067 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012068
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012069 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12070 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12071 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12072 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012073
Kailang Yanga361d842007-06-05 12:30:55 +020012074 { }
12075};
12076
12077/*
12078 * generic initialization of ADC, input mixers and output mixers
12079 */
12080static struct hda_verb alc268_volume_init_verbs[] = {
12081 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012082 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12083 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012084
12085 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12086 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12087 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12088 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12089 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12090
Kailang Yanga361d842007-06-05 12:30:55 +020012091 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012092 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12093 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12094
12095 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012096 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012097
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012098 /* set PCBEEP vol = 0, mute connections */
12099 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12100 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12101 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012102
12103 { }
12104};
12105
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012106static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12107 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12108 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12109 { } /* end */
12110};
12111
Kailang Yanga361d842007-06-05 12:30:55 +020012112static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12113 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12114 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012115 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012116 { } /* end */
12117};
12118
12119static struct snd_kcontrol_new alc268_capture_mixer[] = {
12120 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12121 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12122 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12123 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012124 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012125 { } /* end */
12126};
12127
12128static struct hda_input_mux alc268_capture_source = {
12129 .num_items = 4,
12130 .items = {
12131 { "Mic", 0x0 },
12132 { "Front Mic", 0x1 },
12133 { "Line", 0x2 },
12134 { "CD", 0x3 },
12135 },
12136};
12137
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012138static struct hda_input_mux alc268_acer_capture_source = {
12139 .num_items = 3,
12140 .items = {
12141 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012142 { "Internal Mic", 0x1 },
12143 { "Line", 0x2 },
12144 },
12145};
12146
12147static struct hda_input_mux alc268_acer_dmic_capture_source = {
12148 .num_items = 3,
12149 .items = {
12150 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012151 { "Internal Mic", 0x6 },
12152 { "Line", 0x2 },
12153 },
12154};
12155
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012156#ifdef CONFIG_SND_DEBUG
12157static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012158 /* Volume widgets */
12159 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12160 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12161 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12162 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12163 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12164 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12165 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12166 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12167 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12168 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12169 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12170 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12171 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012172 /* The below appears problematic on some hardwares */
12173 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012174 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12175 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12176 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12177 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12178
12179 /* Modes for retasking pin widgets */
12180 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12181 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12182 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12183 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12184
12185 /* Controls for GPIO pins, assuming they are configured as outputs */
12186 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12187 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12188 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12189 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12190
12191 /* Switches to allow the digital SPDIF output pin to be enabled.
12192 * The ALC268 does not have an SPDIF input.
12193 */
12194 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12195
12196 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12197 * this output to turn on an external amplifier.
12198 */
12199 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12200 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12201
12202 { } /* end */
12203};
12204#endif
12205
Kailang Yanga361d842007-06-05 12:30:55 +020012206/* create input playback/capture controls for the given pin */
12207static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12208 const char *ctlname, int idx)
12209{
12210 char name[32];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012211 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012212 int err;
12213
12214 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012215 switch (nid) {
12216 case 0x14:
12217 case 0x16:
12218 dac = 0x02;
12219 break;
12220 case 0x15:
12221 dac = 0x03;
12222 break;
12223 default:
12224 return 0;
12225 }
12226 if (spec->multiout.dac_nids[0] != dac &&
12227 spec->multiout.dac_nids[1] != dac) {
Kailang Yanga361d842007-06-05 12:30:55 +020012228 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012229 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012230 HDA_OUTPUT));
12231 if (err < 0)
12232 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012233 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12234 }
12235
Kailang Yanga361d842007-06-05 12:30:55 +020012236 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012237 if (nid != 0x16)
12238 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Kailang Yanga361d842007-06-05 12:30:55 +020012239 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012240 else /* mono */
12241 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12242 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012243 if (err < 0)
12244 return err;
12245 return 0;
12246}
12247
12248/* add playback controls from the parsed DAC table */
12249static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12250 const struct auto_pin_cfg *cfg)
12251{
12252 hda_nid_t nid;
12253 int err;
12254
Kailang Yanga361d842007-06-05 12:30:55 +020012255 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012256
12257 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012258 if (nid) {
12259 const char *name;
12260 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12261 name = "Speaker";
12262 else
12263 name = "Front";
12264 err = alc268_new_analog_output(spec, nid, name, 0);
12265 if (err < 0)
12266 return err;
12267 }
Kailang Yanga361d842007-06-05 12:30:55 +020012268
12269 nid = cfg->speaker_pins[0];
12270 if (nid == 0x1d) {
12271 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12272 "Speaker Playback Volume",
12273 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12274 if (err < 0)
12275 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012276 } else {
12277 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12278 if (err < 0)
12279 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012280 }
12281 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012282 if (nid) {
12283 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12284 if (err < 0)
12285 return err;
12286 }
Kailang Yanga361d842007-06-05 12:30:55 +020012287
12288 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12289 if (nid == 0x16) {
12290 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12291 "Mono Playback Switch",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012292 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012293 if (err < 0)
12294 return err;
12295 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012296 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012297}
12298
12299/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020012300static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020012301 const struct auto_pin_cfg *cfg)
12302{
Takashi Iwai05f5f472009-08-25 13:10:18 +020012303 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020012304}
12305
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012306static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12307 hda_nid_t nid, int pin_type)
12308{
12309 int idx;
12310
12311 alc_set_pin_output(codec, nid, pin_type);
12312 if (nid == 0x14 || nid == 0x16)
12313 idx = 0;
12314 else
12315 idx = 1;
12316 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12317}
12318
12319static void alc268_auto_init_multi_out(struct hda_codec *codec)
12320{
12321 struct alc_spec *spec = codec->spec;
12322 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12323 if (nid) {
12324 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12325 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12326 }
12327}
12328
12329static void alc268_auto_init_hp_out(struct hda_codec *codec)
12330{
12331 struct alc_spec *spec = codec->spec;
12332 hda_nid_t pin;
12333
12334 pin = spec->autocfg.hp_pins[0];
12335 if (pin)
12336 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12337 pin = spec->autocfg.speaker_pins[0];
12338 if (pin)
12339 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12340}
12341
Kailang Yanga361d842007-06-05 12:30:55 +020012342static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12343{
12344 struct alc_spec *spec = codec->spec;
12345 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12346 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12347 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12348 unsigned int dac_vol1, dac_vol2;
12349
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012350 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020012351 snd_hda_codec_write(codec, speaker_nid, 0,
12352 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012353 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012354 snd_hda_codec_write(codec, 0x0f, 0,
12355 AC_VERB_SET_AMP_GAIN_MUTE,
12356 AMP_IN_UNMUTE(1));
12357 snd_hda_codec_write(codec, 0x10, 0,
12358 AC_VERB_SET_AMP_GAIN_MUTE,
12359 AMP_IN_UNMUTE(1));
12360 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012361 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012362 snd_hda_codec_write(codec, 0x0f, 0,
12363 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12364 snd_hda_codec_write(codec, 0x10, 0,
12365 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12366 }
12367
12368 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012369 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012370 dac_vol2 = AMP_OUT_ZERO;
12371 else if (line_nid == 0x15)
12372 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012373 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012374 dac_vol2 = AMP_OUT_ZERO;
12375 else if (hp_nid == 0x15)
12376 dac_vol1 = AMP_OUT_ZERO;
12377 if (line_nid != 0x16 || hp_nid != 0x16 ||
12378 spec->autocfg.line_out_pins[1] != 0x16 ||
12379 spec->autocfg.line_out_pins[2] != 0x16)
12380 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12381
12382 snd_hda_codec_write(codec, 0x02, 0,
12383 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12384 snd_hda_codec_write(codec, 0x03, 0,
12385 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12386}
12387
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012388/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012389#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12390#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012391#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012392#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12393
12394/*
12395 * BIOS auto configuration
12396 */
12397static int alc268_parse_auto_config(struct hda_codec *codec)
12398{
12399 struct alc_spec *spec = codec->spec;
12400 int err;
12401 static hda_nid_t alc268_ignore[] = { 0 };
12402
12403 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12404 alc268_ignore);
12405 if (err < 0)
12406 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012407 if (!spec->autocfg.line_outs) {
12408 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12409 spec->multiout.max_channels = 2;
12410 spec->no_analog = 1;
12411 goto dig_only;
12412 }
Kailang Yanga361d842007-06-05 12:30:55 +020012413 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012414 }
Kailang Yanga361d842007-06-05 12:30:55 +020012415 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12416 if (err < 0)
12417 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012418 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020012419 if (err < 0)
12420 return err;
12421
12422 spec->multiout.max_channels = 2;
12423
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012424 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012425 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012426 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012427 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012428 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12429 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012430 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012431 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012432
Takashi Iwai892981f2009-03-02 08:04:35 +010012433 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012434 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012435
Takashi Iwaid88897e2008-10-31 15:01:37 +010012436 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012437 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012438 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012439
Takashi Iwai776e1842007-08-29 15:07:11 +020012440 err = alc_auto_add_mic_boost(codec);
12441 if (err < 0)
12442 return err;
12443
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012444 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12445
Kailang Yanga361d842007-06-05 12:30:55 +020012446 return 1;
12447}
12448
Kailang Yanga361d842007-06-05 12:30:55 +020012449#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12450
12451/* init callback for auto-configuration model -- overriding the default init */
12452static void alc268_auto_init(struct hda_codec *codec)
12453{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012454 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012455 alc268_auto_init_multi_out(codec);
12456 alc268_auto_init_hp_out(codec);
12457 alc268_auto_init_mono_speaker_out(codec);
12458 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012459 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012460 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012461}
12462
12463/*
12464 * configuration and preset
12465 */
12466static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012467 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012468 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012469 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012470 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012471 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012472 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012473 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012474 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012475#ifdef CONFIG_SND_DEBUG
12476 [ALC268_TEST] = "test",
12477#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012478 [ALC268_AUTO] = "auto",
12479};
12480
12481static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012482 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012483 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012484 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012485 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012486 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012487 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12488 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012489 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012490 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012491 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
12492 ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012493 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012494 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012495 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012496 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012497 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012498 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012499 {}
12500};
12501
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012502/* Toshiba laptops have no unique PCI SSID but only codec SSID */
12503static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
12504 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
12505 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
12506 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12507 ALC268_TOSHIBA),
12508 {}
12509};
12510
Kailang Yanga361d842007-06-05 12:30:55 +020012511static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012512 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012513 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
12514 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012515 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12516 alc267_quanta_il1_verbs },
12517 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12518 .dac_nids = alc268_dac_nids,
12519 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12520 .adc_nids = alc268_adc_nids_alt,
12521 .hp_nid = 0x03,
12522 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12523 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012524 .unsol_event = alc_sku_unsol_event,
12525 .setup = alc267_quanta_il1_setup,
12526 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012527 },
Kailang Yanga361d842007-06-05 12:30:55 +020012528 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012529 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12530 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012531 .init_verbs = { alc268_base_init_verbs },
12532 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12533 .dac_nids = alc268_dac_nids,
12534 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12535 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012536 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012537 .hp_nid = 0x03,
12538 .dig_out_nid = ALC268_DIGOUT_NID,
12539 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12540 .channel_mode = alc268_modes,
12541 .input_mux = &alc268_capture_source,
12542 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012543 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012544 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012545 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012546 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12547 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012548 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12549 .dac_nids = alc268_dac_nids,
12550 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12551 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012552 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012553 .hp_nid = 0x03,
12554 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12555 .channel_mode = alc268_modes,
12556 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012557 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012558 .setup = alc268_toshiba_setup,
12559 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020012560 },
12561 [ALC268_ACER] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012562 .mixers = { alc268_acer_mixer, alc268_capture_nosrc_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012563 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012564 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12565 alc268_acer_verbs },
12566 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12567 .dac_nids = alc268_dac_nids,
12568 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12569 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012570 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012571 .hp_nid = 0x02,
12572 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12573 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012574 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012575 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012576 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012577 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012578 [ALC268_ACER_DMIC] = {
12579 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12580 alc268_beep_mixer },
12581 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12582 alc268_acer_verbs },
12583 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12584 .dac_nids = alc268_dac_nids,
12585 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12586 .adc_nids = alc268_adc_nids_alt,
12587 .capsrc_nids = alc268_capsrc_nids,
12588 .hp_nid = 0x02,
12589 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12590 .channel_mode = alc268_modes,
12591 .input_mux = &alc268_acer_dmic_capture_source,
12592 .unsol_event = alc268_acer_unsol_event,
12593 .init_hook = alc268_acer_init_hook,
12594 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012595 [ALC268_ACER_ASPIRE_ONE] = {
12596 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012597 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012598 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012599 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12600 alc268_acer_aspire_one_verbs },
12601 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12602 .dac_nids = alc268_dac_nids,
12603 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12604 .adc_nids = alc268_adc_nids_alt,
12605 .capsrc_nids = alc268_capsrc_nids,
12606 .hp_nid = 0x03,
12607 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12608 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012609 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012610 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012611 .init_hook = alc268_acer_lc_init_hook,
12612 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012613 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012614 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
12615 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012616 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12617 alc268_dell_verbs },
12618 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12619 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012620 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12621 .adc_nids = alc268_adc_nids_alt,
12622 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012623 .hp_nid = 0x02,
12624 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12625 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012626 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012627 .setup = alc268_dell_setup,
12628 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012629 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012630 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012631 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12632 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012633 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12634 alc268_toshiba_verbs },
12635 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12636 .dac_nids = alc268_dac_nids,
12637 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12638 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012639 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012640 .hp_nid = 0x03,
12641 .dig_out_nid = ALC268_DIGOUT_NID,
12642 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12643 .channel_mode = alc268_modes,
12644 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012645 .setup = alc268_toshiba_setup,
12646 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012647 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012648#ifdef CONFIG_SND_DEBUG
12649 [ALC268_TEST] = {
12650 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12651 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12652 alc268_volume_init_verbs },
12653 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12654 .dac_nids = alc268_dac_nids,
12655 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12656 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012657 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012658 .hp_nid = 0x03,
12659 .dig_out_nid = ALC268_DIGOUT_NID,
12660 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12661 .channel_mode = alc268_modes,
12662 .input_mux = &alc268_capture_source,
12663 },
12664#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012665};
12666
12667static int patch_alc268(struct hda_codec *codec)
12668{
12669 struct alc_spec *spec;
12670 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012671 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012672
12673 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12674 if (spec == NULL)
12675 return -ENOMEM;
12676
12677 codec->spec = spec;
12678
12679 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12680 alc268_models,
12681 alc268_cfg_tbl);
12682
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012683 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
12684 board_config = snd_hda_check_board_codec_sid_config(codec,
12685 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
12686
Kailang Yanga361d842007-06-05 12:30:55 +020012687 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012688 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12689 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012690 board_config = ALC268_AUTO;
12691 }
12692
12693 if (board_config == ALC268_AUTO) {
12694 /* automatic parse from the BIOS config */
12695 err = alc268_parse_auto_config(codec);
12696 if (err < 0) {
12697 alc_free(codec);
12698 return err;
12699 } else if (!err) {
12700 printk(KERN_INFO
12701 "hda_codec: Cannot set up configuration "
12702 "from BIOS. Using base mode...\n");
12703 board_config = ALC268_3ST;
12704 }
12705 }
12706
12707 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012708 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020012709
Kailang Yanga361d842007-06-05 12:30:55 +020012710 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12711 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012712 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012713
Kailang Yanga361d842007-06-05 12:30:55 +020012714 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12715
Takashi Iwai22971e32009-02-10 11:56:44 +010012716 has_beep = 0;
12717 for (i = 0; i < spec->num_mixers; i++) {
12718 if (spec->mixers[i] == alc268_beep_mixer) {
12719 has_beep = 1;
12720 break;
12721 }
12722 }
12723
12724 if (has_beep) {
12725 err = snd_hda_attach_beep_device(codec, 0x1);
12726 if (err < 0) {
12727 alc_free(codec);
12728 return err;
12729 }
12730 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12731 /* override the amp caps for beep generator */
12732 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012733 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12734 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12735 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12736 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012737 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012738
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012739 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012740 /* check whether NID 0x07 is valid */
12741 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012742 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012743
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012744 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012745 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012746 if (spec->auto_mic ||
12747 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012748 spec->adc_nids = alc268_adc_nids_alt;
12749 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012750 if (spec->auto_mic || spec->input_mux->num_items == 1)
12751 add_mixer(spec, alc268_capture_nosrc_mixer);
12752 else
12753 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012754 } else {
12755 spec->adc_nids = alc268_adc_nids;
12756 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012757 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012758 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012759 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012760 /* set default input source */
12761 for (i = 0; i < spec->num_adc_nids; i++)
12762 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12763 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012764 i < spec->num_mux_defs ?
12765 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010012766 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012767 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012768
12769 spec->vmaster_nid = 0x02;
12770
Kailang Yanga361d842007-06-05 12:30:55 +020012771 codec->patch_ops = alc_patch_ops;
12772 if (board_config == ALC268_AUTO)
12773 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012774
Takashi Iwaidaead532008-11-28 12:55:36 +010012775 codec->proc_widget_hook = print_realtek_coef;
12776
Kailang Yanga361d842007-06-05 12:30:55 +020012777 return 0;
12778}
12779
12780/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012781 * ALC269 channel source setting (2 channel)
12782 */
12783#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12784
12785#define alc269_dac_nids alc260_dac_nids
12786
12787static hda_nid_t alc269_adc_nids[1] = {
12788 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012789 0x08,
12790};
12791
Takashi Iwaie01bf502008-08-21 16:25:07 +020012792static hda_nid_t alc269_capsrc_nids[1] = {
12793 0x23,
12794};
12795
12796/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12797 * not a mux!
12798 */
12799
Kailang Yangf6a92242007-12-13 16:52:54 +010012800#define alc269_modes alc260_modes
12801#define alc269_capture_source alc880_lg_lw_capture_source
12802
12803static struct snd_kcontrol_new alc269_base_mixer[] = {
12804 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12805 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12806 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12807 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12808 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12809 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12810 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12811 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12812 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12813 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12814 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12815 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12816 { } /* end */
12817};
12818
Kailang Yang60db6b52008-08-26 13:13:00 +020012819static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12820 /* output mixer control */
12821 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12822 {
12823 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12824 .name = "Master Playback Switch",
12825 .info = snd_hda_mixer_amp_switch_info,
12826 .get = snd_hda_mixer_amp_switch_get,
12827 .put = alc268_acer_master_sw_put,
12828 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12829 },
12830 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12831 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12832 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12833 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12834 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12835 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012836 { }
12837};
12838
Tony Vroon64154832008-11-06 15:08:49 +000012839static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12840 /* output mixer control */
12841 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12842 {
12843 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12844 .name = "Master Playback Switch",
12845 .info = snd_hda_mixer_amp_switch_info,
12846 .get = snd_hda_mixer_amp_switch_get,
12847 .put = alc268_acer_master_sw_put,
12848 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12849 },
12850 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12851 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12852 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12853 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12854 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12855 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12856 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12857 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12858 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012859 { }
12860};
12861
Kailang Yangf53281e2008-07-18 12:36:43 +020012862static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020012863 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012864 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020012865 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012866 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020012867 { } /* end */
12868};
12869
Kailang Yangf6a92242007-12-13 16:52:54 +010012870/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012871static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12872 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12873 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012874 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12875 { } /* end */
12876};
12877
12878/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020012879#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020012880
Kailang Yang60db6b52008-08-26 13:13:00 +020012881static struct hda_verb alc269_quanta_fl1_verbs[] = {
12882 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12883 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12884 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12885 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12886 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12887 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12888 { }
12889};
12890
Tony Vroon64154832008-11-06 15:08:49 +000012891static struct hda_verb alc269_lifebook_verbs[] = {
12892 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12893 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12894 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12895 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12896 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12897 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12898 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12899 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12900 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12901 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12902 { }
12903};
12904
Kailang Yang60db6b52008-08-26 13:13:00 +020012905/* toggle speaker-output according to the hp-jack state */
12906static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12907{
12908 unsigned int present;
12909 unsigned char bits;
12910
12911 present = snd_hda_codec_read(codec, 0x15, 0,
12912 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12913 bits = present ? AMP_IN_MUTE(0) : 0;
12914 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12915 AMP_IN_MUTE(0), bits);
12916 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12917 AMP_IN_MUTE(0), bits);
12918
12919 snd_hda_codec_write(codec, 0x20, 0,
12920 AC_VERB_SET_COEF_INDEX, 0x0c);
12921 snd_hda_codec_write(codec, 0x20, 0,
12922 AC_VERB_SET_PROC_COEF, 0x680);
12923
12924 snd_hda_codec_write(codec, 0x20, 0,
12925 AC_VERB_SET_COEF_INDEX, 0x0c);
12926 snd_hda_codec_write(codec, 0x20, 0,
12927 AC_VERB_SET_PROC_COEF, 0x480);
12928}
12929
Tony Vroon64154832008-11-06 15:08:49 +000012930/* toggle speaker-output according to the hp-jacks state */
12931static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12932{
12933 unsigned int present;
12934 unsigned char bits;
12935
12936 /* Check laptop headphone socket */
12937 present = snd_hda_codec_read(codec, 0x15, 0,
12938 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12939
12940 /* Check port replicator headphone socket */
12941 present |= snd_hda_codec_read(codec, 0x1a, 0,
12942 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12943
12944 bits = present ? AMP_IN_MUTE(0) : 0;
12945 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12946 AMP_IN_MUTE(0), bits);
12947 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12948 AMP_IN_MUTE(0), bits);
12949
12950 snd_hda_codec_write(codec, 0x20, 0,
12951 AC_VERB_SET_COEF_INDEX, 0x0c);
12952 snd_hda_codec_write(codec, 0x20, 0,
12953 AC_VERB_SET_PROC_COEF, 0x680);
12954
12955 snd_hda_codec_write(codec, 0x20, 0,
12956 AC_VERB_SET_COEF_INDEX, 0x0c);
12957 snd_hda_codec_write(codec, 0x20, 0,
12958 AC_VERB_SET_PROC_COEF, 0x480);
12959}
12960
Tony Vroon64154832008-11-06 15:08:49 +000012961static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12962{
12963 unsigned int present_laptop;
12964 unsigned int present_dock;
12965
12966 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12967 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12968
12969 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12970 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12971
12972 /* Laptop mic port overrides dock mic port, design decision */
12973 if (present_dock)
12974 snd_hda_codec_write(codec, 0x23, 0,
12975 AC_VERB_SET_CONNECT_SEL, 0x3);
12976 if (present_laptop)
12977 snd_hda_codec_write(codec, 0x23, 0,
12978 AC_VERB_SET_CONNECT_SEL, 0x0);
12979 if (!present_dock && !present_laptop)
12980 snd_hda_codec_write(codec, 0x23, 0,
12981 AC_VERB_SET_CONNECT_SEL, 0x1);
12982}
12983
Kailang Yang60db6b52008-08-26 13:13:00 +020012984static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12985 unsigned int res)
12986{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012987 switch (res >> 26) {
12988 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020012989 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012990 break;
12991 case ALC880_MIC_EVENT:
12992 alc_mic_automute(codec);
12993 break;
12994 }
Kailang Yang60db6b52008-08-26 13:13:00 +020012995}
12996
Tony Vroon64154832008-11-06 15:08:49 +000012997static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12998 unsigned int res)
12999{
13000 if ((res >> 26) == ALC880_HP_EVENT)
13001 alc269_lifebook_speaker_automute(codec);
13002 if ((res >> 26) == ALC880_MIC_EVENT)
13003 alc269_lifebook_mic_autoswitch(codec);
13004}
13005
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013006static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13007{
13008 struct alc_spec *spec = codec->spec;
13009 spec->ext_mic.pin = 0x18;
13010 spec->ext_mic.mux_idx = 0;
13011 spec->int_mic.pin = 0x19;
13012 spec->int_mic.mux_idx = 1;
13013 spec->auto_mic = 1;
13014}
13015
Kailang Yang60db6b52008-08-26 13:13:00 +020013016static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13017{
13018 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013019 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013020}
13021
Tony Vroon64154832008-11-06 15:08:49 +000013022static void alc269_lifebook_init_hook(struct hda_codec *codec)
13023{
13024 alc269_lifebook_speaker_automute(codec);
13025 alc269_lifebook_mic_autoswitch(codec);
13026}
13027
Kailang Yang60db6b52008-08-26 13:13:00 +020013028static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
13029 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13030 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13031 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13032 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13033 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13034 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13035 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13036 {}
13037};
13038
13039static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
13040 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13041 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13042 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13043 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13044 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13045 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13046 {}
13047};
13048
13049/* toggle speaker-output according to the hp-jack state */
13050static void alc269_speaker_automute(struct hda_codec *codec)
13051{
13052 unsigned int present;
13053 unsigned char bits;
13054
13055 present = snd_hda_codec_read(codec, 0x15, 0,
13056 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13057 bits = present ? AMP_IN_MUTE(0) : 0;
13058 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13059 AMP_IN_MUTE(0), bits);
13060 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13061 AMP_IN_MUTE(0), bits);
13062}
13063
Kailang Yang60db6b52008-08-26 13:13:00 +020013064/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013065static void alc269_eeepc_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013066 unsigned int res)
13067{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013068 switch (res >> 26) {
13069 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013070 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013071 break;
13072 case ALC880_MIC_EVENT:
13073 alc_mic_automute(codec);
13074 break;
13075 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013076}
13077
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013078static void alc269_eeepc_dmic_setup(struct hda_codec *codec)
13079{
13080 struct alc_spec *spec = codec->spec;
13081 spec->ext_mic.pin = 0x18;
13082 spec->ext_mic.mux_idx = 0;
13083 spec->int_mic.pin = 0x12;
13084 spec->int_mic.mux_idx = 5;
13085 spec->auto_mic = 1;
13086}
13087
13088static void alc269_eeepc_amic_setup(struct hda_codec *codec)
13089{
13090 struct alc_spec *spec = codec->spec;
13091 spec->ext_mic.pin = 0x18;
13092 spec->ext_mic.mux_idx = 0;
13093 spec->int_mic.pin = 0x19;
13094 spec->int_mic.mux_idx = 1;
13095 spec->auto_mic = 1;
13096}
13097
13098static void alc269_eeepc_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013099{
13100 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013101 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013102}
13103
Kailang Yangf6a92242007-12-13 16:52:54 +010013104/*
13105 * generic initialization of ADC, input mixers and output mixers
13106 */
13107static struct hda_verb alc269_init_verbs[] = {
13108 /*
13109 * Unmute ADC0 and set the default input to mic-in
13110 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013111 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013112
13113 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13114 * analog-loopback mixer widget
13115 * Note: PASD motherboards uses the Line In 2 as the input for
13116 * front panel mic (mic 2)
13117 */
13118 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13119 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13120 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13121 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13122 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13123 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13124
13125 /*
13126 * Set up output mixers (0x0c - 0x0e)
13127 */
13128 /* set vol=0 to output mixers */
13129 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13130 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13131
13132 /* set up input amps for analog loopback */
13133 /* Amp Indices: DAC = 0, mixer = 1 */
13134 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13135 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13136 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13137 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13138 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13139 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13140
13141 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13142 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13143 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13144 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13145 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13146 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13147 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13148
13149 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13150 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13151 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13152 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13153 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13154 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13155 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13156
13157 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13158 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13159
13160 /* FIXME: use matrix-type input source selection */
13161 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13162 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013163 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13164 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013165 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13166 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13167
13168 /* set EAPD */
13169 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13170 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13171 { }
13172};
13173
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013174#define alc269_auto_create_multi_out_ctls \
13175 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020013176#define alc269_auto_create_input_ctls \
13177 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013178
13179#ifdef CONFIG_SND_HDA_POWER_SAVE
13180#define alc269_loopbacks alc880_loopbacks
13181#endif
13182
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013183/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013184#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13185#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13186#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13187#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13188
Takashi Iwaif03d3112009-03-05 14:18:16 +010013189static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13190 .substreams = 1,
13191 .channels_min = 2,
13192 .channels_max = 8,
13193 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13194 /* NID is set in alc_build_pcms */
13195 .ops = {
13196 .open = alc880_playback_pcm_open,
13197 .prepare = alc880_playback_pcm_prepare,
13198 .cleanup = alc880_playback_pcm_cleanup
13199 },
13200};
13201
13202static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13203 .substreams = 1,
13204 .channels_min = 2,
13205 .channels_max = 2,
13206 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13207 /* NID is set in alc_build_pcms */
13208};
13209
Kailang Yangf6a92242007-12-13 16:52:54 +010013210/*
13211 * BIOS auto configuration
13212 */
13213static int alc269_parse_auto_config(struct hda_codec *codec)
13214{
13215 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013216 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013217 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13218
13219 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13220 alc269_ignore);
13221 if (err < 0)
13222 return err;
13223
13224 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13225 if (err < 0)
13226 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013227 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010013228 if (err < 0)
13229 return err;
13230
13231 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13232
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013233 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013234 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13235
Takashi Iwai603c4012008-07-30 15:01:44 +020013236 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013237 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013238
Takashi Iwaid88897e2008-10-31 15:01:37 +010013239 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013240 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013241 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013242 /* set default input source */
13243 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13244 0, AC_VERB_SET_CONNECT_SEL,
13245 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013246
13247 err = alc_auto_add_mic_boost(codec);
13248 if (err < 0)
13249 return err;
13250
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013251 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013252 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013253
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013254 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13255
Kailang Yangf6a92242007-12-13 16:52:54 +010013256 return 1;
13257}
13258
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013259#define alc269_auto_init_multi_out alc268_auto_init_multi_out
13260#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010013261#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13262
13263
13264/* init callback for auto-configuration model -- overriding the default init */
13265static void alc269_auto_init(struct hda_codec *codec)
13266{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013267 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013268 alc269_auto_init_multi_out(codec);
13269 alc269_auto_init_hp_out(codec);
13270 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013271 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013272 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013273}
13274
13275/*
13276 * configuration and preset
13277 */
13278static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013279 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013280 [ALC269_QUANTA_FL1] = "quanta",
13281 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013282 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013283 [ALC269_FUJITSU] = "fujitsu",
13284 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010013285};
13286
13287static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013288 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013289 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13290 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013291 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13292 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13293 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13294 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13295 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13296 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013297 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13298 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013299 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13300 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013301 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013302 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013303 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013304 {}
13305};
13306
13307static struct alc_config_preset alc269_presets[] = {
13308 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013309 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013310 .init_verbs = { alc269_init_verbs },
13311 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13312 .dac_nids = alc269_dac_nids,
13313 .hp_nid = 0x03,
13314 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13315 .channel_mode = alc269_modes,
13316 .input_mux = &alc269_capture_source,
13317 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013318 [ALC269_QUANTA_FL1] = {
13319 .mixers = { alc269_quanta_fl1_mixer },
13320 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13321 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13322 .dac_nids = alc269_dac_nids,
13323 .hp_nid = 0x03,
13324 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13325 .channel_mode = alc269_modes,
13326 .input_mux = &alc269_capture_source,
13327 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013328 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020013329 .init_hook = alc269_quanta_fl1_init_hook,
13330 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013331 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013332 .mixers = { alc269_eeepc_mixer },
13333 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013334 .init_verbs = { alc269_init_verbs,
13335 alc269_eeepc_amic_init_verbs },
13336 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13337 .dac_nids = alc269_dac_nids,
13338 .hp_nid = 0x03,
13339 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13340 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013341 .unsol_event = alc269_eeepc_unsol_event,
13342 .setup = alc269_eeepc_amic_setup,
13343 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013344 },
13345 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013346 .mixers = { alc269_eeepc_mixer },
13347 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013348 .init_verbs = { alc269_init_verbs,
13349 alc269_eeepc_dmic_init_verbs },
13350 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13351 .dac_nids = alc269_dac_nids,
13352 .hp_nid = 0x03,
13353 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13354 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013355 .unsol_event = alc269_eeepc_unsol_event,
13356 .setup = alc269_eeepc_dmic_setup,
13357 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013358 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013359 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013360 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013361 .cap_mixer = alc269_epc_capture_mixer,
13362 .init_verbs = { alc269_init_verbs,
13363 alc269_eeepc_dmic_init_verbs },
13364 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13365 .dac_nids = alc269_dac_nids,
13366 .hp_nid = 0x03,
13367 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13368 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013369 .unsol_event = alc269_eeepc_unsol_event,
13370 .setup = alc269_eeepc_dmic_setup,
13371 .init_hook = alc269_eeepc_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010013372 },
Tony Vroon64154832008-11-06 15:08:49 +000013373 [ALC269_LIFEBOOK] = {
13374 .mixers = { alc269_lifebook_mixer },
13375 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13376 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13377 .dac_nids = alc269_dac_nids,
13378 .hp_nid = 0x03,
13379 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13380 .channel_mode = alc269_modes,
13381 .input_mux = &alc269_capture_source,
13382 .unsol_event = alc269_lifebook_unsol_event,
13383 .init_hook = alc269_lifebook_init_hook,
13384 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013385};
13386
13387static int patch_alc269(struct hda_codec *codec)
13388{
13389 struct alc_spec *spec;
13390 int board_config;
13391 int err;
13392
13393 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13394 if (spec == NULL)
13395 return -ENOMEM;
13396
13397 codec->spec = spec;
13398
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013399 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13400
Kailang Yangf6a92242007-12-13 16:52:54 +010013401 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13402 alc269_models,
13403 alc269_cfg_tbl);
13404
13405 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013406 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13407 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013408 board_config = ALC269_AUTO;
13409 }
13410
13411 if (board_config == ALC269_AUTO) {
13412 /* automatic parse from the BIOS config */
13413 err = alc269_parse_auto_config(codec);
13414 if (err < 0) {
13415 alc_free(codec);
13416 return err;
13417 } else if (!err) {
13418 printk(KERN_INFO
13419 "hda_codec: Cannot set up configuration "
13420 "from BIOS. Using base mode...\n");
13421 board_config = ALC269_BASIC;
13422 }
13423 }
13424
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013425 err = snd_hda_attach_beep_device(codec, 0x1);
13426 if (err < 0) {
13427 alc_free(codec);
13428 return err;
13429 }
13430
Kailang Yangf6a92242007-12-13 16:52:54 +010013431 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013432 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010013433
Takashi Iwaif03d3112009-03-05 14:18:16 +010013434 if (codec->subsystem_id == 0x17aa3bf8) {
13435 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13436 * fix the sample rate of analog I/O to 44.1kHz
13437 */
13438 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13439 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13440 } else {
13441 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13442 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13443 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013444 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13445 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13446
13447 spec->adc_nids = alc269_adc_nids;
13448 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013449 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013450 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013451 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013452 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013453
Takashi Iwai100d5eb2009-08-10 11:55:51 +020013454 spec->vmaster_nid = 0x02;
13455
Kailang Yangf6a92242007-12-13 16:52:54 +010013456 codec->patch_ops = alc_patch_ops;
13457 if (board_config == ALC269_AUTO)
13458 spec->init_hook = alc269_auto_init;
13459#ifdef CONFIG_SND_HDA_POWER_SAVE
13460 if (!spec->loopback.amplist)
13461 spec->loopback.amplist = alc269_loopbacks;
13462#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013463 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013464
13465 return 0;
13466}
13467
13468/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013469 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13470 */
13471
13472/*
13473 * set the path ways for 2 channel output
13474 * need to set the codec line out and mic 1 pin widgets to inputs
13475 */
13476static struct hda_verb alc861_threestack_ch2_init[] = {
13477 /* set pin widget 1Ah (line in) for input */
13478 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013479 /* set pin widget 18h (mic1/2) for input, for mic also enable
13480 * the vref
13481 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013482 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13483
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013484 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13485#if 0
13486 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13487 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13488#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013489 { } /* end */
13490};
13491/*
13492 * 6ch mode
13493 * need to set the codec line out and mic 1 pin widgets to outputs
13494 */
13495static struct hda_verb alc861_threestack_ch6_init[] = {
13496 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13497 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13498 /* set pin widget 18h (mic1) for output (CLFE)*/
13499 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13500
13501 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013502 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013503
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013504 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13505#if 0
13506 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13507 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13508#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013509 { } /* end */
13510};
13511
13512static struct hda_channel_mode alc861_threestack_modes[2] = {
13513 { 2, alc861_threestack_ch2_init },
13514 { 6, alc861_threestack_ch6_init },
13515};
Takashi Iwai22309c32006-08-09 16:57:28 +020013516/* Set mic1 as input and unmute the mixer */
13517static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13518 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13519 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13520 { } /* end */
13521};
13522/* Set mic1 as output and mute mixer */
13523static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13524 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13525 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13526 { } /* end */
13527};
13528
13529static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13530 { 2, alc861_uniwill_m31_ch2_init },
13531 { 4, alc861_uniwill_m31_ch4_init },
13532};
Kailang Yangdf694da2005-12-05 19:42:22 +010013533
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013534/* Set mic1 and line-in as input and unmute the mixer */
13535static struct hda_verb alc861_asus_ch2_init[] = {
13536 /* set pin widget 1Ah (line in) for input */
13537 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013538 /* set pin widget 18h (mic1/2) for input, for mic also enable
13539 * the vref
13540 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013541 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13542
13543 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13544#if 0
13545 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13546 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13547#endif
13548 { } /* end */
13549};
13550/* Set mic1 nad line-in as output and mute mixer */
13551static struct hda_verb alc861_asus_ch6_init[] = {
13552 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13553 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13554 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13555 /* set pin widget 18h (mic1) for output (CLFE)*/
13556 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13557 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13558 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13559 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13560
13561 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13562#if 0
13563 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13564 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13565#endif
13566 { } /* end */
13567};
13568
13569static struct hda_channel_mode alc861_asus_modes[2] = {
13570 { 2, alc861_asus_ch2_init },
13571 { 6, alc861_asus_ch6_init },
13572};
13573
Kailang Yangdf694da2005-12-05 19:42:22 +010013574/* patch-ALC861 */
13575
13576static struct snd_kcontrol_new alc861_base_mixer[] = {
13577 /* output mixer control */
13578 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13579 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13580 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13581 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13582 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13583
13584 /*Input mixer control */
13585 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13586 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13587 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13588 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13589 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13590 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13591 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13592 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13593 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13594 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013595
Kailang Yangdf694da2005-12-05 19:42:22 +010013596 { } /* end */
13597};
13598
13599static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13600 /* output mixer control */
13601 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13602 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13603 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13604 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13605 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13606
13607 /* Input mixer control */
13608 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13609 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13610 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13611 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13612 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13613 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13614 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13615 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13616 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13617 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013618
Kailang Yangdf694da2005-12-05 19:42:22 +010013619 {
13620 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13621 .name = "Channel Mode",
13622 .info = alc_ch_mode_info,
13623 .get = alc_ch_mode_get,
13624 .put = alc_ch_mode_put,
13625 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13626 },
13627 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013628};
13629
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013630static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013631 /* output mixer control */
13632 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13633 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13634 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013635
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013636 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013637};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013638
Takashi Iwai22309c32006-08-09 16:57:28 +020013639static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13640 /* output mixer control */
13641 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13642 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13643 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13644 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13645 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13646
13647 /* Input mixer control */
13648 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13649 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13650 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13651 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13652 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13653 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13654 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13655 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13656 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13657 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013658
Takashi Iwai22309c32006-08-09 16:57:28 +020013659 {
13660 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13661 .name = "Channel Mode",
13662 .info = alc_ch_mode_info,
13663 .get = alc_ch_mode_get,
13664 .put = alc_ch_mode_put,
13665 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13666 },
13667 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013668};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013669
13670static struct snd_kcontrol_new alc861_asus_mixer[] = {
13671 /* output mixer control */
13672 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13673 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13674 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13675 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13676 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13677
13678 /* Input mixer control */
13679 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13680 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13681 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13682 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13683 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13684 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13685 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13686 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13687 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013688 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13689
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013690 {
13691 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13692 .name = "Channel Mode",
13693 .info = alc_ch_mode_info,
13694 .get = alc_ch_mode_get,
13695 .put = alc_ch_mode_put,
13696 .private_value = ARRAY_SIZE(alc861_asus_modes),
13697 },
13698 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013699};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013700
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013701/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013702static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013703 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13704 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013705 { }
13706};
13707
Kailang Yangdf694da2005-12-05 19:42:22 +010013708/*
13709 * generic initialization of ADC, input mixers and output mixers
13710 */
13711static struct hda_verb alc861_base_init_verbs[] = {
13712 /*
13713 * Unmute ADC0 and set the default input to mic-in
13714 */
13715 /* port-A for surround (rear panel) */
13716 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13717 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13718 /* port-B for mic-in (rear panel) with vref */
13719 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13720 /* port-C for line-in (rear panel) */
13721 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13722 /* port-D for Front */
13723 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13724 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13725 /* port-E for HP out (front panel) */
13726 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13727 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013728 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013729 /* port-F for mic-in (front panel) with vref */
13730 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13731 /* port-G for CLFE (rear panel) */
13732 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13733 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13734 /* port-H for side (rear panel) */
13735 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13736 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13737 /* CD-in */
13738 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13739 /* route front mic to ADC1*/
13740 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13741 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013742
Kailang Yangdf694da2005-12-05 19:42:22 +010013743 /* Unmute DAC0~3 & spdif out*/
13744 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13745 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13746 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13747 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13748 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013749
Kailang Yangdf694da2005-12-05 19:42:22 +010013750 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13751 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13752 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13753 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13754 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013755
Kailang Yangdf694da2005-12-05 19:42:22 +010013756 /* Unmute Stereo Mixer 15 */
13757 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13758 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13759 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013760 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013761
13762 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13763 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13764 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13765 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13766 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13767 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13768 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13769 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013770 /* hp used DAC 3 (Front) */
13771 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013772 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13773
13774 { }
13775};
13776
13777static struct hda_verb alc861_threestack_init_verbs[] = {
13778 /*
13779 * Unmute ADC0 and set the default input to mic-in
13780 */
13781 /* port-A for surround (rear panel) */
13782 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13783 /* port-B for mic-in (rear panel) with vref */
13784 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13785 /* port-C for line-in (rear panel) */
13786 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13787 /* port-D for Front */
13788 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13789 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13790 /* port-E for HP out (front panel) */
13791 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13792 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013793 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013794 /* port-F for mic-in (front panel) with vref */
13795 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13796 /* port-G for CLFE (rear panel) */
13797 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13798 /* port-H for side (rear panel) */
13799 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13800 /* CD-in */
13801 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13802 /* route front mic to ADC1*/
13803 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13804 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13805 /* Unmute DAC0~3 & spdif out*/
13806 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13807 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13808 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13809 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13810 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013811
Kailang Yangdf694da2005-12-05 19:42:22 +010013812 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13813 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13814 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13815 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13816 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013817
Kailang Yangdf694da2005-12-05 19:42:22 +010013818 /* Unmute Stereo Mixer 15 */
13819 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13820 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13821 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013822 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013823
13824 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13825 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13826 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13827 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13828 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13829 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13830 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13831 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013832 /* hp used DAC 3 (Front) */
13833 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013834 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13835 { }
13836};
Takashi Iwai22309c32006-08-09 16:57:28 +020013837
13838static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13839 /*
13840 * Unmute ADC0 and set the default input to mic-in
13841 */
13842 /* port-A for surround (rear panel) */
13843 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13844 /* port-B for mic-in (rear panel) with vref */
13845 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13846 /* port-C for line-in (rear panel) */
13847 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13848 /* port-D for Front */
13849 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13850 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13851 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013852 /* this has to be set to VREF80 */
13853 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013854 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013855 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013856 /* port-F for mic-in (front panel) with vref */
13857 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13858 /* port-G for CLFE (rear panel) */
13859 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13860 /* port-H for side (rear panel) */
13861 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13862 /* CD-in */
13863 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13864 /* route front mic to ADC1*/
13865 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13866 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13867 /* Unmute DAC0~3 & spdif out*/
13868 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13869 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13870 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13871 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13872 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013873
Takashi Iwai22309c32006-08-09 16:57:28 +020013874 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13875 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13876 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13877 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13878 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013879
Takashi Iwai22309c32006-08-09 16:57:28 +020013880 /* Unmute Stereo Mixer 15 */
13881 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13882 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13883 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013884 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013885
13886 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13887 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13888 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13889 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13890 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13891 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13892 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13893 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013894 /* hp used DAC 3 (Front) */
13895 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013896 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13897 { }
13898};
13899
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013900static struct hda_verb alc861_asus_init_verbs[] = {
13901 /*
13902 * Unmute ADC0 and set the default input to mic-in
13903 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013904 /* port-A for surround (rear panel)
13905 * according to codec#0 this is the HP jack
13906 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013907 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13908 /* route front PCM to HP */
13909 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13910 /* port-B for mic-in (rear panel) with vref */
13911 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13912 /* port-C for line-in (rear panel) */
13913 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13914 /* port-D for Front */
13915 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13916 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13917 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013918 /* this has to be set to VREF80 */
13919 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013920 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013921 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013922 /* port-F for mic-in (front panel) with vref */
13923 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13924 /* port-G for CLFE (rear panel) */
13925 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13926 /* port-H for side (rear panel) */
13927 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13928 /* CD-in */
13929 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13930 /* route front mic to ADC1*/
13931 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13932 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13933 /* Unmute DAC0~3 & spdif out*/
13934 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13935 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13936 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13937 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13938 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13939 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13940 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13941 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13942 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13943 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013944
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013945 /* Unmute Stereo Mixer 15 */
13946 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13947 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13948 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013949 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013950
13951 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13952 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13953 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13954 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13955 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13956 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13957 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13958 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013959 /* hp used DAC 3 (Front) */
13960 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013961 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13962 { }
13963};
13964
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013965/* additional init verbs for ASUS laptops */
13966static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13967 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13968 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13969 { }
13970};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013971
Kailang Yangdf694da2005-12-05 19:42:22 +010013972/*
13973 * generic initialization of ADC, input mixers and output mixers
13974 */
13975static struct hda_verb alc861_auto_init_verbs[] = {
13976 /*
13977 * Unmute ADC0 and set the default input to mic-in
13978 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013979 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013980 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013981
Kailang Yangdf694da2005-12-05 19:42:22 +010013982 /* Unmute DAC0~3 & spdif out*/
13983 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13984 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13985 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13986 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13987 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013988
Kailang Yangdf694da2005-12-05 19:42:22 +010013989 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13990 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13991 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13992 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13993 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013994
Kailang Yangdf694da2005-12-05 19:42:22 +010013995 /* Unmute Stereo Mixer 15 */
13996 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13997 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13998 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13999 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14000
Takashi Iwai1c209302009-07-22 15:17:45 +020014001 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14002 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14003 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14004 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14005 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14006 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14007 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14008 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014009
14010 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14011 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014012 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14013 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014014 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14015 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014016 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14017 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014018
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014019 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014020
14021 { }
14022};
14023
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014024static struct hda_verb alc861_toshiba_init_verbs[] = {
14025 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014026
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014027 { }
14028};
14029
14030/* toggle speaker-output according to the hp-jack state */
14031static void alc861_toshiba_automute(struct hda_codec *codec)
14032{
14033 unsigned int present;
14034
14035 present = snd_hda_codec_read(codec, 0x0f, 0,
14036 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014037 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14038 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14039 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14040 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014041}
14042
14043static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14044 unsigned int res)
14045{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014046 if ((res >> 26) == ALC880_HP_EVENT)
14047 alc861_toshiba_automute(codec);
14048}
14049
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014050/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014051#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14052#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14053#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14054#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14055
14056
14057#define ALC861_DIGOUT_NID 0x07
14058
14059static struct hda_channel_mode alc861_8ch_modes[1] = {
14060 { 8, NULL }
14061};
14062
14063static hda_nid_t alc861_dac_nids[4] = {
14064 /* front, surround, clfe, side */
14065 0x03, 0x06, 0x05, 0x04
14066};
14067
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014068static hda_nid_t alc660_dac_nids[3] = {
14069 /* front, clfe, surround */
14070 0x03, 0x05, 0x06
14071};
14072
Kailang Yangdf694da2005-12-05 19:42:22 +010014073static hda_nid_t alc861_adc_nids[1] = {
14074 /* ADC0-2 */
14075 0x08,
14076};
14077
14078static struct hda_input_mux alc861_capture_source = {
14079 .num_items = 5,
14080 .items = {
14081 { "Mic", 0x0 },
14082 { "Front Mic", 0x3 },
14083 { "Line", 0x1 },
14084 { "CD", 0x4 },
14085 { "Mixer", 0x5 },
14086 },
14087};
14088
Takashi Iwai1c209302009-07-22 15:17:45 +020014089static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14090{
14091 struct alc_spec *spec = codec->spec;
14092 hda_nid_t mix, srcs[5];
14093 int i, j, num;
14094
14095 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14096 return 0;
14097 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14098 if (num < 0)
14099 return 0;
14100 for (i = 0; i < num; i++) {
14101 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014102 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014103 if (type != AC_WID_AUD_OUT)
14104 continue;
14105 for (j = 0; j < spec->multiout.num_dacs; j++)
14106 if (spec->multiout.dac_nids[j] == srcs[i])
14107 break;
14108 if (j >= spec->multiout.num_dacs)
14109 return srcs[i];
14110 }
14111 return 0;
14112}
14113
Kailang Yangdf694da2005-12-05 19:42:22 +010014114/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014115static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014116 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014117{
Takashi Iwai1c209302009-07-22 15:17:45 +020014118 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014119 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014120 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014121
14122 spec->multiout.dac_nids = spec->private_dac_nids;
14123 for (i = 0; i < cfg->line_outs; i++) {
14124 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014125 dac = alc861_look_for_dac(codec, nid);
14126 if (!dac)
14127 continue;
14128 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014129 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014130 return 0;
14131}
14132
Takashi Iwai1c209302009-07-22 15:17:45 +020014133static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14134 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014135{
14136 char name[32];
Takashi Iwai1c209302009-07-22 15:17:45 +020014137 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
14138 return add_control(codec->spec, ALC_CTL_WIDGET_MUTE, name,
14139 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14140}
14141
14142/* add playback controls from the parsed DAC table */
14143static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14144 const struct auto_pin_cfg *cfg)
14145{
14146 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014147 static const char *chname[4] = {
14148 "Front", "Surround", NULL /*CLFE*/, "Side"
14149 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014150 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014151 int i, err;
14152
14153 if (cfg->line_outs == 1) {
14154 const char *pfx = NULL;
14155 if (!cfg->hp_outs)
14156 pfx = "Master";
14157 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14158 pfx = "Speaker";
14159 if (pfx) {
14160 nid = spec->multiout.dac_nids[0];
14161 return alc861_create_out_sw(codec, pfx, nid, 3);
14162 }
14163 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014164
14165 for (i = 0; i < cfg->line_outs; i++) {
14166 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014167 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014168 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014169 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014170 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014171 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014172 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014173 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014174 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014175 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014176 return err;
14177 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014178 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014179 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014180 return err;
14181 }
14182 }
14183 return 0;
14184}
14185
Takashi Iwai1c209302009-07-22 15:17:45 +020014186static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014187{
Takashi Iwai1c209302009-07-22 15:17:45 +020014188 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014189 int err;
14190 hda_nid_t nid;
14191
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014192 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014193 return 0;
14194
14195 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014196 nid = alc861_look_for_dac(codec, pin);
14197 if (nid) {
14198 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14199 if (err < 0)
14200 return err;
14201 spec->multiout.hp_nid = nid;
14202 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014203 }
14204 return 0;
14205}
14206
14207/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020014208static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014209 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014210{
Takashi Iwai05f5f472009-08-25 13:10:18 +020014211 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014212}
14213
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014214static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14215 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014216 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014217{
Takashi Iwai1c209302009-07-22 15:17:45 +020014218 hda_nid_t mix, srcs[5];
14219 int i, num;
14220
Jacek Luczak564c5be2008-05-03 18:41:23 +020014221 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14222 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014223 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014224 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014225 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14226 return;
14227 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14228 if (num < 0)
14229 return;
14230 for (i = 0; i < num; i++) {
14231 unsigned int mute;
14232 if (srcs[i] == dac || srcs[i] == 0x15)
14233 mute = AMP_IN_UNMUTE(i);
14234 else
14235 mute = AMP_IN_MUTE(i);
14236 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14237 mute);
14238 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014239}
14240
14241static void alc861_auto_init_multi_out(struct hda_codec *codec)
14242{
14243 struct alc_spec *spec = codec->spec;
14244 int i;
14245
14246 for (i = 0; i < spec->autocfg.line_outs; i++) {
14247 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014248 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014249 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014250 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014251 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014252 }
14253}
14254
14255static void alc861_auto_init_hp_out(struct hda_codec *codec)
14256{
14257 struct alc_spec *spec = codec->spec;
14258 hda_nid_t pin;
14259
Takashi Iwaieb06ed82006-09-20 17:10:27 +020014260 pin = spec->autocfg.hp_pins[0];
Takashi Iwai1c209302009-07-22 15:17:45 +020014261 if (pin)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014262 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014263 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014264 pin = spec->autocfg.speaker_pins[0];
14265 if (pin)
Takashi Iwai1c209302009-07-22 15:17:45 +020014266 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT,
14267 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014268}
14269
14270static void alc861_auto_init_analog_input(struct hda_codec *codec)
14271{
14272 struct alc_spec *spec = codec->spec;
14273 int i;
14274
14275 for (i = 0; i < AUTO_PIN_LAST; i++) {
14276 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014277 if (nid >= 0x0c && nid <= 0x11)
14278 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014279 }
14280}
14281
14282/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014283/* return 1 if successful, 0 if the proper config is not found,
14284 * or a negative error code
14285 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014286static int alc861_parse_auto_config(struct hda_codec *codec)
14287{
14288 struct alc_spec *spec = codec->spec;
14289 int err;
14290 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14291
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014292 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14293 alc861_ignore);
14294 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014295 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014296 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014297 return 0; /* can't find valid BIOS pin config */
14298
Takashi Iwai1c209302009-07-22 15:17:45 +020014299 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014300 if (err < 0)
14301 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014302 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014303 if (err < 0)
14304 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014305 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014306 if (err < 0)
14307 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014308 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014309 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014310 return err;
14311
14312 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14313
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014314 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014315 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14316
Takashi Iwai603c4012008-07-30 15:01:44 +020014317 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014318 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014319
Takashi Iwaid88897e2008-10-31 15:01:37 +010014320 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014321
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014322 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014323 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014324
14325 spec->adc_nids = alc861_adc_nids;
14326 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014327 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014328
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014329 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14330
Kailang Yangdf694da2005-12-05 19:42:22 +010014331 return 1;
14332}
14333
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014334/* additional initialization for auto-configuration model */
14335static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014336{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014337 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014338 alc861_auto_init_multi_out(codec);
14339 alc861_auto_init_hp_out(codec);
14340 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014341 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014342 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014343}
14344
Takashi Iwaicb53c622007-08-10 17:21:45 +020014345#ifdef CONFIG_SND_HDA_POWER_SAVE
14346static struct hda_amp_list alc861_loopbacks[] = {
14347 { 0x15, HDA_INPUT, 0 },
14348 { 0x15, HDA_INPUT, 1 },
14349 { 0x15, HDA_INPUT, 2 },
14350 { 0x15, HDA_INPUT, 3 },
14351 { } /* end */
14352};
14353#endif
14354
Kailang Yangdf694da2005-12-05 19:42:22 +010014355
14356/*
14357 * configuration and preset
14358 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014359static const char *alc861_models[ALC861_MODEL_LAST] = {
14360 [ALC861_3ST] = "3stack",
14361 [ALC660_3ST] = "3stack-660",
14362 [ALC861_3ST_DIG] = "3stack-dig",
14363 [ALC861_6ST_DIG] = "6stack-dig",
14364 [ALC861_UNIWILL_M31] = "uniwill-m31",
14365 [ALC861_TOSHIBA] = "toshiba",
14366 [ALC861_ASUS] = "asus",
14367 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14368 [ALC861_AUTO] = "auto",
14369};
14370
14371static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014372 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014373 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14374 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14375 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014376 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014377 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014378 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014379 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14380 * Any other models that need this preset?
14381 */
14382 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014383 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14384 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014385 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14386 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14387 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14388 /* FIXME: the below seems conflict */
14389 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14390 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14391 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014392 {}
14393};
14394
14395static struct alc_config_preset alc861_presets[] = {
14396 [ALC861_3ST] = {
14397 .mixers = { alc861_3ST_mixer },
14398 .init_verbs = { alc861_threestack_init_verbs },
14399 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14400 .dac_nids = alc861_dac_nids,
14401 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14402 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014403 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014404 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14405 .adc_nids = alc861_adc_nids,
14406 .input_mux = &alc861_capture_source,
14407 },
14408 [ALC861_3ST_DIG] = {
14409 .mixers = { alc861_base_mixer },
14410 .init_verbs = { alc861_threestack_init_verbs },
14411 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14412 .dac_nids = alc861_dac_nids,
14413 .dig_out_nid = ALC861_DIGOUT_NID,
14414 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14415 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014416 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014417 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14418 .adc_nids = alc861_adc_nids,
14419 .input_mux = &alc861_capture_source,
14420 },
14421 [ALC861_6ST_DIG] = {
14422 .mixers = { alc861_base_mixer },
14423 .init_verbs = { alc861_base_init_verbs },
14424 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14425 .dac_nids = alc861_dac_nids,
14426 .dig_out_nid = ALC861_DIGOUT_NID,
14427 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14428 .channel_mode = alc861_8ch_modes,
14429 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14430 .adc_nids = alc861_adc_nids,
14431 .input_mux = &alc861_capture_source,
14432 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014433 [ALC660_3ST] = {
14434 .mixers = { alc861_3ST_mixer },
14435 .init_verbs = { alc861_threestack_init_verbs },
14436 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14437 .dac_nids = alc660_dac_nids,
14438 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14439 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014440 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014441 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14442 .adc_nids = alc861_adc_nids,
14443 .input_mux = &alc861_capture_source,
14444 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014445 [ALC861_UNIWILL_M31] = {
14446 .mixers = { alc861_uniwill_m31_mixer },
14447 .init_verbs = { alc861_uniwill_m31_init_verbs },
14448 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14449 .dac_nids = alc861_dac_nids,
14450 .dig_out_nid = ALC861_DIGOUT_NID,
14451 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14452 .channel_mode = alc861_uniwill_m31_modes,
14453 .need_dac_fix = 1,
14454 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14455 .adc_nids = alc861_adc_nids,
14456 .input_mux = &alc861_capture_source,
14457 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014458 [ALC861_TOSHIBA] = {
14459 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014460 .init_verbs = { alc861_base_init_verbs,
14461 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014462 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14463 .dac_nids = alc861_dac_nids,
14464 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14465 .channel_mode = alc883_3ST_2ch_modes,
14466 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14467 .adc_nids = alc861_adc_nids,
14468 .input_mux = &alc861_capture_source,
14469 .unsol_event = alc861_toshiba_unsol_event,
14470 .init_hook = alc861_toshiba_automute,
14471 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014472 [ALC861_ASUS] = {
14473 .mixers = { alc861_asus_mixer },
14474 .init_verbs = { alc861_asus_init_verbs },
14475 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14476 .dac_nids = alc861_dac_nids,
14477 .dig_out_nid = ALC861_DIGOUT_NID,
14478 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14479 .channel_mode = alc861_asus_modes,
14480 .need_dac_fix = 1,
14481 .hp_nid = 0x06,
14482 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14483 .adc_nids = alc861_adc_nids,
14484 .input_mux = &alc861_capture_source,
14485 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014486 [ALC861_ASUS_LAPTOP] = {
14487 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14488 .init_verbs = { alc861_asus_init_verbs,
14489 alc861_asus_laptop_init_verbs },
14490 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14491 .dac_nids = alc861_dac_nids,
14492 .dig_out_nid = ALC861_DIGOUT_NID,
14493 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14494 .channel_mode = alc883_3ST_2ch_modes,
14495 .need_dac_fix = 1,
14496 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14497 .adc_nids = alc861_adc_nids,
14498 .input_mux = &alc861_capture_source,
14499 },
14500};
Kailang Yangdf694da2005-12-05 19:42:22 +010014501
14502
14503static int patch_alc861(struct hda_codec *codec)
14504{
14505 struct alc_spec *spec;
14506 int board_config;
14507 int err;
14508
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014509 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014510 if (spec == NULL)
14511 return -ENOMEM;
14512
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014513 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014514
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014515 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14516 alc861_models,
14517 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014518
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014519 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014520 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14521 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014522 board_config = ALC861_AUTO;
14523 }
14524
14525 if (board_config == ALC861_AUTO) {
14526 /* automatic parse from the BIOS config */
14527 err = alc861_parse_auto_config(codec);
14528 if (err < 0) {
14529 alc_free(codec);
14530 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014531 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014532 printk(KERN_INFO
14533 "hda_codec: Cannot set up configuration "
14534 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014535 board_config = ALC861_3ST_DIG;
14536 }
14537 }
14538
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014539 err = snd_hda_attach_beep_device(codec, 0x23);
14540 if (err < 0) {
14541 alc_free(codec);
14542 return err;
14543 }
14544
Kailang Yangdf694da2005-12-05 19:42:22 +010014545 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014546 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014547
Kailang Yangdf694da2005-12-05 19:42:22 +010014548 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14549 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14550
Kailang Yangdf694da2005-12-05 19:42:22 +010014551 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14552 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14553
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014554 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14555
Takashi Iwai2134ea42008-01-10 16:53:55 +010014556 spec->vmaster_nid = 0x03;
14557
Kailang Yangdf694da2005-12-05 19:42:22 +010014558 codec->patch_ops = alc_patch_ops;
14559 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014560 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014561#ifdef CONFIG_SND_HDA_POWER_SAVE
14562 if (!spec->loopback.amplist)
14563 spec->loopback.amplist = alc861_loopbacks;
14564#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014565 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014566
Kailang Yangdf694da2005-12-05 19:42:22 +010014567 return 0;
14568}
14569
14570/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014571 * ALC861-VD support
14572 *
14573 * Based on ALC882
14574 *
14575 * In addition, an independent DAC
14576 */
14577#define ALC861VD_DIGOUT_NID 0x06
14578
14579static hda_nid_t alc861vd_dac_nids[4] = {
14580 /* front, surr, clfe, side surr */
14581 0x02, 0x03, 0x04, 0x05
14582};
14583
14584/* dac_nids for ALC660vd are in a different order - according to
14585 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014586 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014587 * of ALC660vd codecs, but for now there is only 3stack mixer
14588 * - and it is the same as in 861vd.
14589 * adc_nids in ALC660vd are (is) the same as in 861vd
14590 */
14591static hda_nid_t alc660vd_dac_nids[3] = {
14592 /* front, rear, clfe, rear_surr */
14593 0x02, 0x04, 0x03
14594};
14595
14596static hda_nid_t alc861vd_adc_nids[1] = {
14597 /* ADC0 */
14598 0x09,
14599};
14600
Takashi Iwaie1406342008-02-11 18:32:32 +010014601static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14602
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014603/* input MUX */
14604/* FIXME: should be a matrix-type input source selection */
14605static struct hda_input_mux alc861vd_capture_source = {
14606 .num_items = 4,
14607 .items = {
14608 { "Mic", 0x0 },
14609 { "Front Mic", 0x1 },
14610 { "Line", 0x2 },
14611 { "CD", 0x4 },
14612 },
14613};
14614
Kailang Yang272a5272007-05-14 11:00:38 +020014615static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014616 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014617 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014618 { "Ext Mic", 0x0 },
14619 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014620 },
14621};
14622
Kailang Yangd1a991a2007-08-15 16:21:59 +020014623static struct hda_input_mux alc861vd_hp_capture_source = {
14624 .num_items = 2,
14625 .items = {
14626 { "Front Mic", 0x0 },
14627 { "ATAPI Mic", 0x1 },
14628 },
14629};
14630
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014631/*
14632 * 2ch mode
14633 */
14634static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14635 { 2, NULL }
14636};
14637
14638/*
14639 * 6ch mode
14640 */
14641static struct hda_verb alc861vd_6stack_ch6_init[] = {
14642 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14643 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14644 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14645 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14646 { } /* end */
14647};
14648
14649/*
14650 * 8ch mode
14651 */
14652static struct hda_verb alc861vd_6stack_ch8_init[] = {
14653 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14654 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14655 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14656 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14657 { } /* end */
14658};
14659
14660static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14661 { 6, alc861vd_6stack_ch6_init },
14662 { 8, alc861vd_6stack_ch8_init },
14663};
14664
14665static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14666 {
14667 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14668 .name = "Channel Mode",
14669 .info = alc_ch_mode_info,
14670 .get = alc_ch_mode_get,
14671 .put = alc_ch_mode_put,
14672 },
14673 { } /* end */
14674};
14675
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014676/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14677 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14678 */
14679static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14680 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14681 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14682
14683 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14684 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14685
14686 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14687 HDA_OUTPUT),
14688 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14689 HDA_OUTPUT),
14690 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14691 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14692
14693 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14694 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14695
14696 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14697
14698 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14699 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14700 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14701
14702 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14703 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14704 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14705
14706 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14707 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14708
14709 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14710 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14711
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014712 { } /* end */
14713};
14714
14715static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14716 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14717 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14718
14719 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14720
14721 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14722 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14723 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14724
14725 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14726 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14727 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14728
14729 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14730 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14731
14732 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14733 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14734
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014735 { } /* end */
14736};
14737
Kailang Yangbdd148a2007-05-08 15:19:08 +020014738static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14739 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14740 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14741 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14742
14743 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14744
14745 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14746 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14747 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14748
14749 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14750 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14751 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14752
14753 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14754 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14755
14756 { } /* end */
14757};
14758
Tobin Davisb419f342008-03-07 11:57:51 +010014759/* Pin assignment: Speaker=0x14, HP = 0x15,
14760 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014761 */
14762static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014763 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14764 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014765 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14766 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014767 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14768 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14769 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14770 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14771 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14772 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014773 { } /* end */
14774};
14775
Kailang Yangd1a991a2007-08-15 16:21:59 +020014776/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14777 * Front Mic=0x18, ATAPI Mic = 0x19,
14778 */
14779static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14780 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14781 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14782 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14783 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14784 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14785 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14786 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14787 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014788
Kailang Yangd1a991a2007-08-15 16:21:59 +020014789 { } /* end */
14790};
14791
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014792/*
14793 * generic initialization of ADC, input mixers and output mixers
14794 */
14795static struct hda_verb alc861vd_volume_init_verbs[] = {
14796 /*
14797 * Unmute ADC0 and set the default input to mic-in
14798 */
14799 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14800 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14801
14802 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14803 * the analog-loopback mixer widget
14804 */
14805 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014806 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14807 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14808 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14809 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14810 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014811
14812 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014813 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14814 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14815 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014816 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014817
14818 /*
14819 * Set up output mixers (0x02 - 0x05)
14820 */
14821 /* set vol=0 to output mixers */
14822 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14823 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14824 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14825 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14826
14827 /* set up input amps for analog loopback */
14828 /* Amp Indices: DAC = 0, mixer = 1 */
14829 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14830 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14831 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14832 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14833 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14834 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14835 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14836 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14837
14838 { }
14839};
14840
14841/*
14842 * 3-stack pin configuration:
14843 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14844 */
14845static struct hda_verb alc861vd_3stack_init_verbs[] = {
14846 /*
14847 * Set pin mode and muting
14848 */
14849 /* set front pin widgets 0x14 for output */
14850 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14851 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14852 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14853
14854 /* Mic (rear) pin: input vref at 80% */
14855 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14856 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14857 /* Front Mic pin: input vref at 80% */
14858 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14859 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14860 /* Line In pin: input */
14861 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14862 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14863 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14864 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14865 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14866 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14867 /* CD pin widget for input */
14868 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14869
14870 { }
14871};
14872
14873/*
14874 * 6-stack pin configuration:
14875 */
14876static struct hda_verb alc861vd_6stack_init_verbs[] = {
14877 /*
14878 * Set pin mode and muting
14879 */
14880 /* set front pin widgets 0x14 for output */
14881 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14882 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14883 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14884
14885 /* Rear Pin: output 1 (0x0d) */
14886 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14887 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14888 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14889 /* CLFE Pin: output 2 (0x0e) */
14890 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14891 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14892 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14893 /* Side Pin: output 3 (0x0f) */
14894 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14895 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14896 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14897
14898 /* Mic (rear) pin: input vref at 80% */
14899 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14900 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14901 /* Front Mic pin: input vref at 80% */
14902 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14903 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14904 /* Line In pin: input */
14905 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14906 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14907 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14908 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14909 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14910 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14911 /* CD pin widget for input */
14912 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14913
14914 { }
14915};
14916
Kailang Yangbdd148a2007-05-08 15:19:08 +020014917static struct hda_verb alc861vd_eapd_verbs[] = {
14918 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14919 { }
14920};
14921
Kailang Yangf9423e72008-05-27 12:32:25 +020014922static struct hda_verb alc660vd_eapd_verbs[] = {
14923 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14924 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14925 { }
14926};
14927
Kailang Yangbdd148a2007-05-08 15:19:08 +020014928static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14929 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14930 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14931 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14932 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014933 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014934 {}
14935};
14936
Kailang Yangbdd148a2007-05-08 15:19:08 +020014937static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14938{
14939 unsigned int present;
14940 unsigned char bits;
14941
14942 present = snd_hda_codec_read(codec, 0x18, 0,
14943 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014944 bits = present ? HDA_AMP_MUTE : 0;
14945 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14946 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014947}
14948
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014949static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020014950{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014951 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014952 spec->autocfg.hp_pins[0] = 0x1b;
14953 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014954}
14955
14956static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
14957{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014958 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014959 alc861vd_lenovo_mic_automute(codec);
14960}
14961
14962static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14963 unsigned int res)
14964{
14965 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020014966 case ALC880_MIC_EVENT:
14967 alc861vd_lenovo_mic_automute(codec);
14968 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014969 default:
14970 alc_automute_amp_unsol_event(codec, res);
14971 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020014972 }
14973}
14974
Kailang Yang272a5272007-05-14 11:00:38 +020014975static struct hda_verb alc861vd_dallas_verbs[] = {
14976 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14977 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14978 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14979 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14980
14981 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14982 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14983 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14984 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14985 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14986 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14987 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14988 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014989
Kailang Yang272a5272007-05-14 11:00:38 +020014990 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14991 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14992 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14993 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14994 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14995 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14996 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14997 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14998
14999 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15000 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15001 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15002 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15003 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15004 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15005 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15006 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15007
15008 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15009 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15010 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15011 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15012
15013 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015014 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015015 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15016
15017 { } /* end */
15018};
15019
15020/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015021static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015022{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015023 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015024
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015025 spec->autocfg.hp_pins[0] = 0x15;
15026 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020015027}
15028
Takashi Iwaicb53c622007-08-10 17:21:45 +020015029#ifdef CONFIG_SND_HDA_POWER_SAVE
15030#define alc861vd_loopbacks alc880_loopbacks
15031#endif
15032
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015033/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015034#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15035#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15036#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15037#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15038
15039/*
15040 * configuration and preset
15041 */
15042static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15043 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015044 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015045 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015046 [ALC861VD_3ST] = "3stack",
15047 [ALC861VD_3ST_DIG] = "3stack-digout",
15048 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015049 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015050 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015051 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015052 [ALC861VD_AUTO] = "auto",
15053};
15054
15055static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015056 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15057 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015058 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015059 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010015060 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015061 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015062 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015063 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015064 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015065 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015066 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015067 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015068 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015069 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015070 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015071 {}
15072};
15073
15074static struct alc_config_preset alc861vd_presets[] = {
15075 [ALC660VD_3ST] = {
15076 .mixers = { alc861vd_3st_mixer },
15077 .init_verbs = { alc861vd_volume_init_verbs,
15078 alc861vd_3stack_init_verbs },
15079 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15080 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015081 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15082 .channel_mode = alc861vd_3stack_2ch_modes,
15083 .input_mux = &alc861vd_capture_source,
15084 },
Mike Crash6963f842007-06-25 12:12:51 +020015085 [ALC660VD_3ST_DIG] = {
15086 .mixers = { alc861vd_3st_mixer },
15087 .init_verbs = { alc861vd_volume_init_verbs,
15088 alc861vd_3stack_init_verbs },
15089 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15090 .dac_nids = alc660vd_dac_nids,
15091 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015092 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15093 .channel_mode = alc861vd_3stack_2ch_modes,
15094 .input_mux = &alc861vd_capture_source,
15095 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015096 [ALC861VD_3ST] = {
15097 .mixers = { alc861vd_3st_mixer },
15098 .init_verbs = { alc861vd_volume_init_verbs,
15099 alc861vd_3stack_init_verbs },
15100 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15101 .dac_nids = alc861vd_dac_nids,
15102 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15103 .channel_mode = alc861vd_3stack_2ch_modes,
15104 .input_mux = &alc861vd_capture_source,
15105 },
15106 [ALC861VD_3ST_DIG] = {
15107 .mixers = { alc861vd_3st_mixer },
15108 .init_verbs = { alc861vd_volume_init_verbs,
15109 alc861vd_3stack_init_verbs },
15110 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15111 .dac_nids = alc861vd_dac_nids,
15112 .dig_out_nid = ALC861VD_DIGOUT_NID,
15113 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15114 .channel_mode = alc861vd_3stack_2ch_modes,
15115 .input_mux = &alc861vd_capture_source,
15116 },
15117 [ALC861VD_6ST_DIG] = {
15118 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15119 .init_verbs = { alc861vd_volume_init_verbs,
15120 alc861vd_6stack_init_verbs },
15121 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15122 .dac_nids = alc861vd_dac_nids,
15123 .dig_out_nid = ALC861VD_DIGOUT_NID,
15124 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15125 .channel_mode = alc861vd_6stack_modes,
15126 .input_mux = &alc861vd_capture_source,
15127 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015128 [ALC861VD_LENOVO] = {
15129 .mixers = { alc861vd_lenovo_mixer },
15130 .init_verbs = { alc861vd_volume_init_verbs,
15131 alc861vd_3stack_init_verbs,
15132 alc861vd_eapd_verbs,
15133 alc861vd_lenovo_unsol_verbs },
15134 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15135 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015136 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15137 .channel_mode = alc861vd_3stack_2ch_modes,
15138 .input_mux = &alc861vd_capture_source,
15139 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015140 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015141 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015142 },
Kailang Yang272a5272007-05-14 11:00:38 +020015143 [ALC861VD_DALLAS] = {
15144 .mixers = { alc861vd_dallas_mixer },
15145 .init_verbs = { alc861vd_dallas_verbs },
15146 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15147 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015148 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15149 .channel_mode = alc861vd_3stack_2ch_modes,
15150 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015151 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015152 .setup = alc861vd_dallas_setup,
15153 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015154 },
15155 [ALC861VD_HP] = {
15156 .mixers = { alc861vd_hp_mixer },
15157 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15158 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15159 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015160 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015161 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15162 .channel_mode = alc861vd_3stack_2ch_modes,
15163 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015164 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015165 .setup = alc861vd_dallas_setup,
15166 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020015167 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015168 [ALC660VD_ASUS_V1S] = {
15169 .mixers = { alc861vd_lenovo_mixer },
15170 .init_verbs = { alc861vd_volume_init_verbs,
15171 alc861vd_3stack_init_verbs,
15172 alc861vd_eapd_verbs,
15173 alc861vd_lenovo_unsol_verbs },
15174 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15175 .dac_nids = alc660vd_dac_nids,
15176 .dig_out_nid = ALC861VD_DIGOUT_NID,
15177 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15178 .channel_mode = alc861vd_3stack_2ch_modes,
15179 .input_mux = &alc861vd_capture_source,
15180 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015181 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015182 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015183 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015184};
15185
15186/*
15187 * BIOS auto configuration
15188 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015189static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15190 const struct auto_pin_cfg *cfg)
15191{
15192 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
15193}
15194
15195
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015196static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15197 hda_nid_t nid, int pin_type, int dac_idx)
15198{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015199 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015200}
15201
15202static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15203{
15204 struct alc_spec *spec = codec->spec;
15205 int i;
15206
15207 for (i = 0; i <= HDA_SIDE; i++) {
15208 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015209 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015210 if (nid)
15211 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015212 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015213 }
15214}
15215
15216
15217static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15218{
15219 struct alc_spec *spec = codec->spec;
15220 hda_nid_t pin;
15221
15222 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015223 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015224 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015225 pin = spec->autocfg.speaker_pins[0];
15226 if (pin)
15227 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015228}
15229
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015230#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15231
15232static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15233{
15234 struct alc_spec *spec = codec->spec;
15235 int i;
15236
15237 for (i = 0; i < AUTO_PIN_LAST; i++) {
15238 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020015239 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015240 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015241 if (nid != ALC861VD_PIN_CD_NID &&
15242 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015243 snd_hda_codec_write(codec, nid, 0,
15244 AC_VERB_SET_AMP_GAIN_MUTE,
15245 AMP_OUT_MUTE);
15246 }
15247 }
15248}
15249
Takashi Iwaif511b012008-08-15 16:46:42 +020015250#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15251
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015252#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15253#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15254
15255/* add playback controls from the parsed DAC table */
15256/* Based on ALC880 version. But ALC861VD has separate,
15257 * different NIDs for mute/unmute switch and volume control */
15258static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15259 const struct auto_pin_cfg *cfg)
15260{
15261 char name[32];
15262 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15263 hda_nid_t nid_v, nid_s;
15264 int i, err;
15265
15266 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015267 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015268 continue;
15269 nid_v = alc861vd_idx_to_mixer_vol(
15270 alc880_dac_to_idx(
15271 spec->multiout.dac_nids[i]));
15272 nid_s = alc861vd_idx_to_mixer_switch(
15273 alc880_dac_to_idx(
15274 spec->multiout.dac_nids[i]));
15275
15276 if (i == 2) {
15277 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015278 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15279 "Center Playback Volume",
15280 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15281 HDA_OUTPUT));
15282 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015283 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015284 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15285 "LFE Playback Volume",
15286 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15287 HDA_OUTPUT));
15288 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015289 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015290 err = add_control(spec, ALC_CTL_BIND_MUTE,
15291 "Center Playback Switch",
15292 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15293 HDA_INPUT));
15294 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015295 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015296 err = add_control(spec, ALC_CTL_BIND_MUTE,
15297 "LFE Playback Switch",
15298 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15299 HDA_INPUT));
15300 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015301 return err;
15302 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015303 const char *pfx;
15304 if (cfg->line_outs == 1 &&
15305 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
15306 if (!cfg->hp_pins)
15307 pfx = "Speaker";
15308 else
15309 pfx = "PCM";
15310 } else
15311 pfx = chname[i];
15312 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015313 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15314 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15315 HDA_OUTPUT));
15316 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015317 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015318 if (cfg->line_outs == 1 &&
15319 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15320 pfx = "Speaker";
15321 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015322 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015323 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015324 HDA_INPUT));
15325 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015326 return err;
15327 }
15328 }
15329 return 0;
15330}
15331
15332/* add playback controls for speaker and HP outputs */
15333/* Based on ALC880 version. But ALC861VD has separate,
15334 * different NIDs for mute/unmute switch and volume control */
15335static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15336 hda_nid_t pin, const char *pfx)
15337{
15338 hda_nid_t nid_v, nid_s;
15339 int err;
15340 char name[32];
15341
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015342 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015343 return 0;
15344
15345 if (alc880_is_fixed_pin(pin)) {
15346 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15347 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015348 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015349 spec->multiout.hp_nid = nid_v;
15350 else
15351 spec->multiout.extra_out_nid[0] = nid_v;
15352 /* control HP volume/switch on the output mixer amp */
15353 nid_v = alc861vd_idx_to_mixer_vol(
15354 alc880_fixed_pin_idx(pin));
15355 nid_s = alc861vd_idx_to_mixer_switch(
15356 alc880_fixed_pin_idx(pin));
15357
15358 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015359 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15360 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15361 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015362 return err;
15363 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015364 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15365 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15366 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015367 return err;
15368 } else if (alc880_is_multi_pin(pin)) {
15369 /* set manual connection */
15370 /* we have only a switch on HP-out PIN */
15371 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015372 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15373 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15374 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015375 return err;
15376 }
15377 return 0;
15378}
15379
15380/* parse the BIOS configuration and set up the alc_spec
15381 * return 1 if successful, 0 if the proper config is not found,
15382 * or a negative error code
15383 * Based on ALC880 version - had to change it to override
15384 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15385static int alc861vd_parse_auto_config(struct hda_codec *codec)
15386{
15387 struct alc_spec *spec = codec->spec;
15388 int err;
15389 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15390
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015391 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15392 alc861vd_ignore);
15393 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015394 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015395 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015396 return 0; /* can't find valid BIOS pin config */
15397
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015398 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15399 if (err < 0)
15400 return err;
15401 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15402 if (err < 0)
15403 return err;
15404 err = alc861vd_auto_create_extra_out(spec,
15405 spec->autocfg.speaker_pins[0],
15406 "Speaker");
15407 if (err < 0)
15408 return err;
15409 err = alc861vd_auto_create_extra_out(spec,
15410 spec->autocfg.hp_pins[0],
15411 "Headphone");
15412 if (err < 0)
15413 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015414 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015415 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015416 return err;
15417
15418 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15419
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015420 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015421 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15422
Takashi Iwai603c4012008-07-30 15:01:44 +020015423 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015424 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015425
Takashi Iwaid88897e2008-10-31 15:01:37 +010015426 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015427
15428 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015429 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015430
Takashi Iwai776e1842007-08-29 15:07:11 +020015431 err = alc_auto_add_mic_boost(codec);
15432 if (err < 0)
15433 return err;
15434
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015435 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15436
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015437 return 1;
15438}
15439
15440/* additional initialization for auto-configuration model */
15441static void alc861vd_auto_init(struct hda_codec *codec)
15442{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015443 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015444 alc861vd_auto_init_multi_out(codec);
15445 alc861vd_auto_init_hp_out(codec);
15446 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015447 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015448 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015449 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015450}
15451
15452static int patch_alc861vd(struct hda_codec *codec)
15453{
15454 struct alc_spec *spec;
15455 int err, board_config;
15456
15457 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15458 if (spec == NULL)
15459 return -ENOMEM;
15460
15461 codec->spec = spec;
15462
15463 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15464 alc861vd_models,
15465 alc861vd_cfg_tbl);
15466
15467 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015468 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15469 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015470 board_config = ALC861VD_AUTO;
15471 }
15472
15473 if (board_config == ALC861VD_AUTO) {
15474 /* automatic parse from the BIOS config */
15475 err = alc861vd_parse_auto_config(codec);
15476 if (err < 0) {
15477 alc_free(codec);
15478 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015479 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015480 printk(KERN_INFO
15481 "hda_codec: Cannot set up configuration "
15482 "from BIOS. Using base mode...\n");
15483 board_config = ALC861VD_3ST;
15484 }
15485 }
15486
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015487 err = snd_hda_attach_beep_device(codec, 0x23);
15488 if (err < 0) {
15489 alc_free(codec);
15490 return err;
15491 }
15492
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015493 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015494 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015495
Kailang Yang2f893282008-05-27 12:14:47 +020015496 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015497 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015498 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015499 }
15500
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015501 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15502 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15503
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015504 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15505 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15506
Takashi Iwaidd704692009-08-11 08:45:11 +020015507 if (!spec->adc_nids) {
15508 spec->adc_nids = alc861vd_adc_nids;
15509 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15510 }
15511 if (!spec->capsrc_nids)
15512 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015513
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015514 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015515 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015516
Takashi Iwai2134ea42008-01-10 16:53:55 +010015517 spec->vmaster_nid = 0x02;
15518
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015519 codec->patch_ops = alc_patch_ops;
15520
15521 if (board_config == ALC861VD_AUTO)
15522 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015523#ifdef CONFIG_SND_HDA_POWER_SAVE
15524 if (!spec->loopback.amplist)
15525 spec->loopback.amplist = alc861vd_loopbacks;
15526#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015527 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015528
15529 return 0;
15530}
15531
15532/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015533 * ALC662 support
15534 *
15535 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15536 * configuration. Each pin widget can choose any input DACs and a mixer.
15537 * Each ADC is connected from a mixer of all inputs. This makes possible
15538 * 6-channel independent captures.
15539 *
15540 * In addition, an independent DAC for the multi-playback (not used in this
15541 * driver yet).
15542 */
15543#define ALC662_DIGOUT_NID 0x06
15544#define ALC662_DIGIN_NID 0x0a
15545
15546static hda_nid_t alc662_dac_nids[4] = {
15547 /* front, rear, clfe, rear_surr */
15548 0x02, 0x03, 0x04
15549};
15550
Kailang Yang622e84c2009-04-21 07:39:04 +020015551static hda_nid_t alc272_dac_nids[2] = {
15552 0x02, 0x03
15553};
15554
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015555static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015556 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015557 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015558};
Takashi Iwaie1406342008-02-11 18:32:32 +010015559
Kailang Yang622e84c2009-04-21 07:39:04 +020015560static hda_nid_t alc272_adc_nids[1] = {
15561 /* ADC1-2 */
15562 0x08,
15563};
15564
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015565static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015566static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15567
Takashi Iwaie1406342008-02-11 18:32:32 +010015568
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015569/* input MUX */
15570/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015571static struct hda_input_mux alc662_capture_source = {
15572 .num_items = 4,
15573 .items = {
15574 { "Mic", 0x0 },
15575 { "Front Mic", 0x1 },
15576 { "Line", 0x2 },
15577 { "CD", 0x4 },
15578 },
15579};
15580
15581static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15582 .num_items = 2,
15583 .items = {
15584 { "Mic", 0x1 },
15585 { "Line", 0x2 },
15586 },
15587};
Kailang Yang291702f2007-10-16 14:28:03 +020015588
Kailang Yang6dda9f42008-05-27 12:05:31 +020015589static struct hda_input_mux alc663_capture_source = {
15590 .num_items = 3,
15591 .items = {
15592 { "Mic", 0x0 },
15593 { "Front Mic", 0x1 },
15594 { "Line", 0x2 },
15595 },
15596};
15597
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015598#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020015599static struct hda_input_mux alc272_nc10_capture_source = {
15600 .num_items = 16,
15601 .items = {
15602 { "Autoselect Mic", 0x0 },
15603 { "Internal Mic", 0x1 },
15604 { "In-0x02", 0x2 },
15605 { "In-0x03", 0x3 },
15606 { "In-0x04", 0x4 },
15607 { "In-0x05", 0x5 },
15608 { "In-0x06", 0x6 },
15609 { "In-0x07", 0x7 },
15610 { "In-0x08", 0x8 },
15611 { "In-0x09", 0x9 },
15612 { "In-0x0a", 0x0a },
15613 { "In-0x0b", 0x0b },
15614 { "In-0x0c", 0x0c },
15615 { "In-0x0d", 0x0d },
15616 { "In-0x0e", 0x0e },
15617 { "In-0x0f", 0x0f },
15618 },
15619};
15620#endif
15621
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015622/*
15623 * 2ch mode
15624 */
15625static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15626 { 2, NULL }
15627};
15628
15629/*
15630 * 2ch mode
15631 */
15632static struct hda_verb alc662_3ST_ch2_init[] = {
15633 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15634 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15635 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15636 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15637 { } /* end */
15638};
15639
15640/*
15641 * 6ch mode
15642 */
15643static struct hda_verb alc662_3ST_ch6_init[] = {
15644 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15645 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15646 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15647 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15648 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15649 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15650 { } /* end */
15651};
15652
15653static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15654 { 2, alc662_3ST_ch2_init },
15655 { 6, alc662_3ST_ch6_init },
15656};
15657
15658/*
15659 * 2ch mode
15660 */
15661static struct hda_verb alc662_sixstack_ch6_init[] = {
15662 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15663 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15664 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15665 { } /* end */
15666};
15667
15668/*
15669 * 6ch mode
15670 */
15671static struct hda_verb alc662_sixstack_ch8_init[] = {
15672 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15673 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15674 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15675 { } /* end */
15676};
15677
15678static struct hda_channel_mode alc662_5stack_modes[2] = {
15679 { 2, alc662_sixstack_ch6_init },
15680 { 6, alc662_sixstack_ch8_init },
15681};
15682
15683/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15684 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15685 */
15686
15687static struct snd_kcontrol_new alc662_base_mixer[] = {
15688 /* output mixer control */
15689 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015690 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015691 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015692 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015693 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15694 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015695 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15696 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015697 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15698
15699 /*Input mixer control */
15700 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15701 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15702 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15703 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15704 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15705 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15706 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15707 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015708 { } /* end */
15709};
15710
15711static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15712 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015713 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015714 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15715 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15716 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, 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 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15722 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015723 { } /* end */
15724};
15725
15726static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15727 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015728 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015729 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015730 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015731 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15732 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015733 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15734 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015735 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15736 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15737 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15738 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15739 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15740 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15741 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15742 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15743 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015744 { } /* end */
15745};
15746
15747static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15748 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15749 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015750 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15751 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015752 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15753 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15754 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15755 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15756 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015757 { } /* end */
15758};
15759
Kailang Yang291702f2007-10-16 14:28:03 +020015760static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015761 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15762 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015763
15764 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15765 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15766 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15767
15768 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15769 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15770 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15771 { } /* end */
15772};
15773
Kailang Yang8c427222008-01-10 13:03:59 +010015774static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015775 ALC262_HIPPO_MASTER_SWITCH,
15776 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015777 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015778 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15779 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015780 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15781 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15782 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15783 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15784 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15785 { } /* end */
15786};
15787
Kailang Yangf1d4e282008-08-26 14:03:29 +020015788static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15789 .ops = &snd_hda_bind_vol,
15790 .values = {
15791 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15792 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15793 0
15794 },
15795};
15796
15797static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15798 .ops = &snd_hda_bind_sw,
15799 .values = {
15800 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15801 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15802 0
15803 },
15804};
15805
Kailang Yang6dda9f42008-05-27 12:05:31 +020015806static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015807 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15808 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15809 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15810 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15811 { } /* end */
15812};
15813
15814static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15815 .ops = &snd_hda_bind_sw,
15816 .values = {
15817 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15818 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15819 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15820 0
15821 },
15822};
15823
15824static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15825 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15826 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15827 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15828 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15829 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15830 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15831
15832 { } /* end */
15833};
15834
15835static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15836 .ops = &snd_hda_bind_sw,
15837 .values = {
15838 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15839 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15840 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15841 0
15842 },
15843};
15844
15845static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15846 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15847 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
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("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15851 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15852 { } /* end */
15853};
15854
15855static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015856 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15857 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015858 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15859 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15860 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15861 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15862 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15863 { } /* end */
15864};
15865
15866static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15867 .ops = &snd_hda_bind_vol,
15868 .values = {
15869 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15870 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15871 0
15872 },
15873};
15874
15875static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15876 .ops = &snd_hda_bind_sw,
15877 .values = {
15878 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15879 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15880 0
15881 },
15882};
15883
15884static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15885 HDA_BIND_VOL("Master Playback Volume",
15886 &alc663_asus_two_bind_master_vol),
15887 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15888 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015889 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15890 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15891 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015892 { } /* end */
15893};
15894
15895static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15896 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15897 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15898 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15899 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15900 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15901 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015902 { } /* end */
15903};
15904
15905static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15906 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15907 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15908 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15909 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15910 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15911
15912 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15913 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15914 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15915 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15916 { } /* end */
15917};
15918
15919static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15920 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15921 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15922 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15923
15924 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15925 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15926 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15927 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15928 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15929 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15930 { } /* end */
15931};
15932
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015933static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15934 {
15935 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15936 .name = "Channel Mode",
15937 .info = alc_ch_mode_info,
15938 .get = alc_ch_mode_get,
15939 .put = alc_ch_mode_put,
15940 },
15941 { } /* end */
15942};
15943
15944static struct hda_verb alc662_init_verbs[] = {
15945 /* ADC: mute amp left and right */
15946 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15947 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15948 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15949
Takashi Iwaicb53c622007-08-10 17:21:45 +020015950 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15951 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15952 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15953 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15954 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015955
Kailang Yangb60dd392007-09-20 12:50:29 +020015956 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15957 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15958 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15959 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15960 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15961 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015962
15963 /* Front Pin: output 0 (0x0c) */
15964 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15965 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15966
15967 /* Rear Pin: output 1 (0x0d) */
15968 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15969 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15970
15971 /* CLFE Pin: output 2 (0x0e) */
15972 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15973 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15974
15975 /* Mic (rear) pin: input vref at 80% */
15976 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15977 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15978 /* Front Mic pin: input vref at 80% */
15979 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15980 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15981 /* Line In pin: input */
15982 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15983 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15984 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15985 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15986 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15987 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15988 /* CD pin widget for input */
15989 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15990
15991 /* FIXME: use matrix-type input source selection */
15992 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15993 /* Input mixer */
15994 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020015995 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015996
15997 /* always trun on EAPD */
15998 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15999 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16000
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016001 { }
16002};
16003
16004static struct hda_verb alc662_sue_init_verbs[] = {
16005 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16006 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016007 {}
16008};
16009
16010static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16011 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16012 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16013 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016014};
16015
Kailang Yang8c427222008-01-10 13:03:59 +010016016/* Set Unsolicited Event*/
16017static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16018 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16019 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16020 {}
16021};
16022
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016023/*
16024 * generic initialization of ADC, input mixers and output mixers
16025 */
16026static struct hda_verb alc662_auto_init_verbs[] = {
16027 /*
16028 * Unmute ADC and set the default input to mic-in
16029 */
16030 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16031 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16032
16033 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16034 * mixer widget
16035 * Note: PASD motherboards uses the Line In 2 as the input for front
16036 * panel mic (mic 2)
16037 */
16038 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016039 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16040 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16041 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16042 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16043 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016044
16045 /*
16046 * Set up output mixers (0x0c - 0x0f)
16047 */
16048 /* set vol=0 to output mixers */
16049 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16050 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16051 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16052
16053 /* set up input amps for analog loopback */
16054 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020016055 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16056 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16057 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16058 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16059 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16060 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016061
16062
16063 /* FIXME: use matrix-type input source selection */
16064 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16065 /* Input mixer */
16066 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016067 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016068 { }
16069};
16070
Takashi Iwai24fb9172008-09-02 14:48:20 +020016071/* additional verbs for ALC663 */
16072static struct hda_verb alc663_auto_init_verbs[] = {
16073 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16074 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16075 { }
16076};
16077
Kailang Yang6dda9f42008-05-27 12:05:31 +020016078static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016079 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16080 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016081 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16082 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016083 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16084 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16085 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016086 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16087 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16088 {}
16089};
16090
Kailang Yangf1d4e282008-08-26 14:03:29 +020016091static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16092 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16093 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16094 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16095 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16096 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16097 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16098 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16099 {}
16100};
16101
16102static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16103 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16104 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16105 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16106 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16107 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16108 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16109 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16110 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16111 {}
16112};
16113
16114static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16115 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16116 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16117 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16118 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16119 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16120 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16121 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16122 {}
16123};
16124
16125static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16126 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16127 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16128 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16129 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16130 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16131 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16132 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16133 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16134 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16135 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16136 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16137 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16138 {}
16139};
16140
16141static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16142 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16143 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16144 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16145 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16146 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16147 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16148 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16149 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16150 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16151 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16152 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16153 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16154 {}
16155};
16156
Kailang Yang6dda9f42008-05-27 12:05:31 +020016157static struct hda_verb alc663_g71v_init_verbs[] = {
16158 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16159 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16160 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16161
16162 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16163 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16164 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16165
16166 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16167 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16168 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16169 {}
16170};
16171
16172static struct hda_verb alc663_g50v_init_verbs[] = {
16173 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16174 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16175 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16176
16177 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16178 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16179 {}
16180};
16181
Kailang Yangf1d4e282008-08-26 14:03:29 +020016182static struct hda_verb alc662_ecs_init_verbs[] = {
16183 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16184 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16185 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16186 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16187 {}
16188};
16189
Kailang Yang622e84c2009-04-21 07:39:04 +020016190static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16191 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16192 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16193 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16194 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16195 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16196 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16197 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16198 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16199 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16200 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16201 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16202 {}
16203};
16204
16205static struct hda_verb alc272_dell_init_verbs[] = {
16206 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16207 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16208 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16209 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16210 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16211 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16212 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16213 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16214 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16215 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16216 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16217 {}
16218};
16219
Kailang Yangf1d4e282008-08-26 14:03:29 +020016220static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16221 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16222 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16223 { } /* end */
16224};
16225
Kailang Yang622e84c2009-04-21 07:39:04 +020016226static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16227 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16228 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16229 { } /* end */
16230};
16231
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016232static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16233{
16234 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016235 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016236
16237 present = snd_hda_codec_read(codec, 0x14, 0,
16238 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016239 bits = present ? HDA_AMP_MUTE : 0;
16240 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16241 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016242}
16243
16244static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16245{
16246 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016247 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016248
16249 present = snd_hda_codec_read(codec, 0x1b, 0,
16250 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016251 bits = present ? HDA_AMP_MUTE : 0;
16252 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16253 HDA_AMP_MUTE, bits);
16254 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16255 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016256}
16257
16258static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16259 unsigned int res)
16260{
16261 if ((res >> 26) == ALC880_HP_EVENT)
16262 alc662_lenovo_101e_all_automute(codec);
16263 if ((res >> 26) == ALC880_FRONT_EVENT)
16264 alc662_lenovo_101e_ispeaker_automute(codec);
16265}
16266
Kailang Yang291702f2007-10-16 14:28:03 +020016267/* unsolicited event for HP jack sensing */
16268static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16269 unsigned int res)
16270{
Kailang Yang291702f2007-10-16 14:28:03 +020016271 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016272 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016273 else
16274 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016275}
16276
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016277static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020016278{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016279 struct alc_spec *spec = codec->spec;
16280
16281 alc262_hippo1_setup(codec);
16282 spec->ext_mic.pin = 0x18;
16283 spec->ext_mic.mux_idx = 0;
16284 spec->int_mic.pin = 0x19;
16285 spec->int_mic.mux_idx = 1;
16286 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020016287}
16288
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016289static void alc662_eeepc_inithook(struct hda_codec *codec)
16290{
16291 alc262_hippo_automute(codec);
16292 alc_mic_automute(codec);
16293}
16294
16295static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010016296{
Takashi Iwai42171c12009-05-08 14:11:43 +020016297 struct alc_spec *spec = codec->spec;
16298
16299 spec->autocfg.hp_pins[0] = 0x14;
16300 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010016301}
16302
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016303#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
16304
Kailang Yang6dda9f42008-05-27 12:05:31 +020016305static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16306{
16307 unsigned int present;
16308 unsigned char bits;
16309
16310 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016311 AC_VERB_GET_PIN_SENSE, 0)
16312 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016313 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016314 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16315 AMP_IN_MUTE(0), bits);
16316 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16317 AMP_IN_MUTE(0), bits);
16318}
16319
16320static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16321{
16322 unsigned int present;
16323 unsigned char bits;
16324
16325 present = snd_hda_codec_read(codec, 0x21, 0,
16326 AC_VERB_GET_PIN_SENSE, 0)
16327 & AC_PINSENSE_PRESENCE;
16328 bits = present ? HDA_AMP_MUTE : 0;
16329 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16330 AMP_IN_MUTE(0), bits);
16331 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16332 AMP_IN_MUTE(0), bits);
16333 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16334 AMP_IN_MUTE(0), bits);
16335 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16336 AMP_IN_MUTE(0), bits);
16337}
16338
16339static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16340{
16341 unsigned int present;
16342 unsigned char bits;
16343
16344 present = snd_hda_codec_read(codec, 0x15, 0,
16345 AC_VERB_GET_PIN_SENSE, 0)
16346 & AC_PINSENSE_PRESENCE;
16347 bits = present ? HDA_AMP_MUTE : 0;
16348 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16349 AMP_IN_MUTE(0), bits);
16350 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16351 AMP_IN_MUTE(0), bits);
16352 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16353 AMP_IN_MUTE(0), bits);
16354 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16355 AMP_IN_MUTE(0), bits);
16356}
16357
16358static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16359{
16360 unsigned int present;
16361 unsigned char bits;
16362
16363 present = snd_hda_codec_read(codec, 0x1b, 0,
16364 AC_VERB_GET_PIN_SENSE, 0)
16365 & AC_PINSENSE_PRESENCE;
16366 bits = present ? 0 : PIN_OUT;
16367 snd_hda_codec_write(codec, 0x14, 0,
16368 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16369}
16370
16371static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16372{
16373 unsigned int present1, present2;
16374
16375 present1 = snd_hda_codec_read(codec, 0x21, 0,
16376 AC_VERB_GET_PIN_SENSE, 0)
16377 & AC_PINSENSE_PRESENCE;
16378 present2 = snd_hda_codec_read(codec, 0x15, 0,
16379 AC_VERB_GET_PIN_SENSE, 0)
16380 & AC_PINSENSE_PRESENCE;
16381
16382 if (present1 || present2) {
16383 snd_hda_codec_write_cache(codec, 0x14, 0,
16384 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16385 } else {
16386 snd_hda_codec_write_cache(codec, 0x14, 0,
16387 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16388 }
16389}
16390
16391static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16392{
16393 unsigned int present1, present2;
16394
16395 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16396 AC_VERB_GET_PIN_SENSE, 0)
16397 & AC_PINSENSE_PRESENCE;
16398 present2 = snd_hda_codec_read(codec, 0x15, 0,
16399 AC_VERB_GET_PIN_SENSE, 0)
16400 & AC_PINSENSE_PRESENCE;
16401
16402 if (present1 || present2) {
16403 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16404 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16405 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16406 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16407 } else {
16408 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16409 AMP_IN_MUTE(0), 0);
16410 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16411 AMP_IN_MUTE(0), 0);
16412 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016413}
16414
Kailang Yang6dda9f42008-05-27 12:05:31 +020016415static void alc663_m51va_unsol_event(struct hda_codec *codec,
16416 unsigned int res)
16417{
16418 switch (res >> 26) {
16419 case ALC880_HP_EVENT:
16420 alc663_m51va_speaker_automute(codec);
16421 break;
16422 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016423 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016424 break;
16425 }
16426}
16427
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016428static void alc663_m51va_setup(struct hda_codec *codec)
16429{
16430 struct alc_spec *spec = codec->spec;
16431 spec->ext_mic.pin = 0x18;
16432 spec->ext_mic.mux_idx = 0;
16433 spec->int_mic.pin = 0x12;
16434 spec->int_mic.mux_idx = 1;
16435 spec->auto_mic = 1;
16436}
16437
Kailang Yang6dda9f42008-05-27 12:05:31 +020016438static void alc663_m51va_inithook(struct hda_codec *codec)
16439{
16440 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016441 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016442}
16443
Kailang Yangf1d4e282008-08-26 14:03:29 +020016444/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016445#define alc663_mode1_unsol_event alc663_m51va_unsol_event
16446#define alc663_mode1_setup alc663_m51va_setup
16447#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020016448
Kailang Yangf1d4e282008-08-26 14:03:29 +020016449/* ***************** Mode2 ******************************/
16450static void alc662_mode2_unsol_event(struct hda_codec *codec,
16451 unsigned int res)
16452{
16453 switch (res >> 26) {
16454 case ALC880_HP_EVENT:
16455 alc662_f5z_speaker_automute(codec);
16456 break;
16457 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016458 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016459 break;
16460 }
16461}
16462
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016463#define alc662_mode2_setup alc663_m51va_setup
16464
Kailang Yangf1d4e282008-08-26 14:03:29 +020016465static void alc662_mode2_inithook(struct hda_codec *codec)
16466{
16467 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016468 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016469}
16470/* ***************** Mode3 ******************************/
16471static void alc663_mode3_unsol_event(struct hda_codec *codec,
16472 unsigned int res)
16473{
16474 switch (res >> 26) {
16475 case ALC880_HP_EVENT:
16476 alc663_two_hp_m1_speaker_automute(codec);
16477 break;
16478 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016479 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016480 break;
16481 }
16482}
16483
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016484#define alc663_mode3_setup alc663_m51va_setup
16485
Kailang Yangf1d4e282008-08-26 14:03:29 +020016486static void alc663_mode3_inithook(struct hda_codec *codec)
16487{
16488 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016489 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016490}
16491/* ***************** Mode4 ******************************/
16492static void alc663_mode4_unsol_event(struct hda_codec *codec,
16493 unsigned int res)
16494{
16495 switch (res >> 26) {
16496 case ALC880_HP_EVENT:
16497 alc663_21jd_two_speaker_automute(codec);
16498 break;
16499 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016500 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016501 break;
16502 }
16503}
16504
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016505#define alc663_mode4_setup alc663_m51va_setup
16506
Kailang Yangf1d4e282008-08-26 14:03:29 +020016507static void alc663_mode4_inithook(struct hda_codec *codec)
16508{
16509 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016510 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016511}
16512/* ***************** Mode5 ******************************/
16513static void alc663_mode5_unsol_event(struct hda_codec *codec,
16514 unsigned int res)
16515{
16516 switch (res >> 26) {
16517 case ALC880_HP_EVENT:
16518 alc663_15jd_two_speaker_automute(codec);
16519 break;
16520 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016521 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016522 break;
16523 }
16524}
16525
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016526#define alc663_mode5_setup alc663_m51va_setup
16527
Kailang Yangf1d4e282008-08-26 14:03:29 +020016528static void alc663_mode5_inithook(struct hda_codec *codec)
16529{
16530 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016531 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016532}
16533/* ***************** Mode6 ******************************/
16534static void alc663_mode6_unsol_event(struct hda_codec *codec,
16535 unsigned int res)
16536{
16537 switch (res >> 26) {
16538 case ALC880_HP_EVENT:
16539 alc663_two_hp_m2_speaker_automute(codec);
16540 break;
16541 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016542 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016543 break;
16544 }
16545}
16546
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016547#define alc663_mode6_setup alc663_m51va_setup
16548
Kailang Yangf1d4e282008-08-26 14:03:29 +020016549static void alc663_mode6_inithook(struct hda_codec *codec)
16550{
16551 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016552 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016553}
16554
Kailang Yang6dda9f42008-05-27 12:05:31 +020016555static void alc663_g71v_hp_automute(struct hda_codec *codec)
16556{
16557 unsigned int present;
16558 unsigned char bits;
16559
16560 present = snd_hda_codec_read(codec, 0x21, 0,
16561 AC_VERB_GET_PIN_SENSE, 0)
16562 & AC_PINSENSE_PRESENCE;
16563 bits = present ? HDA_AMP_MUTE : 0;
16564 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16565 HDA_AMP_MUTE, bits);
16566 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16567 HDA_AMP_MUTE, bits);
16568}
16569
16570static void alc663_g71v_front_automute(struct hda_codec *codec)
16571{
16572 unsigned int present;
16573 unsigned char bits;
16574
16575 present = snd_hda_codec_read(codec, 0x15, 0,
16576 AC_VERB_GET_PIN_SENSE, 0)
16577 & AC_PINSENSE_PRESENCE;
16578 bits = present ? HDA_AMP_MUTE : 0;
16579 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16580 HDA_AMP_MUTE, bits);
16581}
16582
16583static void alc663_g71v_unsol_event(struct hda_codec *codec,
16584 unsigned int res)
16585{
16586 switch (res >> 26) {
16587 case ALC880_HP_EVENT:
16588 alc663_g71v_hp_automute(codec);
16589 break;
16590 case ALC880_FRONT_EVENT:
16591 alc663_g71v_front_automute(codec);
16592 break;
16593 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016594 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016595 break;
16596 }
16597}
16598
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016599#define alc663_g71v_setup alc663_m51va_setup
16600
Kailang Yang6dda9f42008-05-27 12:05:31 +020016601static void alc663_g71v_inithook(struct hda_codec *codec)
16602{
16603 alc663_g71v_front_automute(codec);
16604 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016605 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016606}
16607
16608static void alc663_g50v_unsol_event(struct hda_codec *codec,
16609 unsigned int res)
16610{
16611 switch (res >> 26) {
16612 case ALC880_HP_EVENT:
16613 alc663_m51va_speaker_automute(codec);
16614 break;
16615 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016616 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016617 break;
16618 }
16619}
16620
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016621#define alc663_g50v_setup alc663_m51va_setup
16622
Kailang Yang6dda9f42008-05-27 12:05:31 +020016623static void alc663_g50v_inithook(struct hda_codec *codec)
16624{
16625 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016626 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016627}
16628
Kailang Yangf1d4e282008-08-26 14:03:29 +020016629static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16630 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016631 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016632
16633 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16634 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16635 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16636
16637 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16638 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16639 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16640 { } /* end */
16641};
16642
Chris Pockelé9541ba12009-05-12 08:08:53 +020016643static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16644 /* Master Playback automatically created from Speaker and Headphone */
16645 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16646 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16647 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16648 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16649
16650 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16651 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16652 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16653
16654 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16655 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16656 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16657 { } /* end */
16658};
16659
Takashi Iwaicb53c622007-08-10 17:21:45 +020016660#ifdef CONFIG_SND_HDA_POWER_SAVE
16661#define alc662_loopbacks alc880_loopbacks
16662#endif
16663
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016664
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016665/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016666#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16667#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16668#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16669#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16670
16671/*
16672 * configuration and preset
16673 */
16674static const char *alc662_models[ALC662_MODEL_LAST] = {
16675 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16676 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16677 [ALC662_3ST_6ch] = "3stack-6ch",
16678 [ALC662_5ST_DIG] = "6stack-dig",
16679 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016680 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016681 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016682 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016683 [ALC663_ASUS_M51VA] = "m51va",
16684 [ALC663_ASUS_G71V] = "g71v",
16685 [ALC663_ASUS_H13] = "h13",
16686 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016687 [ALC663_ASUS_MODE1] = "asus-mode1",
16688 [ALC662_ASUS_MODE2] = "asus-mode2",
16689 [ALC663_ASUS_MODE3] = "asus-mode3",
16690 [ALC663_ASUS_MODE4] = "asus-mode4",
16691 [ALC663_ASUS_MODE5] = "asus-mode5",
16692 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016693 [ALC272_DELL] = "dell",
16694 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016695 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016696 [ALC662_AUTO] = "auto",
16697};
16698
16699static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016700 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016701 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16702 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016703 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16704 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16705 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16706 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16707 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16708 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16709 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16710 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16711 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16712 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16713 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16714 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016715 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16716 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16717 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016718 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16719 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16720 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16721 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016722 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016723 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16724 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016725 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016726 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16727 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16728 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016729 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16730 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16731 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016732 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16733 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16734 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016735 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016736 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16737 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016738 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016739 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016740 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016741 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16742 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16743 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016744 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016745 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16746 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016747 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016748 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016749 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016750 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016751 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16752 ALC662_3ST_6ch_DIG),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016753 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016754 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16755 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016756 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016757 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016758 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016759 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016760 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016761 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16762 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016763 {}
16764};
16765
16766static struct alc_config_preset alc662_presets[] = {
16767 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016768 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016769 .init_verbs = { alc662_init_verbs },
16770 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16771 .dac_nids = alc662_dac_nids,
16772 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016773 .dig_in_nid = ALC662_DIGIN_NID,
16774 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16775 .channel_mode = alc662_3ST_2ch_modes,
16776 .input_mux = &alc662_capture_source,
16777 },
16778 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016779 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016780 .init_verbs = { alc662_init_verbs },
16781 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16782 .dac_nids = alc662_dac_nids,
16783 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016784 .dig_in_nid = ALC662_DIGIN_NID,
16785 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16786 .channel_mode = alc662_3ST_6ch_modes,
16787 .need_dac_fix = 1,
16788 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016789 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016790 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016791 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016792 .init_verbs = { alc662_init_verbs },
16793 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16794 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016795 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16796 .channel_mode = alc662_3ST_6ch_modes,
16797 .need_dac_fix = 1,
16798 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016799 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016800 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016801 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016802 .init_verbs = { alc662_init_verbs },
16803 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16804 .dac_nids = alc662_dac_nids,
16805 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016806 .dig_in_nid = ALC662_DIGIN_NID,
16807 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16808 .channel_mode = alc662_5stack_modes,
16809 .input_mux = &alc662_capture_source,
16810 },
16811 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016812 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016813 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16814 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16815 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016816 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16817 .channel_mode = alc662_3ST_2ch_modes,
16818 .input_mux = &alc662_lenovo_101e_capture_source,
16819 .unsol_event = alc662_lenovo_101e_unsol_event,
16820 .init_hook = alc662_lenovo_101e_all_automute,
16821 },
Kailang Yang291702f2007-10-16 14:28:03 +020016822 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016823 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016824 .init_verbs = { alc662_init_verbs,
16825 alc662_eeepc_sue_init_verbs },
16826 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16827 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016828 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16829 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020016830 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016831 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020016832 .init_hook = alc662_eeepc_inithook,
16833 },
Kailang Yang8c427222008-01-10 13:03:59 +010016834 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016835 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016836 alc662_chmode_mixer },
16837 .init_verbs = { alc662_init_verbs,
16838 alc662_eeepc_ep20_sue_init_verbs },
16839 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16840 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016841 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16842 .channel_mode = alc662_3ST_6ch_modes,
16843 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016844 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016845 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010016846 .init_hook = alc662_eeepc_ep20_inithook,
16847 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016848 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016849 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016850 .init_verbs = { alc662_init_verbs,
16851 alc662_ecs_init_verbs },
16852 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16853 .dac_nids = alc662_dac_nids,
16854 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16855 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016856 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016857 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016858 .init_hook = alc662_eeepc_inithook,
16859 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016860 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016861 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016862 .init_verbs = { alc662_init_verbs, alc663_m51va_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 Yang6dda9f42008-05-27 12:05:31 +020016868 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016869 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016870 .init_hook = alc663_m51va_inithook,
16871 },
16872 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016873 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016874 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16875 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16876 .dac_nids = alc662_dac_nids,
16877 .dig_out_nid = ALC662_DIGOUT_NID,
16878 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16879 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016880 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016881 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016882 .init_hook = alc663_g71v_inithook,
16883 },
16884 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016885 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016886 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16887 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16888 .dac_nids = alc662_dac_nids,
16889 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16890 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016891 .unsol_event = alc663_m51va_unsol_event,
16892 .init_hook = alc663_m51va_inithook,
16893 },
16894 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016895 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016896 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16897 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16898 .dac_nids = alc662_dac_nids,
16899 .dig_out_nid = ALC662_DIGOUT_NID,
16900 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16901 .channel_mode = alc662_3ST_6ch_modes,
16902 .input_mux = &alc663_capture_source,
16903 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016904 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016905 .init_hook = alc663_g50v_inithook,
16906 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016907 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016908 .mixers = { alc663_m51va_mixer },
16909 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016910 .init_verbs = { alc662_init_verbs,
16911 alc663_21jd_amic_init_verbs },
16912 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16913 .hp_nid = 0x03,
16914 .dac_nids = alc662_dac_nids,
16915 .dig_out_nid = ALC662_DIGOUT_NID,
16916 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16917 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016918 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016919 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016920 .init_hook = alc663_mode1_inithook,
16921 },
16922 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016923 .mixers = { alc662_1bjd_mixer },
16924 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016925 .init_verbs = { alc662_init_verbs,
16926 alc662_1bjd_amic_init_verbs },
16927 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16928 .dac_nids = alc662_dac_nids,
16929 .dig_out_nid = ALC662_DIGOUT_NID,
16930 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16931 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016932 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016933 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016934 .init_hook = alc662_mode2_inithook,
16935 },
16936 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016937 .mixers = { alc663_two_hp_m1_mixer },
16938 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016939 .init_verbs = { alc662_init_verbs,
16940 alc663_two_hp_amic_m1_init_verbs },
16941 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16942 .hp_nid = 0x03,
16943 .dac_nids = alc662_dac_nids,
16944 .dig_out_nid = ALC662_DIGOUT_NID,
16945 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16946 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016947 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016948 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016949 .init_hook = alc663_mode3_inithook,
16950 },
16951 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016952 .mixers = { alc663_asus_21jd_clfe_mixer },
16953 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016954 .init_verbs = { alc662_init_verbs,
16955 alc663_21jd_amic_init_verbs},
16956 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16957 .hp_nid = 0x03,
16958 .dac_nids = alc662_dac_nids,
16959 .dig_out_nid = ALC662_DIGOUT_NID,
16960 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16961 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016962 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016963 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016964 .init_hook = alc663_mode4_inithook,
16965 },
16966 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016967 .mixers = { alc663_asus_15jd_clfe_mixer },
16968 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016969 .init_verbs = { alc662_init_verbs,
16970 alc663_15jd_amic_init_verbs },
16971 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16972 .hp_nid = 0x03,
16973 .dac_nids = alc662_dac_nids,
16974 .dig_out_nid = ALC662_DIGOUT_NID,
16975 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16976 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016977 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016978 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016979 .init_hook = alc663_mode5_inithook,
16980 },
16981 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016982 .mixers = { alc663_two_hp_m2_mixer },
16983 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016984 .init_verbs = { alc662_init_verbs,
16985 alc663_two_hp_amic_m2_init_verbs },
16986 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16987 .hp_nid = 0x03,
16988 .dac_nids = alc662_dac_nids,
16989 .dig_out_nid = ALC662_DIGOUT_NID,
16990 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16991 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016992 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016993 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016994 .init_hook = alc663_mode6_inithook,
16995 },
Kailang Yang622e84c2009-04-21 07:39:04 +020016996 [ALC272_DELL] = {
16997 .mixers = { alc663_m51va_mixer },
16998 .cap_mixer = alc272_auto_capture_mixer,
16999 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17000 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17001 .dac_nids = alc662_dac_nids,
17002 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17003 .adc_nids = alc272_adc_nids,
17004 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17005 .capsrc_nids = alc272_capsrc_nids,
17006 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017007 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017008 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017009 .init_hook = alc663_m51va_inithook,
17010 },
17011 [ALC272_DELL_ZM1] = {
17012 .mixers = { alc663_m51va_mixer },
17013 .cap_mixer = alc662_auto_capture_mixer,
17014 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17015 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17016 .dac_nids = alc662_dac_nids,
17017 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17018 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017019 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020017020 .capsrc_nids = alc662_capsrc_nids,
17021 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017022 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017023 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017024 .init_hook = alc663_m51va_inithook,
17025 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017026 [ALC272_SAMSUNG_NC10] = {
17027 .mixers = { alc272_nc10_mixer },
17028 .init_verbs = { alc662_init_verbs,
17029 alc663_21jd_amic_init_verbs },
17030 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17031 .dac_nids = alc272_dac_nids,
17032 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17033 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017034 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020017035 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017036 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020017037 .init_hook = alc663_mode4_inithook,
17038 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017039};
17040
17041
17042/*
17043 * BIOS auto configuration
17044 */
17045
17046/* add playback controls from the parsed DAC table */
17047static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
17048 const struct auto_pin_cfg *cfg)
17049{
17050 char name[32];
17051 static const char *chname[4] = {
17052 "Front", "Surround", NULL /*CLFE*/, "Side"
17053 };
17054 hda_nid_t nid;
17055 int i, err;
17056
17057 for (i = 0; i < cfg->line_outs; i++) {
17058 if (!spec->multiout.dac_nids[i])
17059 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020017060 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017061 if (i == 2) {
17062 /* Center/LFE */
17063 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17064 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017065 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
17066 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017067 if (err < 0)
17068 return err;
17069 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17070 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017071 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
17072 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017073 if (err < 0)
17074 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017075 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017076 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017077 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017078 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017079 if (err < 0)
17080 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017081 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017082 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017083 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017084 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017085 if (err < 0)
17086 return err;
17087 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017088 const char *pfx;
17089 if (cfg->line_outs == 1 &&
17090 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
17091 if (!cfg->hp_pins)
17092 pfx = "Speaker";
17093 else
17094 pfx = "PCM";
17095 } else
17096 pfx = chname[i];
17097 sprintf(name, "%s Playback Volume", pfx);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017098 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017099 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
17100 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017101 if (err < 0)
17102 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017103 if (cfg->line_outs == 1 &&
17104 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
17105 pfx = "Speaker";
17106 sprintf(name, "%s Playback Switch", pfx);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017107 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17108 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
17109 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017110 if (err < 0)
17111 return err;
17112 }
17113 }
17114 return 0;
17115}
17116
17117/* add playback controls for speaker and HP outputs */
17118static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
17119 const char *pfx)
17120{
17121 hda_nid_t nid;
17122 int err;
17123 char name[32];
17124
17125 if (!pin)
17126 return 0;
17127
Takashi Iwai24fb9172008-09-02 14:48:20 +020017128 if (pin == 0x17) {
17129 /* ALC663 has a mono output pin on 0x17 */
17130 sprintf(name, "%s Playback Switch", pfx);
17131 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17132 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
17133 return err;
17134 }
17135
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017136 if (alc880_is_fixed_pin(pin)) {
17137 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010017138 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017139 /* specify the DAC as the extra output */
17140 if (!spec->multiout.hp_nid)
17141 spec->multiout.hp_nid = nid;
17142 else
17143 spec->multiout.extra_out_nid[0] = nid;
17144 /* control HP volume/switch on the output mixer amp */
17145 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17146 sprintf(name, "%s Playback Volume", pfx);
17147 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
17148 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
17149 if (err < 0)
17150 return err;
17151 sprintf(name, "%s Playback Switch", pfx);
17152 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
17153 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
17154 if (err < 0)
17155 return err;
17156 } else if (alc880_is_multi_pin(pin)) {
17157 /* set manual connection */
17158 /* we have only a switch on HP-out PIN */
17159 sprintf(name, "%s Playback Switch", pfx);
17160 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17161 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17162 if (err < 0)
17163 return err;
17164 }
17165 return 0;
17166}
17167
17168/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017169#define alc662_auto_create_input_ctls \
17170 alc880_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017171
17172static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17173 hda_nid_t nid, int pin_type,
17174 int dac_idx)
17175{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017176 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017177 /* need the manual connection? */
17178 if (alc880_is_multi_pin(nid)) {
17179 struct alc_spec *spec = codec->spec;
17180 int idx = alc880_multi_pin_idx(nid);
17181 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
17182 AC_VERB_SET_CONNECT_SEL,
17183 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
17184 }
17185}
17186
17187static void alc662_auto_init_multi_out(struct hda_codec *codec)
17188{
17189 struct alc_spec *spec = codec->spec;
17190 int i;
17191
17192 for (i = 0; i <= HDA_SIDE; i++) {
17193 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017194 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017195 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017196 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017197 i);
17198 }
17199}
17200
17201static void alc662_auto_init_hp_out(struct hda_codec *codec)
17202{
17203 struct alc_spec *spec = codec->spec;
17204 hda_nid_t pin;
17205
17206 pin = spec->autocfg.hp_pins[0];
17207 if (pin) /* connect to front */
17208 /* use dac 0 */
17209 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017210 pin = spec->autocfg.speaker_pins[0];
17211 if (pin)
17212 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017213}
17214
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017215#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17216
17217static void alc662_auto_init_analog_input(struct hda_codec *codec)
17218{
17219 struct alc_spec *spec = codec->spec;
17220 int i;
17221
17222 for (i = 0; i < AUTO_PIN_LAST; i++) {
17223 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020017224 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017225 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017226 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017227 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017228 snd_hda_codec_write(codec, nid, 0,
17229 AC_VERB_SET_AMP_GAIN_MUTE,
17230 AMP_OUT_MUTE);
17231 }
17232 }
17233}
17234
Takashi Iwaif511b012008-08-15 16:46:42 +020017235#define alc662_auto_init_input_src alc882_auto_init_input_src
17236
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017237static int alc662_parse_auto_config(struct hda_codec *codec)
17238{
17239 struct alc_spec *spec = codec->spec;
17240 int err;
17241 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17242
17243 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17244 alc662_ignore);
17245 if (err < 0)
17246 return err;
17247 if (!spec->autocfg.line_outs)
17248 return 0; /* can't find valid BIOS pin config */
17249
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017250 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17251 if (err < 0)
17252 return err;
17253 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
17254 if (err < 0)
17255 return err;
17256 err = alc662_auto_create_extra_out(spec,
17257 spec->autocfg.speaker_pins[0],
17258 "Speaker");
17259 if (err < 0)
17260 return err;
17261 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
17262 "Headphone");
17263 if (err < 0)
17264 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017265 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017266 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017267 return err;
17268
17269 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17270
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017271 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017272 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17273
Takashi Iwai603c4012008-07-30 15:01:44 +020017274 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017275 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017276
17277 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017278 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017279
Takashi Iwaid88897e2008-10-31 15:01:37 +010017280 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017281 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017282 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017283
17284 err = alc_auto_add_mic_boost(codec);
17285 if (err < 0)
17286 return err;
17287
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017288 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17289
Takashi Iwai8c872862007-06-19 12:11:16 +020017290 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017291}
17292
17293/* additional initialization for auto-configuration model */
17294static void alc662_auto_init(struct hda_codec *codec)
17295{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017296 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017297 alc662_auto_init_multi_out(codec);
17298 alc662_auto_init_hp_out(codec);
17299 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017300 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017301 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017302 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017303}
17304
17305static int patch_alc662(struct hda_codec *codec)
17306{
17307 struct alc_spec *spec;
17308 int err, board_config;
17309
17310 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17311 if (!spec)
17312 return -ENOMEM;
17313
17314 codec->spec = spec;
17315
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017316 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17317
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017318 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17319 alc662_models,
17320 alc662_cfg_tbl);
17321 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017322 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17323 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017324 board_config = ALC662_AUTO;
17325 }
17326
17327 if (board_config == ALC662_AUTO) {
17328 /* automatic parse from the BIOS config */
17329 err = alc662_parse_auto_config(codec);
17330 if (err < 0) {
17331 alc_free(codec);
17332 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020017333 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017334 printk(KERN_INFO
17335 "hda_codec: Cannot set up configuration "
17336 "from BIOS. Using base mode...\n");
17337 board_config = ALC662_3ST_2ch_DIG;
17338 }
17339 }
17340
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017341 err = snd_hda_attach_beep_device(codec, 0x1);
17342 if (err < 0) {
17343 alc_free(codec);
17344 return err;
17345 }
17346
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017347 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017348 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017349
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017350 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17351 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17352
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017353 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17354 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17355
Takashi Iwaidd704692009-08-11 08:45:11 +020017356 if (!spec->adc_nids) {
17357 spec->adc_nids = alc662_adc_nids;
17358 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17359 }
17360 if (!spec->capsrc_nids)
17361 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017362
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017363 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017364 set_capture_mixer(codec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017365 if (codec->vendor_id == 0x10ec0662)
17366 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17367 else
17368 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017369
Takashi Iwai2134ea42008-01-10 16:53:55 +010017370 spec->vmaster_nid = 0x02;
17371
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017372 codec->patch_ops = alc_patch_ops;
17373 if (board_config == ALC662_AUTO)
17374 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017375#ifdef CONFIG_SND_HDA_POWER_SAVE
17376 if (!spec->loopback.amplist)
17377 spec->loopback.amplist = alc662_loopbacks;
17378#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017379 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017380
17381 return 0;
17382}
17383
17384/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017385 * patch entries
17386 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017387static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017388 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017389 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017390 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017391 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017392 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017393 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017394 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017395 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017396 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17397 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17398 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017399 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017400 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017401 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17402 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017403 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017404 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017405 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017406 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020017407 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017408 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020017409 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017410 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017411 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017412 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020017413 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017414 .patch = patch_alc882 },
17415 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
17416 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017417 {} /* terminator */
17418};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017419
17420MODULE_ALIAS("snd-hda-codec-id:10ec*");
17421
17422MODULE_LICENSE("GPL");
17423MODULE_DESCRIPTION("Realtek HD-audio codec");
17424
17425static struct hda_codec_preset_list realtek_list = {
17426 .preset = snd_hda_preset_realtek,
17427 .owner = THIS_MODULE,
17428};
17429
17430static int __init patch_realtek_init(void)
17431{
17432 return snd_hda_add_codec_preset(&realtek_list);
17433}
17434
17435static void __exit patch_realtek_exit(void)
17436{
17437 snd_hda_delete_codec_preset(&realtek_list);
17438}
17439
17440module_init(patch_realtek_init)
17441module_exit(patch_realtek_exit)