blob: 11b989bacd3c936e124faa5528fd859dfac65aa9 [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 Yangebb83ee2009-12-17 12:23:00 +0100134 ALC269_ASUS_AMIC,
135 ALC269_ASUS_DMIC,
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 Yangebb83ee2009-12-17 12:23:00 +0100191 ALC663_ASUS_MODE7,
192 ALC663_ASUS_MODE8,
Kailang Yang622e84c2009-04-21 07:39:04 +0200193 ALC272_DELL,
194 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200195 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200196 ALC662_AUTO,
197 ALC662_MODEL_LAST,
198};
199
Kailang Yangdf694da2005-12-05 19:42:22 +0100200/* ALC882 models */
201enum {
202 ALC882_3ST_DIG,
203 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200204 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200205 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200206 ALC882_TARGA,
207 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200208 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100209 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200210 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200211 ALC885_MB5,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200212 ALC885_IMAC24,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -0800213 ALC885_IMAC91,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200214 ALC883_3ST_2ch_DIG,
215 ALC883_3ST_6ch_DIG,
216 ALC883_3ST_6ch,
217 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200218 ALC883_TARGA_DIG,
219 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200220 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200221 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200222 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800223 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100224 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200225 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200226 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200227 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200228 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100229 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200230 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200231 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200232 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200233 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200234 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200235 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100236 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100237 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430238 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100239 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100240 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800241 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200242 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200243 ALC889A_INTEL,
244 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200245 ALC888_ASUS_M90V,
246 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200247 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100248 ALC1200_ASUS_P5Q,
Guido Günther3e1647c52009-06-05 00:47:26 +0200249 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200250 ALC882_AUTO,
251 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200252};
253
Kailang Yangdf694da2005-12-05 19:42:22 +0100254/* for GPIO Poll */
255#define GPIO_MASK 0x03
256
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200257/* extra amp-initialization sequence types */
258enum {
259 ALC_INIT_NONE,
260 ALC_INIT_DEFAULT,
261 ALC_INIT_GPIO1,
262 ALC_INIT_GPIO2,
263 ALC_INIT_GPIO3,
264};
265
Takashi Iwai6c819492009-08-10 18:47:44 +0200266struct alc_mic_route {
267 hda_nid_t pin;
268 unsigned char mux_idx;
269 unsigned char amix_idx;
270};
271
272#define MUX_IDX_UNDEF ((unsigned char)-1)
273
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274struct alc_spec {
275 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100276 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100278 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100279 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200281 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200282 * don't forget NULL
283 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200284 */
285 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200287 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 struct hda_pcm_stream *stream_analog_playback;
289 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100290 struct hda_pcm_stream *stream_analog_alt_playback;
291 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200293 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 struct hda_pcm_stream *stream_digital_playback;
295 struct hda_pcm_stream *stream_digital_capture;
296
297 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200298 struct hda_multi_out multiout; /* playback set-up
299 * max_channels, dacs must be set
300 * dig_out_nid and hp_nid are optional
301 */
Takashi Iwai63300792008-01-24 15:31:36 +0100302 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100303 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100304 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305
306 /* capture */
307 unsigned int num_adc_nids;
308 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100309 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200310 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311
312 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200313 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314 const struct hda_input_mux *input_mux;
315 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200316 struct alc_mic_route ext_mic;
317 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318
319 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100320 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200322 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200323 int const_channel_count;
324 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325
326 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100327 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200328
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200329 /* dynamic controls, init_verbs and input_mux */
330 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200331 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200332 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200333 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200334 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
335 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100336
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100337 /* hooks */
338 void (*init_hook)(struct hda_codec *codec);
339 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100340#ifdef CONFIG_SND_HDA_POWER_SAVE
341 void (*power_hook)(struct hda_codec *codec, int power);
342#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100343
Takashi Iwai834be882006-03-01 14:16:17 +0100344 /* for pin sensing */
345 unsigned int sense_updated: 1;
346 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100347 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200348 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200349
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100350 /* other flags */
351 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200352 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100353
Takashi Iwai2134ea42008-01-10 16:53:55 +0100354 /* for virtual master */
355 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200356#ifdef CONFIG_SND_HDA_POWER_SAVE
357 struct hda_loopback_check loopback;
358#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200359
360 /* for PLL fix */
361 hda_nid_t pll_nid;
362 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100363};
364
365/*
366 * configuration template - to be copied to the spec instance
367 */
368struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200369 struct snd_kcontrol_new *mixers[5]; /* should be identical size
370 * with spec
371 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100372 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100373 const struct hda_verb *init_verbs[5];
374 unsigned int num_dacs;
375 hda_nid_t *dac_nids;
376 hda_nid_t dig_out_nid; /* optional */
377 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800378 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100379 unsigned int num_adc_nids;
380 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100381 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100382 hda_nid_t dig_in_nid;
383 unsigned int num_channel_mode;
384 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200385 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200386 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200387 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100388 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100389 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200390 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100391 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200392#ifdef CONFIG_SND_HDA_POWER_SAVE
393 struct hda_amp_list *loopbacks;
Hector Martinf5de24b2009-12-20 22:51:31 +0100394 void (*power_hook)(struct hda_codec *codec, int power);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200395#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396};
397
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398
399/*
400 * input MUX handling
401 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200402static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
403 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404{
405 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
406 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200407 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
408 if (mux_idx >= spec->num_mux_defs)
409 mux_idx = 0;
410 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411}
412
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200413static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
414 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415{
416 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
417 struct alc_spec *spec = codec->spec;
418 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
419
420 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
421 return 0;
422}
423
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200424static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
425 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426{
427 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
428 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100429 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100431 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100432 hda_nid_t nid = spec->capsrc_nids ?
433 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200434 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435
Takashi Iwaicd896c32008-11-18 12:36:33 +0100436 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
437 imux = &spec->input_mux[mux_idx];
438
Takashi Iwaia22d5432009-07-27 12:54:26 +0200439 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200440 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100441 /* Matrix-mixer style (e.g. ALC882) */
442 unsigned int *cur_val = &spec->cur_mux[adc_idx];
443 unsigned int i, idx;
444
445 idx = ucontrol->value.enumerated.item[0];
446 if (idx >= imux->num_items)
447 idx = imux->num_items - 1;
448 if (*cur_val == idx)
449 return 0;
450 for (i = 0; i < imux->num_items; i++) {
451 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
452 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
453 imux->items[i].index,
454 HDA_AMP_MUTE, v);
455 }
456 *cur_val = idx;
457 return 1;
458 } else {
459 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100460 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100461 &spec->cur_mux[adc_idx]);
462 }
463}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200464
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465/*
466 * channel mode setting
467 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200468static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
469 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470{
471 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
472 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100473 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
474 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475}
476
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200477static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
478 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479{
480 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
481 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100482 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200483 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200484 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485}
486
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200487static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
488 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489{
490 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
491 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200492 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
493 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200494 &spec->ext_channel_count);
495 if (err >= 0 && !spec->const_channel_count) {
496 spec->multiout.max_channels = spec->ext_channel_count;
497 if (spec->need_dac_fix)
498 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
499 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200500 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501}
502
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100504 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200505 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100506 * being part of a format specifier. Maximum allowed length of a value is
507 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100508 *
509 * Note: some retasking pin complexes seem to ignore requests for input
510 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
511 * are requested. Therefore order this list so that this behaviour will not
512 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200513 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
514 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200515 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100516static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100517 "Mic 50pc bias", "Mic 80pc bias",
518 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100519};
520static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100521 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100522};
523/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200524 * in the pin being assumed to be exclusively an input or an output pin. In
525 * addition, "input" pins may or may not process the mic bias option
526 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
527 * accept requests for bias as of chip versions up to March 2006) and/or
528 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100529 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200530#define ALC_PIN_DIR_IN 0x00
531#define ALC_PIN_DIR_OUT 0x01
532#define ALC_PIN_DIR_INOUT 0x02
533#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
534#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100535
Kailang Yangea1fb292008-08-26 12:58:38 +0200536/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100537 * For each direction the minimum and maximum values are given.
538 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200539static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100540 { 0, 2 }, /* ALC_PIN_DIR_IN */
541 { 3, 4 }, /* ALC_PIN_DIR_OUT */
542 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200543 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
544 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100545};
546#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
547#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
548#define alc_pin_mode_n_items(_dir) \
549 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
550
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200551static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
552 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200553{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100554 unsigned int item_num = uinfo->value.enumerated.item;
555 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
556
557 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200558 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100559 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
560
561 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
562 item_num = alc_pin_mode_min(dir);
563 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200564 return 0;
565}
566
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200567static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
568 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200569{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100570 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200571 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
572 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100573 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200574 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200575 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
576 AC_VERB_GET_PIN_WIDGET_CONTROL,
577 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200578
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100579 /* Find enumerated value for current pinctl setting */
580 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200581 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100582 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200583 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100584 return 0;
585}
586
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200587static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
588 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100589{
590 signed int change;
591 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
592 hda_nid_t nid = kcontrol->private_value & 0xffff;
593 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
594 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200595 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
596 AC_VERB_GET_PIN_WIDGET_CONTROL,
597 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100598
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200599 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100600 val = alc_pin_mode_min(dir);
601
602 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100603 if (change) {
604 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200605 snd_hda_codec_write_cache(codec, nid, 0,
606 AC_VERB_SET_PIN_WIDGET_CONTROL,
607 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100608
Kailang Yangea1fb292008-08-26 12:58:38 +0200609 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100610 * for the requested pin mode. Enum values of 2 or less are
611 * input modes.
612 *
613 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200614 * reduces noise slightly (particularly on input) so we'll
615 * do it. However, having both input and output buffers
616 * enabled simultaneously doesn't seem to be problematic if
617 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100618 */
619 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200620 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
621 HDA_AMP_MUTE, HDA_AMP_MUTE);
622 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
623 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100624 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200625 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
626 HDA_AMP_MUTE, HDA_AMP_MUTE);
627 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
628 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100629 }
630 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200631 return change;
632}
633
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100634#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200635 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100636 .info = alc_pin_mode_info, \
637 .get = alc_pin_mode_get, \
638 .put = alc_pin_mode_put, \
639 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100640
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100641/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
642 * together using a mask with more than one bit set. This control is
643 * currently used only by the ALC260 test model. At this stage they are not
644 * needed for any "production" models.
645 */
646#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200647#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200648
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200649static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
650 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100651{
652 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
653 hda_nid_t nid = kcontrol->private_value & 0xffff;
654 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
655 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200656 unsigned int val = snd_hda_codec_read(codec, nid, 0,
657 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100658
659 *valp = (val & mask) != 0;
660 return 0;
661}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200662static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
663 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100664{
665 signed int change;
666 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
667 hda_nid_t nid = kcontrol->private_value & 0xffff;
668 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
669 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200670 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
671 AC_VERB_GET_GPIO_DATA,
672 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100673
674 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200675 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
676 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100677 gpio_data &= ~mask;
678 else
679 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200680 snd_hda_codec_write_cache(codec, nid, 0,
681 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100682
683 return change;
684}
685#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
686 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
687 .info = alc_gpio_data_info, \
688 .get = alc_gpio_data_get, \
689 .put = alc_gpio_data_put, \
690 .private_value = nid | (mask<<16) }
691#endif /* CONFIG_SND_DEBUG */
692
Jonathan Woithe92621f12006-02-28 11:47:47 +0100693/* A switch control to allow the enabling of the digital IO pins on the
694 * ALC260. This is incredibly simplistic; the intention of this control is
695 * to provide something in the test model allowing digital outputs to be
696 * identified if present. If models are found which can utilise these
697 * outputs a more complete mixer control can be devised for those models if
698 * necessary.
699 */
700#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200701#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200702
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200703static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
704 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100705{
706 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
707 hda_nid_t nid = kcontrol->private_value & 0xffff;
708 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
709 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200710 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100711 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100712
713 *valp = (val & mask) != 0;
714 return 0;
715}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200716static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
717 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100718{
719 signed int change;
720 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
721 hda_nid_t nid = kcontrol->private_value & 0xffff;
722 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
723 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200724 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100725 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200726 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100727
728 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200729 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100730 if (val==0)
731 ctrl_data &= ~mask;
732 else
733 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200734 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
735 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100736
737 return change;
738}
739#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
740 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
741 .info = alc_spdif_ctrl_info, \
742 .get = alc_spdif_ctrl_get, \
743 .put = alc_spdif_ctrl_put, \
744 .private_value = nid | (mask<<16) }
745#endif /* CONFIG_SND_DEBUG */
746
Jonathan Woithef8225f62008-01-08 12:16:54 +0100747/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
748 * Again, this is only used in the ALC26x test models to help identify when
749 * the EAPD line must be asserted for features to work.
750 */
751#ifdef CONFIG_SND_DEBUG
752#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
753
754static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
755 struct snd_ctl_elem_value *ucontrol)
756{
757 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
758 hda_nid_t nid = kcontrol->private_value & 0xffff;
759 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
760 long *valp = ucontrol->value.integer.value;
761 unsigned int val = snd_hda_codec_read(codec, nid, 0,
762 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
763
764 *valp = (val & mask) != 0;
765 return 0;
766}
767
768static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
769 struct snd_ctl_elem_value *ucontrol)
770{
771 int change;
772 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
773 hda_nid_t nid = kcontrol->private_value & 0xffff;
774 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
775 long val = *ucontrol->value.integer.value;
776 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
777 AC_VERB_GET_EAPD_BTLENABLE,
778 0x00);
779
780 /* Set/unset the masked control bit(s) as needed */
781 change = (!val ? 0 : mask) != (ctrl_data & mask);
782 if (!val)
783 ctrl_data &= ~mask;
784 else
785 ctrl_data |= mask;
786 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
787 ctrl_data);
788
789 return change;
790}
791
792#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
793 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
794 .info = alc_eapd_ctrl_info, \
795 .get = alc_eapd_ctrl_get, \
796 .put = alc_eapd_ctrl_put, \
797 .private_value = nid | (mask<<16) }
798#endif /* CONFIG_SND_DEBUG */
799
Kailang Yangdf694da2005-12-05 19:42:22 +0100800/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100801 * set up the input pin config (depending on the given auto-pin type)
802 */
803static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
804 int auto_pin_type)
805{
806 unsigned int val = PIN_IN;
807
808 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
809 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100810 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100811 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
812 if (pincap & AC_PINCAP_VREF_80)
813 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200814 else if (pincap & AC_PINCAP_VREF_50)
815 val = PIN_VREF50;
816 else if (pincap & AC_PINCAP_VREF_100)
817 val = PIN_VREF100;
818 else if (pincap & AC_PINCAP_VREF_GRD)
819 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100820 }
821 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
822}
823
824/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100825 */
826static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
827{
828 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
829 return;
830 spec->mixers[spec->num_mixers++] = mix;
831}
832
833static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
834{
835 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
836 return;
837 spec->init_verbs[spec->num_init_verbs++] = verb;
838}
839
Takashi Iwaidaead532008-11-28 12:55:36 +0100840#ifdef CONFIG_PROC_FS
841/*
842 * hook for proc
843 */
844static void print_realtek_coef(struct snd_info_buffer *buffer,
845 struct hda_codec *codec, hda_nid_t nid)
846{
847 int coeff;
848
849 if (nid != 0x20)
850 return;
851 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
852 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
853 coeff = snd_hda_codec_read(codec, nid, 0,
854 AC_VERB_GET_COEF_INDEX, 0);
855 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
856}
857#else
858#define print_realtek_coef NULL
859#endif
860
Takashi Iwaid88897e2008-10-31 15:01:37 +0100861/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100862 * set up from the preset table
863 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200864static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200865 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100866{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200867 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100868 int i;
869
870 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100871 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100872 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200873 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
874 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100875 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200876
Kailang Yangdf694da2005-12-05 19:42:22 +0100877 spec->channel_mode = preset->channel_mode;
878 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200879 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200880 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100881
Hector Martin3b315d72009-06-02 10:54:19 +0200882 if (preset->const_channel_count)
883 spec->multiout.max_channels = preset->const_channel_count;
884 else
885 spec->multiout.max_channels = spec->channel_mode[0].channels;
886 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100887
888 spec->multiout.num_dacs = preset->num_dacs;
889 spec->multiout.dac_nids = preset->dac_nids;
890 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800891 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100892 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200893
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200894 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200895 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200896 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100897 spec->input_mux = preset->input_mux;
898
899 spec->num_adc_nids = preset->num_adc_nids;
900 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100901 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100902 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100903
904 spec->unsol_event = preset->unsol_event;
905 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200906#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100907 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200908 spec->loopback.amplist = preset->loopbacks;
909#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200910
911 if (preset->setup)
912 preset->setup(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100913}
914
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200915/* Enable GPIO mask and set output */
916static struct hda_verb alc_gpio1_init_verbs[] = {
917 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
918 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
919 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
920 { }
921};
922
923static struct hda_verb alc_gpio2_init_verbs[] = {
924 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
925 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
926 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
927 { }
928};
929
Kailang Yangbdd148a2007-05-08 15:19:08 +0200930static struct hda_verb alc_gpio3_init_verbs[] = {
931 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
932 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
933 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
934 { }
935};
936
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200937/*
938 * Fix hardware PLL issue
939 * On some codecs, the analog PLL gating control must be off while
940 * the default value is 1.
941 */
942static void alc_fix_pll(struct hda_codec *codec)
943{
944 struct alc_spec *spec = codec->spec;
945 unsigned int val;
946
947 if (!spec->pll_nid)
948 return;
949 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
950 spec->pll_coef_idx);
951 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
952 AC_VERB_GET_PROC_COEF, 0);
953 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
954 spec->pll_coef_idx);
955 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
956 val & ~(1 << spec->pll_coef_bit));
957}
958
959static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
960 unsigned int coef_idx, unsigned int coef_bit)
961{
962 struct alc_spec *spec = codec->spec;
963 spec->pll_nid = nid;
964 spec->pll_coef_idx = coef_idx;
965 spec->pll_coef_bit = coef_bit;
966 alc_fix_pll(codec);
967}
968
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200969static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200970{
971 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200972 unsigned int nid = spec->autocfg.hp_pins[0];
973 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200974
Takashi Iwaiad87c642009-11-02 14:23:15 +0100975 if (!nid)
976 return;
Wu Fengguang864f92b2009-11-18 12:38:02 +0800977 spec->jack_present = snd_hda_jack_detect(codec, nid);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200978 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
979 nid = spec->autocfg.speaker_pins[i];
980 if (!nid)
981 break;
982 snd_hda_codec_write(codec, nid, 0,
983 AC_VERB_SET_PIN_WIDGET_CONTROL,
984 spec->jack_present ? 0 : PIN_OUT);
985 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200986}
987
Takashi Iwai6c819492009-08-10 18:47:44 +0200988static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
989 hda_nid_t nid)
990{
991 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
992 int i, nums;
993
994 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
995 for (i = 0; i < nums; i++)
996 if (conn[i] == nid)
997 return i;
998 return -1;
999}
1000
Kailang Yang7fb0d782008-10-15 11:12:35 +02001001static void alc_mic_automute(struct hda_codec *codec)
1002{
1003 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001004 struct alc_mic_route *dead, *alive;
1005 unsigned int present, type;
1006 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001007
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001008 if (!spec->auto_mic)
1009 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001010 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1011 return;
1012 if (snd_BUG_ON(!spec->adc_nids))
1013 return;
1014
1015 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1016
Wu Fengguang864f92b2009-11-18 12:38:02 +08001017 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001018 if (present) {
1019 alive = &spec->ext_mic;
1020 dead = &spec->int_mic;
1021 } else {
1022 alive = &spec->int_mic;
1023 dead = &spec->ext_mic;
1024 }
1025
Takashi Iwai6c819492009-08-10 18:47:44 +02001026 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1027 if (type == AC_WID_AUD_MIX) {
1028 /* Matrix-mixer style (e.g. ALC882) */
1029 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1030 alive->mux_idx,
1031 HDA_AMP_MUTE, 0);
1032 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1033 dead->mux_idx,
1034 HDA_AMP_MUTE, HDA_AMP_MUTE);
1035 } else {
1036 /* MUX style (e.g. ALC880) */
1037 snd_hda_codec_write_cache(codec, cap_nid, 0,
1038 AC_VERB_SET_CONNECT_SEL,
1039 alive->mux_idx);
1040 }
1041
1042 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001043}
1044
Kailang Yangc9b58002007-10-16 14:30:01 +02001045/* unsolicited event for HP jack sensing */
1046static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1047{
1048 if (codec->vendor_id == 0x10ec0880)
1049 res >>= 28;
1050 else
1051 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001052 switch (res) {
1053 case ALC880_HP_EVENT:
1054 alc_automute_pin(codec);
1055 break;
1056 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001057 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001058 break;
1059 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001060}
1061
1062static void alc_inithook(struct hda_codec *codec)
1063{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001064 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001065 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001066}
1067
Kailang Yangf9423e72008-05-27 12:32:25 +02001068/* additional initialization for ALC888 variants */
1069static void alc888_coef_init(struct hda_codec *codec)
1070{
1071 unsigned int tmp;
1072
1073 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1074 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1075 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001076 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001077 /* alc888S-VC */
1078 snd_hda_codec_read(codec, 0x20, 0,
1079 AC_VERB_SET_PROC_COEF, 0x830);
1080 else
1081 /* alc888-VB */
1082 snd_hda_codec_read(codec, 0x20, 0,
1083 AC_VERB_SET_PROC_COEF, 0x3030);
1084}
1085
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001086static void alc889_coef_init(struct hda_codec *codec)
1087{
1088 unsigned int tmp;
1089
1090 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1091 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1092 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1093 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1094}
1095
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001096static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001097{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001098 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001099
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001100 switch (type) {
1101 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001102 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1103 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001104 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001105 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1106 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001107 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001108 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1109 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001110 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001111 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001112 case 0x10ec0260:
1113 snd_hda_codec_write(codec, 0x0f, 0,
1114 AC_VERB_SET_EAPD_BTLENABLE, 2);
1115 snd_hda_codec_write(codec, 0x10, 0,
1116 AC_VERB_SET_EAPD_BTLENABLE, 2);
1117 break;
1118 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001119 case 0x10ec0267:
1120 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001121 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001122 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001123 case 0x10ec0660:
1124 case 0x10ec0662:
1125 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001126 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001127 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001128 snd_hda_codec_write(codec, 0x14, 0,
1129 AC_VERB_SET_EAPD_BTLENABLE, 2);
1130 snd_hda_codec_write(codec, 0x15, 0,
1131 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001132 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001133 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001134 switch (codec->vendor_id) {
1135 case 0x10ec0260:
1136 snd_hda_codec_write(codec, 0x1a, 0,
1137 AC_VERB_SET_COEF_INDEX, 7);
1138 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1139 AC_VERB_GET_PROC_COEF, 0);
1140 snd_hda_codec_write(codec, 0x1a, 0,
1141 AC_VERB_SET_COEF_INDEX, 7);
1142 snd_hda_codec_write(codec, 0x1a, 0,
1143 AC_VERB_SET_PROC_COEF,
1144 tmp | 0x2010);
1145 break;
1146 case 0x10ec0262:
1147 case 0x10ec0880:
1148 case 0x10ec0882:
1149 case 0x10ec0883:
1150 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001151 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001152 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001153 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001154 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001155 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001156 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001157 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001158 case 0x10ec0267:
1159 case 0x10ec0268:
1160 snd_hda_codec_write(codec, 0x20, 0,
1161 AC_VERB_SET_COEF_INDEX, 7);
1162 tmp = snd_hda_codec_read(codec, 0x20, 0,
1163 AC_VERB_GET_PROC_COEF, 0);
1164 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001165 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001166 snd_hda_codec_write(codec, 0x20, 0,
1167 AC_VERB_SET_PROC_COEF,
1168 tmp | 0x3000);
1169 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001170 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001171 break;
1172 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001173}
Kailang Yangea1fb292008-08-26 12:58:38 +02001174
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001175static void alc_init_auto_hp(struct hda_codec *codec)
1176{
1177 struct alc_spec *spec = codec->spec;
1178
1179 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001180 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001181
Kailang Yangc9b58002007-10-16 14:30:01 +02001182 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001183 if (spec->autocfg.line_out_pins[0] &&
1184 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001185 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001186 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001187 else
1188 return;
1189 }
1190
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001191 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1192 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001193 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1194 AC_VERB_SET_UNSOLICITED_ENABLE,
1195 AC_USRSP_EN | ALC880_HP_EVENT);
1196 spec->unsol_event = alc_sku_unsol_event;
1197}
1198
Takashi Iwai6c819492009-08-10 18:47:44 +02001199static void alc_init_auto_mic(struct hda_codec *codec)
1200{
1201 struct alc_spec *spec = codec->spec;
1202 struct auto_pin_cfg *cfg = &spec->autocfg;
1203 hda_nid_t fixed, ext;
1204 int i;
1205
1206 /* there must be only two mic inputs exclusively */
1207 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1208 if (cfg->input_pins[i])
1209 return;
1210
1211 fixed = ext = 0;
1212 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1213 hda_nid_t nid = cfg->input_pins[i];
1214 unsigned int defcfg;
1215 if (!nid)
1216 return;
1217 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1218 switch (get_defcfg_connect(defcfg)) {
1219 case AC_JACK_PORT_FIXED:
1220 if (fixed)
1221 return; /* already occupied */
1222 fixed = nid;
1223 break;
1224 case AC_JACK_PORT_COMPLEX:
1225 if (ext)
1226 return; /* already occupied */
1227 ext = nid;
1228 break;
1229 default:
1230 return; /* invalid entry */
1231 }
1232 }
1233 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1234 return; /* no unsol support */
1235 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1236 ext, fixed);
1237 spec->ext_mic.pin = ext;
1238 spec->int_mic.pin = fixed;
1239 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1240 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1241 spec->auto_mic = 1;
1242 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1243 AC_VERB_SET_UNSOLICITED_ENABLE,
1244 AC_USRSP_EN | ALC880_MIC_EVENT);
1245 spec->unsol_event = alc_sku_unsol_event;
1246}
1247
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001248/* check subsystem ID and set up device-specific initialization;
1249 * return 1 if initialized, 0 if invalid SSID
1250 */
1251/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1252 * 31 ~ 16 : Manufacture ID
1253 * 15 ~ 8 : SKU ID
1254 * 7 ~ 0 : Assembly ID
1255 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1256 */
1257static int alc_subsystem_id(struct hda_codec *codec,
1258 hda_nid_t porta, hda_nid_t porte,
1259 hda_nid_t portd)
1260{
1261 unsigned int ass, tmp, i;
1262 unsigned nid;
1263 struct alc_spec *spec = codec->spec;
1264
1265 ass = codec->subsystem_id & 0xffff;
1266 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1267 goto do_sku;
1268
1269 /* invalid SSID, check the special NID pin defcfg instead */
1270 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001271 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001272 * 29~21 : reserve
1273 * 20 : PCBEEP input
1274 * 19~16 : Check sum (15:1)
1275 * 15~1 : Custom
1276 * 0 : override
1277 */
1278 nid = 0x1d;
1279 if (codec->vendor_id == 0x10ec0260)
1280 nid = 0x17;
1281 ass = snd_hda_codec_get_pincfg(codec, nid);
1282 snd_printd("realtek: No valid SSID, "
1283 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001284 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001285 if (!(ass & 1) && !(ass & 0x100000))
1286 return 0;
1287 if ((ass >> 30) != 1) /* no physical connection */
1288 return 0;
1289
1290 /* check sum */
1291 tmp = 0;
1292 for (i = 1; i < 16; i++) {
1293 if ((ass >> i) & 1)
1294 tmp++;
1295 }
1296 if (((ass >> 16) & 0xf) != tmp)
1297 return 0;
1298do_sku:
1299 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1300 ass & 0xffff, codec->vendor_id);
1301 /*
1302 * 0 : override
1303 * 1 : Swap Jack
1304 * 2 : 0 --> Desktop, 1 --> Laptop
1305 * 3~5 : External Amplifier control
1306 * 7~6 : Reserved
1307 */
1308 tmp = (ass & 0x38) >> 3; /* external Amp control */
1309 switch (tmp) {
1310 case 1:
1311 spec->init_amp = ALC_INIT_GPIO1;
1312 break;
1313 case 3:
1314 spec->init_amp = ALC_INIT_GPIO2;
1315 break;
1316 case 7:
1317 spec->init_amp = ALC_INIT_GPIO3;
1318 break;
1319 case 5:
1320 spec->init_amp = ALC_INIT_DEFAULT;
1321 break;
1322 }
1323
1324 /* is laptop or Desktop and enable the function "Mute internal speaker
1325 * when the external headphone out jack is plugged"
1326 */
1327 if (!(ass & 0x8000))
1328 return 1;
1329 /*
1330 * 10~8 : Jack location
1331 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1332 * 14~13: Resvered
1333 * 15 : 1 --> enable the function "Mute internal speaker
1334 * when the external headphone out jack is plugged"
1335 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001336 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001337 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001338 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1339 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001340 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001341 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001342 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001343 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001344 nid = portd;
Kailang Yangc9b58002007-10-16 14:30:01 +02001345 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001346 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001347 for (i = 0; i < spec->autocfg.line_outs; i++)
1348 if (spec->autocfg.line_out_pins[i] == nid)
1349 return 1;
1350 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001351 }
1352
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001353 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001354 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001355 return 1;
1356}
Kailang Yangea1fb292008-08-26 12:58:38 +02001357
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001358static void alc_ssid_check(struct hda_codec *codec,
1359 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1360{
1361 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1362 struct alc_spec *spec = codec->spec;
1363 snd_printd("realtek: "
1364 "Enable default setup for auto mode as fallback\n");
1365 spec->init_amp = ALC_INIT_DEFAULT;
1366 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001367 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001368 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001369}
1370
Takashi Iwai41e41f12005-06-08 14:48:49 +02001371/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001372 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001373 */
1374
1375struct alc_pincfg {
1376 hda_nid_t nid;
1377 u32 val;
1378};
1379
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001380struct alc_fixup {
1381 const struct alc_pincfg *pins;
1382 const struct hda_verb *verbs;
1383};
1384
1385static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001386 const struct snd_pci_quirk *quirk,
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001387 const struct alc_fixup *fix)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001388{
1389 const struct alc_pincfg *cfg;
1390
1391 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1392 if (!quirk)
1393 return;
1394
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001395 fix += quirk->value;
1396 cfg = fix->pins;
1397 if (cfg) {
1398 for (; cfg->nid; cfg++)
1399 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1400 }
1401 if (fix->verbs)
1402 add_verb(codec->spec, fix->verbs);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001403}
1404
Kailang Yang274693f2009-12-03 10:07:50 +01001405static int alc_read_coef_idx(struct hda_codec *codec,
1406 unsigned int coef_idx)
1407{
1408 unsigned int val;
1409 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1410 coef_idx);
1411 val = snd_hda_codec_read(codec, 0x20, 0,
1412 AC_VERB_GET_PROC_COEF, 0);
1413 return val;
1414}
1415
Takashi Iwaif95474e2007-07-10 00:47:43 +02001416/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001417 * ALC888
1418 */
1419
1420/*
1421 * 2ch mode
1422 */
1423static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1424/* Mic-in jack as mic in */
1425 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1426 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1427/* Line-in jack as Line in */
1428 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1429 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1430/* Line-Out as Front */
1431 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1432 { } /* end */
1433};
1434
1435/*
1436 * 4ch mode
1437 */
1438static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1439/* Mic-in jack as mic in */
1440 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1441 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1442/* Line-in jack as Surround */
1443 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1444 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1445/* Line-Out as Front */
1446 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1447 { } /* end */
1448};
1449
1450/*
1451 * 6ch mode
1452 */
1453static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1454/* Mic-in jack as CLFE */
1455 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1456 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1457/* Line-in jack as Surround */
1458 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1459 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1460/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1461 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1462 { } /* end */
1463};
1464
1465/*
1466 * 8ch mode
1467 */
1468static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1469/* Mic-in jack as CLFE */
1470 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1471 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1472/* Line-in jack as Surround */
1473 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1474 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1475/* Line-Out as Side */
1476 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1477 { } /* end */
1478};
1479
1480static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1481 { 2, alc888_4ST_ch2_intel_init },
1482 { 4, alc888_4ST_ch4_intel_init },
1483 { 6, alc888_4ST_ch6_intel_init },
1484 { 8, alc888_4ST_ch8_intel_init },
1485};
1486
1487/*
1488 * ALC888 Fujitsu Siemens Amillo xa3530
1489 */
1490
1491static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1492/* Front Mic: set to PIN_IN (empty by default) */
1493 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1494/* Connect Internal HP to Front */
1495 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1496 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1497 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1498/* Connect Bass HP to Front */
1499 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1500 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1501 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1502/* Connect Line-Out side jack (SPDIF) to Side */
1503 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1504 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1505 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1506/* Connect Mic jack to CLFE */
1507 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1508 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1509 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1510/* Connect Line-in jack to Surround */
1511 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1512 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1513 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1514/* Connect HP out jack to Front */
1515 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1516 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1517 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1518/* Enable unsolicited event for HP jack and Line-out jack */
1519 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1520 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1521 {}
1522};
1523
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001524static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001525{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001526 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001527 unsigned int mute;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001528 hda_nid_t nid;
1529 int i;
1530
1531 spec->jack_present = 0;
1532 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1533 nid = spec->autocfg.hp_pins[i];
1534 if (!nid)
1535 break;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001536 if (snd_hda_jack_detect(codec, nid)) {
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001537 spec->jack_present = 1;
1538 break;
1539 }
1540 }
1541
1542 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001543 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001544 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1545 nid = spec->autocfg.speaker_pins[i];
1546 if (!nid)
1547 break;
1548 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1549 HDA_AMP_MUTE, mute);
1550 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001551}
1552
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001553static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1554 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001555{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001556 if (codec->vendor_id == 0x10ec0880)
1557 res >>= 28;
1558 else
1559 res >>= 26;
1560 if (res == ALC880_HP_EVENT)
1561 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001562}
1563
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001564static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001565{
1566 struct alc_spec *spec = codec->spec;
1567
1568 spec->autocfg.hp_pins[0] = 0x15;
1569 spec->autocfg.speaker_pins[0] = 0x14;
1570 spec->autocfg.speaker_pins[1] = 0x16;
1571 spec->autocfg.speaker_pins[2] = 0x17;
1572 spec->autocfg.speaker_pins[3] = 0x19;
1573 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001574}
1575
1576static void alc889_intel_init_hook(struct hda_codec *codec)
1577{
1578 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001579 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001580}
1581
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001582static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001583{
1584 struct alc_spec *spec = codec->spec;
1585
1586 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1587 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1588 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1589 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001590}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001591
1592/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001593 * ALC888 Acer Aspire 4930G model
1594 */
1595
1596static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1597/* Front Mic: set to PIN_IN (empty by default) */
1598 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1599/* Unselect Front Mic by default in input mixer 3 */
1600 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001601/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001602 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1603/* Connect Internal HP to front */
1604 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1605 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1606 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1607/* Connect HP out to front */
1608 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1609 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1610 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1611 { }
1612};
1613
Hector Martin3b315d72009-06-02 10:54:19 +02001614/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001615 * ALC888 Acer Aspire 6530G model
1616 */
1617
1618static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1619/* Bias voltage on for external mic port */
1620 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001621/* Front Mic: set to PIN_IN (empty by default) */
1622 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1623/* Unselect Front Mic by default in input mixer 3 */
1624 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001625/* Enable unsolicited event for HP jack */
1626 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1627/* Enable speaker output */
1628 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1629 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1630/* Enable headphone output */
1631 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1632 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1633 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1634 { }
1635};
1636
1637/*
Hector Martin018df412009-06-04 00:13:40 +02001638 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001639 */
1640
Hector Martin018df412009-06-04 00:13:40 +02001641static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001642/* Front Mic: set to PIN_IN (empty by default) */
1643 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1644/* Unselect Front Mic by default in input mixer 3 */
1645 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1646/* Enable unsolicited event for HP jack */
1647 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1648/* Connect Internal Front to Front */
1649 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1650 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1651 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1652/* Connect Internal Rear to Rear */
1653 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1654 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1655 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1656/* Connect Internal CLFE to CLFE */
1657 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1658 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1659 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1660/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001661 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001662 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1663 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1664/* Enable all DACs */
1665/* DAC DISABLE/MUTE 1? */
1666/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1667 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1668 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1669/* DAC DISABLE/MUTE 2? */
1670/* some bit here disables the other DACs. Init=0x4900 */
1671 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1672 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02001673/* DMIC fix
1674 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1675 * which makes the stereo useless. However, either the mic or the ALC889
1676 * makes the signal become a difference/sum signal instead of standard
1677 * stereo, which is annoying. So instead we flip this bit which makes the
1678 * codec replicate the sum signal to both channels, turning it into a
1679 * normal mono mic.
1680 */
1681/* DMIC_CONTROL? Init value = 0x0001 */
1682 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1683 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001684 { }
1685};
1686
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001687static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001688 /* Front mic only available on one ADC */
1689 {
1690 .num_items = 4,
1691 .items = {
1692 { "Mic", 0x0 },
1693 { "Line", 0x2 },
1694 { "CD", 0x4 },
1695 { "Front Mic", 0xb },
1696 },
1697 },
1698 {
1699 .num_items = 3,
1700 .items = {
1701 { "Mic", 0x0 },
1702 { "Line", 0x2 },
1703 { "CD", 0x4 },
1704 },
1705 }
1706};
1707
Tony Vroond2fd4b02009-06-21 00:40:10 +01001708static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1709 /* Interal mic only available on one ADC */
1710 {
Tony Vroon684a8842009-06-26 09:27:50 +01001711 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001712 .items = {
1713 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001714 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001715 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001716 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001717 { "Int Mic", 0xb },
1718 },
1719 },
1720 {
Tony Vroon684a8842009-06-26 09:27:50 +01001721 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001722 .items = {
1723 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001724 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001725 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001726 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001727 },
1728 }
1729};
1730
Hector Martin018df412009-06-04 00:13:40 +02001731static struct hda_input_mux alc889_capture_sources[3] = {
1732 /* Digital mic only available on first "ADC" */
1733 {
1734 .num_items = 5,
1735 .items = {
1736 { "Mic", 0x0 },
1737 { "Line", 0x2 },
1738 { "CD", 0x4 },
1739 { "Front Mic", 0xb },
1740 { "Input Mix", 0xa },
1741 },
1742 },
1743 {
1744 .num_items = 4,
1745 .items = {
1746 { "Mic", 0x0 },
1747 { "Line", 0x2 },
1748 { "CD", 0x4 },
1749 { "Input Mix", 0xa },
1750 },
1751 },
1752 {
1753 .num_items = 4,
1754 .items = {
1755 { "Mic", 0x0 },
1756 { "Line", 0x2 },
1757 { "CD", 0x4 },
1758 { "Input Mix", 0xa },
1759 },
1760 }
1761};
1762
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001763static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001764 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1765 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1766 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1767 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1768 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1769 HDA_OUTPUT),
1770 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1771 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1772 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1773 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1774 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1775 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1776 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1777 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1778 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1779 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1780 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1781 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001782 { } /* end */
1783};
1784
Hector Martin556eea92009-12-20 22:51:23 +01001785static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
1786 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1787 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1788 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1789 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1790 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1791 HDA_OUTPUT),
1792 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1793 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1794 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1795 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1796 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1797 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1798 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1799 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1800 { } /* end */
1801};
1802
1803
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001804static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001805{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001806 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001807
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001808 spec->autocfg.hp_pins[0] = 0x15;
1809 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01001810 spec->autocfg.speaker_pins[1] = 0x16;
1811 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001812}
1813
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001814static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001815{
1816 struct alc_spec *spec = codec->spec;
1817
1818 spec->autocfg.hp_pins[0] = 0x15;
1819 spec->autocfg.speaker_pins[0] = 0x14;
1820 spec->autocfg.speaker_pins[1] = 0x16;
1821 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001822}
1823
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001824static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001825{
1826 struct alc_spec *spec = codec->spec;
1827
1828 spec->autocfg.hp_pins[0] = 0x15;
1829 spec->autocfg.speaker_pins[0] = 0x14;
1830 spec->autocfg.speaker_pins[1] = 0x16;
1831 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001832}
1833
Hector Martinf5de24b2009-12-20 22:51:31 +01001834#ifdef CONFIG_SND_HDA_POWER_SAVE
1835static void alc889_power_eapd(struct hda_codec *codec, int power)
1836{
1837 snd_hda_codec_write(codec, 0x14, 0,
1838 AC_VERB_SET_EAPD_BTLENABLE, power ? 2 : 0);
1839 snd_hda_codec_write(codec, 0x15, 0,
1840 AC_VERB_SET_EAPD_BTLENABLE, power ? 2 : 0);
1841}
1842#endif
1843
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001844/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001845 * ALC880 3-stack model
1846 *
1847 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001848 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1849 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001850 */
1851
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001852static hda_nid_t alc880_dac_nids[4] = {
1853 /* front, rear, clfe, rear_surr */
1854 0x02, 0x05, 0x04, 0x03
1855};
1856
1857static hda_nid_t alc880_adc_nids[3] = {
1858 /* ADC0-2 */
1859 0x07, 0x08, 0x09,
1860};
1861
1862/* The datasheet says the node 0x07 is connected from inputs,
1863 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001864 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001865 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001866static hda_nid_t alc880_adc_nids_alt[2] = {
1867 /* ADC1-2 */
1868 0x08, 0x09,
1869};
1870
1871#define ALC880_DIGOUT_NID 0x06
1872#define ALC880_DIGIN_NID 0x0a
1873
1874static struct hda_input_mux alc880_capture_source = {
1875 .num_items = 4,
1876 .items = {
1877 { "Mic", 0x0 },
1878 { "Front Mic", 0x3 },
1879 { "Line", 0x2 },
1880 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001881 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001882};
1883
1884/* channel source setting (2/6 channel selection for 3-stack) */
1885/* 2ch mode */
1886static struct hda_verb alc880_threestack_ch2_init[] = {
1887 /* set line-in to input, mute it */
1888 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1889 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1890 /* set mic-in to input vref 80%, mute it */
1891 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1892 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001893 { } /* end */
1894};
1895
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001896/* 6ch mode */
1897static struct hda_verb alc880_threestack_ch6_init[] = {
1898 /* set line-in to output, unmute it */
1899 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1900 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1901 /* set mic-in to output, unmute it */
1902 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1903 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1904 { } /* end */
1905};
1906
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001907static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001908 { 2, alc880_threestack_ch2_init },
1909 { 6, alc880_threestack_ch6_init },
1910};
1911
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001912static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001913 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001914 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001915 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001916 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001917 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1918 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001919 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1920 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001921 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1922 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1923 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1924 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1925 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1926 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1927 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1928 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001929 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001930 {
1931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1932 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001933 .info = alc_ch_mode_info,
1934 .get = alc_ch_mode_get,
1935 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001936 },
1937 { } /* end */
1938};
1939
1940/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001941static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1942 struct snd_ctl_elem_info *uinfo)
1943{
1944 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1945 struct alc_spec *spec = codec->spec;
1946 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001947
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001948 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001949 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1950 HDA_INPUT);
1951 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001952 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001953 return err;
1954}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001955
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001956static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1957 unsigned int size, unsigned int __user *tlv)
1958{
1959 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1960 struct alc_spec *spec = codec->spec;
1961 int err;
1962
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001963 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001964 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1965 HDA_INPUT);
1966 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001967 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001968 return err;
1969}
1970
1971typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1972 struct snd_ctl_elem_value *ucontrol);
1973
1974static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1975 struct snd_ctl_elem_value *ucontrol,
1976 getput_call_t func)
1977{
1978 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1979 struct alc_spec *spec = codec->spec;
1980 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1981 int err;
1982
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001983 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001984 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1985 3, 0, HDA_INPUT);
1986 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001987 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001988 return err;
1989}
1990
1991static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1992 struct snd_ctl_elem_value *ucontrol)
1993{
1994 return alc_cap_getput_caller(kcontrol, ucontrol,
1995 snd_hda_mixer_amp_volume_get);
1996}
1997
1998static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1999 struct snd_ctl_elem_value *ucontrol)
2000{
2001 return alc_cap_getput_caller(kcontrol, ucontrol,
2002 snd_hda_mixer_amp_volume_put);
2003}
2004
2005/* capture mixer elements */
2006#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2007
2008static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2009 struct snd_ctl_elem_value *ucontrol)
2010{
2011 return alc_cap_getput_caller(kcontrol, ucontrol,
2012 snd_hda_mixer_amp_switch_get);
2013}
2014
2015static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2016 struct snd_ctl_elem_value *ucontrol)
2017{
2018 return alc_cap_getput_caller(kcontrol, ucontrol,
2019 snd_hda_mixer_amp_switch_put);
2020}
2021
Takashi Iwaia23b6882009-03-23 15:21:36 +01002022#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002023 { \
2024 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2025 .name = "Capture Switch", \
2026 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2027 .count = num, \
2028 .info = alc_cap_sw_info, \
2029 .get = alc_cap_sw_get, \
2030 .put = alc_cap_sw_put, \
2031 }, \
2032 { \
2033 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2034 .name = "Capture Volume", \
2035 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2036 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2037 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2038 .count = num, \
2039 .info = alc_cap_vol_info, \
2040 .get = alc_cap_vol_get, \
2041 .put = alc_cap_vol_put, \
2042 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002043 }
2044
2045#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002046 { \
2047 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2048 /* .name = "Capture Source", */ \
2049 .name = "Input Source", \
2050 .count = num, \
2051 .info = alc_mux_enum_info, \
2052 .get = alc_mux_enum_get, \
2053 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002054 }
2055
2056#define DEFINE_CAPMIX(num) \
2057static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2058 _DEFINE_CAPMIX(num), \
2059 _DEFINE_CAPSRC(num), \
2060 { } /* end */ \
2061}
2062
2063#define DEFINE_CAPMIX_NOSRC(num) \
2064static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2065 _DEFINE_CAPMIX(num), \
2066 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002067}
2068
2069/* up to three ADCs */
2070DEFINE_CAPMIX(1);
2071DEFINE_CAPMIX(2);
2072DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002073DEFINE_CAPMIX_NOSRC(1);
2074DEFINE_CAPMIX_NOSRC(2);
2075DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002076
2077/*
2078 * ALC880 5-stack model
2079 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002080 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2081 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002082 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2083 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2084 */
2085
2086/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002087static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002088 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002089 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002090 { } /* end */
2091};
2092
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002093/* channel source setting (6/8 channel selection for 5-stack) */
2094/* 6ch mode */
2095static struct hda_verb alc880_fivestack_ch6_init[] = {
2096 /* set line-in to input, mute it */
2097 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2098 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002099 { } /* end */
2100};
2101
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002102/* 8ch mode */
2103static struct hda_verb alc880_fivestack_ch8_init[] = {
2104 /* set line-in to output, unmute it */
2105 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2106 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2107 { } /* end */
2108};
2109
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002110static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002111 { 6, alc880_fivestack_ch6_init },
2112 { 8, alc880_fivestack_ch8_init },
2113};
2114
2115
2116/*
2117 * ALC880 6-stack model
2118 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002119 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2120 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002121 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2122 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2123 */
2124
2125static hda_nid_t alc880_6st_dac_nids[4] = {
2126 /* front, rear, clfe, rear_surr */
2127 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002128};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002129
2130static struct hda_input_mux alc880_6stack_capture_source = {
2131 .num_items = 4,
2132 .items = {
2133 { "Mic", 0x0 },
2134 { "Front Mic", 0x1 },
2135 { "Line", 0x2 },
2136 { "CD", 0x4 },
2137 },
2138};
2139
2140/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002141static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002142 { 8, NULL },
2143};
2144
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002145static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002146 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002147 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002148 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002149 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002150 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2151 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002152 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2153 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002154 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002155 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002156 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2157 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2158 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2159 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2160 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2161 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2162 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2163 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002164 {
2165 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2166 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002167 .info = alc_ch_mode_info,
2168 .get = alc_ch_mode_get,
2169 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002170 },
2171 { } /* end */
2172};
2173
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002174
2175/*
2176 * ALC880 W810 model
2177 *
2178 * W810 has rear IO for:
2179 * Front (DAC 02)
2180 * Surround (DAC 03)
2181 * Center/LFE (DAC 04)
2182 * Digital out (06)
2183 *
2184 * The system also has a pair of internal speakers, and a headphone jack.
2185 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002186 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002187 * There is a variable resistor to control the speaker or headphone
2188 * volume. This is a hardware-only device without a software API.
2189 *
2190 * Plugging headphones in will disable the internal speakers. This is
2191 * implemented in hardware, not via the driver using jack sense. In
2192 * a similar fashion, plugging into the rear socket marked "front" will
2193 * disable both the speakers and headphones.
2194 *
2195 * For input, there's a microphone jack, and an "audio in" jack.
2196 * These may not do anything useful with this driver yet, because I
2197 * haven't setup any initialization verbs for these yet...
2198 */
2199
2200static hda_nid_t alc880_w810_dac_nids[3] = {
2201 /* front, rear/surround, clfe */
2202 0x02, 0x03, 0x04
2203};
2204
2205/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002206static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002207 { 6, NULL }
2208};
2209
2210/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002211static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002212 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002213 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002214 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002215 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002216 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2217 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002218 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2219 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002220 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2221 { } /* end */
2222};
2223
2224
2225/*
2226 * Z710V model
2227 *
2228 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002229 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2230 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002231 */
2232
2233static hda_nid_t alc880_z71v_dac_nids[1] = {
2234 0x02
2235};
2236#define ALC880_Z71V_HP_DAC 0x03
2237
2238/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002239static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002240 { 2, NULL }
2241};
2242
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002243static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002244 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002245 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002246 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002247 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002248 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2249 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2250 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2251 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2252 { } /* end */
2253};
2254
2255
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002256/*
2257 * ALC880 F1734 model
2258 *
2259 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2260 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2261 */
2262
2263static hda_nid_t alc880_f1734_dac_nids[1] = {
2264 0x03
2265};
2266#define ALC880_F1734_HP_DAC 0x02
2267
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002268static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002269 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002270 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002271 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2272 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002273 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2274 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002275 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2276 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002277 { } /* end */
2278};
2279
Takashi Iwai937b4162008-02-11 14:52:36 +01002280static struct hda_input_mux alc880_f1734_capture_source = {
2281 .num_items = 2,
2282 .items = {
2283 { "Mic", 0x1 },
2284 { "CD", 0x4 },
2285 },
2286};
2287
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002288
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002289/*
2290 * ALC880 ASUS model
2291 *
2292 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2293 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2294 * Mic = 0x18, Line = 0x1a
2295 */
2296
2297#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2298#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2299
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002300static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002301 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002302 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002303 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002304 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002305 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2306 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002307 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2308 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002309 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2310 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2311 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2312 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2313 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2314 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002315 {
2316 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2317 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002318 .info = alc_ch_mode_info,
2319 .get = alc_ch_mode_get,
2320 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002321 },
2322 { } /* end */
2323};
2324
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002325/*
2326 * ALC880 ASUS W1V model
2327 *
2328 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2329 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2330 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2331 */
2332
2333/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002334static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002335 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2336 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002337 { } /* end */
2338};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002339
Kailang Yangdf694da2005-12-05 19:42:22 +01002340/* TCL S700 */
2341static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2342 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2343 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2344 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2345 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2346 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2347 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2348 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2349 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2350 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002351 { } /* end */
2352};
2353
Kailang Yangccc656c2006-10-17 12:32:26 +02002354/* Uniwill */
2355static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002356 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2357 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2358 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2359 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002360 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2361 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2362 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2363 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2364 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2365 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2366 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2367 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2368 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2369 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2370 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2371 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002372 {
2373 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2374 .name = "Channel Mode",
2375 .info = alc_ch_mode_info,
2376 .get = alc_ch_mode_get,
2377 .put = alc_ch_mode_put,
2378 },
2379 { } /* end */
2380};
2381
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002382static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2383 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2384 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2385 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2386 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2387 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2388 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2389 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2390 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2391 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2392 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2393 { } /* end */
2394};
2395
Kailang Yangccc656c2006-10-17 12:32:26 +02002396static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002397 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2398 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2399 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2400 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002401 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2402 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2403 { } /* end */
2404};
2405
Linus Torvalds1da177e2005-04-16 15:20:36 -07002406/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002407 * virtual master controls
2408 */
2409
2410/*
2411 * slave controls for virtual master
2412 */
2413static const char *alc_slave_vols[] = {
2414 "Front Playback Volume",
2415 "Surround Playback Volume",
2416 "Center Playback Volume",
2417 "LFE Playback Volume",
2418 "Side Playback Volume",
2419 "Headphone Playback Volume",
2420 "Speaker Playback Volume",
2421 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002422 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002423 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002424 NULL,
2425};
2426
2427static const char *alc_slave_sws[] = {
2428 "Front Playback Switch",
2429 "Surround Playback Switch",
2430 "Center Playback Switch",
2431 "LFE Playback Switch",
2432 "Side Playback Switch",
2433 "Headphone Playback Switch",
2434 "Speaker Playback Switch",
2435 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002436 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002437 "Line-Out Playback Switch",
2438 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002439 NULL,
2440};
2441
2442/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002443 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002444 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002445
2446static void alc_free_kctls(struct hda_codec *codec);
2447
Takashi Iwai67d634c2009-11-16 15:35:59 +01002448#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002449/* additional beep mixers; the actual parameters are overwritten at build */
2450static struct snd_kcontrol_new alc_beep_mixer[] = {
2451 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002452 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002453 { } /* end */
2454};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002455#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002456
Linus Torvalds1da177e2005-04-16 15:20:36 -07002457static int alc_build_controls(struct hda_codec *codec)
2458{
2459 struct alc_spec *spec = codec->spec;
2460 int err;
2461 int i;
2462
2463 for (i = 0; i < spec->num_mixers; i++) {
2464 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2465 if (err < 0)
2466 return err;
2467 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002468 if (spec->cap_mixer) {
2469 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2470 if (err < 0)
2471 return err;
2472 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002473 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002474 err = snd_hda_create_spdif_out_ctls(codec,
2475 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002476 if (err < 0)
2477 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002478 if (!spec->no_analog) {
2479 err = snd_hda_create_spdif_share_sw(codec,
2480 &spec->multiout);
2481 if (err < 0)
2482 return err;
2483 spec->multiout.share_spdif = 1;
2484 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002485 }
2486 if (spec->dig_in_nid) {
2487 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2488 if (err < 0)
2489 return err;
2490 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002491
Takashi Iwai67d634c2009-11-16 15:35:59 +01002492#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002493 /* create beep controls if needed */
2494 if (spec->beep_amp) {
2495 struct snd_kcontrol_new *knew;
2496 for (knew = alc_beep_mixer; knew->name; knew++) {
2497 struct snd_kcontrol *kctl;
2498 kctl = snd_ctl_new1(knew, codec);
2499 if (!kctl)
2500 return -ENOMEM;
2501 kctl->private_value = spec->beep_amp;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01002502 err = snd_hda_ctl_add(codec,
2503 get_amp_nid_(spec->beep_amp), kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002504 if (err < 0)
2505 return err;
2506 }
2507 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002508#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002509
Takashi Iwai2134ea42008-01-10 16:53:55 +01002510 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002511 if (!spec->no_analog &&
2512 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002513 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002514 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002515 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002516 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002517 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002518 if (err < 0)
2519 return err;
2520 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002521 if (!spec->no_analog &&
2522 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002523 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2524 NULL, alc_slave_sws);
2525 if (err < 0)
2526 return err;
2527 }
2528
Takashi Iwai603c4012008-07-30 15:01:44 +02002529 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002530 return 0;
2531}
2532
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002533
Linus Torvalds1da177e2005-04-16 15:20:36 -07002534/*
2535 * initialize the codec volumes, etc
2536 */
2537
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002538/*
2539 * generic initialization of ADC, input mixers and output mixers
2540 */
2541static struct hda_verb alc880_volume_init_verbs[] = {
2542 /*
2543 * Unmute ADC0-2 and set the default input to mic-in
2544 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002545 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002546 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002547 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002548 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002549 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002550 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002551
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002552 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2553 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002554 * Note: PASD motherboards uses the Line In 2 as the input for front
2555 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002556 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002557 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002558 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2559 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2560 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2561 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2562 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2563 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2564 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002565
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002566 /*
2567 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002568 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002569 /* set vol=0 to output mixers */
2570 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2571 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2572 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2573 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2574 /* set up input amps for analog loopback */
2575 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002576 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2577 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002578 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2579 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002580 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2581 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002582 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2583 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002584
2585 { }
2586};
2587
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002588/*
2589 * 3-stack pin configuration:
2590 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2591 */
2592static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2593 /*
2594 * preset connection lists of input pins
2595 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2596 */
2597 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2598 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2599 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2600
2601 /*
2602 * Set pin mode and muting
2603 */
2604 /* set front pin widgets 0x14 for output */
2605 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2606 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2607 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2608 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2609 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2610 /* Mic2 (as headphone out) for HP output */
2611 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2612 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2613 /* Line In pin widget for input */
2614 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2615 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2616 /* Line2 (as front mic) pin widget for input and vref at 80% */
2617 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2618 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2619 /* CD pin widget for input */
2620 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2621
2622 { }
2623};
2624
2625/*
2626 * 5-stack pin configuration:
2627 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2628 * line-in/side = 0x1a, f-mic = 0x1b
2629 */
2630static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2631 /*
2632 * preset connection lists of input pins
2633 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2634 */
2635 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2636 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2637
2638 /*
2639 * Set pin mode and muting
2640 */
2641 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002642 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2643 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2644 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2645 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002646 /* unmute pins for output (no gain on this amp) */
2647 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2648 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2649 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2650 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2651
Linus Torvalds1da177e2005-04-16 15:20:36 -07002652 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002653 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002654 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2655 /* Mic2 (as headphone out) for HP output */
2656 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002657 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002658 /* Line In pin widget for input */
2659 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2660 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2661 /* Line2 (as front mic) pin widget for input and vref at 80% */
2662 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2663 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2664 /* CD pin widget for input */
2665 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002666
2667 { }
2668};
2669
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002670/*
2671 * W810 pin configuration:
2672 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2673 */
2674static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002675 /* hphone/speaker input selector: front DAC */
2676 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2677
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002678 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2679 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2680 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2681 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2682 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2683 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2684
2685 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002686 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002687
Linus Torvalds1da177e2005-04-16 15:20:36 -07002688 { }
2689};
2690
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002691/*
2692 * Z71V pin configuration:
2693 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2694 */
2695static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002696 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002697 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002698 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002699 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002700
Takashi Iwai16ded522005-06-10 19:58:24 +02002701 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002702 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002703 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002704 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002705
2706 { }
2707};
2708
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002709/*
2710 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002711 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2712 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002713 */
2714static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2715 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2716
Takashi Iwai16ded522005-06-10 19:58:24 +02002717 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002718 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002719 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002720 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002721 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002722 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002723 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002724 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2725
Takashi Iwai16ded522005-06-10 19:58:24 +02002726 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002727 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002728 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002729 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002730 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002731 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002732 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002733 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002734 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002735
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002736 { }
2737};
Takashi Iwai16ded522005-06-10 19:58:24 +02002738
Kailang Yangccc656c2006-10-17 12:32:26 +02002739/*
2740 * Uniwill pin configuration:
2741 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2742 * line = 0x1a
2743 */
2744static struct hda_verb alc880_uniwill_init_verbs[] = {
2745 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2746
2747 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2748 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2749 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2750 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2751 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2752 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2753 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2754 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2755 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2756 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2757 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2758 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2759 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2760 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2761
2762 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2763 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2764 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2765 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2766 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2767 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2768 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2769 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2770 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2771
2772 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2773 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2774
2775 { }
2776};
2777
2778/*
2779* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002780* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002781 */
2782static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2783 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2784
2785 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2786 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2787 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2788 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2789 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2790 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2791 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2792 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2793 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2794 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2795 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2796 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2797
2798 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2799 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2800 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2801 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2802 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2803 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2804
2805 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2806 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2807
2808 { }
2809};
2810
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002811static struct hda_verb alc880_beep_init_verbs[] = {
2812 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2813 { }
2814};
2815
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002816/* auto-toggle front mic */
2817static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2818{
2819 unsigned int present;
2820 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002821
Wu Fengguang864f92b2009-11-18 12:38:02 +08002822 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002823 bits = present ? HDA_AMP_MUTE : 0;
2824 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002825}
2826
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002827static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002828{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002829 struct alc_spec *spec = codec->spec;
2830
2831 spec->autocfg.hp_pins[0] = 0x14;
2832 spec->autocfg.speaker_pins[0] = 0x15;
2833 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002834}
2835
2836static void alc880_uniwill_init_hook(struct hda_codec *codec)
2837{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002838 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002839 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002840}
2841
2842static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2843 unsigned int res)
2844{
2845 /* Looks like the unsol event is incompatible with the standard
2846 * definition. 4bit tag is placed at 28 bit!
2847 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002848 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002849 case ALC880_MIC_EVENT:
2850 alc880_uniwill_mic_automute(codec);
2851 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002852 default:
2853 alc_automute_amp_unsol_event(codec, res);
2854 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002855 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002856}
2857
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002858static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002859{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002860 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002861
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002862 spec->autocfg.hp_pins[0] = 0x14;
2863 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02002864}
2865
2866static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2867{
2868 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002869
Kailang Yangccc656c2006-10-17 12:32:26 +02002870 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002871 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2872 present &= HDA_AMP_VOLMASK;
2873 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2874 HDA_AMP_VOLMASK, present);
2875 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2876 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002877}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002878
Kailang Yangccc656c2006-10-17 12:32:26 +02002879static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2880 unsigned int res)
2881{
2882 /* Looks like the unsol event is incompatible with the standard
2883 * definition. 4bit tag is placed at 28 bit!
2884 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002885 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002886 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002887 else
2888 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002889}
2890
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002891/*
2892 * F1734 pin configuration:
2893 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2894 */
2895static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002896 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002897 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2898 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2899 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2900 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2901
2902 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2903 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2904 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2905 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2906
2907 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2908 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002909 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002910 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2911 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2912 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2913 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2914 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2915 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002916
Takashi Iwai937b4162008-02-11 14:52:36 +01002917 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2918 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2919
Takashi Iwai16ded522005-06-10 19:58:24 +02002920 { }
2921};
2922
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002923/*
2924 * ASUS pin configuration:
2925 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2926 */
2927static struct hda_verb alc880_pin_asus_init_verbs[] = {
2928 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2929 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2930 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2931 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2932
2933 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2934 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2935 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2936 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2937 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2938 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2939 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2940 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2941
2942 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2943 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2944 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2945 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2946 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2947 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2948 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2949 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2950 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002951
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002952 { }
2953};
2954
2955/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002956#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2957#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02002958#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002959
Kailang Yangdf694da2005-12-05 19:42:22 +01002960/* Clevo m520g init */
2961static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2962 /* headphone output */
2963 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2964 /* line-out */
2965 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2966 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2967 /* Line-in */
2968 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2969 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2970 /* CD */
2971 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2972 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2973 /* Mic1 (rear panel) */
2974 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2975 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2976 /* Mic2 (front panel) */
2977 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2978 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2979 /* headphone */
2980 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2981 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2982 /* change to EAPD mode */
2983 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2984 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2985
2986 { }
2987};
2988
2989static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002990 /* change to EAPD mode */
2991 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2992 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2993
Kailang Yangdf694da2005-12-05 19:42:22 +01002994 /* Headphone output */
2995 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2996 /* Front output*/
2997 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2998 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2999
3000 /* Line In pin widget for input */
3001 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3002 /* CD pin widget for input */
3003 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3004 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3005 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3006
3007 /* change to EAPD mode */
3008 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3009 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3010
3011 { }
3012};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003013
3014/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003015 * LG m1 express dual
3016 *
3017 * Pin assignment:
3018 * Rear Line-In/Out (blue): 0x14
3019 * Build-in Mic-In: 0x15
3020 * Speaker-out: 0x17
3021 * HP-Out (green): 0x1b
3022 * Mic-In/Out (red): 0x19
3023 * SPDIF-Out: 0x1e
3024 */
3025
3026/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3027static hda_nid_t alc880_lg_dac_nids[3] = {
3028 0x05, 0x02, 0x03
3029};
3030
3031/* seems analog CD is not working */
3032static struct hda_input_mux alc880_lg_capture_source = {
3033 .num_items = 3,
3034 .items = {
3035 { "Mic", 0x1 },
3036 { "Line", 0x5 },
3037 { "Internal Mic", 0x6 },
3038 },
3039};
3040
3041/* 2,4,6 channel modes */
3042static struct hda_verb alc880_lg_ch2_init[] = {
3043 /* set line-in and mic-in to input */
3044 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3045 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3046 { }
3047};
3048
3049static struct hda_verb alc880_lg_ch4_init[] = {
3050 /* set line-in to out and mic-in to input */
3051 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3052 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3053 { }
3054};
3055
3056static struct hda_verb alc880_lg_ch6_init[] = {
3057 /* set line-in and mic-in to output */
3058 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3059 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3060 { }
3061};
3062
3063static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3064 { 2, alc880_lg_ch2_init },
3065 { 4, alc880_lg_ch4_init },
3066 { 6, alc880_lg_ch6_init },
3067};
3068
3069static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003070 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3071 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003072 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3073 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3074 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3075 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3076 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3077 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3078 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3079 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3080 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3081 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3082 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3083 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3084 {
3085 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3086 .name = "Channel Mode",
3087 .info = alc_ch_mode_info,
3088 .get = alc_ch_mode_get,
3089 .put = alc_ch_mode_put,
3090 },
3091 { } /* end */
3092};
3093
3094static struct hda_verb alc880_lg_init_verbs[] = {
3095 /* set capture source to mic-in */
3096 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3097 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3098 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3099 /* mute all amp mixer inputs */
3100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003101 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003103 /* line-in to input */
3104 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3105 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3106 /* built-in mic */
3107 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3108 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3109 /* speaker-out */
3110 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3111 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3112 /* mic-in to input */
3113 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3114 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3115 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3116 /* HP-out */
3117 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3118 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3119 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3120 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003121 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003122 { }
3123};
3124
3125/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003126static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003127{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003128 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003129
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003130 spec->autocfg.hp_pins[0] = 0x1b;
3131 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003132}
3133
3134/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003135 * LG LW20
3136 *
3137 * Pin assignment:
3138 * Speaker-out: 0x14
3139 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003140 * Built-in Mic-In: 0x19
3141 * Line-In: 0x1b
3142 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003143 * SPDIF-Out: 0x1e
3144 */
3145
Takashi Iwaid6815182006-03-23 16:06:23 +01003146static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003147 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003148 .items = {
3149 { "Mic", 0x0 },
3150 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003151 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003152 },
3153};
3154
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003155#define alc880_lg_lw_modes alc880_threestack_modes
3156
Takashi Iwaid6815182006-03-23 16:06:23 +01003157static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003158 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3159 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3160 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3161 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3162 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3163 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3164 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3165 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3166 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3167 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003168 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3169 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3170 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3171 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003172 {
3173 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3174 .name = "Channel Mode",
3175 .info = alc_ch_mode_info,
3176 .get = alc_ch_mode_get,
3177 .put = alc_ch_mode_put,
3178 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003179 { } /* end */
3180};
3181
3182static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003183 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3184 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3185 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3186
Takashi Iwaid6815182006-03-23 16:06:23 +01003187 /* set capture source to mic-in */
3188 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3189 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3190 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003191 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003192 /* speaker-out */
3193 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3194 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3195 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003196 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3197 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3198 /* mic-in to input */
3199 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3200 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3201 /* built-in mic */
3202 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3203 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3204 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003205 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003206 { }
3207};
3208
3209/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003210static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003211{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003212 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003213
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003214 spec->autocfg.hp_pins[0] = 0x1b;
3215 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003216}
3217
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003218static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3219 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3220 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3221 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3222 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3223 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3224 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3225 { } /* end */
3226};
3227
3228static struct hda_input_mux alc880_medion_rim_capture_source = {
3229 .num_items = 2,
3230 .items = {
3231 { "Mic", 0x0 },
3232 { "Internal Mic", 0x1 },
3233 },
3234};
3235
3236static struct hda_verb alc880_medion_rim_init_verbs[] = {
3237 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3238
3239 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3240 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3241
3242 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3243 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3244 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3245 /* Mic2 (as headphone out) for HP output */
3246 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3247 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3248 /* Internal Speaker */
3249 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3250 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3251
3252 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3253 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3254
3255 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3256 { }
3257};
3258
3259/* toggle speaker-output according to the hp-jack state */
3260static void alc880_medion_rim_automute(struct hda_codec *codec)
3261{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003262 struct alc_spec *spec = codec->spec;
3263 alc_automute_amp(codec);
3264 /* toggle EAPD */
3265 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003266 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3267 else
3268 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3269}
3270
3271static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3272 unsigned int res)
3273{
3274 /* Looks like the unsol event is incompatible with the standard
3275 * definition. 4bit tag is placed at 28 bit!
3276 */
3277 if ((res >> 28) == ALC880_HP_EVENT)
3278 alc880_medion_rim_automute(codec);
3279}
3280
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003281static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003282{
3283 struct alc_spec *spec = codec->spec;
3284
3285 spec->autocfg.hp_pins[0] = 0x14;
3286 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003287}
3288
Takashi Iwaicb53c622007-08-10 17:21:45 +02003289#ifdef CONFIG_SND_HDA_POWER_SAVE
3290static struct hda_amp_list alc880_loopbacks[] = {
3291 { 0x0b, HDA_INPUT, 0 },
3292 { 0x0b, HDA_INPUT, 1 },
3293 { 0x0b, HDA_INPUT, 2 },
3294 { 0x0b, HDA_INPUT, 3 },
3295 { 0x0b, HDA_INPUT, 4 },
3296 { } /* end */
3297};
3298
3299static struct hda_amp_list alc880_lg_loopbacks[] = {
3300 { 0x0b, HDA_INPUT, 1 },
3301 { 0x0b, HDA_INPUT, 6 },
3302 { 0x0b, HDA_INPUT, 7 },
3303 { } /* end */
3304};
3305#endif
3306
Takashi Iwaid6815182006-03-23 16:06:23 +01003307/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003308 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003309 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003310
Linus Torvalds1da177e2005-04-16 15:20:36 -07003311static int alc_init(struct hda_codec *codec)
3312{
3313 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003314 unsigned int i;
3315
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003316 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003317 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003318
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003319 for (i = 0; i < spec->num_init_verbs; i++)
3320 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003321
3322 if (spec->init_hook)
3323 spec->init_hook(codec);
3324
Linus Torvalds1da177e2005-04-16 15:20:36 -07003325 return 0;
3326}
3327
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003328static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3329{
3330 struct alc_spec *spec = codec->spec;
3331
3332 if (spec->unsol_event)
3333 spec->unsol_event(codec, res);
3334}
3335
Takashi Iwaicb53c622007-08-10 17:21:45 +02003336#ifdef CONFIG_SND_HDA_POWER_SAVE
3337static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3338{
3339 struct alc_spec *spec = codec->spec;
3340 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3341}
3342#endif
3343
Linus Torvalds1da177e2005-04-16 15:20:36 -07003344/*
3345 * Analog playback callbacks
3346 */
3347static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3348 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003349 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003350{
3351 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003352 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3353 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003354}
3355
3356static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3357 struct hda_codec *codec,
3358 unsigned int stream_tag,
3359 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003360 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003361{
3362 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003363 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3364 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003365}
3366
3367static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3368 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003369 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003370{
3371 struct alc_spec *spec = codec->spec;
3372 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3373}
3374
3375/*
3376 * Digital out
3377 */
3378static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3379 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003380 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003381{
3382 struct alc_spec *spec = codec->spec;
3383 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3384}
3385
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003386static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3387 struct hda_codec *codec,
3388 unsigned int stream_tag,
3389 unsigned int format,
3390 struct snd_pcm_substream *substream)
3391{
3392 struct alc_spec *spec = codec->spec;
3393 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3394 stream_tag, format, substream);
3395}
3396
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003397static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3398 struct hda_codec *codec,
3399 struct snd_pcm_substream *substream)
3400{
3401 struct alc_spec *spec = codec->spec;
3402 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3403}
3404
Linus Torvalds1da177e2005-04-16 15:20:36 -07003405static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3406 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003407 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003408{
3409 struct alc_spec *spec = codec->spec;
3410 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3411}
3412
3413/*
3414 * Analog capture
3415 */
Takashi Iwai63300792008-01-24 15:31:36 +01003416static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003417 struct hda_codec *codec,
3418 unsigned int stream_tag,
3419 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003420 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003421{
3422 struct alc_spec *spec = codec->spec;
3423
Takashi Iwai63300792008-01-24 15:31:36 +01003424 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003425 stream_tag, 0, format);
3426 return 0;
3427}
3428
Takashi Iwai63300792008-01-24 15:31:36 +01003429static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003430 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003431 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003432{
3433 struct alc_spec *spec = codec->spec;
3434
Takashi Iwai888afa12008-03-18 09:57:50 +01003435 snd_hda_codec_cleanup_stream(codec,
3436 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003437 return 0;
3438}
3439
3440
3441/*
3442 */
3443static struct hda_pcm_stream alc880_pcm_analog_playback = {
3444 .substreams = 1,
3445 .channels_min = 2,
3446 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003447 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003448 .ops = {
3449 .open = alc880_playback_pcm_open,
3450 .prepare = alc880_playback_pcm_prepare,
3451 .cleanup = alc880_playback_pcm_cleanup
3452 },
3453};
3454
3455static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003456 .substreams = 1,
3457 .channels_min = 2,
3458 .channels_max = 2,
3459 /* NID is set in alc_build_pcms */
3460};
3461
3462static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3463 .substreams = 1,
3464 .channels_min = 2,
3465 .channels_max = 2,
3466 /* NID is set in alc_build_pcms */
3467};
3468
3469static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3470 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003471 .channels_min = 2,
3472 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003473 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003474 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003475 .prepare = alc880_alt_capture_pcm_prepare,
3476 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003477 },
3478};
3479
3480static struct hda_pcm_stream alc880_pcm_digital_playback = {
3481 .substreams = 1,
3482 .channels_min = 2,
3483 .channels_max = 2,
3484 /* NID is set in alc_build_pcms */
3485 .ops = {
3486 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003487 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003488 .prepare = alc880_dig_playback_pcm_prepare,
3489 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003490 },
3491};
3492
3493static struct hda_pcm_stream alc880_pcm_digital_capture = {
3494 .substreams = 1,
3495 .channels_min = 2,
3496 .channels_max = 2,
3497 /* NID is set in alc_build_pcms */
3498};
3499
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003500/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003501static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003502 .substreams = 0,
3503 .channels_min = 0,
3504 .channels_max = 0,
3505};
3506
Linus Torvalds1da177e2005-04-16 15:20:36 -07003507static int alc_build_pcms(struct hda_codec *codec)
3508{
3509 struct alc_spec *spec = codec->spec;
3510 struct hda_pcm *info = spec->pcm_rec;
3511 int i;
3512
3513 codec->num_pcms = 1;
3514 codec->pcm_info = info;
3515
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003516 if (spec->no_analog)
3517 goto skip_analog;
3518
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003519 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3520 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003521 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003522
Takashi Iwai4a471b72005-12-07 13:56:29 +01003523 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003524 if (snd_BUG_ON(!spec->multiout.dac_nids))
3525 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003526 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3527 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3528 }
3529 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003530 if (snd_BUG_ON(!spec->adc_nids))
3531 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003532 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3533 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3534 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003535
Takashi Iwai4a471b72005-12-07 13:56:29 +01003536 if (spec->channel_mode) {
3537 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3538 for (i = 0; i < spec->num_channel_mode; i++) {
3539 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3540 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3541 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003542 }
3543 }
3544
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003545 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003546 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003547 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003548 snprintf(spec->stream_name_digital,
3549 sizeof(spec->stream_name_digital),
3550 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003551 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003552 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003553 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003554 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003555 if (spec->dig_out_type)
3556 info->pcm_type = spec->dig_out_type;
3557 else
3558 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003559 if (spec->multiout.dig_out_nid &&
3560 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003561 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3562 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3563 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003564 if (spec->dig_in_nid &&
3565 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003566 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3567 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3568 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003569 /* FIXME: do we need this for all Realtek codec models? */
3570 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003571 }
3572
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003573 if (spec->no_analog)
3574 return 0;
3575
Takashi Iwaie08a0072006-09-07 17:52:14 +02003576 /* If the use of more than one ADC is requested for the current
3577 * model, configure a second analog capture-only PCM.
3578 */
3579 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003580 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3581 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003582 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003583 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003584 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003585 if (spec->alt_dac_nid) {
3586 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3587 *spec->stream_analog_alt_playback;
3588 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3589 spec->alt_dac_nid;
3590 } else {
3591 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3592 alc_pcm_null_stream;
3593 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3594 }
3595 if (spec->num_adc_nids > 1) {
3596 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3597 *spec->stream_analog_alt_capture;
3598 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3599 spec->adc_nids[1];
3600 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3601 spec->num_adc_nids - 1;
3602 } else {
3603 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3604 alc_pcm_null_stream;
3605 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003606 }
3607 }
3608
Linus Torvalds1da177e2005-04-16 15:20:36 -07003609 return 0;
3610}
3611
Takashi Iwai603c4012008-07-30 15:01:44 +02003612static void alc_free_kctls(struct hda_codec *codec)
3613{
3614 struct alc_spec *spec = codec->spec;
3615
3616 if (spec->kctls.list) {
3617 struct snd_kcontrol_new *kctl = spec->kctls.list;
3618 int i;
3619 for (i = 0; i < spec->kctls.used; i++)
3620 kfree(kctl[i].name);
3621 }
3622 snd_array_free(&spec->kctls);
3623}
3624
Linus Torvalds1da177e2005-04-16 15:20:36 -07003625static void alc_free(struct hda_codec *codec)
3626{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003627 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003628
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003629 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003630 return;
3631
Takashi Iwai603c4012008-07-30 15:01:44 +02003632 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003633 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003634 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003635}
3636
Hector Martinf5de24b2009-12-20 22:51:31 +01003637#ifdef CONFIG_SND_HDA_POWER_SAVE
3638static int alc_suspend(struct hda_codec *codec, pm_message_t state)
3639{
3640 struct alc_spec *spec = codec->spec;
3641 if (spec && spec->power_hook)
3642 spec->power_hook(codec, 0);
3643 return 0;
3644}
3645#endif
3646
Takashi Iwaie044c392008-10-27 16:56:24 +01003647#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003648static int alc_resume(struct hda_codec *codec)
3649{
Hector Martinf5de24b2009-12-20 22:51:31 +01003650#ifdef CONFIG_SND_HDA_POWER_SAVE
3651 struct alc_spec *spec = codec->spec;
3652#endif
Takashi Iwaie044c392008-10-27 16:56:24 +01003653 codec->patch_ops.init(codec);
3654 snd_hda_codec_resume_amp(codec);
3655 snd_hda_codec_resume_cache(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003656#ifdef CONFIG_SND_HDA_POWER_SAVE
3657 if (spec && spec->power_hook)
3658 spec->power_hook(codec, 1);
3659#endif
Takashi Iwaie044c392008-10-27 16:56:24 +01003660 return 0;
3661}
Takashi Iwaie044c392008-10-27 16:56:24 +01003662#endif
3663
Linus Torvalds1da177e2005-04-16 15:20:36 -07003664/*
3665 */
3666static struct hda_codec_ops alc_patch_ops = {
3667 .build_controls = alc_build_controls,
3668 .build_pcms = alc_build_pcms,
3669 .init = alc_init,
3670 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003671 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003672#ifdef SND_HDA_NEEDS_RESUME
3673 .resume = alc_resume,
3674#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003675#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01003676 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003677 .check_power_status = alc_check_power_status,
3678#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003679};
3680
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003681
3682/*
3683 * Test configuration for debugging
3684 *
3685 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3686 * enum controls.
3687 */
3688#ifdef CONFIG_SND_DEBUG
3689static hda_nid_t alc880_test_dac_nids[4] = {
3690 0x02, 0x03, 0x04, 0x05
3691};
3692
3693static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003694 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003695 .items = {
3696 { "In-1", 0x0 },
3697 { "In-2", 0x1 },
3698 { "In-3", 0x2 },
3699 { "In-4", 0x3 },
3700 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003701 { "Front", 0x5 },
3702 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003703 },
3704};
3705
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003706static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003707 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003708 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003709 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003710 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003711};
3712
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003713static int alc_test_pin_ctl_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 "N/A", "Line Out", "HP Out",
3718 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3719 };
3720 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3721 uinfo->count = 1;
3722 uinfo->value.enumerated.items = 8;
3723 if (uinfo->value.enumerated.item >= 8)
3724 uinfo->value.enumerated.item = 7;
3725 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3726 return 0;
3727}
3728
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003729static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3730 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003731{
3732 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3733 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3734 unsigned int pin_ctl, item = 0;
3735
3736 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3737 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3738 if (pin_ctl & AC_PINCTL_OUT_EN) {
3739 if (pin_ctl & AC_PINCTL_HP_EN)
3740 item = 2;
3741 else
3742 item = 1;
3743 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3744 switch (pin_ctl & AC_PINCTL_VREFEN) {
3745 case AC_PINCTL_VREF_HIZ: item = 3; break;
3746 case AC_PINCTL_VREF_50: item = 4; break;
3747 case AC_PINCTL_VREF_GRD: item = 5; break;
3748 case AC_PINCTL_VREF_80: item = 6; break;
3749 case AC_PINCTL_VREF_100: item = 7; break;
3750 }
3751 }
3752 ucontrol->value.enumerated.item[0] = item;
3753 return 0;
3754}
3755
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003756static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3757 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003758{
3759 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3760 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3761 static unsigned int ctls[] = {
3762 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3763 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3764 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3765 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3766 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3767 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3768 };
3769 unsigned int old_ctl, new_ctl;
3770
3771 old_ctl = snd_hda_codec_read(codec, nid, 0,
3772 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3773 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3774 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003775 int val;
3776 snd_hda_codec_write_cache(codec, nid, 0,
3777 AC_VERB_SET_PIN_WIDGET_CONTROL,
3778 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003779 val = ucontrol->value.enumerated.item[0] >= 3 ?
3780 HDA_AMP_MUTE : 0;
3781 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3782 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003783 return 1;
3784 }
3785 return 0;
3786}
3787
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003788static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3789 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003790{
3791 static char *texts[] = {
3792 "Front", "Surround", "CLFE", "Side"
3793 };
3794 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3795 uinfo->count = 1;
3796 uinfo->value.enumerated.items = 4;
3797 if (uinfo->value.enumerated.item >= 4)
3798 uinfo->value.enumerated.item = 3;
3799 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3800 return 0;
3801}
3802
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003803static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3804 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003805{
3806 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3807 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3808 unsigned int sel;
3809
3810 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3811 ucontrol->value.enumerated.item[0] = sel & 3;
3812 return 0;
3813}
3814
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003815static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3816 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003817{
3818 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3819 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3820 unsigned int sel;
3821
3822 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3823 if (ucontrol->value.enumerated.item[0] != sel) {
3824 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003825 snd_hda_codec_write_cache(codec, nid, 0,
3826 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003827 return 1;
3828 }
3829 return 0;
3830}
3831
3832#define PIN_CTL_TEST(xname,nid) { \
3833 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3834 .name = xname, \
3835 .info = alc_test_pin_ctl_info, \
3836 .get = alc_test_pin_ctl_get, \
3837 .put = alc_test_pin_ctl_put, \
3838 .private_value = nid \
3839 }
3840
3841#define PIN_SRC_TEST(xname,nid) { \
3842 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3843 .name = xname, \
3844 .info = alc_test_pin_src_info, \
3845 .get = alc_test_pin_src_get, \
3846 .put = alc_test_pin_src_put, \
3847 .private_value = nid \
3848 }
3849
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003850static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003851 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3852 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3853 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3854 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003855 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3856 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3857 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3858 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003859 PIN_CTL_TEST("Front Pin Mode", 0x14),
3860 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3861 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3862 PIN_CTL_TEST("Side Pin Mode", 0x17),
3863 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3864 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3865 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3866 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3867 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3868 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3869 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3870 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3871 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3872 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3873 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3874 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3875 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3876 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3877 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3878 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3879 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3880 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003881 {
3882 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3883 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003884 .info = alc_ch_mode_info,
3885 .get = alc_ch_mode_get,
3886 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003887 },
3888 { } /* end */
3889};
3890
3891static struct hda_verb alc880_test_init_verbs[] = {
3892 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003893 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3894 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3895 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3896 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3897 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3898 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3899 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3900 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003901 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003902 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3903 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3904 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3905 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003906 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003907 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3908 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3909 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3910 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003911 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003912 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3913 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3914 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3915 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003916 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003917 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3918 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003919 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3920 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3921 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003922 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003923 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3924 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3925 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3926 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003927 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003928 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003929 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003930 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003931 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003932 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003933 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003934 /* Analog input/passthru */
3935 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3936 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3937 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3938 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3939 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003940 { }
3941};
3942#endif
3943
Linus Torvalds1da177e2005-04-16 15:20:36 -07003944/*
3945 */
3946
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003947static const char *alc880_models[ALC880_MODEL_LAST] = {
3948 [ALC880_3ST] = "3stack",
3949 [ALC880_TCL_S700] = "tcl",
3950 [ALC880_3ST_DIG] = "3stack-digout",
3951 [ALC880_CLEVO] = "clevo",
3952 [ALC880_5ST] = "5stack",
3953 [ALC880_5ST_DIG] = "5stack-digout",
3954 [ALC880_W810] = "w810",
3955 [ALC880_Z71V] = "z71v",
3956 [ALC880_6ST] = "6stack",
3957 [ALC880_6ST_DIG] = "6stack-digout",
3958 [ALC880_ASUS] = "asus",
3959 [ALC880_ASUS_W1V] = "asus-w1v",
3960 [ALC880_ASUS_DIG] = "asus-dig",
3961 [ALC880_ASUS_DIG2] = "asus-dig2",
3962 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003963 [ALC880_UNIWILL_P53] = "uniwill-p53",
3964 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003965 [ALC880_F1734] = "F1734",
3966 [ALC880_LG] = "lg",
3967 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003968 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003969#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003970 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003971#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003972 [ALC880_AUTO] = "auto",
3973};
3974
3975static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003976 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003977 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3978 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3979 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3980 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3981 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3982 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3983 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3984 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003985 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3986 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003987 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3988 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3989 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3990 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3991 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3992 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3993 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3994 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3995 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3996 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003997 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003998 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3999 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4000 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004001 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004002 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004003 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4004 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004005 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4006 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004007 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4008 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4009 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4010 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004011 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4012 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004013 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004014 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004015 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004016 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004017 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4018 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004019 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004020 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004021 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004022 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004023 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004024 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004025 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004026 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004027 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004028 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4029 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004030 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004031 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4032 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4033 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4034 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004035 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4036 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004037 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004038 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004039 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4040 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004041 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4042 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4043 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004044 /* default Intel */
4045 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004046 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4047 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004048 {}
4049};
4050
Takashi Iwai16ded522005-06-10 19:58:24 +02004051/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004052 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004053 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004054static struct alc_config_preset alc880_presets[] = {
4055 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004056 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004057 .init_verbs = { alc880_volume_init_verbs,
4058 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004059 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004060 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004061 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4062 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004063 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004064 .input_mux = &alc880_capture_source,
4065 },
4066 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004067 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004068 .init_verbs = { alc880_volume_init_verbs,
4069 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004070 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004071 .dac_nids = alc880_dac_nids,
4072 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004073 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4074 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004075 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004076 .input_mux = &alc880_capture_source,
4077 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004078 [ALC880_TCL_S700] = {
4079 .mixers = { alc880_tcl_s700_mixer },
4080 .init_verbs = { alc880_volume_init_verbs,
4081 alc880_pin_tcl_S700_init_verbs,
4082 alc880_gpio2_init_verbs },
4083 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4084 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004085 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4086 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004087 .hp_nid = 0x03,
4088 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4089 .channel_mode = alc880_2_jack_modes,
4090 .input_mux = &alc880_capture_source,
4091 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004092 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004093 .mixers = { alc880_three_stack_mixer,
4094 alc880_five_stack_mixer},
4095 .init_verbs = { alc880_volume_init_verbs,
4096 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004097 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4098 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004099 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4100 .channel_mode = alc880_fivestack_modes,
4101 .input_mux = &alc880_capture_source,
4102 },
4103 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004104 .mixers = { alc880_three_stack_mixer,
4105 alc880_five_stack_mixer },
4106 .init_verbs = { alc880_volume_init_verbs,
4107 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004108 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4109 .dac_nids = alc880_dac_nids,
4110 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004111 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4112 .channel_mode = alc880_fivestack_modes,
4113 .input_mux = &alc880_capture_source,
4114 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004115 [ALC880_6ST] = {
4116 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004117 .init_verbs = { alc880_volume_init_verbs,
4118 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004119 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4120 .dac_nids = alc880_6st_dac_nids,
4121 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4122 .channel_mode = alc880_sixstack_modes,
4123 .input_mux = &alc880_6stack_capture_source,
4124 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004125 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004126 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004127 .init_verbs = { alc880_volume_init_verbs,
4128 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004129 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4130 .dac_nids = alc880_6st_dac_nids,
4131 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004132 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4133 .channel_mode = alc880_sixstack_modes,
4134 .input_mux = &alc880_6stack_capture_source,
4135 },
4136 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004137 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004138 .init_verbs = { alc880_volume_init_verbs,
4139 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004140 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004141 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4142 .dac_nids = alc880_w810_dac_nids,
4143 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004144 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4145 .channel_mode = alc880_w810_modes,
4146 .input_mux = &alc880_capture_source,
4147 },
4148 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004149 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004150 .init_verbs = { alc880_volume_init_verbs,
4151 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004152 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4153 .dac_nids = alc880_z71v_dac_nids,
4154 .dig_out_nid = ALC880_DIGOUT_NID,
4155 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004156 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4157 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004158 .input_mux = &alc880_capture_source,
4159 },
4160 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004161 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004162 .init_verbs = { alc880_volume_init_verbs,
4163 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004164 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4165 .dac_nids = alc880_f1734_dac_nids,
4166 .hp_nid = 0x02,
4167 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4168 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004169 .input_mux = &alc880_f1734_capture_source,
4170 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004171 .setup = alc880_uniwill_p53_setup,
4172 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004173 },
4174 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004175 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004176 .init_verbs = { alc880_volume_init_verbs,
4177 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004178 alc880_gpio1_init_verbs },
4179 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4180 .dac_nids = alc880_asus_dac_nids,
4181 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4182 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004183 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004184 .input_mux = &alc880_capture_source,
4185 },
4186 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004187 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004188 .init_verbs = { alc880_volume_init_verbs,
4189 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004190 alc880_gpio1_init_verbs },
4191 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4192 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004193 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004194 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4195 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004196 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004197 .input_mux = &alc880_capture_source,
4198 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004199 [ALC880_ASUS_DIG2] = {
4200 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004201 .init_verbs = { alc880_volume_init_verbs,
4202 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004203 alc880_gpio2_init_verbs }, /* use GPIO2 */
4204 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4205 .dac_nids = alc880_asus_dac_nids,
4206 .dig_out_nid = ALC880_DIGOUT_NID,
4207 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4208 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004209 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004210 .input_mux = &alc880_capture_source,
4211 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004212 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004213 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004214 .init_verbs = { alc880_volume_init_verbs,
4215 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004216 alc880_gpio1_init_verbs },
4217 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4218 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004219 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004220 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4221 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004222 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004223 .input_mux = &alc880_capture_source,
4224 },
4225 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004226 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004227 .init_verbs = { alc880_volume_init_verbs,
4228 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004229 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4230 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004231 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004232 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4233 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004234 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004235 .input_mux = &alc880_capture_source,
4236 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004237 [ALC880_UNIWILL] = {
4238 .mixers = { alc880_uniwill_mixer },
4239 .init_verbs = { alc880_volume_init_verbs,
4240 alc880_uniwill_init_verbs },
4241 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4242 .dac_nids = alc880_asus_dac_nids,
4243 .dig_out_nid = ALC880_DIGOUT_NID,
4244 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4245 .channel_mode = alc880_threestack_modes,
4246 .need_dac_fix = 1,
4247 .input_mux = &alc880_capture_source,
4248 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004249 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004250 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004251 },
4252 [ALC880_UNIWILL_P53] = {
4253 .mixers = { alc880_uniwill_p53_mixer },
4254 .init_verbs = { alc880_volume_init_verbs,
4255 alc880_uniwill_p53_init_verbs },
4256 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4257 .dac_nids = alc880_asus_dac_nids,
4258 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004259 .channel_mode = alc880_threestack_modes,
4260 .input_mux = &alc880_capture_source,
4261 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004262 .setup = alc880_uniwill_p53_setup,
4263 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004264 },
4265 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004266 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004267 .init_verbs = { alc880_volume_init_verbs,
4268 alc880_uniwill_p53_init_verbs,
4269 alc880_beep_init_verbs },
4270 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4271 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004272 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004273 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4274 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004275 .input_mux = &alc880_capture_source,
4276 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004277 .setup = alc880_uniwill_p53_setup,
4278 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004279 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004280 [ALC880_CLEVO] = {
4281 .mixers = { alc880_three_stack_mixer },
4282 .init_verbs = { alc880_volume_init_verbs,
4283 alc880_pin_clevo_init_verbs },
4284 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4285 .dac_nids = alc880_dac_nids,
4286 .hp_nid = 0x03,
4287 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4288 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004289 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004290 .input_mux = &alc880_capture_source,
4291 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004292 [ALC880_LG] = {
4293 .mixers = { alc880_lg_mixer },
4294 .init_verbs = { alc880_volume_init_verbs,
4295 alc880_lg_init_verbs },
4296 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4297 .dac_nids = alc880_lg_dac_nids,
4298 .dig_out_nid = ALC880_DIGOUT_NID,
4299 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4300 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004301 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004302 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004303 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004304 .setup = alc880_lg_setup,
4305 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004306#ifdef CONFIG_SND_HDA_POWER_SAVE
4307 .loopbacks = alc880_lg_loopbacks,
4308#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004309 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004310 [ALC880_LG_LW] = {
4311 .mixers = { alc880_lg_lw_mixer },
4312 .init_verbs = { alc880_volume_init_verbs,
4313 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004314 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004315 .dac_nids = alc880_dac_nids,
4316 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004317 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4318 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004319 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004320 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004321 .setup = alc880_lg_lw_setup,
4322 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004323 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004324 [ALC880_MEDION_RIM] = {
4325 .mixers = { alc880_medion_rim_mixer },
4326 .init_verbs = { alc880_volume_init_verbs,
4327 alc880_medion_rim_init_verbs,
4328 alc_gpio2_init_verbs },
4329 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4330 .dac_nids = alc880_dac_nids,
4331 .dig_out_nid = ALC880_DIGOUT_NID,
4332 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4333 .channel_mode = alc880_2_jack_modes,
4334 .input_mux = &alc880_medion_rim_capture_source,
4335 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004336 .setup = alc880_medion_rim_setup,
4337 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004338 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004339#ifdef CONFIG_SND_DEBUG
4340 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004341 .mixers = { alc880_test_mixer },
4342 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004343 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4344 .dac_nids = alc880_test_dac_nids,
4345 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004346 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4347 .channel_mode = alc880_test_modes,
4348 .input_mux = &alc880_test_capture_source,
4349 },
4350#endif
4351};
4352
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004353/*
4354 * Automatic parse of I/O pins from the BIOS configuration
4355 */
4356
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004357enum {
4358 ALC_CTL_WIDGET_VOL,
4359 ALC_CTL_WIDGET_MUTE,
4360 ALC_CTL_BIND_MUTE,
4361};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004362static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004363 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4364 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004365 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004366};
4367
4368/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004369static int add_control(struct alc_spec *spec, int type, const char *name,
4370 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004371{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004372 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004373
Takashi Iwai603c4012008-07-30 15:01:44 +02004374 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4375 knew = snd_array_new(&spec->kctls);
4376 if (!knew)
4377 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004378 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004379 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004380 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004381 return -ENOMEM;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004382 if (get_amp_nid_(val))
Takashi Iwai9c96fa52009-11-16 11:25:33 +01004383 knew->subdevice = HDA_SUBDEV_NID_FLAG | get_amp_nid_(val);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004384 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004385 return 0;
4386}
4387
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004388static int add_control_with_pfx(struct alc_spec *spec, int type,
4389 const char *pfx, const char *dir,
4390 const char *sfx, unsigned long val)
4391{
4392 char name[32];
4393 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
4394 return add_control(spec, type, name, val);
4395}
4396
4397#define add_pb_vol_ctrl(spec, type, pfx, val) \
4398 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val)
4399#define add_pb_sw_ctrl(spec, type, pfx, val) \
4400 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val)
4401
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004402#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4403#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4404#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4405#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004406#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4407#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4408#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4409#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4410#define ALC880_PIN_CD_NID 0x1c
4411
4412/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004413static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4414 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004415{
4416 hda_nid_t nid;
4417 int assigned[4];
4418 int i, j;
4419
4420 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004421 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004422
4423 /* check the pins hardwired to audio widget */
4424 for (i = 0; i < cfg->line_outs; i++) {
4425 nid = cfg->line_out_pins[i];
4426 if (alc880_is_fixed_pin(nid)) {
4427 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004428 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004429 assigned[idx] = 1;
4430 }
4431 }
4432 /* left pins can be connect to any audio widget */
4433 for (i = 0; i < cfg->line_outs; i++) {
4434 nid = cfg->line_out_pins[i];
4435 if (alc880_is_fixed_pin(nid))
4436 continue;
4437 /* search for an empty channel */
4438 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004439 if (!assigned[j]) {
4440 spec->multiout.dac_nids[i] =
4441 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004442 assigned[j] = 1;
4443 break;
4444 }
4445 }
4446 }
4447 spec->multiout.num_dacs = cfg->line_outs;
4448 return 0;
4449}
4450
4451/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004452static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4453 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004454{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004455 static const char *chname[4] = {
4456 "Front", "Surround", NULL /*CLFE*/, "Side"
4457 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004458 hda_nid_t nid;
4459 int i, err;
4460
4461 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004462 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004463 continue;
4464 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4465 if (i == 2) {
4466 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004467 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4468 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004469 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4470 HDA_OUTPUT));
4471 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004472 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004473 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4474 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004475 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4476 HDA_OUTPUT));
4477 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004478 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004479 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4480 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004481 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4482 HDA_INPUT));
4483 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004484 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004485 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4486 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004487 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4488 HDA_INPUT));
4489 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004490 return err;
4491 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004492 const char *pfx;
4493 if (cfg->line_outs == 1 &&
4494 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4495 pfx = "Speaker";
4496 else
4497 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004498 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004499 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4500 HDA_OUTPUT));
4501 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004502 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004503 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004504 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4505 HDA_INPUT));
4506 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004507 return err;
4508 }
4509 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004510 return 0;
4511}
4512
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004513/* add playback controls for speaker and HP outputs */
4514static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4515 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004516{
4517 hda_nid_t nid;
4518 int err;
4519
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004520 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004521 return 0;
4522
4523 if (alc880_is_fixed_pin(pin)) {
4524 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004525 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004526 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004527 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004528 else
4529 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004530 /* control HP volume/switch on the output mixer amp */
4531 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004532 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004533 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4534 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004535 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004536 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004537 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4538 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004539 return err;
4540 } else if (alc880_is_multi_pin(pin)) {
4541 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004542 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004543 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004544 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4545 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004546 return err;
4547 }
4548 return 0;
4549}
4550
4551/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004552static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4553 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004554 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004555{
Kailang Yangdf694da2005-12-05 19:42:22 +01004556 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004557
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004558 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004559 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4560 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004561 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004562 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004563 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4564 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004565 return err;
4566 return 0;
4567}
4568
Takashi Iwai05f5f472009-08-25 13:10:18 +02004569static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004570{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004571 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4572 return (pincap & AC_PINCAP_IN) != 0;
4573}
4574
4575/* create playback/capture controls for input pins */
4576static int alc_auto_create_input_ctls(struct hda_codec *codec,
4577 const struct auto_pin_cfg *cfg,
4578 hda_nid_t mixer,
4579 hda_nid_t cap1, hda_nid_t cap2)
4580{
4581 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004582 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004583 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004584
4585 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004586 hda_nid_t pin;
4587
4588 pin = cfg->input_pins[i];
4589 if (!alc_is_input_pin(codec, pin))
4590 continue;
4591
4592 if (mixer) {
4593 idx = get_connection_index(codec, mixer, pin);
4594 if (idx >= 0) {
4595 err = new_analog_input(spec, pin,
4596 auto_pin_cfg_labels[i],
4597 idx, mixer);
4598 if (err < 0)
4599 return err;
4600 }
4601 }
4602
4603 if (!cap1)
4604 continue;
4605 idx = get_connection_index(codec, cap1, pin);
4606 if (idx < 0 && cap2)
4607 idx = get_connection_index(codec, cap2, pin);
4608 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004609 imux->items[imux->num_items].label =
4610 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004611 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004612 imux->num_items++;
4613 }
4614 }
4615 return 0;
4616}
4617
Takashi Iwai05f5f472009-08-25 13:10:18 +02004618static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4619 const struct auto_pin_cfg *cfg)
4620{
4621 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4622}
4623
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004624static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4625 unsigned int pin_type)
4626{
4627 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4628 pin_type);
4629 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004630 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4631 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004632}
4633
Kailang Yangdf694da2005-12-05 19:42:22 +01004634static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4635 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004636 int dac_idx)
4637{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004638 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004639 /* need the manual connection? */
4640 if (alc880_is_multi_pin(nid)) {
4641 struct alc_spec *spec = codec->spec;
4642 int idx = alc880_multi_pin_idx(nid);
4643 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4644 AC_VERB_SET_CONNECT_SEL,
4645 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4646 }
4647}
4648
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004649static int get_pin_type(int line_out_type)
4650{
4651 if (line_out_type == AUTO_PIN_HP_OUT)
4652 return PIN_HP;
4653 else
4654 return PIN_OUT;
4655}
4656
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004657static void alc880_auto_init_multi_out(struct hda_codec *codec)
4658{
4659 struct alc_spec *spec = codec->spec;
4660 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004661
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004662 for (i = 0; i < spec->autocfg.line_outs; i++) {
4663 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004664 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4665 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004666 }
4667}
4668
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004669static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004670{
4671 struct alc_spec *spec = codec->spec;
4672 hda_nid_t pin;
4673
Takashi Iwai82bc9552006-03-21 11:24:42 +01004674 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004675 if (pin) /* connect to front */
4676 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004677 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004678 if (pin) /* connect to front */
4679 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4680}
4681
4682static void alc880_auto_init_analog_input(struct hda_codec *codec)
4683{
4684 struct alc_spec *spec = codec->spec;
4685 int i;
4686
4687 for (i = 0; i < AUTO_PIN_LAST; i++) {
4688 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004689 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004690 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004691 if (nid != ALC880_PIN_CD_NID &&
4692 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004693 snd_hda_codec_write(codec, nid, 0,
4694 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004695 AMP_OUT_MUTE);
4696 }
4697 }
4698}
4699
4700/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004701/* return 1 if successful, 0 if the proper config is not found,
4702 * or a negative error code
4703 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004704static int alc880_parse_auto_config(struct hda_codec *codec)
4705{
4706 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004707 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004708 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004709
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004710 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4711 alc880_ignore);
4712 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004713 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004714 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004715 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004716
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004717 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4718 if (err < 0)
4719 return err;
4720 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4721 if (err < 0)
4722 return err;
4723 err = alc880_auto_create_extra_out(spec,
4724 spec->autocfg.speaker_pins[0],
4725 "Speaker");
4726 if (err < 0)
4727 return err;
4728 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4729 "Headphone");
4730 if (err < 0)
4731 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004732 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004733 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004734 return err;
4735
4736 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4737
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004738 /* check multiple SPDIF-out (for recent codecs) */
4739 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4740 hda_nid_t dig_nid;
4741 err = snd_hda_get_connections(codec,
4742 spec->autocfg.dig_out_pins[i],
4743 &dig_nid, 1);
4744 if (err < 0)
4745 continue;
4746 if (!i)
4747 spec->multiout.dig_out_nid = dig_nid;
4748 else {
4749 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004750 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004751 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004752 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004753 }
4754 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004755 if (spec->autocfg.dig_in_pin)
4756 spec->dig_in_nid = ALC880_DIGIN_NID;
4757
Takashi Iwai603c4012008-07-30 15:01:44 +02004758 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004759 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004760
Takashi Iwaid88897e2008-10-31 15:01:37 +01004761 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004762
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004763 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004764 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004765
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004766 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4767
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004768 return 1;
4769}
4770
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004771/* additional initialization for auto-configuration model */
4772static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004773{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004774 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004775 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004776 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004777 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004778 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004779 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004780}
4781
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004782/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4783 * one of two digital mic pins, e.g. on ALC272
4784 */
4785static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004786{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004787 struct alc_spec *spec = codec->spec;
4788 int i;
4789
4790 for (i = 0; i < spec->num_adc_nids; i++) {
4791 hda_nid_t cap = spec->capsrc_nids ?
4792 spec->capsrc_nids[i] : spec->adc_nids[i];
4793 int iidx, eidx;
4794
4795 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4796 if (iidx < 0)
4797 continue;
4798 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4799 if (eidx < 0)
4800 continue;
4801 spec->int_mic.mux_idx = iidx;
4802 spec->ext_mic.mux_idx = eidx;
4803 if (spec->capsrc_nids)
4804 spec->capsrc_nids += i;
4805 spec->adc_nids += i;
4806 spec->num_adc_nids = 1;
4807 return;
4808 }
4809 snd_printd(KERN_INFO "hda_codec: %s: "
4810 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4811 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4812 spec->auto_mic = 0; /* disable auto-mic to be sure */
4813}
4814
4815static void set_capture_mixer(struct hda_codec *codec)
4816{
4817 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01004818 static struct snd_kcontrol_new *caps[2][3] = {
4819 { alc_capture_mixer_nosrc1,
4820 alc_capture_mixer_nosrc2,
4821 alc_capture_mixer_nosrc3 },
4822 { alc_capture_mixer1,
4823 alc_capture_mixer2,
4824 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004825 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004826 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4827 int mux;
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004828 if (spec->auto_mic) {
4829 mux = 0;
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004830 fixup_automic_adc(codec);
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004831 } else if (spec->input_mux && spec->input_mux->num_items > 1)
Takashi Iwaia23b6882009-03-23 15:21:36 +01004832 mux = 1;
4833 else
4834 mux = 0;
4835 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4836 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004837}
4838
Takashi Iwai67d634c2009-11-16 15:35:59 +01004839#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004840#define set_beep_amp(spec, nid, idx, dir) \
4841 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwai67d634c2009-11-16 15:35:59 +01004842#else
4843#define set_beep_amp(spec, nid, idx, dir) /* NOP */
4844#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004845
4846/*
4847 * OK, here we have finally the patch for ALC880
4848 */
4849
Linus Torvalds1da177e2005-04-16 15:20:36 -07004850static int patch_alc880(struct hda_codec *codec)
4851{
4852 struct alc_spec *spec;
4853 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004854 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004855
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004856 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004857 if (spec == NULL)
4858 return -ENOMEM;
4859
4860 codec->spec = spec;
4861
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004862 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4863 alc880_models,
4864 alc880_cfg_tbl);
4865 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004866 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4867 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004868 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004869 }
4870
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004871 if (board_config == ALC880_AUTO) {
4872 /* automatic parse from the BIOS config */
4873 err = alc880_parse_auto_config(codec);
4874 if (err < 0) {
4875 alc_free(codec);
4876 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004877 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004878 printk(KERN_INFO
4879 "hda_codec: Cannot set up configuration "
4880 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004881 board_config = ALC880_3ST;
4882 }
4883 }
4884
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004885 err = snd_hda_attach_beep_device(codec, 0x1);
4886 if (err < 0) {
4887 alc_free(codec);
4888 return err;
4889 }
4890
Kailang Yangdf694da2005-12-05 19:42:22 +01004891 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02004892 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004893
Linus Torvalds1da177e2005-04-16 15:20:36 -07004894 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4895 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004896 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004897
Linus Torvalds1da177e2005-04-16 15:20:36 -07004898 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4899 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4900
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004901 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004902 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004903 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004904 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02004905 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004906 if (wcap != AC_WID_AUD_IN) {
4907 spec->adc_nids = alc880_adc_nids_alt;
4908 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004909 } else {
4910 spec->adc_nids = alc880_adc_nids;
4911 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004912 }
4913 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004914 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004915 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004916
Takashi Iwai2134ea42008-01-10 16:53:55 +01004917 spec->vmaster_nid = 0x0c;
4918
Linus Torvalds1da177e2005-04-16 15:20:36 -07004919 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004920 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004921 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004922#ifdef CONFIG_SND_HDA_POWER_SAVE
4923 if (!spec->loopback.amplist)
4924 spec->loopback.amplist = alc880_loopbacks;
4925#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004926 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004927
4928 return 0;
4929}
4930
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004931
Linus Torvalds1da177e2005-04-16 15:20:36 -07004932/*
4933 * ALC260 support
4934 */
4935
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004936static hda_nid_t alc260_dac_nids[1] = {
4937 /* front */
4938 0x02,
4939};
4940
4941static hda_nid_t alc260_adc_nids[1] = {
4942 /* ADC0 */
4943 0x04,
4944};
4945
Kailang Yangdf694da2005-12-05 19:42:22 +01004946static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004947 /* ADC1 */
4948 0x05,
4949};
4950
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004951/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4952 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4953 */
4954static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004955 /* ADC0, ADC1 */
4956 0x04, 0x05
4957};
4958
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004959#define ALC260_DIGOUT_NID 0x03
4960#define ALC260_DIGIN_NID 0x06
4961
4962static struct hda_input_mux alc260_capture_source = {
4963 .num_items = 4,
4964 .items = {
4965 { "Mic", 0x0 },
4966 { "Front Mic", 0x1 },
4967 { "Line", 0x2 },
4968 { "CD", 0x4 },
4969 },
4970};
4971
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004972/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004973 * headphone jack and the internal CD lines since these are the only pins at
4974 * which audio can appear. For flexibility, also allow the option of
4975 * recording the mixer output on the second ADC (ADC0 doesn't have a
4976 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004977 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004978static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4979 {
4980 .num_items = 3,
4981 .items = {
4982 { "Mic/Line", 0x0 },
4983 { "CD", 0x4 },
4984 { "Headphone", 0x2 },
4985 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004986 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004987 {
4988 .num_items = 4,
4989 .items = {
4990 { "Mic/Line", 0x0 },
4991 { "CD", 0x4 },
4992 { "Headphone", 0x2 },
4993 { "Mixer", 0x5 },
4994 },
4995 },
4996
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004997};
4998
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004999/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5000 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005001 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005002static struct hda_input_mux alc260_acer_capture_sources[2] = {
5003 {
5004 .num_items = 4,
5005 .items = {
5006 { "Mic", 0x0 },
5007 { "Line", 0x2 },
5008 { "CD", 0x4 },
5009 { "Headphone", 0x5 },
5010 },
5011 },
5012 {
5013 .num_items = 5,
5014 .items = {
5015 { "Mic", 0x0 },
5016 { "Line", 0x2 },
5017 { "CD", 0x4 },
5018 { "Headphone", 0x6 },
5019 { "Mixer", 0x5 },
5020 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005021 },
5022};
Michael Schwingencc959482009-02-22 18:58:45 +01005023
5024/* Maxdata Favorit 100XS */
5025static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5026 {
5027 .num_items = 2,
5028 .items = {
5029 { "Line/Mic", 0x0 },
5030 { "CD", 0x4 },
5031 },
5032 },
5033 {
5034 .num_items = 3,
5035 .items = {
5036 { "Line/Mic", 0x0 },
5037 { "CD", 0x4 },
5038 { "Mixer", 0x5 },
5039 },
5040 },
5041};
5042
Linus Torvalds1da177e2005-04-16 15:20:36 -07005043/*
5044 * This is just place-holder, so there's something for alc_build_pcms to look
5045 * at when it calculates the maximum number of channels. ALC260 has no mixer
5046 * element which allows changing the channel mode, so the verb list is
5047 * never used.
5048 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005049static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005050 { 2, NULL },
5051};
5052
Kailang Yangdf694da2005-12-05 19:42:22 +01005053
5054/* Mixer combinations
5055 *
5056 * basic: base_output + input + pc_beep + capture
5057 * HP: base_output + input + capture_alt
5058 * HP_3013: hp_3013 + input + capture
5059 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005060 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005061 */
5062
5063static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005064 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005065 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005066 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5067 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5068 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5069 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5070 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005071};
Kailang Yangdf694da2005-12-05 19:42:22 +01005072
5073static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005074 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5075 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5076 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5077 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5078 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5079 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5080 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5081 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005082 { } /* end */
5083};
5084
Takashi Iwaibec15c32008-01-28 18:16:30 +01005085/* update HP, line and mono out pins according to the master switch */
5086static void alc260_hp_master_update(struct hda_codec *codec,
5087 hda_nid_t hp, hda_nid_t line,
5088 hda_nid_t mono)
5089{
5090 struct alc_spec *spec = codec->spec;
5091 unsigned int val = spec->master_sw ? PIN_HP : 0;
5092 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005093 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005094 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005095 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005096 val);
5097 /* mono (speaker) depending on the HP jack sense */
5098 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005099 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005100 val);
5101}
5102
5103static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5104 struct snd_ctl_elem_value *ucontrol)
5105{
5106 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5107 struct alc_spec *spec = codec->spec;
5108 *ucontrol->value.integer.value = spec->master_sw;
5109 return 0;
5110}
5111
5112static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5113 struct snd_ctl_elem_value *ucontrol)
5114{
5115 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5116 struct alc_spec *spec = codec->spec;
5117 int val = !!*ucontrol->value.integer.value;
5118 hda_nid_t hp, line, mono;
5119
5120 if (val == spec->master_sw)
5121 return 0;
5122 spec->master_sw = val;
5123 hp = (kcontrol->private_value >> 16) & 0xff;
5124 line = (kcontrol->private_value >> 8) & 0xff;
5125 mono = kcontrol->private_value & 0xff;
5126 alc260_hp_master_update(codec, hp, line, mono);
5127 return 1;
5128}
5129
5130static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5131 {
5132 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5133 .name = "Master Playback Switch",
5134 .info = snd_ctl_boolean_mono_info,
5135 .get = alc260_hp_master_sw_get,
5136 .put = alc260_hp_master_sw_put,
5137 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5138 },
5139 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5140 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5141 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5142 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5143 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5144 HDA_OUTPUT),
5145 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5146 { } /* end */
5147};
5148
5149static struct hda_verb alc260_hp_unsol_verbs[] = {
5150 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5151 {},
5152};
5153
5154static void alc260_hp_automute(struct hda_codec *codec)
5155{
5156 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005157
Wu Fengguang864f92b2009-11-18 12:38:02 +08005158 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005159 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5160}
5161
5162static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5163{
5164 if ((res >> 26) == ALC880_HP_EVENT)
5165 alc260_hp_automute(codec);
5166}
5167
Kailang Yangdf694da2005-12-05 19:42:22 +01005168static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005169 {
5170 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5171 .name = "Master Playback Switch",
5172 .info = snd_ctl_boolean_mono_info,
5173 .get = alc260_hp_master_sw_get,
5174 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005175 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005176 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005177 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5178 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5179 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5180 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5181 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5182 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005183 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5184 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005185 { } /* end */
5186};
5187
Kailang Yang3f878302008-08-26 13:02:23 +02005188static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5189 .ops = &snd_hda_bind_vol,
5190 .values = {
5191 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5192 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5193 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5194 0
5195 },
5196};
5197
5198static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5199 .ops = &snd_hda_bind_sw,
5200 .values = {
5201 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5202 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5203 0
5204 },
5205};
5206
5207static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5208 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5209 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5210 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5211 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5212 { } /* end */
5213};
5214
Takashi Iwaibec15c32008-01-28 18:16:30 +01005215static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5216 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5217 {},
5218};
5219
5220static void alc260_hp_3013_automute(struct hda_codec *codec)
5221{
5222 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005223
Wu Fengguang864f92b2009-11-18 12:38:02 +08005224 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005225 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005226}
5227
5228static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5229 unsigned int res)
5230{
5231 if ((res >> 26) == ALC880_HP_EVENT)
5232 alc260_hp_3013_automute(codec);
5233}
5234
Kailang Yang3f878302008-08-26 13:02:23 +02005235static void alc260_hp_3012_automute(struct hda_codec *codec)
5236{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005237 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005238
Kailang Yang3f878302008-08-26 13:02:23 +02005239 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5240 bits);
5241 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5242 bits);
5243 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5244 bits);
5245}
5246
5247static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5248 unsigned int res)
5249{
5250 if ((res >> 26) == ALC880_HP_EVENT)
5251 alc260_hp_3012_automute(codec);
5252}
5253
5254/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005255 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5256 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005257static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005258 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005259 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005260 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005261 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5262 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5263 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5264 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005265 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005266 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5267 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005268 { } /* end */
5269};
5270
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005271/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5272 * versions of the ALC260 don't act on requests to enable mic bias from NID
5273 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5274 * datasheet doesn't mention this restriction. At this stage it's not clear
5275 * whether this behaviour is intentional or is a hardware bug in chip
5276 * revisions available in early 2006. Therefore for now allow the
5277 * "Headphone Jack Mode" control to span all choices, but if it turns out
5278 * that the lack of mic bias for this NID is intentional we could change the
5279 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5280 *
5281 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5282 * don't appear to make the mic bias available from the "line" jack, even
5283 * though the NID used for this jack (0x14) can supply it. The theory is
5284 * that perhaps Acer have included blocking capacitors between the ALC260
5285 * and the output jack. If this turns out to be the case for all such
5286 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5287 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005288 *
5289 * The C20x Tablet series have a mono internal speaker which is controlled
5290 * via the chip's Mono sum widget and pin complex, so include the necessary
5291 * controls for such models. On models without a "mono speaker" the control
5292 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005293 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005294static struct snd_kcontrol_new alc260_acer_mixer[] = {
5295 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5296 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005297 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005298 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005299 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005300 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005301 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005302 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5303 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5304 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5305 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5306 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5307 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5308 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5309 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005310 { } /* end */
5311};
5312
Michael Schwingencc959482009-02-22 18:58:45 +01005313/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5314 */
5315static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5316 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5317 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5318 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5319 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5320 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5321 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5322 { } /* end */
5323};
5324
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005325/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5326 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5327 */
5328static struct snd_kcontrol_new alc260_will_mixer[] = {
5329 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5330 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5331 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5332 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5333 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5334 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5335 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5336 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5337 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5338 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005339 { } /* end */
5340};
5341
5342/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5343 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5344 */
5345static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5346 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5347 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5348 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5349 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5350 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5351 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5352 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5353 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5354 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5355 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5356 { } /* end */
5357};
5358
Kailang Yangdf694da2005-12-05 19:42:22 +01005359/*
5360 * initialization verbs
5361 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005362static struct hda_verb alc260_init_verbs[] = {
5363 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005364 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005365 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005366 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005367 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005368 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005369 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005370 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005371 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005372 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005373 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005374 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005375 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005376 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005377 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005378 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005379 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005380 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5381 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005382 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005383 /* set connection select to line in (default select for this ADC) */
5384 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005385 /* mute capture amp left and right */
5386 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5387 /* set connection select to line in (default select for this ADC) */
5388 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005389 /* set vol=0 Line-Out mixer amp left and right */
5390 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5391 /* unmute pin widget amp left and right (no gain on this amp) */
5392 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5393 /* set vol=0 HP mixer amp left and right */
5394 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5395 /* unmute pin widget amp left and right (no gain on this amp) */
5396 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5397 /* set vol=0 Mono mixer amp left and right */
5398 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5399 /* unmute pin widget amp left and right (no gain on this amp) */
5400 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5401 /* unmute LINE-2 out pin */
5402 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005403 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5404 * Line In 2 = 0x03
5405 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005406 /* mute analog inputs */
5407 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5408 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5409 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5410 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5411 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005412 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005413 /* mute Front out path */
5414 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5415 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5416 /* mute Headphone out path */
5417 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5418 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5419 /* mute Mono out path */
5420 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5421 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005422 { }
5423};
5424
Takashi Iwai474167d2006-05-17 17:17:43 +02005425#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005426static struct hda_verb alc260_hp_init_verbs[] = {
5427 /* Headphone and output */
5428 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5429 /* mono output */
5430 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5431 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5432 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5433 /* Mic2 (front panel) pin widget for input and vref at 80% */
5434 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5435 /* Line In pin widget for input */
5436 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5437 /* Line-2 pin widget for output */
5438 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5439 /* CD pin widget for input */
5440 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5441 /* unmute amp left and right */
5442 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5443 /* set connection select to line in (default select for this ADC) */
5444 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5445 /* unmute Line-Out mixer amp left and right (volume = 0) */
5446 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5447 /* mute pin widget amp left and right (no gain on this amp) */
5448 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5449 /* unmute HP mixer amp left and right (volume = 0) */
5450 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5451 /* mute pin widget amp left and right (no gain on this amp) */
5452 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005453 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5454 * Line In 2 = 0x03
5455 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005456 /* mute analog inputs */
5457 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5458 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5459 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5461 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005462 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5463 /* Unmute Front out path */
5464 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5465 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5466 /* Unmute Headphone out path */
5467 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5468 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5469 /* Unmute Mono out path */
5470 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5471 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5472 { }
5473};
Takashi Iwai474167d2006-05-17 17:17:43 +02005474#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005475
5476static struct hda_verb alc260_hp_3013_init_verbs[] = {
5477 /* Line out and output */
5478 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5479 /* mono output */
5480 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5481 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5482 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5483 /* Mic2 (front panel) pin widget for input and vref at 80% */
5484 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5485 /* Line In pin widget for input */
5486 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5487 /* Headphone pin widget for output */
5488 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5489 /* CD pin widget for input */
5490 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5491 /* unmute amp left and right */
5492 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5493 /* set connection select to line in (default select for this ADC) */
5494 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5495 /* unmute Line-Out mixer amp left and right (volume = 0) */
5496 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5497 /* mute pin widget amp left and right (no gain on this amp) */
5498 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5499 /* unmute HP mixer amp left and right (volume = 0) */
5500 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5501 /* mute pin widget amp left and right (no gain on this amp) */
5502 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005503 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5504 * Line In 2 = 0x03
5505 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005506 /* mute analog inputs */
5507 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5508 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5509 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5510 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5511 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005512 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5513 /* Unmute Front out path */
5514 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5515 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5516 /* Unmute Headphone out path */
5517 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5518 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5519 /* Unmute Mono out path */
5520 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5521 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5522 { }
5523};
5524
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005525/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005526 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5527 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005528 */
5529static struct hda_verb alc260_fujitsu_init_verbs[] = {
5530 /* Disable all GPIOs */
5531 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5532 /* Internal speaker is connected to headphone pin */
5533 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5534 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5535 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005536 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5537 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5538 /* Ensure all other unused pins are disabled and muted. */
5539 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5540 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005541 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005542 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005543 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005544 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5545 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5546 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005547
Jonathan Woithef7ace402006-02-28 11:46:14 +01005548 /* Disable digital (SPDIF) pins */
5549 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5550 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005551
Kailang Yangea1fb292008-08-26 12:58:38 +02005552 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005553 * when acting as an output.
5554 */
5555 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5556
5557 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005558 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5559 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5560 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5561 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5562 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5563 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5564 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5565 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5566 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005567
Jonathan Woithef7ace402006-02-28 11:46:14 +01005568 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5569 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5570 /* Unmute Line1 pin widget output buffer since it starts as an output.
5571 * If the pin mode is changed by the user the pin mode control will
5572 * take care of enabling the pin's input/output buffers as needed.
5573 * Therefore there's no need to enable the input buffer at this
5574 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005575 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005576 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005577 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005578 * mixer ctrl)
5579 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005580 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005581
Jonathan Woithef7ace402006-02-28 11:46:14 +01005582 /* Mute capture amp left and right */
5583 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005584 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005585 * in (on mic1 pin)
5586 */
5587 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005588
Jonathan Woithef7ace402006-02-28 11:46:14 +01005589 /* Do the same for the second ADC: mute capture input amp and
5590 * set ADC connection to line in (on mic1 pin)
5591 */
5592 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5593 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005594
Jonathan Woithef7ace402006-02-28 11:46:14 +01005595 /* Mute all inputs to mixer widget (even unconnected ones) */
5596 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5597 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5598 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5599 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5600 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5601 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5602 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5603 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005604
5605 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005606};
5607
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005608/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5609 * similar laptops (adapted from Fujitsu init verbs).
5610 */
5611static struct hda_verb alc260_acer_init_verbs[] = {
5612 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5613 * the headphone jack. Turn this on and rely on the standard mute
5614 * methods whenever the user wants to turn these outputs off.
5615 */
5616 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5617 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5618 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5619 /* Internal speaker/Headphone jack is connected to Line-out pin */
5620 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5621 /* Internal microphone/Mic jack is connected to Mic1 pin */
5622 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5623 /* Line In jack is connected to Line1 pin */
5624 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005625 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5626 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005627 /* Ensure all other unused pins are disabled and muted. */
5628 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5629 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005630 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5631 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5632 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5633 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5634 /* Disable digital (SPDIF) pins */
5635 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5636 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5637
Kailang Yangea1fb292008-08-26 12:58:38 +02005638 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005639 * bus when acting as outputs.
5640 */
5641 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5642 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5643
5644 /* Start with output sum widgets muted and their output gains at min */
5645 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5646 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5647 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5648 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5649 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5650 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5651 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5652 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5653 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5654
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005655 /* Unmute Line-out pin widget amp left and right
5656 * (no equiv mixer ctrl)
5657 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005658 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005659 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5660 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005661 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5662 * inputs. If the pin mode is changed by the user the pin mode control
5663 * will take care of enabling the pin's input/output buffers as needed.
5664 * Therefore there's no need to enable the input buffer at this
5665 * stage.
5666 */
5667 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5668 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5669
5670 /* Mute capture amp left and right */
5671 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5672 /* Set ADC connection select to match default mixer setting - mic
5673 * (on mic1 pin)
5674 */
5675 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5676
5677 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005678 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005679 */
5680 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005681 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005682
5683 /* Mute all inputs to mixer widget (even unconnected ones) */
5684 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5685 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5686 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5687 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5688 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5689 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5690 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5691 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5692
5693 { }
5694};
5695
Michael Schwingencc959482009-02-22 18:58:45 +01005696/* Initialisation sequence for Maxdata Favorit 100XS
5697 * (adapted from Acer init verbs).
5698 */
5699static struct hda_verb alc260_favorit100_init_verbs[] = {
5700 /* GPIO 0 enables the output jack.
5701 * Turn this on and rely on the standard mute
5702 * methods whenever the user wants to turn these outputs off.
5703 */
5704 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5705 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5706 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5707 /* Line/Mic input jack is connected to Mic1 pin */
5708 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5709 /* Ensure all other unused pins are disabled and muted. */
5710 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5711 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5712 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5713 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5714 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5715 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5716 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5717 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5718 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5719 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5720 /* Disable digital (SPDIF) pins */
5721 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5722 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5723
5724 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5725 * bus when acting as outputs.
5726 */
5727 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5728 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5729
5730 /* Start with output sum widgets muted and their output gains at min */
5731 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5732 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5733 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5734 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5735 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5736 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5737 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5738 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5739 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5740
5741 /* Unmute Line-out pin widget amp left and right
5742 * (no equiv mixer ctrl)
5743 */
5744 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5745 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5746 * inputs. If the pin mode is changed by the user the pin mode control
5747 * will take care of enabling the pin's input/output buffers as needed.
5748 * Therefore there's no need to enable the input buffer at this
5749 * stage.
5750 */
5751 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5752
5753 /* Mute capture amp left and right */
5754 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5755 /* Set ADC connection select to match default mixer setting - mic
5756 * (on mic1 pin)
5757 */
5758 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5759
5760 /* Do similar with the second ADC: mute capture input amp and
5761 * set ADC connection to mic to match ALSA's default state.
5762 */
5763 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5764 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5765
5766 /* Mute all inputs to mixer widget (even unconnected ones) */
5767 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5768 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5769 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5770 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5771 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5772 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5773 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5774 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5775
5776 { }
5777};
5778
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005779static struct hda_verb alc260_will_verbs[] = {
5780 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5781 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5782 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5783 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5784 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5785 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5786 {}
5787};
5788
5789static struct hda_verb alc260_replacer_672v_verbs[] = {
5790 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5791 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5792 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5793
5794 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5795 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5796 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5797
5798 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5799 {}
5800};
5801
5802/* toggle speaker-output according to the hp-jack state */
5803static void alc260_replacer_672v_automute(struct hda_codec *codec)
5804{
5805 unsigned int present;
5806
5807 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08005808 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005809 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005810 snd_hda_codec_write_cache(codec, 0x01, 0,
5811 AC_VERB_SET_GPIO_DATA, 1);
5812 snd_hda_codec_write_cache(codec, 0x0f, 0,
5813 AC_VERB_SET_PIN_WIDGET_CONTROL,
5814 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005815 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005816 snd_hda_codec_write_cache(codec, 0x01, 0,
5817 AC_VERB_SET_GPIO_DATA, 0);
5818 snd_hda_codec_write_cache(codec, 0x0f, 0,
5819 AC_VERB_SET_PIN_WIDGET_CONTROL,
5820 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005821 }
5822}
5823
5824static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5825 unsigned int res)
5826{
5827 if ((res >> 26) == ALC880_HP_EVENT)
5828 alc260_replacer_672v_automute(codec);
5829}
5830
Kailang Yang3f878302008-08-26 13:02:23 +02005831static struct hda_verb alc260_hp_dc7600_verbs[] = {
5832 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5833 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5834 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5835 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5836 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5837 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5838 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5839 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5840 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5841 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5842 {}
5843};
5844
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005845/* Test configuration for debugging, modelled after the ALC880 test
5846 * configuration.
5847 */
5848#ifdef CONFIG_SND_DEBUG
5849static hda_nid_t alc260_test_dac_nids[1] = {
5850 0x02,
5851};
5852static hda_nid_t alc260_test_adc_nids[2] = {
5853 0x04, 0x05,
5854};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005855/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005856 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005857 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005858 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005859static struct hda_input_mux alc260_test_capture_sources[2] = {
5860 {
5861 .num_items = 7,
5862 .items = {
5863 { "MIC1 pin", 0x0 },
5864 { "MIC2 pin", 0x1 },
5865 { "LINE1 pin", 0x2 },
5866 { "LINE2 pin", 0x3 },
5867 { "CD pin", 0x4 },
5868 { "LINE-OUT pin", 0x5 },
5869 { "HP-OUT pin", 0x6 },
5870 },
5871 },
5872 {
5873 .num_items = 8,
5874 .items = {
5875 { "MIC1 pin", 0x0 },
5876 { "MIC2 pin", 0x1 },
5877 { "LINE1 pin", 0x2 },
5878 { "LINE2 pin", 0x3 },
5879 { "CD pin", 0x4 },
5880 { "Mixer", 0x5 },
5881 { "LINE-OUT pin", 0x6 },
5882 { "HP-OUT pin", 0x7 },
5883 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005884 },
5885};
5886static struct snd_kcontrol_new alc260_test_mixer[] = {
5887 /* Output driver widgets */
5888 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5889 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5890 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5891 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5892 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5893 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5894
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005895 /* Modes for retasking pin widgets
5896 * Note: the ALC260 doesn't seem to act on requests to enable mic
5897 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5898 * mention this restriction. At this stage it's not clear whether
5899 * this behaviour is intentional or is a hardware bug in chip
5900 * revisions available at least up until early 2006. Therefore for
5901 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5902 * choices, but if it turns out that the lack of mic bias for these
5903 * NIDs is intentional we could change their modes from
5904 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5905 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005906 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5907 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5908 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5909 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5910 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5911 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5912
5913 /* Loopback mixer controls */
5914 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5915 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5916 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5917 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5918 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5919 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5920 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5921 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5922 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5923 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005924 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5925 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5926 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5927 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005928
5929 /* Controls for GPIO pins, assuming they are configured as outputs */
5930 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5931 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5932 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5933 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5934
Jonathan Woithe92621f12006-02-28 11:47:47 +01005935 /* Switches to allow the digital IO pins to be enabled. The datasheet
5936 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005937 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005938 */
5939 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5940 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5941
Jonathan Woithef8225f62008-01-08 12:16:54 +01005942 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5943 * this output to turn on an external amplifier.
5944 */
5945 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5946 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5947
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005948 { } /* end */
5949};
5950static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005951 /* Enable all GPIOs as outputs with an initial value of 0 */
5952 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5953 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5954 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5955
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005956 /* Enable retasking pins as output, initially without power amp */
5957 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5958 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5959 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5960 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5961 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5962 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5963
Jonathan Woithe92621f12006-02-28 11:47:47 +01005964 /* Disable digital (SPDIF) pins initially, but users can enable
5965 * them via a mixer switch. In the case of SPDIF-out, this initverb
5966 * payload also sets the generation to 0, output to be in "consumer"
5967 * PCM format, copyright asserted, no pre-emphasis and no validity
5968 * control.
5969 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005970 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5971 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5972
Kailang Yangea1fb292008-08-26 12:58:38 +02005973 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005974 * OUT1 sum bus when acting as an output.
5975 */
5976 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5977 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5978 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5979 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5980
5981 /* Start with output sum widgets muted and their output gains at min */
5982 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5983 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5984 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5985 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5986 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5987 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5988 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5989 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5990 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5991
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005992 /* Unmute retasking pin widget output buffers since the default
5993 * state appears to be output. As the pin mode is changed by the
5994 * user the pin mode control will take care of enabling the pin's
5995 * input/output buffers as needed.
5996 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005997 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5998 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5999 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6000 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6001 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6002 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6003 /* Also unmute the mono-out pin widget */
6004 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6005
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006006 /* Mute capture amp left and right */
6007 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006008 /* Set ADC connection select to match default mixer setting (mic1
6009 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006010 */
6011 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6012
6013 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006014 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006015 */
6016 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6017 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6018
6019 /* Mute all inputs to mixer widget (even unconnected ones) */
6020 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6021 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6022 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6023 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6024 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6025 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6026 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6027 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6028
6029 { }
6030};
6031#endif
6032
Takashi Iwai63300792008-01-24 15:31:36 +01006033#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6034#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006035
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006036#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6037#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6038
Kailang Yangdf694da2005-12-05 19:42:22 +01006039/*
6040 * for BIOS auto-configuration
6041 */
6042
6043static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006044 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006045{
6046 hda_nid_t nid_vol;
6047 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006048 int err;
6049
6050 if (nid >= 0x0f && nid < 0x11) {
6051 nid_vol = nid - 0x7;
6052 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6053 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6054 } else if (nid == 0x11) {
6055 nid_vol = nid - 0x7;
6056 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6057 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6058 } else if (nid >= 0x12 && nid <= 0x15) {
6059 nid_vol = 0x08;
6060 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6061 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6062 } else
6063 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006064
Takashi Iwai863b4512008-10-21 17:01:47 +02006065 if (!(*vol_bits & (1 << nid_vol))) {
6066 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006067 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006068 if (err < 0)
6069 return err;
6070 *vol_bits |= (1 << nid_vol);
6071 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006072 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006073 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006074 return err;
6075 return 1;
6076}
6077
6078/* add playback controls from the parsed DAC table */
6079static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6080 const struct auto_pin_cfg *cfg)
6081{
6082 hda_nid_t nid;
6083 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006084 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006085
6086 spec->multiout.num_dacs = 1;
6087 spec->multiout.dac_nids = spec->private_dac_nids;
6088 spec->multiout.dac_nids[0] = 0x02;
6089
6090 nid = cfg->line_out_pins[0];
6091 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006092 const char *pfx;
6093 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6094 pfx = "Master";
6095 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6096 pfx = "Speaker";
6097 else
6098 pfx = "Front";
6099 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006100 if (err < 0)
6101 return err;
6102 }
6103
Takashi Iwai82bc9552006-03-21 11:24:42 +01006104 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006105 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006106 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006107 if (err < 0)
6108 return err;
6109 }
6110
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006111 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006112 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006113 err = alc260_add_playback_controls(spec, nid, "Headphone",
6114 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006115 if (err < 0)
6116 return err;
6117 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006118 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006119}
6120
6121/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006122static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006123 const struct auto_pin_cfg *cfg)
6124{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006125 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006126}
6127
6128static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6129 hda_nid_t nid, int pin_type,
6130 int sel_idx)
6131{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006132 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006133 /* need the manual connection? */
6134 if (nid >= 0x12) {
6135 int idx = nid - 0x12;
6136 snd_hda_codec_write(codec, idx + 0x0b, 0,
6137 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006138 }
6139}
6140
6141static void alc260_auto_init_multi_out(struct hda_codec *codec)
6142{
6143 struct alc_spec *spec = codec->spec;
6144 hda_nid_t nid;
6145
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006146 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006147 if (nid) {
6148 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6149 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6150 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006151
Takashi Iwai82bc9552006-03-21 11:24:42 +01006152 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006153 if (nid)
6154 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6155
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006156 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006157 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006158 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006159}
Kailang Yangdf694da2005-12-05 19:42:22 +01006160
6161#define ALC260_PIN_CD_NID 0x16
6162static void alc260_auto_init_analog_input(struct hda_codec *codec)
6163{
6164 struct alc_spec *spec = codec->spec;
6165 int i;
6166
6167 for (i = 0; i < AUTO_PIN_LAST; i++) {
6168 hda_nid_t nid = spec->autocfg.input_pins[i];
6169 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006170 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006171 if (nid != ALC260_PIN_CD_NID &&
6172 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006173 snd_hda_codec_write(codec, nid, 0,
6174 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006175 AMP_OUT_MUTE);
6176 }
6177 }
6178}
6179
6180/*
6181 * generic initialization of ADC, input mixers and output mixers
6182 */
6183static struct hda_verb alc260_volume_init_verbs[] = {
6184 /*
6185 * Unmute ADC0-1 and set the default input to mic-in
6186 */
6187 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6188 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6189 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6190 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006191
Kailang Yangdf694da2005-12-05 19:42:22 +01006192 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6193 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006194 * Note: PASD motherboards uses the Line In 2 as the input for
6195 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006196 */
6197 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006198 /* mute analog inputs */
6199 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6200 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6201 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6202 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6203 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006204
6205 /*
6206 * Set up output mixers (0x08 - 0x0a)
6207 */
6208 /* set vol=0 to output mixers */
6209 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6210 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6211 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6212 /* set up input amps for analog loopback */
6213 /* Amp Indices: DAC = 0, mixer = 1 */
6214 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6215 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6216 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6217 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6218 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6219 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006220
Kailang Yangdf694da2005-12-05 19:42:22 +01006221 { }
6222};
6223
6224static int alc260_parse_auto_config(struct hda_codec *codec)
6225{
6226 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006227 int err;
6228 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6229
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006230 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6231 alc260_ignore);
6232 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006233 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006234 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6235 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006236 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006237 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006238 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006239 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006240 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006241 return err;
6242
6243 spec->multiout.max_channels = 2;
6244
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006245 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006246 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006247 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006248 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006249
Takashi Iwaid88897e2008-10-31 15:01:37 +01006250 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006251
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006252 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006253 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006254
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006255 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6256
Kailang Yangdf694da2005-12-05 19:42:22 +01006257 return 1;
6258}
6259
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006260/* additional initialization for auto-configuration model */
6261static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006262{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006263 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006264 alc260_auto_init_multi_out(codec);
6265 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006266 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006267 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006268}
6269
Takashi Iwaicb53c622007-08-10 17:21:45 +02006270#ifdef CONFIG_SND_HDA_POWER_SAVE
6271static struct hda_amp_list alc260_loopbacks[] = {
6272 { 0x07, HDA_INPUT, 0 },
6273 { 0x07, HDA_INPUT, 1 },
6274 { 0x07, HDA_INPUT, 2 },
6275 { 0x07, HDA_INPUT, 3 },
6276 { 0x07, HDA_INPUT, 4 },
6277 { } /* end */
6278};
6279#endif
6280
Kailang Yangdf694da2005-12-05 19:42:22 +01006281/*
6282 * ALC260 configurations
6283 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006284static const char *alc260_models[ALC260_MODEL_LAST] = {
6285 [ALC260_BASIC] = "basic",
6286 [ALC260_HP] = "hp",
6287 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006288 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006289 [ALC260_FUJITSU_S702X] = "fujitsu",
6290 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006291 [ALC260_WILL] = "will",
6292 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006293 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006294#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006295 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006296#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006297 [ALC260_AUTO] = "auto",
6298};
6299
6300static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006301 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006302 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006303 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006304 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006305 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006306 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006307 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006308 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006309 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006310 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6311 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6312 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6313 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6314 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6315 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6316 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6317 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6318 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006319 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006320 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006321 {}
6322};
6323
Kailang Yangdf694da2005-12-05 19:42:22 +01006324static struct alc_config_preset alc260_presets[] = {
6325 [ALC260_BASIC] = {
6326 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006327 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006328 .init_verbs = { alc260_init_verbs },
6329 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6330 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006331 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006332 .adc_nids = alc260_adc_nids,
6333 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6334 .channel_mode = alc260_modes,
6335 .input_mux = &alc260_capture_source,
6336 },
6337 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006338 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006339 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006340 .init_verbs = { alc260_init_verbs,
6341 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006342 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6343 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006344 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6345 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006346 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6347 .channel_mode = alc260_modes,
6348 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006349 .unsol_event = alc260_hp_unsol_event,
6350 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006351 },
Kailang Yang3f878302008-08-26 13:02:23 +02006352 [ALC260_HP_DC7600] = {
6353 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006354 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006355 .init_verbs = { alc260_init_verbs,
6356 alc260_hp_dc7600_verbs },
6357 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6358 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006359 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6360 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006361 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6362 .channel_mode = alc260_modes,
6363 .input_mux = &alc260_capture_source,
6364 .unsol_event = alc260_hp_3012_unsol_event,
6365 .init_hook = alc260_hp_3012_automute,
6366 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006367 [ALC260_HP_3013] = {
6368 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006369 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006370 .init_verbs = { alc260_hp_3013_init_verbs,
6371 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006372 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6373 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006374 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6375 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006376 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6377 .channel_mode = alc260_modes,
6378 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006379 .unsol_event = alc260_hp_3013_unsol_event,
6380 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006381 },
6382 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006383 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006384 .init_verbs = { alc260_fujitsu_init_verbs },
6385 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6386 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006387 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6388 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006389 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6390 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006391 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6392 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006393 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006394 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006395 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006396 .init_verbs = { alc260_acer_init_verbs },
6397 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6398 .dac_nids = alc260_dac_nids,
6399 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6400 .adc_nids = alc260_dual_adc_nids,
6401 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6402 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006403 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6404 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006405 },
Michael Schwingencc959482009-02-22 18:58:45 +01006406 [ALC260_FAVORIT100] = {
6407 .mixers = { alc260_favorit100_mixer },
6408 .init_verbs = { alc260_favorit100_init_verbs },
6409 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6410 .dac_nids = alc260_dac_nids,
6411 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6412 .adc_nids = alc260_dual_adc_nids,
6413 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6414 .channel_mode = alc260_modes,
6415 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6416 .input_mux = alc260_favorit100_capture_sources,
6417 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006418 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006419 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006420 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6421 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6422 .dac_nids = alc260_dac_nids,
6423 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6424 .adc_nids = alc260_adc_nids,
6425 .dig_out_nid = ALC260_DIGOUT_NID,
6426 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6427 .channel_mode = alc260_modes,
6428 .input_mux = &alc260_capture_source,
6429 },
6430 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006431 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006432 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6433 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6434 .dac_nids = alc260_dac_nids,
6435 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6436 .adc_nids = alc260_adc_nids,
6437 .dig_out_nid = ALC260_DIGOUT_NID,
6438 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6439 .channel_mode = alc260_modes,
6440 .input_mux = &alc260_capture_source,
6441 .unsol_event = alc260_replacer_672v_unsol_event,
6442 .init_hook = alc260_replacer_672v_automute,
6443 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006444#ifdef CONFIG_SND_DEBUG
6445 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006446 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006447 .init_verbs = { alc260_test_init_verbs },
6448 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6449 .dac_nids = alc260_test_dac_nids,
6450 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6451 .adc_nids = alc260_test_adc_nids,
6452 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6453 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006454 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6455 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006456 },
6457#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006458};
6459
Linus Torvalds1da177e2005-04-16 15:20:36 -07006460static int patch_alc260(struct hda_codec *codec)
6461{
6462 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006463 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006464
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006465 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006466 if (spec == NULL)
6467 return -ENOMEM;
6468
6469 codec->spec = spec;
6470
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006471 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6472 alc260_models,
6473 alc260_cfg_tbl);
6474 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006475 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006476 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006477 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006478 }
6479
Kailang Yangdf694da2005-12-05 19:42:22 +01006480 if (board_config == ALC260_AUTO) {
6481 /* automatic parse from the BIOS config */
6482 err = alc260_parse_auto_config(codec);
6483 if (err < 0) {
6484 alc_free(codec);
6485 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006486 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006487 printk(KERN_INFO
6488 "hda_codec: Cannot set up configuration "
6489 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006490 board_config = ALC260_BASIC;
6491 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006492 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006493
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006494 err = snd_hda_attach_beep_device(codec, 0x1);
6495 if (err < 0) {
6496 alc_free(codec);
6497 return err;
6498 }
6499
Kailang Yangdf694da2005-12-05 19:42:22 +01006500 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006501 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006502
Linus Torvalds1da177e2005-04-16 15:20:36 -07006503 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6504 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6505
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006506 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6507 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6508
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006509 if (!spec->adc_nids && spec->input_mux) {
6510 /* check whether NID 0x04 is valid */
6511 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006512 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006513 /* get type */
6514 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6515 spec->adc_nids = alc260_adc_nids_alt;
6516 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6517 } else {
6518 spec->adc_nids = alc260_adc_nids;
6519 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6520 }
6521 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006522 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006523 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006524
Takashi Iwai2134ea42008-01-10 16:53:55 +01006525 spec->vmaster_nid = 0x08;
6526
Linus Torvalds1da177e2005-04-16 15:20:36 -07006527 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006528 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006529 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006530#ifdef CONFIG_SND_HDA_POWER_SAVE
6531 if (!spec->loopback.amplist)
6532 spec->loopback.amplist = alc260_loopbacks;
6533#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006534 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006535
6536 return 0;
6537}
6538
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006539
Linus Torvalds1da177e2005-04-16 15:20:36 -07006540/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006541 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006542 *
6543 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6544 * configuration. Each pin widget can choose any input DACs and a mixer.
6545 * Each ADC is connected from a mixer of all inputs. This makes possible
6546 * 6-channel independent captures.
6547 *
6548 * In addition, an independent DAC for the multi-playback (not used in this
6549 * driver yet).
6550 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006551#define ALC882_DIGOUT_NID 0x06
6552#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006553#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6554#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6555#define ALC1200_DIGOUT_NID 0x10
6556
Linus Torvalds1da177e2005-04-16 15:20:36 -07006557
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006558static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006559 { 8, NULL }
6560};
6561
Takashi Iwai4953550a2009-06-30 15:28:30 +02006562/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006563static hda_nid_t alc882_dac_nids[4] = {
6564 /* front, rear, clfe, rear_surr */
6565 0x02, 0x03, 0x04, 0x05
6566};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006567#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006568
Takashi Iwai4953550a2009-06-30 15:28:30 +02006569/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006570#define alc882_adc_nids alc880_adc_nids
6571#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006572#define alc883_adc_nids alc882_adc_nids_alt
6573static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6574static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6575#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006576
Takashi Iwaie1406342008-02-11 18:32:32 +01006577static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6578static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006579#define alc883_capsrc_nids alc882_capsrc_nids_alt
6580static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6581#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006582
Linus Torvalds1da177e2005-04-16 15:20:36 -07006583/* input MUX */
6584/* FIXME: should be a matrix-type input source selection */
6585
6586static struct hda_input_mux alc882_capture_source = {
6587 .num_items = 4,
6588 .items = {
6589 { "Mic", 0x0 },
6590 { "Front Mic", 0x1 },
6591 { "Line", 0x2 },
6592 { "CD", 0x4 },
6593 },
6594};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006595
Takashi Iwai4953550a2009-06-30 15:28:30 +02006596#define alc883_capture_source alc882_capture_source
6597
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006598static struct hda_input_mux alc889_capture_source = {
6599 .num_items = 3,
6600 .items = {
6601 { "Front Mic", 0x0 },
6602 { "Mic", 0x3 },
6603 { "Line", 0x2 },
6604 },
6605};
6606
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006607static struct hda_input_mux mb5_capture_source = {
6608 .num_items = 3,
6609 .items = {
6610 { "Mic", 0x1 },
6611 { "Line", 0x2 },
6612 { "CD", 0x4 },
6613 },
6614};
6615
Takashi Iwai4953550a2009-06-30 15:28:30 +02006616static struct hda_input_mux alc883_3stack_6ch_intel = {
6617 .num_items = 4,
6618 .items = {
6619 { "Mic", 0x1 },
6620 { "Front Mic", 0x0 },
6621 { "Line", 0x2 },
6622 { "CD", 0x4 },
6623 },
6624};
6625
6626static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6627 .num_items = 2,
6628 .items = {
6629 { "Mic", 0x1 },
6630 { "Line", 0x2 },
6631 },
6632};
6633
6634static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6635 .num_items = 4,
6636 .items = {
6637 { "Mic", 0x0 },
6638 { "iMic", 0x1 },
6639 { "Line", 0x2 },
6640 { "CD", 0x4 },
6641 },
6642};
6643
6644static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6645 .num_items = 2,
6646 .items = {
6647 { "Mic", 0x0 },
6648 { "Int Mic", 0x1 },
6649 },
6650};
6651
6652static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6653 .num_items = 3,
6654 .items = {
6655 { "Mic", 0x0 },
6656 { "Front Mic", 0x1 },
6657 { "Line", 0x4 },
6658 },
6659};
6660
6661static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6662 .num_items = 2,
6663 .items = {
6664 { "Mic", 0x0 },
6665 { "Line", 0x2 },
6666 },
6667};
6668
6669static struct hda_input_mux alc889A_mb31_capture_source = {
6670 .num_items = 2,
6671 .items = {
6672 { "Mic", 0x0 },
6673 /* Front Mic (0x01) unused */
6674 { "Line", 0x2 },
6675 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02006676 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006677 },
6678};
6679
6680/*
6681 * 2ch mode
6682 */
6683static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6684 { 2, NULL }
6685};
6686
Kailang Yangdf694da2005-12-05 19:42:22 +01006687/*
Kailang Yang272a5272007-05-14 11:00:38 +02006688 * 2ch mode
6689 */
6690static struct hda_verb alc882_3ST_ch2_init[] = {
6691 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6692 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6693 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6694 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6695 { } /* end */
6696};
6697
6698/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006699 * 4ch mode
6700 */
6701static struct hda_verb alc882_3ST_ch4_init[] = {
6702 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6703 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
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 { } /* end */
6708};
6709
6710/*
Kailang Yang272a5272007-05-14 11:00:38 +02006711 * 6ch mode
6712 */
6713static struct hda_verb alc882_3ST_ch6_init[] = {
6714 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6715 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6716 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6717 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6718 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6719 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6720 { } /* end */
6721};
6722
Takashi Iwai4953550a2009-06-30 15:28:30 +02006723static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006724 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006725 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006726 { 6, alc882_3ST_ch6_init },
6727};
6728
Takashi Iwai4953550a2009-06-30 15:28:30 +02006729#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6730
Kailang Yang272a5272007-05-14 11:00:38 +02006731/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04306732 * 2ch mode
6733 */
6734static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6735 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6736 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6737 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6738 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6739 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6740 { } /* end */
6741};
6742
6743/*
6744 * 4ch mode
6745 */
6746static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
6747 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6748 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6749 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6750 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6751 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6752 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6753 { } /* end */
6754};
6755
6756/*
6757 * 6ch mode
6758 */
6759static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
6760 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6761 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6762 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6763 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6764 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6765 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6766 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6767 { } /* end */
6768};
6769
6770static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
6771 { 2, alc883_3ST_ch2_clevo_init },
6772 { 4, alc883_3ST_ch4_clevo_init },
6773 { 6, alc883_3ST_ch6_clevo_init },
6774};
6775
6776
6777/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006778 * 6ch mode
6779 */
6780static struct hda_verb alc882_sixstack_ch6_init[] = {
6781 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6782 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6783 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6784 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6785 { } /* end */
6786};
6787
6788/*
6789 * 8ch mode
6790 */
6791static struct hda_verb alc882_sixstack_ch8_init[] = {
6792 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6793 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6794 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6795 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6796 { } /* end */
6797};
6798
6799static struct hda_channel_mode alc882_sixstack_modes[2] = {
6800 { 6, alc882_sixstack_ch6_init },
6801 { 8, alc882_sixstack_ch8_init },
6802};
6803
Takashi Iwai87350ad2007-08-16 18:19:38 +02006804/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006805 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006806 */
6807
6808/*
6809 * 2ch mode
6810 */
6811static struct hda_verb alc885_mbp_ch2_init[] = {
6812 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6813 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6814 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6815 { } /* end */
6816};
6817
6818/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006819 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02006820 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006821static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006822 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6823 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6824 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6825 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6826 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6827 { } /* end */
6828};
6829
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006830static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006831 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006832 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006833};
6834
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006835/*
6836 * 2ch
6837 * Speakers/Woofer/HP = Front
6838 * LineIn = Input
6839 */
6840static struct hda_verb alc885_mb5_ch2_init[] = {
6841 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6842 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6843 { } /* end */
6844};
6845
6846/*
6847 * 6ch mode
6848 * Speakers/HP = Front
6849 * Woofer = LFE
6850 * LineIn = Surround
6851 */
6852static struct hda_verb alc885_mb5_ch6_init[] = {
6853 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6854 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6855 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6856 { } /* end */
6857};
6858
6859static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6860 { 2, alc885_mb5_ch2_init },
6861 { 6, alc885_mb5_ch6_init },
6862};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006863
Takashi Iwai4953550a2009-06-30 15:28:30 +02006864
6865/*
6866 * 2ch mode
6867 */
6868static struct hda_verb alc883_4ST_ch2_init[] = {
6869 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6870 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6871 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6872 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6873 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6874 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6875 { } /* end */
6876};
6877
6878/*
6879 * 4ch mode
6880 */
6881static struct hda_verb alc883_4ST_ch4_init[] = {
6882 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6883 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6884 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6885 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6886 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6887 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6888 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6889 { } /* end */
6890};
6891
6892/*
6893 * 6ch mode
6894 */
6895static struct hda_verb alc883_4ST_ch6_init[] = {
6896 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6897 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6898 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6899 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6900 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6901 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6902 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6903 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6904 { } /* end */
6905};
6906
6907/*
6908 * 8ch mode
6909 */
6910static struct hda_verb alc883_4ST_ch8_init[] = {
6911 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6912 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6913 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6914 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6915 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6916 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6917 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6918 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6919 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6920 { } /* end */
6921};
6922
6923static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6924 { 2, alc883_4ST_ch2_init },
6925 { 4, alc883_4ST_ch4_init },
6926 { 6, alc883_4ST_ch6_init },
6927 { 8, alc883_4ST_ch8_init },
6928};
6929
6930
6931/*
6932 * 2ch mode
6933 */
6934static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6935 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6936 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6937 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6938 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6939 { } /* end */
6940};
6941
6942/*
6943 * 4ch mode
6944 */
6945static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6946 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6947 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6948 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6949 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6950 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6951 { } /* end */
6952};
6953
6954/*
6955 * 6ch mode
6956 */
6957static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6958 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6959 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6960 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6961 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6962 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6963 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6964 { } /* end */
6965};
6966
6967static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6968 { 2, alc883_3ST_ch2_intel_init },
6969 { 4, alc883_3ST_ch4_intel_init },
6970 { 6, alc883_3ST_ch6_intel_init },
6971};
6972
6973/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006974 * 2ch mode
6975 */
6976static struct hda_verb alc889_ch2_intel_init[] = {
6977 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6978 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
6979 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
6980 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
6981 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6982 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6983 { } /* end */
6984};
6985
6986/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006987 * 6ch mode
6988 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006989static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006990 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6991 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6992 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6993 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6994 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006995 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6996 { } /* end */
6997};
6998
6999/*
7000 * 8ch mode
7001 */
7002static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007003 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7004 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7005 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7006 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7007 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007008 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7009 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007010 { } /* end */
7011};
7012
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007013static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7014 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007015 { 6, alc889_ch6_intel_init },
7016 { 8, alc889_ch8_intel_init },
7017};
7018
7019/*
7020 * 6ch mode
7021 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007022static struct hda_verb alc883_sixstack_ch6_init[] = {
7023 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7024 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7025 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7026 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7027 { } /* end */
7028};
7029
7030/*
7031 * 8ch mode
7032 */
7033static struct hda_verb alc883_sixstack_ch8_init[] = {
7034 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7035 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7036 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7037 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7038 { } /* end */
7039};
7040
7041static struct hda_channel_mode alc883_sixstack_modes[2] = {
7042 { 6, alc883_sixstack_ch6_init },
7043 { 8, alc883_sixstack_ch8_init },
7044};
7045
7046
Linus Torvalds1da177e2005-04-16 15:20:36 -07007047/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7048 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7049 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007050static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007051 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007052 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007053 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007054 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007055 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7056 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007057 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7058 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007059 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007060 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007061 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7062 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7063 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7064 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7065 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7066 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007067 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007068 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7069 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007070 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007071 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007072 { } /* end */
7073};
7074
Takashi Iwai87350ad2007-08-16 18:19:38 +02007075static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007076 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7077 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7078 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7079 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7080 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007081 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7082 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007083 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7084 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007085 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007086 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7087 { } /* end */
7088};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007089
7090static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007091 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7092 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7093 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7094 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7095 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7096 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307097 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7098 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007099 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7100 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7101 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7102 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7103 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7104 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7105 { } /* end */
7106};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007107
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007108static struct snd_kcontrol_new alc885_imac91_mixer[] = {
7109 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7110 HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
7111 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
7112 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7113 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7114 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7115 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7116 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7117 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7118 { } /* end */
7119};
7120
7121
Kailang Yangbdd148a2007-05-08 15:19:08 +02007122static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7123 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7124 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7125 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7126 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7127 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7128 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7129 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7130 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7131 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007132 { } /* end */
7133};
7134
Kailang Yang272a5272007-05-14 11:00:38 +02007135static struct snd_kcontrol_new alc882_targa_mixer[] = {
7136 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7137 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7138 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7139 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7140 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7141 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7142 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7143 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7144 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007145 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007146 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7147 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007148 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007149 { } /* end */
7150};
7151
7152/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7153 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7154 */
7155static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7156 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7157 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7158 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7159 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7160 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7161 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7162 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7163 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7164 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7165 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7166 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7167 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007168 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007169 { } /* end */
7170};
7171
Takashi Iwai914759b2007-09-06 14:52:04 +02007172static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7173 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7174 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7175 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7176 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7177 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7178 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7179 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7180 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7181 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7182 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007183 { } /* end */
7184};
7185
Kailang Yangdf694da2005-12-05 19:42:22 +01007186static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7187 {
7188 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7189 .name = "Channel Mode",
7190 .info = alc_ch_mode_info,
7191 .get = alc_ch_mode_get,
7192 .put = alc_ch_mode_put,
7193 },
7194 { } /* end */
7195};
7196
Takashi Iwai4953550a2009-06-30 15:28:30 +02007197static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007198 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007199 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7200 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7201 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007202 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007203 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7204 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7205 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007206 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007207 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7208 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7209 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007210 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007211 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7212 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7213 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007214
Takashi Iwaicb638122009-07-03 10:56:10 +02007215 /* mute analog input loopbacks */
7216 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7217 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7218 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7219 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7220 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7221
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007222 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007223 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007224 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007225 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007226 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007227 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007228 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007229 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007230 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007231 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007232 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007233 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007234 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007235 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007236 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007237 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007238 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007239 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007240 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7241 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007242 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007243 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7244 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007245 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007246 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7247 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7248 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7249 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7250 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007251 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007252 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007253
7254 /* FIXME: use matrix-type input source selection */
7255 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007256 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007257 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7258 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7259 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7260 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007261 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007262 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7263 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7264 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7265 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007266 /* ADC2: mute amp left and right */
7267 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007268 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007269 /* ADC3: mute amp left and right */
7270 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007271 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007272
7273 { }
7274};
7275
Takashi Iwai4953550a2009-06-30 15:28:30 +02007276static struct hda_verb alc882_adc1_init_verbs[] = {
7277 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7278 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7279 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7280 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7281 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7282 /* ADC1: mute amp left and right */
7283 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7284 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7285 { }
7286};
7287
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007288static struct hda_verb alc882_eapd_verbs[] = {
7289 /* change to EAPD mode */
7290 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007291 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007292 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007293};
7294
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007295static struct hda_verb alc889_eapd_verbs[] = {
7296 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7297 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7298 { }
7299};
7300
Wu Fengguang6732bd02009-07-30 09:19:14 +02007301static struct hda_verb alc_hp15_unsol_verbs[] = {
7302 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7303 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7304 {}
7305};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007306
7307static struct hda_verb alc885_init_verbs[] = {
7308 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7309 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7310 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7311 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7312 /* Rear mixer */
7313 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7314 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7315 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7316 /* CLFE mixer */
7317 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7318 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7319 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7320 /* Side mixer */
7321 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7322 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7323 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7324
7325 /* mute analog input loopbacks */
7326 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7327 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7328 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7329
7330 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007331 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007332 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7333 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7334 /* Front Pin: output 0 (0x0c) */
7335 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7336 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7337 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7338 /* Rear Pin: output 1 (0x0d) */
7339 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7340 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7341 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7342 /* CLFE Pin: output 2 (0x0e) */
7343 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7344 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7345 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7346 /* Side Pin: output 3 (0x0f) */
7347 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7348 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7349 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7350 /* Mic (rear) pin: input vref at 80% */
7351 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7352 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7353 /* Front Mic pin: input vref at 80% */
7354 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7355 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7356 /* Line In pin: input */
7357 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7358 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7359
7360 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7361 /* Input mixer1 */
7362 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7363 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7364 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7365 /* Input mixer2 */
7366 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7367 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7368 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7369 /* Input mixer3 */
7370 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7371 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7372 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7373 /* ADC2: mute amp left and right */
7374 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7375 /* ADC3: mute amp left and right */
7376 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7377
7378 { }
7379};
7380
7381static struct hda_verb alc885_init_input_verbs[] = {
7382 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7383 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7384 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7385 { }
7386};
7387
7388
7389/* Unmute Selector 24h and set the default input to front mic */
7390static struct hda_verb alc889_init_input_verbs[] = {
7391 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7392 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7393 { }
7394};
7395
7396
Takashi Iwai4953550a2009-06-30 15:28:30 +02007397#define alc883_init_verbs alc882_base_init_verbs
7398
Tobin Davis9102cd12006-12-15 10:02:12 +01007399/* Mac Pro test */
7400static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7401 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7402 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7403 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7404 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7405 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007406 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007407 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7408 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007409 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007410 { } /* end */
7411};
7412
7413static struct hda_verb alc882_macpro_init_verbs[] = {
7414 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7415 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7416 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7417 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7418 /* Front Pin: output 0 (0x0c) */
7419 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7420 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7421 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7422 /* Front Mic pin: input vref at 80% */
7423 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7424 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7425 /* Speaker: output */
7426 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7427 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7428 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7429 /* Headphone output (output 0 - 0x0c) */
7430 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7431 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7432 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7433
7434 /* FIXME: use matrix-type input source selection */
7435 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7436 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7437 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7438 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7439 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7440 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7441 /* Input mixer2 */
7442 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7443 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7444 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7445 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7446 /* Input mixer3 */
7447 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7448 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7449 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7450 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7451 /* ADC1: mute amp left and right */
7452 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7453 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7454 /* ADC2: mute amp left and right */
7455 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7456 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7457 /* ADC3: mute amp left and right */
7458 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7459 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7460
7461 { }
7462};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007463
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007464/* Macbook 5,1 */
7465static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007466 /* DACs */
7467 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7468 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7469 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7470 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007471 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007472 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7473 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7474 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007475 /* Surround mixer */
7476 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7477 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7478 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7479 /* LFE mixer */
7480 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7481 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7482 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7483 /* HP mixer */
7484 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7485 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7486 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7487 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007488 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7489 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007490 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7491 /* LFE Pin (0x0e) */
7492 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7493 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7494 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7495 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007496 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7497 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007498 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10307499 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007500 /* Front Mic pin: input vref at 80% */
7501 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7502 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7503 /* Line In pin */
7504 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7505 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7506
7507 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7508 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7509 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7510 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7511 { }
7512};
7513
Takashi Iwai87350ad2007-08-16 18:19:38 +02007514/* Macbook Pro rev3 */
7515static struct hda_verb alc885_mbp3_init_verbs[] = {
7516 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7517 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7518 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7519 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7520 /* Rear mixer */
7521 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7522 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7523 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007524 /* HP mixer */
7525 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7526 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7527 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007528 /* Front Pin: output 0 (0x0c) */
7529 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7530 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7531 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007532 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007533 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007534 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7535 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007536 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7537 /* Mic (rear) pin: input vref at 80% */
7538 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7539 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7540 /* Front Mic pin: input vref at 80% */
7541 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7542 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7543 /* Line In pin: use output 1 when in LineOut mode */
7544 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7545 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7546 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7547
7548 /* FIXME: use matrix-type input source selection */
7549 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7550 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7551 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7552 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7553 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7554 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7555 /* Input mixer2 */
7556 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7557 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7558 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7559 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7560 /* Input mixer3 */
7561 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7562 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7563 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7564 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7565 /* ADC1: mute amp left and right */
7566 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7567 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7568 /* ADC2: mute amp left and right */
7569 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7570 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7571 /* ADC3: mute amp left and right */
7572 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7573 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7574
7575 { }
7576};
7577
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007578/* iMac 9,1 */
7579static struct hda_verb alc885_imac91_init_verbs[] = {
7580 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
7581 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7582 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7583 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7584 /* Rear mixer */
7585 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7586 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7587 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7588 /* HP Pin: output 0 (0x0c) */
7589 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7590 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7591 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7592 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7593 /* Internal Speakers: output 0 (0x0d) */
7594 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7595 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7596 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7597 /* Mic (rear) pin: input vref at 80% */
7598 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7599 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7600 /* Front Mic pin: input vref at 80% */
7601 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7602 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7603 /* Line In pin: use output 1 when in LineOut mode */
7604 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7605 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7606 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7607
7608 /* FIXME: use matrix-type input source selection */
7609 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7610 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7611 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7612 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7613 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7614 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7615 /* Input mixer2 */
7616 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7617 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7618 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7619 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7620 /* Input mixer3 */
7621 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7622 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7623 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7624 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7625 /* ADC1: mute amp left and right */
7626 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7627 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7628 /* ADC2: mute amp left and right */
7629 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7630 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7631 /* ADC3: mute amp left and right */
7632 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7633 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7634
7635 { }
7636};
7637
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007638/* iMac 24 mixer. */
7639static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7640 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7641 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7642 { } /* end */
7643};
7644
7645/* iMac 24 init verbs. */
7646static struct hda_verb alc885_imac24_init_verbs[] = {
7647 /* Internal speakers: output 0 (0x0c) */
7648 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7649 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7650 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7651 /* Internal speakers: output 0 (0x0c) */
7652 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7653 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7654 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7655 /* Headphone: output 0 (0x0c) */
7656 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7657 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7658 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7659 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7660 /* Front Mic: input vref at 80% */
7661 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7662 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7663 { }
7664};
7665
7666/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007667static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007668{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007669 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007670
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007671 spec->autocfg.hp_pins[0] = 0x14;
7672 spec->autocfg.speaker_pins[0] = 0x18;
7673 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007674}
7675
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007676static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007677{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007678 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007679
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007680 spec->autocfg.hp_pins[0] = 0x15;
7681 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02007682}
7683
Alex Murraya76221d2010-01-13 23:15:03 +10307684static void alc885_mb5_automute(struct hda_codec *codec)
7685{
7686 unsigned int present;
7687
7688 present = snd_hda_codec_read(codec, 0x14, 0,
7689 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7690 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
7691 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7692 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
7693 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7694
7695}
7696
7697static void alc885_mb5_unsol_event(struct hda_codec *codec,
7698 unsigned int res)
7699{
7700 /* Headphone insertion or removal. */
7701 if ((res >> 26) == ALC880_HP_EVENT)
7702 alc885_mb5_automute(codec);
7703}
7704
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007705static void alc885_imac91_automute(struct hda_codec *codec)
7706{
7707 unsigned int present;
7708
7709 present = snd_hda_codec_read(codec, 0x14, 0,
7710 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7711 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7712 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7713 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
7714 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7715
7716}
7717
7718static void alc885_imac91_unsol_event(struct hda_codec *codec,
7719 unsigned int res)
7720{
7721 /* Headphone insertion or removal. */
7722 if ((res >> 26) == ALC880_HP_EVENT)
7723 alc885_imac91_automute(codec);
7724}
Takashi Iwai87350ad2007-08-16 18:19:38 +02007725
Kailang Yang272a5272007-05-14 11:00:38 +02007726static struct hda_verb alc882_targa_verbs[] = {
7727 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7728 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7729
7730 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7731 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007732
Kailang Yang272a5272007-05-14 11:00:38 +02007733 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7734 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7735 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7736
7737 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007738 { } /* end */
7739};
7740
7741/* toggle speaker-output according to the hp-jack state */
7742static void alc882_targa_automute(struct hda_codec *codec)
7743{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007744 struct alc_spec *spec = codec->spec;
7745 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007746 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007747 spec->jack_present ? 1 : 3);
7748}
7749
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007750static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007751{
7752 struct alc_spec *spec = codec->spec;
7753
7754 spec->autocfg.hp_pins[0] = 0x14;
7755 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02007756}
7757
7758static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7759{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007760 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007761 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007762}
7763
7764static struct hda_verb alc882_asus_a7j_verbs[] = {
7765 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7766 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7767
7768 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7769 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7770 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007771
Kailang Yang272a5272007-05-14 11:00:38 +02007772 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7773 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7774 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7775
7776 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7777 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7778 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7779 { } /* end */
7780};
7781
Takashi Iwai914759b2007-09-06 14:52:04 +02007782static struct hda_verb alc882_asus_a7m_verbs[] = {
7783 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7784 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7785
7786 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7787 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7788 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007789
Takashi Iwai914759b2007-09-06 14:52:04 +02007790 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7791 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7792 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7793
7794 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7795 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7796 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7797 { } /* end */
7798};
7799
Tobin Davis9102cd12006-12-15 10:02:12 +01007800static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7801{
7802 unsigned int gpiostate, gpiomask, gpiodir;
7803
7804 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7805 AC_VERB_GET_GPIO_DATA, 0);
7806
7807 if (!muted)
7808 gpiostate |= (1 << pin);
7809 else
7810 gpiostate &= ~(1 << pin);
7811
7812 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7813 AC_VERB_GET_GPIO_MASK, 0);
7814 gpiomask |= (1 << pin);
7815
7816 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7817 AC_VERB_GET_GPIO_DIRECTION, 0);
7818 gpiodir |= (1 << pin);
7819
7820
7821 snd_hda_codec_write(codec, codec->afg, 0,
7822 AC_VERB_SET_GPIO_MASK, gpiomask);
7823 snd_hda_codec_write(codec, codec->afg, 0,
7824 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7825
7826 msleep(1);
7827
7828 snd_hda_codec_write(codec, codec->afg, 0,
7829 AC_VERB_SET_GPIO_DATA, gpiostate);
7830}
7831
Takashi Iwai7debbe52007-08-16 15:01:03 +02007832/* set up GPIO at initialization */
7833static void alc885_macpro_init_hook(struct hda_codec *codec)
7834{
7835 alc882_gpio_mute(codec, 0, 0);
7836 alc882_gpio_mute(codec, 1, 0);
7837}
7838
7839/* set up GPIO and update auto-muting at initialization */
7840static void alc885_imac24_init_hook(struct hda_codec *codec)
7841{
7842 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007843 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007844}
7845
Kailang Yangdf694da2005-12-05 19:42:22 +01007846/*
7847 * generic initialization of ADC, input mixers and output mixers
7848 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007849static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007850 /*
7851 * Unmute ADC0-2 and set the default input to mic-in
7852 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007853 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7854 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7855 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7856 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7857
Takashi Iwaicb53c622007-08-10 17:21:45 +02007858 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007859 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007860 * Note: PASD motherboards uses the Line In 2 as the input for
7861 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007862 */
7863 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007864 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7865 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7866 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7867 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7868 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007869
7870 /*
7871 * Set up output mixers (0x0c - 0x0f)
7872 */
7873 /* set vol=0 to output mixers */
7874 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7875 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7876 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7877 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7878 /* set up input amps for analog loopback */
7879 /* Amp Indices: DAC = 0, mixer = 1 */
7880 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7881 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7882 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7883 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7884 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7885 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7886 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7887 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7888 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7889 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7890
7891 /* FIXME: use matrix-type input source selection */
7892 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01007893 /* Input mixer2 */
7894 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7895 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7896 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7897 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7898 /* Input mixer3 */
7899 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7900 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7901 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7902 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7903
7904 { }
7905};
7906
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007907/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7908static struct hda_verb alc889A_mb31_ch2_init[] = {
7909 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7910 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7911 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7912 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7913 { } /* end */
7914};
7915
7916/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7917static struct hda_verb alc889A_mb31_ch4_init[] = {
7918 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7919 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7920 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7921 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7922 { } /* end */
7923};
7924
7925/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7926static struct hda_verb alc889A_mb31_ch5_init[] = {
7927 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7928 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7929 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7930 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7931 { } /* end */
7932};
7933
7934/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7935static struct hda_verb alc889A_mb31_ch6_init[] = {
7936 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7937 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7938 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7939 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7940 { } /* end */
7941};
7942
7943static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7944 { 2, alc889A_mb31_ch2_init },
7945 { 4, alc889A_mb31_ch4_init },
7946 { 5, alc889A_mb31_ch5_init },
7947 { 6, alc889A_mb31_ch6_init },
7948};
7949
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007950static struct hda_verb alc883_medion_eapd_verbs[] = {
7951 /* eanable EAPD on medion laptop */
7952 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7953 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7954 { }
7955};
7956
Takashi Iwai4953550a2009-06-30 15:28:30 +02007957#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007958
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007959static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7960 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7961 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7962 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7963 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7964 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7965 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7966 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7967 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7968 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7969 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7970 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7971 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7972 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007973 { } /* end */
7974};
7975
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007976static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007977 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7978 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7979 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7980 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7981 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7982 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7983 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7984 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7985 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7986 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007987 { } /* end */
7988};
7989
Jiang zhefb97dc62008-03-06 11:07:11 +01007990static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7991 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7992 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7993 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7994 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7995 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7996 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7997 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7998 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7999 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8000 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008001 { } /* end */
8002};
8003
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008004static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8005 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8006 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8007 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8008 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8009 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8010 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8011 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8012 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008013 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008014 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8015 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008016 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008017 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008018 { } /* end */
8019};
8020
8021static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8022 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8023 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8024 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8025 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8026 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8027 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8028 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8029 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8030 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8031 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8032 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8033 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8034 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8035 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008036 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008037 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8038 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008039 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008040 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008041 { } /* end */
8042};
8043
Jiang zhe17bba1b2008-06-04 12:11:07 +02008044static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8045 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8046 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8047 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8048 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8049 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8050 HDA_OUTPUT),
8051 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8052 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8053 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8054 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8055 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8056 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8057 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8058 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8059 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8060 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8061 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8062 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8063 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8064 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008065 { } /* end */
8066};
8067
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008068static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8069 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8070 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8071 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8072 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8073 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8074 HDA_OUTPUT),
8075 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8076 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8077 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8078 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8079 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8080 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8081 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8082 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8083 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8084 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8085 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8086 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8087 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8088 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8089 { } /* end */
8090};
8091
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008092static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008093 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008094 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008095 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008096 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008097 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8098 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008099 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8100 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008101 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8102 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8103 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8104 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8105 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8106 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008107 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008108 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8109 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008110 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008111 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008112 { } /* end */
8113};
8114
Sasha Alexandrc2592492009-06-16 14:52:54 -04008115static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008116 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008117 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008118 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008119 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008120 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8121 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8122 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8123 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8124 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8125 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8126 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8127 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8128 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8129 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8130 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008131 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008132 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008133 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008134};
Kailang Yangccc656c2006-10-17 12:32:26 +02008135
Sasha Alexandrc2592492009-06-16 14:52:54 -04008136static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008137 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008138 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008139 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008140 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008141 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8142 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8143 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008144 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008145 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008146 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8147 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8148 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008149 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008150};
Kailang Yangccc656c2006-10-17 12:32:26 +02008151
Takashi Iwaib99dba32009-09-17 18:23:00 +02008152static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8153 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8154 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8155 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8156 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8157 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8158 { } /* end */
8159};
8160
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008161static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8162 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8163 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008164 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8165 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008166 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8167 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8168 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8169 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008170 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008171};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008172
Kailang Yang272a5272007-05-14 11:00:38 +02008173static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8174 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8175 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8176 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8177 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8178 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8179 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8180 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8181 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8182 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008183 { } /* end */
8184};
8185
8186static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8187 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8188 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8189 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8190 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8191 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8192 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8193 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8194 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8195 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008196 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008197};
Kailang Yang272a5272007-05-14 11:00:38 +02008198
Tobin Davis2880a862007-08-07 11:50:26 +02008199static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008200 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8201 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008202 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008203 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8204 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008205 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8206 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8207 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008208 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008209};
Tobin Davis2880a862007-08-07 11:50:26 +02008210
Tony Vroond2fd4b02009-06-21 00:40:10 +01008211static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8212 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8213 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8214 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8215 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008216 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8217 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008218 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8219 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8220 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8221 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8222 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8223 { } /* end */
8224};
8225
Kailang Yange2757d52008-08-26 13:17:46 +02008226static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8227 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8228 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8229 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8230 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8231 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8232 0x0d, 1, 0x0, HDA_OUTPUT),
8233 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8234 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8235 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8236 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8237 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008238 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8239 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8240 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8241 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8242 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8243 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8244 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8245 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8246 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8247 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008248 { } /* end */
8249};
8250
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008251static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8252 /* Output mixers */
8253 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8254 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8255 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8256 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8257 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8258 HDA_OUTPUT),
8259 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8260 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8261 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8262 /* Output switches */
8263 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8264 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8265 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8266 /* Boost mixers */
8267 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8268 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8269 /* Input mixers */
8270 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8271 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8272 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8273 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8274 { } /* end */
8275};
8276
Guido Günther3e1647c52009-06-05 00:47:26 +02008277static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8278 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8279 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8280 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8281 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8282 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8283 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8284 { } /* end */
8285};
8286
Kailang Yange2757d52008-08-26 13:17:46 +02008287static struct hda_bind_ctls alc883_bind_cap_vol = {
8288 .ops = &snd_hda_bind_vol,
8289 .values = {
8290 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8291 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8292 0
8293 },
8294};
8295
8296static struct hda_bind_ctls alc883_bind_cap_switch = {
8297 .ops = &snd_hda_bind_sw,
8298 .values = {
8299 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8300 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8301 0
8302 },
8303};
8304
8305static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8306 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8307 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8308 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8309 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8310 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8311 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8312 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8313 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008314 { } /* end */
8315};
8316
8317static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008318 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8319 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8320 {
8321 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8322 /* .name = "Capture Source", */
8323 .name = "Input Source",
8324 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008325 .info = alc_mux_enum_info,
8326 .get = alc_mux_enum_get,
8327 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008328 },
8329 { } /* end */
8330};
8331
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008332static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8333 {
8334 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8335 .name = "Channel Mode",
8336 .info = alc_ch_mode_info,
8337 .get = alc_ch_mode_get,
8338 .put = alc_ch_mode_put,
8339 },
8340 { } /* end */
8341};
8342
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008343/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008344static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008345{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008346 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008347
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008348 spec->autocfg.hp_pins[0] = 0x15;
8349 spec->autocfg.speaker_pins[0] = 0x14;
8350 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008351}
8352
8353/* auto-toggle front mic */
8354/*
8355static void alc883_mitac_mic_automute(struct hda_codec *codec)
8356{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008357 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008358
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008359 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8360}
8361*/
8362
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008363static struct hda_verb alc883_mitac_verbs[] = {
8364 /* HP */
8365 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8366 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8367 /* Subwoofer */
8368 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8369 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8370
8371 /* enable unsolicited event */
8372 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8373 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8374
8375 { } /* end */
8376};
8377
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308378static struct hda_verb alc883_clevo_m540r_verbs[] = {
8379 /* HP */
8380 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8381 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8382 /* Int speaker */
8383 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8384
8385 /* enable unsolicited event */
8386 /*
8387 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8388 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8389 */
8390
8391 { } /* end */
8392};
8393
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008394static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008395 /* HP */
8396 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8397 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8398 /* Int speaker */
8399 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8400 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8401
8402 /* enable unsolicited event */
8403 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008404 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008405
8406 { } /* end */
8407};
8408
Jiang zhefb97dc62008-03-06 11:07:11 +01008409static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8410 /* HP */
8411 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8412 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8413 /* Subwoofer */
8414 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8415 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8416
8417 /* enable unsolicited event */
8418 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8419
8420 { } /* end */
8421};
8422
Sasha Alexandrc2592492009-06-16 14:52:54 -04008423static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008424 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8425 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8426
8427 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8428 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008429
David Heidelberger64a8be72009-06-08 16:15:18 +02008430/* Connect Line-Out side jack (SPDIF) to Side */
8431 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8432 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8433 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8434/* Connect Mic jack to CLFE */
8435 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8436 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8437 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8438/* Connect Line-in jack to Surround */
8439 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8440 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8441 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8442/* Connect HP out jack to Front */
8443 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8444 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8445 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008446
8447 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008448
8449 { } /* end */
8450};
8451
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008452static struct hda_verb alc883_lenovo_101e_verbs[] = {
8453 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8454 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8455 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8456 { } /* end */
8457};
8458
Kailang Yang272a5272007-05-14 11:00:38 +02008459static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8460 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8461 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8462 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8463 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8464 { } /* end */
8465};
8466
8467static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8468 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8469 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8470 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8471 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8472 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8473 { } /* end */
8474};
8475
Kailang Yang189609a2007-08-20 11:31:23 +02008476static struct hda_verb alc883_haier_w66_verbs[] = {
8477 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8478 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8479
8480 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8481
8482 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8483 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8484 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8485 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8486 { } /* end */
8487};
8488
Kailang Yange2757d52008-08-26 13:17:46 +02008489static struct hda_verb alc888_lenovo_sky_verbs[] = {
8490 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8491 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8492 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8493 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8494 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8495 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8496 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8497 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8498 { } /* end */
8499};
8500
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008501static struct hda_verb alc888_6st_dell_verbs[] = {
8502 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8503 { }
8504};
8505
Guido Günther3e1647c52009-06-05 00:47:26 +02008506static struct hda_verb alc883_vaiott_verbs[] = {
8507 /* HP */
8508 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8509 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8510
8511 /* enable unsolicited event */
8512 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8513
8514 { } /* end */
8515};
8516
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008517static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008518{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008519 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008520
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008521 spec->autocfg.hp_pins[0] = 0x1b;
8522 spec->autocfg.speaker_pins[0] = 0x14;
8523 spec->autocfg.speaker_pins[1] = 0x16;
8524 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008525}
8526
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008527static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008528 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008529 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8530 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008531 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008532 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008533};
8534
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008535/*
8536 * 2ch mode
8537 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008538static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008539 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8540 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8541 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8542 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008543 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008544};
8545
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008546/*
8547 * 4ch mode
8548 */
8549static struct hda_verb alc888_3st_hp_4ch_init[] = {
8550 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8551 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8552 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8553 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8554 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8555 { } /* end */
8556};
8557
8558/*
8559 * 6ch mode
8560 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008561static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008562 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8563 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008564 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008565 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8566 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008567 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8568 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008569};
8570
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008571static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008572 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008573 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008574 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008575};
8576
Kailang Yang272a5272007-05-14 11:00:38 +02008577/* toggle front-jack and RCA according to the hp-jack state */
8578static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8579{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008580 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02008581
Takashi Iwai47fd8302007-08-10 17:11:07 +02008582 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8583 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8584 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8585 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008586}
8587
8588/* toggle RCA according to the front-jack state */
8589static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8590{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008591 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02008592
Takashi Iwai47fd8302007-08-10 17:11:07 +02008593 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8594 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008595}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008596
Kailang Yang272a5272007-05-14 11:00:38 +02008597static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8598 unsigned int res)
8599{
8600 if ((res >> 26) == ALC880_HP_EVENT)
8601 alc888_lenovo_ms7195_front_automute(codec);
8602 if ((res >> 26) == ALC880_FRONT_EVENT)
8603 alc888_lenovo_ms7195_rca_automute(codec);
8604}
8605
8606static struct hda_verb alc883_medion_md2_verbs[] = {
8607 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8608 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8609
8610 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8611
8612 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8613 { } /* end */
8614};
8615
8616/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008617static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008618{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008619 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008620
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008621 spec->autocfg.hp_pins[0] = 0x14;
8622 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008623}
8624
Kailang Yangccc656c2006-10-17 12:32:26 +02008625/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008626#define alc883_targa_init_hook alc882_targa_init_hook
8627#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008628
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008629static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8630{
8631 unsigned int present;
8632
Takashi Iwaid56757a2009-11-18 08:00:14 +01008633 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008634 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8635 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8636}
8637
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008638static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008639{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008640 struct alc_spec *spec = codec->spec;
8641
8642 spec->autocfg.hp_pins[0] = 0x15;
8643 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008644}
8645
8646static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8647{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008648 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008649 alc883_clevo_m720_mic_automute(codec);
8650}
8651
8652static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008653 unsigned int res)
8654{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008655 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008656 case ALC880_MIC_EVENT:
8657 alc883_clevo_m720_mic_automute(codec);
8658 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008659 default:
8660 alc_automute_amp_unsol_event(codec, res);
8661 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008662 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008663}
8664
Jiang zhefb97dc62008-03-06 11:07:11 +01008665/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008666static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008667{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008668 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008669
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008670 spec->autocfg.hp_pins[0] = 0x14;
8671 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01008672}
8673
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008674static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008675{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008676 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008677
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008678 spec->autocfg.hp_pins[0] = 0x1b;
8679 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02008680}
8681
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008682static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8683{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008684 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008685
Takashi Iwai47fd8302007-08-10 17:11:07 +02008686 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8687 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008688}
8689
8690static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8691{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008692 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008693
Takashi Iwai47fd8302007-08-10 17:11:07 +02008694 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8695 HDA_AMP_MUTE, bits);
8696 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8697 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008698}
8699
8700static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8701 unsigned int res)
8702{
8703 if ((res >> 26) == ALC880_HP_EVENT)
8704 alc883_lenovo_101e_all_automute(codec);
8705 if ((res >> 26) == ALC880_FRONT_EVENT)
8706 alc883_lenovo_101e_ispeaker_automute(codec);
8707}
8708
Takashi Iwai676a9b52007-08-16 15:23:35 +02008709/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008710static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008711{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008712 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008713
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008714 spec->autocfg.hp_pins[0] = 0x14;
8715 spec->autocfg.speaker_pins[0] = 0x15;
8716 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02008717}
8718
Kailang Yangd1a991a2007-08-15 16:21:59 +02008719static struct hda_verb alc883_acer_eapd_verbs[] = {
8720 /* HP Pin: output 0 (0x0c) */
8721 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8722 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8723 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8724 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008725 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8726 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008727 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008728 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8729 /* eanable EAPD on medion laptop */
8730 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8731 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008732 /* enable unsolicited event */
8733 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008734 { }
8735};
8736
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008737static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8738 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8739 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8740 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8741 { } /* end */
8742};
8743
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008744static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008745{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008746 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008747
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008748 spec->autocfg.hp_pins[0] = 0x1b;
8749 spec->autocfg.speaker_pins[0] = 0x14;
8750 spec->autocfg.speaker_pins[1] = 0x15;
8751 spec->autocfg.speaker_pins[2] = 0x16;
8752 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008753}
8754
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008755static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008756{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008757 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008758
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008759 spec->autocfg.hp_pins[0] = 0x1b;
8760 spec->autocfg.speaker_pins[0] = 0x14;
8761 spec->autocfg.speaker_pins[1] = 0x15;
8762 spec->autocfg.speaker_pins[2] = 0x16;
8763 spec->autocfg.speaker_pins[3] = 0x17;
8764 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02008765}
8766
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008767static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c52009-06-05 00:47:26 +02008768{
8769 struct alc_spec *spec = codec->spec;
8770
8771 spec->autocfg.hp_pins[0] = 0x15;
8772 spec->autocfg.speaker_pins[0] = 0x14;
8773 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c52009-06-05 00:47:26 +02008774}
8775
Kailang Yange2757d52008-08-26 13:17:46 +02008776static struct hda_verb alc888_asus_m90v_verbs[] = {
8777 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8778 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8779 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8780 /* enable unsolicited event */
8781 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8782 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8783 { } /* end */
8784};
8785
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008786static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008787{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008788 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008789
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008790 spec->autocfg.hp_pins[0] = 0x1b;
8791 spec->autocfg.speaker_pins[0] = 0x14;
8792 spec->autocfg.speaker_pins[1] = 0x15;
8793 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008794 spec->ext_mic.pin = 0x18;
8795 spec->int_mic.pin = 0x19;
8796 spec->ext_mic.mux_idx = 0;
8797 spec->int_mic.mux_idx = 1;
8798 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02008799}
8800
8801static struct hda_verb alc888_asus_eee1601_verbs[] = {
8802 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8803 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8804 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8805 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8806 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8807 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8808 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8809 /* enable unsolicited event */
8810 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8811 { } /* end */
8812};
8813
Kailang Yange2757d52008-08-26 13:17:46 +02008814static void alc883_eee1601_inithook(struct hda_codec *codec)
8815{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008816 struct alc_spec *spec = codec->spec;
8817
8818 spec->autocfg.hp_pins[0] = 0x14;
8819 spec->autocfg.speaker_pins[0] = 0x1b;
8820 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008821}
8822
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008823static struct hda_verb alc889A_mb31_verbs[] = {
8824 /* Init rear pin (used as headphone output) */
8825 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8826 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8827 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8828 /* Init line pin (used as output in 4ch and 6ch mode) */
8829 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8830 /* Init line 2 pin (used as headphone out by default) */
8831 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8832 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8833 { } /* end */
8834};
8835
8836/* Mute speakers according to the headphone jack state */
8837static void alc889A_mb31_automute(struct hda_codec *codec)
8838{
8839 unsigned int present;
8840
8841 /* Mute only in 2ch or 4ch mode */
8842 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8843 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08008844 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008845 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8846 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8847 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8848 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8849 }
8850}
8851
8852static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8853{
8854 if ((res >> 26) == ALC880_HP_EVENT)
8855 alc889A_mb31_automute(codec);
8856}
8857
Takashi Iwai4953550a2009-06-30 15:28:30 +02008858
Takashi Iwaicb53c622007-08-10 17:21:45 +02008859#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02008860#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02008861#endif
8862
Sasha Alexandrdef319f2009-06-16 16:00:15 -04008863/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008864#define alc882_pcm_analog_playback alc880_pcm_analog_playback
8865#define alc882_pcm_analog_capture alc880_pcm_analog_capture
8866#define alc882_pcm_digital_playback alc880_pcm_digital_playback
8867#define alc882_pcm_digital_capture alc880_pcm_digital_capture
8868
8869static hda_nid_t alc883_slave_dig_outs[] = {
8870 ALC1200_DIGOUT_NID, 0,
8871};
8872
8873static hda_nid_t alc1200_slave_dig_outs[] = {
8874 ALC883_DIGOUT_NID, 0,
8875};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008876
8877/*
8878 * configuration and preset
8879 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008880static const char *alc882_models[ALC882_MODEL_LAST] = {
8881 [ALC882_3ST_DIG] = "3stack-dig",
8882 [ALC882_6ST_DIG] = "6stack-dig",
8883 [ALC882_ARIMA] = "arima",
8884 [ALC882_W2JC] = "w2jc",
8885 [ALC882_TARGA] = "targa",
8886 [ALC882_ASUS_A7J] = "asus-a7j",
8887 [ALC882_ASUS_A7M] = "asus-a7m",
8888 [ALC885_MACPRO] = "macpro",
8889 [ALC885_MB5] = "mb5",
8890 [ALC885_MBP3] = "mbp3",
8891 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008892 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008893 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008894 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8895 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008896 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008897 [ALC883_TARGA_DIG] = "targa-dig",
8898 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02008899 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008900 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008901 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008902 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02008903 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02008904 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008905 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008906 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008907 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008908 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008909 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008910 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8911 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008912 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008913 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008914 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008915 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008916 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308917 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008918 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008919 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008920 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008921 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008922 [ALC889A_INTEL] = "intel-alc889a",
8923 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008924 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008925 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c52009-06-05 00:47:26 +02008926 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008927 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008928};
8929
Takashi Iwai4953550a2009-06-30 15:28:30 +02008930static struct snd_pci_quirk alc882_cfg_tbl[] = {
8931 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8932
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008933 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008934 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008935 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008936 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8937 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008938 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008939 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8940 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008941 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01008942 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02008943 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8944 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02008945 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
8946 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008947 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
8948 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008949 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02008950 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008951 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01008952 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008953 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
8954 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02008955 /* default Acer -- disabled as it causes more problems.
8956 * model=auto should work fine now
8957 */
8958 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008959
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008960 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008961
Tobin Davisfebe3372007-06-12 11:27:46 +02008962 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008963 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8964 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008965 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008966 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008967 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008968
8969 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8970 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8971 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008972 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008973 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8974 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8975 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008976 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008977 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008978 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008979 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008980
8981 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02008982 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008983 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008984 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008985 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8986 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008987 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008988 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008989 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8990
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008991 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8992 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8993 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008994 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01008995 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008996 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008997 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008998 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008999 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9000 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9001 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9002 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9003 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9004 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009005 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009006 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9007 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9008 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009009 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009010 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9011 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009012 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009013 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009014 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009015 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009016 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009017 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009018 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009019 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009020
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009021 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009022 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9023 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309024 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009025 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009026 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009027 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009028 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009029 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009030 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009031 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009032 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009033 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009034 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009035 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9036 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009037 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009038 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009039 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009040 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009041 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009042
Jiang zhe17bba1b2008-06-04 12:11:07 +02009043 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9044 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009045 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009046 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9047 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9048 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009049 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009050
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009051 {}
9052};
9053
Takashi Iwai4953550a2009-06-30 15:28:30 +02009054/* codec SSID table for Intel Mac */
9055static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9056 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9057 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9058 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9059 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9060 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9061 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9062 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
9063 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9064 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9065 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009066 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009067 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009068 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9069 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009070 */
9071 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009072 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009073 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009074};
9075
Takashi Iwai4953550a2009-06-30 15:28:30 +02009076static struct alc_config_preset alc882_presets[] = {
9077 [ALC882_3ST_DIG] = {
9078 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009079 .init_verbs = { alc882_base_init_verbs,
9080 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009081 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9082 .dac_nids = alc882_dac_nids,
9083 .dig_out_nid = ALC882_DIGOUT_NID,
9084 .dig_in_nid = ALC882_DIGIN_NID,
9085 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9086 .channel_mode = alc882_ch_modes,
9087 .need_dac_fix = 1,
9088 .input_mux = &alc882_capture_source,
9089 },
9090 [ALC882_6ST_DIG] = {
9091 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009092 .init_verbs = { alc882_base_init_verbs,
9093 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009094 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9095 .dac_nids = alc882_dac_nids,
9096 .dig_out_nid = ALC882_DIGOUT_NID,
9097 .dig_in_nid = ALC882_DIGIN_NID,
9098 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9099 .channel_mode = alc882_sixstack_modes,
9100 .input_mux = &alc882_capture_source,
9101 },
9102 [ALC882_ARIMA] = {
9103 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009104 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9105 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009106 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9107 .dac_nids = alc882_dac_nids,
9108 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9109 .channel_mode = alc882_sixstack_modes,
9110 .input_mux = &alc882_capture_source,
9111 },
9112 [ALC882_W2JC] = {
9113 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009114 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9115 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009116 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9117 .dac_nids = alc882_dac_nids,
9118 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9119 .channel_mode = alc880_threestack_modes,
9120 .need_dac_fix = 1,
9121 .input_mux = &alc882_capture_source,
9122 .dig_out_nid = ALC882_DIGOUT_NID,
9123 },
9124 [ALC885_MBP3] = {
9125 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9126 .init_verbs = { alc885_mbp3_init_verbs,
9127 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009128 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009129 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009130 .hp_nid = 0x04,
9131 .channel_mode = alc885_mbp_4ch_modes,
9132 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009133 .input_mux = &alc882_capture_source,
9134 .dig_out_nid = ALC882_DIGOUT_NID,
9135 .dig_in_nid = ALC882_DIGIN_NID,
9136 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009137 .setup = alc885_mbp3_setup,
9138 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009139 },
9140 [ALC885_MB5] = {
9141 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9142 .init_verbs = { alc885_mb5_init_verbs,
9143 alc880_gpio1_init_verbs },
9144 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9145 .dac_nids = alc882_dac_nids,
9146 .channel_mode = alc885_mb5_6ch_modes,
9147 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9148 .input_mux = &mb5_capture_source,
9149 .dig_out_nid = ALC882_DIGOUT_NID,
9150 .dig_in_nid = ALC882_DIGIN_NID,
Alex Murraya76221d2010-01-13 23:15:03 +10309151 .unsol_event = alc885_mb5_unsol_event,
9152 .init_hook = alc885_mb5_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009153 },
9154 [ALC885_MACPRO] = {
9155 .mixers = { alc882_macpro_mixer },
9156 .init_verbs = { alc882_macpro_init_verbs },
9157 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9158 .dac_nids = alc882_dac_nids,
9159 .dig_out_nid = ALC882_DIGOUT_NID,
9160 .dig_in_nid = ALC882_DIGIN_NID,
9161 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9162 .channel_mode = alc882_ch_modes,
9163 .input_mux = &alc882_capture_source,
9164 .init_hook = alc885_macpro_init_hook,
9165 },
9166 [ALC885_IMAC24] = {
9167 .mixers = { alc885_imac24_mixer },
9168 .init_verbs = { alc885_imac24_init_verbs },
9169 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9170 .dac_nids = alc882_dac_nids,
9171 .dig_out_nid = ALC882_DIGOUT_NID,
9172 .dig_in_nid = ALC882_DIGIN_NID,
9173 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9174 .channel_mode = alc882_ch_modes,
9175 .input_mux = &alc882_capture_source,
9176 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009177 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009178 .init_hook = alc885_imac24_init_hook,
9179 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009180 [ALC885_IMAC91] = {
9181 .mixers = { alc885_imac91_mixer, alc882_chmode_mixer },
9182 .init_verbs = { alc885_imac91_init_verbs,
9183 alc880_gpio1_init_verbs },
9184 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9185 .dac_nids = alc882_dac_nids,
9186 .channel_mode = alc885_mbp_4ch_modes,
9187 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
9188 .input_mux = &alc882_capture_source,
9189 .dig_out_nid = ALC882_DIGOUT_NID,
9190 .dig_in_nid = ALC882_DIGIN_NID,
9191 .unsol_event = alc885_imac91_unsol_event,
9192 .init_hook = alc885_imac91_automute,
9193 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009194 [ALC882_TARGA] = {
9195 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009196 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009197 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009198 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9199 .dac_nids = alc882_dac_nids,
9200 .dig_out_nid = ALC882_DIGOUT_NID,
9201 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9202 .adc_nids = alc882_adc_nids,
9203 .capsrc_nids = alc882_capsrc_nids,
9204 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9205 .channel_mode = alc882_3ST_6ch_modes,
9206 .need_dac_fix = 1,
9207 .input_mux = &alc882_capture_source,
9208 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009209 .setup = alc882_targa_setup,
9210 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009211 },
9212 [ALC882_ASUS_A7J] = {
9213 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009214 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9215 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009216 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9217 .dac_nids = alc882_dac_nids,
9218 .dig_out_nid = ALC882_DIGOUT_NID,
9219 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9220 .adc_nids = alc882_adc_nids,
9221 .capsrc_nids = alc882_capsrc_nids,
9222 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9223 .channel_mode = alc882_3ST_6ch_modes,
9224 .need_dac_fix = 1,
9225 .input_mux = &alc882_capture_source,
9226 },
9227 [ALC882_ASUS_A7M] = {
9228 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009229 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9230 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009231 alc882_asus_a7m_verbs },
9232 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9233 .dac_nids = alc882_dac_nids,
9234 .dig_out_nid = ALC882_DIGOUT_NID,
9235 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9236 .channel_mode = alc880_threestack_modes,
9237 .need_dac_fix = 1,
9238 .input_mux = &alc882_capture_source,
9239 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009240 [ALC883_3ST_2ch_DIG] = {
9241 .mixers = { alc883_3ST_2ch_mixer },
9242 .init_verbs = { alc883_init_verbs },
9243 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9244 .dac_nids = alc883_dac_nids,
9245 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009246 .dig_in_nid = ALC883_DIGIN_NID,
9247 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9248 .channel_mode = alc883_3ST_2ch_modes,
9249 .input_mux = &alc883_capture_source,
9250 },
9251 [ALC883_3ST_6ch_DIG] = {
9252 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9253 .init_verbs = { alc883_init_verbs },
9254 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9255 .dac_nids = alc883_dac_nids,
9256 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009257 .dig_in_nid = ALC883_DIGIN_NID,
9258 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9259 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009260 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009261 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009262 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009263 [ALC883_3ST_6ch] = {
9264 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9265 .init_verbs = { alc883_init_verbs },
9266 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9267 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009268 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9269 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009270 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009271 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009272 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009273 [ALC883_3ST_6ch_INTEL] = {
9274 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9275 .init_verbs = { alc883_init_verbs },
9276 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9277 .dac_nids = alc883_dac_nids,
9278 .dig_out_nid = ALC883_DIGOUT_NID,
9279 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009280 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009281 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9282 .channel_mode = alc883_3ST_6ch_intel_modes,
9283 .need_dac_fix = 1,
9284 .input_mux = &alc883_3stack_6ch_intel,
9285 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009286 [ALC889A_INTEL] = {
9287 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009288 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9289 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009290 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9291 .dac_nids = alc883_dac_nids,
9292 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9293 .adc_nids = alc889_adc_nids,
9294 .dig_out_nid = ALC883_DIGOUT_NID,
9295 .dig_in_nid = ALC883_DIGIN_NID,
9296 .slave_dig_outs = alc883_slave_dig_outs,
9297 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9298 .channel_mode = alc889_8ch_intel_modes,
9299 .capsrc_nids = alc889_capsrc_nids,
9300 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009301 .setup = alc889_automute_setup,
9302 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009303 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009304 .need_dac_fix = 1,
9305 },
9306 [ALC889_INTEL] = {
9307 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9308 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009309 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009310 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9311 .dac_nids = alc883_dac_nids,
9312 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9313 .adc_nids = alc889_adc_nids,
9314 .dig_out_nid = ALC883_DIGOUT_NID,
9315 .dig_in_nid = ALC883_DIGIN_NID,
9316 .slave_dig_outs = alc883_slave_dig_outs,
9317 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9318 .channel_mode = alc889_8ch_intel_modes,
9319 .capsrc_nids = alc889_capsrc_nids,
9320 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009321 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009322 .init_hook = alc889_intel_init_hook,
9323 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009324 .need_dac_fix = 1,
9325 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009326 [ALC883_6ST_DIG] = {
9327 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9328 .init_verbs = { alc883_init_verbs },
9329 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9330 .dac_nids = alc883_dac_nids,
9331 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009332 .dig_in_nid = ALC883_DIGIN_NID,
9333 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9334 .channel_mode = alc883_sixstack_modes,
9335 .input_mux = &alc883_capture_source,
9336 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009337 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009338 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009339 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9340 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009341 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9342 .dac_nids = alc883_dac_nids,
9343 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009344 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9345 .channel_mode = alc883_3ST_6ch_modes,
9346 .need_dac_fix = 1,
9347 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009348 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009349 .setup = alc882_targa_setup,
9350 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009351 },
9352 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009353 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009354 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9355 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009356 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9357 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009358 .adc_nids = alc883_adc_nids_alt,
9359 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009360 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +02009361 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009362 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9363 .channel_mode = alc883_3ST_2ch_modes,
9364 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009365 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009366 .setup = alc882_targa_setup,
9367 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009368 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009369 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009370 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9371 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +02009372 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009373 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009374 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9375 .dac_nids = alc883_dac_nids,
9376 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9377 .adc_nids = alc883_adc_nids_rev,
9378 .capsrc_nids = alc883_capsrc_nids_rev,
9379 .dig_out_nid = ALC883_DIGOUT_NID,
9380 .dig_in_nid = ALC883_DIGIN_NID,
9381 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9382 .channel_mode = alc883_4ST_8ch_modes,
9383 .need_dac_fix = 1,
9384 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009385 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009386 .setup = alc882_targa_setup,
9387 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009388 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009389 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009390 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009391 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9392 * and the headphone jack. Turn this on and rely on the
9393 * standard mute methods whenever the user wants to turn
9394 * these outputs off.
9395 */
9396 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9397 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9398 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009399 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9400 .channel_mode = alc883_3ST_2ch_modes,
9401 .input_mux = &alc883_capture_source,
9402 },
Tobin Davis2880a862007-08-07 11:50:26 +02009403 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009404 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009405 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009406 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9407 .dac_nids = alc883_dac_nids,
9408 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009409 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9410 .channel_mode = alc883_3ST_2ch_modes,
9411 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009412 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009413 .setup = alc883_acer_aspire_setup,
9414 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009415 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009416 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009417 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009418 alc883_chmode_mixer },
9419 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9420 alc888_acer_aspire_4930g_verbs },
9421 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9422 .dac_nids = alc883_dac_nids,
9423 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9424 .adc_nids = alc883_adc_nids_rev,
9425 .capsrc_nids = alc883_capsrc_nids_rev,
9426 .dig_out_nid = ALC883_DIGOUT_NID,
9427 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9428 .channel_mode = alc883_3ST_6ch_modes,
9429 .need_dac_fix = 1,
9430 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009431 ARRAY_SIZE(alc888_2_capture_sources),
9432 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009433 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009434 .setup = alc888_acer_aspire_4930g_setup,
9435 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009436 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009437 [ALC888_ACER_ASPIRE_6530G] = {
9438 .mixers = { alc888_acer_aspire_6530_mixer },
9439 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9440 alc888_acer_aspire_6530g_verbs },
9441 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9442 .dac_nids = alc883_dac_nids,
9443 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9444 .adc_nids = alc883_adc_nids_rev,
9445 .capsrc_nids = alc883_capsrc_nids_rev,
9446 .dig_out_nid = ALC883_DIGOUT_NID,
9447 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9448 .channel_mode = alc883_3ST_2ch_modes,
9449 .num_mux_defs =
9450 ARRAY_SIZE(alc888_2_capture_sources),
9451 .input_mux = alc888_acer_aspire_6530_sources,
9452 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009453 .setup = alc888_acer_aspire_6530g_setup,
9454 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009455 },
Hector Martin3b315d72009-06-02 10:54:19 +02009456 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +01009457 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +02009458 alc883_chmode_mixer },
9459 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +01009460 alc889_acer_aspire_8930g_verbs,
9461 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +02009462 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9463 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009464 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9465 .adc_nids = alc889_adc_nids,
9466 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009467 .dig_out_nid = ALC883_DIGOUT_NID,
9468 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9469 .channel_mode = alc883_3ST_6ch_modes,
9470 .need_dac_fix = 1,
9471 .const_channel_count = 6,
9472 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009473 ARRAY_SIZE(alc889_capture_sources),
9474 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009475 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009476 .setup = alc889_acer_aspire_8930g_setup,
9477 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +01009478#ifdef CONFIG_SND_HDA_POWER_SAVE
9479 .power_hook = alc889_power_eapd,
9480#endif
Hector Martin3b315d72009-06-02 10:54:19 +02009481 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009482 [ALC888_ACER_ASPIRE_7730G] = {
9483 .mixers = { alc883_3ST_6ch_mixer,
9484 alc883_chmode_mixer },
9485 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9486 alc888_acer_aspire_7730G_verbs },
9487 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9488 .dac_nids = alc883_dac_nids,
9489 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9490 .adc_nids = alc883_adc_nids_rev,
9491 .capsrc_nids = alc883_capsrc_nids_rev,
9492 .dig_out_nid = ALC883_DIGOUT_NID,
9493 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9494 .channel_mode = alc883_3ST_6ch_modes,
9495 .need_dac_fix = 1,
9496 .const_channel_count = 6,
9497 .input_mux = &alc883_capture_source,
9498 .unsol_event = alc_automute_amp_unsol_event,
9499 .setup = alc888_acer_aspire_6530g_setup,
9500 .init_hook = alc_automute_amp,
9501 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009502 [ALC883_MEDION] = {
9503 .mixers = { alc883_fivestack_mixer,
9504 alc883_chmode_mixer },
9505 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009506 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009507 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9508 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009509 .adc_nids = alc883_adc_nids_alt,
9510 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009511 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02009512 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9513 .channel_mode = alc883_sixstack_modes,
9514 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009515 },
Kailang Yang272a5272007-05-14 11:00:38 +02009516 [ALC883_MEDION_MD2] = {
9517 .mixers = { alc883_medion_md2_mixer},
9518 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9519 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9520 .dac_nids = alc883_dac_nids,
9521 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009522 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9523 .channel_mode = alc883_3ST_2ch_modes,
9524 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009525 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009526 .setup = alc883_medion_md2_setup,
9527 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009528 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009529 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009530 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009531 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9532 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9533 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009534 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9535 .channel_mode = alc883_3ST_2ch_modes,
9536 .input_mux = &alc883_capture_source,
9537 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309538 [ALC883_CLEVO_M540R] = {
9539 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9540 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9541 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9542 .dac_nids = alc883_dac_nids,
9543 .dig_out_nid = ALC883_DIGOUT_NID,
9544 .dig_in_nid = ALC883_DIGIN_NID,
9545 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9546 .channel_mode = alc883_3ST_6ch_clevo_modes,
9547 .need_dac_fix = 1,
9548 .input_mux = &alc883_capture_source,
9549 /* This machine has the hardware HP auto-muting, thus
9550 * we need no software mute via unsol event
9551 */
9552 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009553 [ALC883_CLEVO_M720] = {
9554 .mixers = { alc883_clevo_m720_mixer },
9555 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009556 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9557 .dac_nids = alc883_dac_nids,
9558 .dig_out_nid = ALC883_DIGOUT_NID,
9559 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9560 .channel_mode = alc883_3ST_2ch_modes,
9561 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009562 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009563 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009564 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009565 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009566 [ALC883_LENOVO_101E_2ch] = {
9567 .mixers = { alc883_lenovo_101e_2ch_mixer},
9568 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9569 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9570 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009571 .adc_nids = alc883_adc_nids_alt,
9572 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009573 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009574 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9575 .channel_mode = alc883_3ST_2ch_modes,
9576 .input_mux = &alc883_lenovo_101e_capture_source,
9577 .unsol_event = alc883_lenovo_101e_unsol_event,
9578 .init_hook = alc883_lenovo_101e_all_automute,
9579 },
Kailang Yang272a5272007-05-14 11:00:38 +02009580 [ALC883_LENOVO_NB0763] = {
9581 .mixers = { alc883_lenovo_nb0763_mixer },
9582 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9583 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9584 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009585 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9586 .channel_mode = alc883_3ST_2ch_modes,
9587 .need_dac_fix = 1,
9588 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009589 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009590 .setup = alc883_medion_md2_setup,
9591 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009592 },
9593 [ALC888_LENOVO_MS7195_DIG] = {
9594 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9595 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9596 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9597 .dac_nids = alc883_dac_nids,
9598 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009599 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9600 .channel_mode = alc883_3ST_6ch_modes,
9601 .need_dac_fix = 1,
9602 .input_mux = &alc883_capture_source,
9603 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9604 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009605 },
9606 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009607 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009608 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9609 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9610 .dac_nids = alc883_dac_nids,
9611 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009612 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9613 .channel_mode = alc883_3ST_2ch_modes,
9614 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009615 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009616 .setup = alc883_haier_w66_setup,
9617 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009618 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009619 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009620 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009621 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009622 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9623 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009624 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9625 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009626 .need_dac_fix = 1,
9627 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009628 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009629 .setup = alc888_3st_hp_setup,
9630 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009631 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009632 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009633 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009634 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9635 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9636 .dac_nids = alc883_dac_nids,
9637 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009638 .dig_in_nid = ALC883_DIGIN_NID,
9639 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9640 .channel_mode = alc883_sixstack_modes,
9641 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009642 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009643 .setup = alc888_6st_dell_setup,
9644 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009645 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009646 [ALC883_MITAC] = {
9647 .mixers = { alc883_mitac_mixer },
9648 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9649 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9650 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009651 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9652 .channel_mode = alc883_3ST_2ch_modes,
9653 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009654 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009655 .setup = alc883_mitac_setup,
9656 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009657 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009658 [ALC883_FUJITSU_PI2515] = {
9659 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9660 .init_verbs = { alc883_init_verbs,
9661 alc883_2ch_fujitsu_pi2515_verbs},
9662 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9663 .dac_nids = alc883_dac_nids,
9664 .dig_out_nid = ALC883_DIGOUT_NID,
9665 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9666 .channel_mode = alc883_3ST_2ch_modes,
9667 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009668 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009669 .setup = alc883_2ch_fujitsu_pi2515_setup,
9670 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +01009671 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009672 [ALC888_FUJITSU_XA3530] = {
9673 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9674 .init_verbs = { alc883_init_verbs,
9675 alc888_fujitsu_xa3530_verbs },
9676 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9677 .dac_nids = alc883_dac_nids,
9678 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9679 .adc_nids = alc883_adc_nids_rev,
9680 .capsrc_nids = alc883_capsrc_nids_rev,
9681 .dig_out_nid = ALC883_DIGOUT_NID,
9682 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9683 .channel_mode = alc888_4ST_8ch_intel_modes,
9684 .num_mux_defs =
9685 ARRAY_SIZE(alc888_2_capture_sources),
9686 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009687 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009688 .setup = alc888_fujitsu_xa3530_setup,
9689 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009690 },
Kailang Yange2757d52008-08-26 13:17:46 +02009691 [ALC888_LENOVO_SKY] = {
9692 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9693 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9694 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9695 .dac_nids = alc883_dac_nids,
9696 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009697 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9698 .channel_mode = alc883_sixstack_modes,
9699 .need_dac_fix = 1,
9700 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009701 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009702 .setup = alc888_lenovo_sky_setup,
9703 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +02009704 },
9705 [ALC888_ASUS_M90V] = {
9706 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9707 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9708 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9709 .dac_nids = alc883_dac_nids,
9710 .dig_out_nid = ALC883_DIGOUT_NID,
9711 .dig_in_nid = ALC883_DIGIN_NID,
9712 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9713 .channel_mode = alc883_3ST_6ch_modes,
9714 .need_dac_fix = 1,
9715 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009716 .unsol_event = alc_sku_unsol_event,
9717 .setup = alc883_mode2_setup,
9718 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +02009719 },
9720 [ALC888_ASUS_EEE1601] = {
9721 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009722 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009723 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9724 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9725 .dac_nids = alc883_dac_nids,
9726 .dig_out_nid = ALC883_DIGOUT_NID,
9727 .dig_in_nid = ALC883_DIGIN_NID,
9728 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9729 .channel_mode = alc883_3ST_2ch_modes,
9730 .need_dac_fix = 1,
9731 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009732 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009733 .init_hook = alc883_eee1601_inithook,
9734 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009735 [ALC1200_ASUS_P5Q] = {
9736 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9737 .init_verbs = { alc883_init_verbs },
9738 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9739 .dac_nids = alc883_dac_nids,
9740 .dig_out_nid = ALC1200_DIGOUT_NID,
9741 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009742 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009743 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9744 .channel_mode = alc883_sixstack_modes,
9745 .input_mux = &alc883_capture_source,
9746 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009747 [ALC889A_MB31] = {
9748 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9749 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9750 alc880_gpio1_init_verbs },
9751 .adc_nids = alc883_adc_nids,
9752 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009753 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009754 .dac_nids = alc883_dac_nids,
9755 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9756 .channel_mode = alc889A_mb31_6ch_modes,
9757 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9758 .input_mux = &alc889A_mb31_capture_source,
9759 .dig_out_nid = ALC883_DIGOUT_NID,
9760 .unsol_event = alc889A_mb31_unsol_event,
9761 .init_hook = alc889A_mb31_automute,
9762 },
Guido Günther3e1647c52009-06-05 00:47:26 +02009763 [ALC883_SONY_VAIO_TT] = {
9764 .mixers = { alc883_vaiott_mixer },
9765 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9766 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9767 .dac_nids = alc883_dac_nids,
9768 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9769 .channel_mode = alc883_3ST_2ch_modes,
9770 .input_mux = &alc883_capture_source,
9771 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009772 .setup = alc883_vaiott_setup,
9773 .init_hook = alc_automute_amp,
Guido Günther3e1647c52009-06-05 00:47:26 +02009774 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009775};
9776
9777
9778/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02009779 * Pin config fixes
9780 */
9781enum {
9782 PINFIX_ABIT_AW9D_MAX
9783};
9784
9785static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9786 { 0x15, 0x01080104 }, /* side */
9787 { 0x16, 0x01011012 }, /* rear */
9788 { 0x17, 0x01016011 }, /* clfe */
9789 { }
9790};
9791
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009792static const struct alc_fixup alc882_fixups[] = {
9793 [PINFIX_ABIT_AW9D_MAX] = {
9794 .pins = alc882_abit_aw9d_pinfix
9795 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009796};
9797
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009798static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009799 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9800 {}
9801};
9802
9803/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009804 * BIOS auto configuration
9805 */
Takashi Iwai05f5f472009-08-25 13:10:18 +02009806static int alc882_auto_create_input_ctls(struct hda_codec *codec,
9807 const struct auto_pin_cfg *cfg)
9808{
9809 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
9810}
9811
Takashi Iwai4953550a2009-06-30 15:28:30 +02009812static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009813 hda_nid_t nid, int pin_type,
9814 int dac_idx)
9815{
9816 /* set as output */
9817 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009818 int idx;
9819
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009820 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009821 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9822 idx = 4;
9823 else
9824 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009825 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9826
9827}
9828
Takashi Iwai4953550a2009-06-30 15:28:30 +02009829static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009830{
9831 struct alc_spec *spec = codec->spec;
9832 int i;
9833
9834 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009835 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009836 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009837 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009838 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009839 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009840 }
9841}
9842
Takashi Iwai4953550a2009-06-30 15:28:30 +02009843static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009844{
9845 struct alc_spec *spec = codec->spec;
9846 hda_nid_t pin;
9847
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009848 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009849 if (pin) /* connect to front */
9850 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009851 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009852 pin = spec->autocfg.speaker_pins[0];
9853 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009854 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009855}
9856
Takashi Iwai4953550a2009-06-30 15:28:30 +02009857static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009858{
9859 struct alc_spec *spec = codec->spec;
9860 int i;
9861
9862 for (i = 0; i < AUTO_PIN_LAST; i++) {
9863 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +02009864 if (!nid)
9865 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +02009866 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009867 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9868 snd_hda_codec_write(codec, nid, 0,
9869 AC_VERB_SET_AMP_GAIN_MUTE,
9870 AMP_OUT_MUTE);
9871 }
9872}
9873
9874static void alc882_auto_init_input_src(struct hda_codec *codec)
9875{
9876 struct alc_spec *spec = codec->spec;
9877 int c;
9878
9879 for (c = 0; c < spec->num_adc_nids; c++) {
9880 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9881 hda_nid_t nid = spec->capsrc_nids[c];
9882 unsigned int mux_idx;
9883 const struct hda_input_mux *imux;
9884 int conns, mute, idx, item;
9885
9886 conns = snd_hda_get_connections(codec, nid, conn_list,
9887 ARRAY_SIZE(conn_list));
9888 if (conns < 0)
9889 continue;
9890 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9891 imux = &spec->input_mux[mux_idx];
9892 for (idx = 0; idx < conns; idx++) {
9893 /* if the current connection is the selected one,
9894 * unmute it as default - otherwise mute it
9895 */
9896 mute = AMP_IN_MUTE(idx);
9897 for (item = 0; item < imux->num_items; item++) {
9898 if (imux->items[item].index == idx) {
9899 if (spec->cur_mux[c] == item)
9900 mute = AMP_IN_UNMUTE(idx);
9901 break;
9902 }
9903 }
9904 /* check if we have a selector or mixer
9905 * we could check for the widget type instead, but
9906 * just check for Amp-In presence (in case of mixer
9907 * without amp-in there is something wrong, this
9908 * function shouldn't be used or capsrc nid is wrong)
9909 */
9910 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009911 snd_hda_codec_write(codec, nid, 0,
9912 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009913 mute);
9914 else if (mute != AMP_IN_MUTE(idx))
9915 snd_hda_codec_write(codec, nid, 0,
9916 AC_VERB_SET_CONNECT_SEL,
9917 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009918 }
9919 }
9920}
9921
Takashi Iwai4953550a2009-06-30 15:28:30 +02009922/* add mic boosts if needed */
9923static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009924{
9925 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009926 int err;
9927 hda_nid_t nid;
9928
9929 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9930 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9931 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9932 "Mic Boost",
9933 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9934 if (err < 0)
9935 return err;
9936 }
9937 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9938 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9939 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9940 "Front Mic Boost",
9941 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9942 if (err < 0)
9943 return err;
9944 }
9945 return 0;
9946}
9947
9948/* almost identical with ALC880 parser... */
9949static int alc882_parse_auto_config(struct hda_codec *codec)
9950{
9951 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009952 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
9953 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009954
Takashi Iwai05f5f472009-08-25 13:10:18 +02009955 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9956 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009957 if (err < 0)
9958 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009959 if (!spec->autocfg.line_outs)
9960 return 0; /* can't find valid BIOS pin config */
9961
9962 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
9963 if (err < 0)
9964 return err;
9965 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
9966 if (err < 0)
9967 return err;
9968 err = alc880_auto_create_extra_out(spec,
9969 spec->autocfg.speaker_pins[0],
9970 "Speaker");
9971 if (err < 0)
9972 return err;
9973 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
9974 "Headphone");
9975 if (err < 0)
9976 return err;
9977 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
9978 if (err < 0)
9979 return err;
9980
9981 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9982
9983 /* check multiple SPDIF-out (for recent codecs) */
9984 for (i = 0; i < spec->autocfg.dig_outs; i++) {
9985 hda_nid_t dig_nid;
9986 err = snd_hda_get_connections(codec,
9987 spec->autocfg.dig_out_pins[i],
9988 &dig_nid, 1);
9989 if (err < 0)
9990 continue;
9991 if (!i)
9992 spec->multiout.dig_out_nid = dig_nid;
9993 else {
9994 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01009995 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai05f5f472009-08-25 13:10:18 +02009996 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01009997 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009998 }
9999 }
10000 if (spec->autocfg.dig_in_pin)
10001 spec->dig_in_nid = ALC880_DIGIN_NID;
10002
10003 if (spec->kctls.list)
10004 add_mixer(spec, spec->kctls.list);
10005
10006 add_verb(spec, alc883_auto_init_verbs);
10007 /* if ADC 0x07 is available, initialize it, too */
10008 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10009 add_verb(spec, alc882_adc1_init_verbs);
10010
10011 spec->num_mux_defs = 1;
10012 spec->input_mux = &spec->private_imux[0];
10013
10014 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
Takashi Iwai776e1842007-08-29 15:07:11 +020010015
10016 err = alc_auto_add_mic_boost(codec);
10017 if (err < 0)
10018 return err;
10019
Takashi Iwai776e1842007-08-29 15:07:11 +020010020 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010021}
10022
10023/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010024static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010025{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010026 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010027 alc882_auto_init_multi_out(codec);
10028 alc882_auto_init_hp_out(codec);
10029 alc882_auto_init_analog_input(codec);
10030 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010031 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010032 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010033}
10034
Takashi Iwai4953550a2009-06-30 15:28:30 +020010035static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010036{
10037 struct alc_spec *spec;
10038 int err, board_config;
10039
10040 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10041 if (spec == NULL)
10042 return -ENOMEM;
10043
10044 codec->spec = spec;
10045
Takashi Iwai4953550a2009-06-30 15:28:30 +020010046 switch (codec->vendor_id) {
10047 case 0x10ec0882:
10048 case 0x10ec0885:
10049 break;
10050 default:
10051 /* ALC883 and variants */
10052 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10053 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010054 }
10055
Takashi Iwai4953550a2009-06-30 15:28:30 +020010056 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10057 alc882_models,
10058 alc882_cfg_tbl);
10059
10060 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10061 board_config = snd_hda_check_board_codec_sid_config(codec,
10062 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10063
10064 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010065 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010066 codec->chip_name);
10067 board_config = ALC882_AUTO;
10068 }
10069
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010070 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010071
10072 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010073 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010074 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010075 if (err < 0) {
10076 alc_free(codec);
10077 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010078 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010079 printk(KERN_INFO
10080 "hda_codec: Cannot set up configuration "
10081 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010082 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010083 }
10084 }
10085
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010086 err = snd_hda_attach_beep_device(codec, 0x1);
10087 if (err < 0) {
10088 alc_free(codec);
10089 return err;
10090 }
10091
Takashi Iwai4953550a2009-06-30 15:28:30 +020010092 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010093 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010094
Takashi Iwai4953550a2009-06-30 15:28:30 +020010095 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10096 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10097 /* FIXME: setup DAC5 */
10098 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10099 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10100
10101 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10102 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10103
10104 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010105 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010106
10107 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010108 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010109 spec->num_adc_nids = 0;
10110 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010111 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010112 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010113 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010114 hda_nid_t nid = alc882_adc_nids[i];
10115 unsigned int wcap = get_wcaps(codec, nid);
10116 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010117 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010118 if (wcap != AC_WID_AUD_IN)
10119 continue;
10120 spec->private_adc_nids[spec->num_adc_nids] = nid;
10121 err = snd_hda_get_connections(codec, nid, &cap, 1);
10122 if (err < 0)
10123 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010124 err = snd_hda_get_connections(codec, cap, items,
10125 ARRAY_SIZE(items));
10126 if (err < 0)
10127 continue;
10128 for (j = 0; j < imux->num_items; j++)
10129 if (imux->items[j].index >= err)
10130 break;
10131 if (j < imux->num_items)
10132 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010133 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10134 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010135 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010136 spec->adc_nids = spec->private_adc_nids;
10137 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010138 }
10139
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010140 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010010141 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010142
Takashi Iwai2134ea42008-01-10 16:53:55 +010010143 spec->vmaster_nid = 0x0c;
10144
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010145 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010146 if (board_config == ALC882_AUTO)
10147 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010148#ifdef CONFIG_SND_HDA_POWER_SAVE
10149 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010150 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010151#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010010152 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010153
10154 return 0;
10155}
10156
Takashi Iwai4953550a2009-06-30 15:28:30 +020010157
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010158/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010159 * ALC262 support
10160 */
10161
10162#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10163#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10164
10165#define alc262_dac_nids alc260_dac_nids
10166#define alc262_adc_nids alc882_adc_nids
10167#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010168#define alc262_capsrc_nids alc882_capsrc_nids
10169#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010170
10171#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010172#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010173
Kailang Yang4e555fe2008-08-26 13:05:55 +020010174static hda_nid_t alc262_dmic_adc_nids[1] = {
10175 /* ADC0 */
10176 0x09
10177};
10178
10179static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10180
Kailang Yangdf694da2005-12-05 19:42:22 +010010181static struct snd_kcontrol_new alc262_base_mixer[] = {
10182 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10183 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10184 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10185 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10186 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10187 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10188 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10189 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010190 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010191 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10192 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010193 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010194 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10195 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10196 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10197 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010198 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010199};
10200
Takashi Iwaice875f02008-01-28 18:17:43 +010010201/* update HP, line and mono-out pins according to the master switch */
10202static void alc262_hp_master_update(struct hda_codec *codec)
10203{
10204 struct alc_spec *spec = codec->spec;
10205 int val = spec->master_sw;
10206
10207 /* HP & line-out */
10208 snd_hda_codec_write_cache(codec, 0x1b, 0,
10209 AC_VERB_SET_PIN_WIDGET_CONTROL,
10210 val ? PIN_HP : 0);
10211 snd_hda_codec_write_cache(codec, 0x15, 0,
10212 AC_VERB_SET_PIN_WIDGET_CONTROL,
10213 val ? PIN_HP : 0);
10214 /* mono (speaker) depending on the HP jack sense */
10215 val = val && !spec->jack_present;
10216 snd_hda_codec_write_cache(codec, 0x16, 0,
10217 AC_VERB_SET_PIN_WIDGET_CONTROL,
10218 val ? PIN_OUT : 0);
10219}
10220
10221static void alc262_hp_bpc_automute(struct hda_codec *codec)
10222{
10223 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010224
10225 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010226 alc262_hp_master_update(codec);
10227}
10228
10229static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10230{
10231 if ((res >> 26) != ALC880_HP_EVENT)
10232 return;
10233 alc262_hp_bpc_automute(codec);
10234}
10235
10236static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10237{
10238 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010239
10240 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010241 alc262_hp_master_update(codec);
10242}
10243
10244static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10245 unsigned int res)
10246{
10247 if ((res >> 26) != ALC880_HP_EVENT)
10248 return;
10249 alc262_hp_wildwest_automute(codec);
10250}
10251
Takashi Iwaib72519b2009-05-08 14:31:55 +020010252#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010253
10254static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10255 struct snd_ctl_elem_value *ucontrol)
10256{
10257 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10258 struct alc_spec *spec = codec->spec;
10259 int val = !!*ucontrol->value.integer.value;
10260
10261 if (val == spec->master_sw)
10262 return 0;
10263 spec->master_sw = val;
10264 alc262_hp_master_update(codec);
10265 return 1;
10266}
10267
Takashi Iwaib72519b2009-05-08 14:31:55 +020010268#define ALC262_HP_MASTER_SWITCH \
10269 { \
10270 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10271 .name = "Master Playback Switch", \
10272 .info = snd_ctl_boolean_mono_info, \
10273 .get = alc262_hp_master_sw_get, \
10274 .put = alc262_hp_master_sw_put, \
10275 }
10276
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010277static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010278 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010279 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10280 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10281 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010282 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10283 HDA_OUTPUT),
10284 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10285 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010286 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10287 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010288 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010289 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10290 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010291 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010292 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10293 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10294 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10295 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010296 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10297 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10298 { } /* end */
10299};
10300
Kailang Yangcd7509a2007-01-26 18:33:17 +010010301static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010302 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010303 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10304 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10305 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10306 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010307 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10308 HDA_OUTPUT),
10309 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10310 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010311 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10312 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010313 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010314 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10315 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10316 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10317 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010318 { } /* end */
10319};
10320
10321static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10322 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10323 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010324 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010325 { } /* end */
10326};
10327
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010328/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010329static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010330{
10331 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010332
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010333 spec->autocfg.hp_pins[0] = 0x15;
10334 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010335}
10336
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010337static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010338 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10339 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010340 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10341 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10342 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10343 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10344 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10345 { } /* end */
10346};
10347
10348static struct hda_verb alc262_hp_t5735_verbs[] = {
10349 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10350 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10351
10352 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10353 { }
10354};
10355
Kailang Yang8c427222008-01-10 13:03:59 +010010356static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010357 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10358 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010359 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10360 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010361 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10362 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10363 { } /* end */
10364};
10365
10366static struct hda_verb alc262_hp_rp5700_verbs[] = {
10367 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10368 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10369 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10370 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10371 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10372 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10373 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10374 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10375 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10376 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10377 {}
10378};
10379
10380static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10381 .num_items = 1,
10382 .items = {
10383 { "Line", 0x1 },
10384 },
10385};
10386
Takashi Iwai42171c12009-05-08 14:11:43 +020010387/* bind hp and internal speaker mute (with plug check) as master switch */
10388static void alc262_hippo_master_update(struct hda_codec *codec)
10389{
10390 struct alc_spec *spec = codec->spec;
10391 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10392 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10393 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10394 unsigned int mute;
10395
10396 /* HP */
10397 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10398 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10399 HDA_AMP_MUTE, mute);
10400 /* mute internal speaker per jack sense */
10401 if (spec->jack_present)
10402 mute = HDA_AMP_MUTE;
10403 if (line_nid)
10404 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10405 HDA_AMP_MUTE, mute);
10406 if (speaker_nid && speaker_nid != line_nid)
10407 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10408 HDA_AMP_MUTE, mute);
10409}
10410
10411#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10412
10413static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10414 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010415{
10416 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010417 struct alc_spec *spec = codec->spec;
10418 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010419
Takashi Iwai42171c12009-05-08 14:11:43 +020010420 if (val == spec->master_sw)
10421 return 0;
10422 spec->master_sw = val;
10423 alc262_hippo_master_update(codec);
10424 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010425}
Takashi Iwai5b319542007-07-26 11:49:22 +020010426
Takashi Iwai42171c12009-05-08 14:11:43 +020010427#define ALC262_HIPPO_MASTER_SWITCH \
10428 { \
10429 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10430 .name = "Master Playback Switch", \
10431 .info = snd_ctl_boolean_mono_info, \
10432 .get = alc262_hippo_master_sw_get, \
10433 .put = alc262_hippo_master_sw_put, \
10434 }
10435
10436static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10437 ALC262_HIPPO_MASTER_SWITCH,
10438 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10439 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10440 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10441 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10442 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10443 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10444 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10445 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10446 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10447 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10448 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10449 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10450 { } /* end */
10451};
10452
10453static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10454 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10455 ALC262_HIPPO_MASTER_SWITCH,
10456 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10457 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10458 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10459 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10460 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10461 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10462 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10463 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10464 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10465 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10466 { } /* end */
10467};
10468
10469/* mute/unmute internal speaker according to the hp jack and mute state */
10470static void alc262_hippo_automute(struct hda_codec *codec)
10471{
10472 struct alc_spec *spec = codec->spec;
10473 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020010474
Wu Fengguang864f92b2009-11-18 12:38:02 +080010475 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020010476 alc262_hippo_master_update(codec);
10477}
10478
10479static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10480{
10481 if ((res >> 26) != ALC880_HP_EVENT)
10482 return;
10483 alc262_hippo_automute(codec);
10484}
10485
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010486static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010487{
10488 struct alc_spec *spec = codec->spec;
10489
10490 spec->autocfg.hp_pins[0] = 0x15;
10491 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010492}
10493
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010494static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010495{
10496 struct alc_spec *spec = codec->spec;
10497
10498 spec->autocfg.hp_pins[0] = 0x1b;
10499 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010500}
10501
10502
Kailang Yang272a5272007-05-14 11:00:38 +020010503static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010504 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010505 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010506 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10507 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10508 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10509 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10510 { } /* end */
10511};
10512
Kailang Yang83c34212007-07-05 11:43:05 +020010513static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010514 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10515 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010516 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10517 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10518 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10519 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10520 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10521 { } /* end */
10522};
Kailang Yang272a5272007-05-14 11:00:38 +020010523
Tony Vroonba340e82009-02-02 19:01:30 +000010524static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10525 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10526 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10527 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10528 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10529 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10530 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10531 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10532 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10533 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10534 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10535 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10536 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10537 { } /* end */
10538};
10539
10540static struct hda_verb alc262_tyan_verbs[] = {
10541 /* Headphone automute */
10542 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10543 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10544 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10545
10546 /* P11 AUX_IN, white 4-pin connector */
10547 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10548 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10549 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10550 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10551
10552 {}
10553};
10554
10555/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010556static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010557{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010558 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010559
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010560 spec->autocfg.hp_pins[0] = 0x1b;
10561 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010562}
10563
Tony Vroonba340e82009-02-02 19:01:30 +000010564
Kailang Yangdf694da2005-12-05 19:42:22 +010010565#define alc262_capture_mixer alc882_capture_mixer
10566#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10567
10568/*
10569 * generic initialization of ADC, input mixers and output mixers
10570 */
10571static struct hda_verb alc262_init_verbs[] = {
10572 /*
10573 * Unmute ADC0-2 and set the default input to mic-in
10574 */
10575 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10576 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10577 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10578 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10579 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10580 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10581
Takashi Iwaicb53c622007-08-10 17:21:45 +020010582 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010583 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010584 * Note: PASD motherboards uses the Line In 2 as the input for
10585 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010586 */
10587 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010588 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10589 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10590 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10591 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10592 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010593
10594 /*
10595 * Set up output mixers (0x0c - 0x0e)
10596 */
10597 /* set vol=0 to output mixers */
10598 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10599 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10600 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10601 /* set up input amps for analog loopback */
10602 /* Amp Indices: DAC = 0, mixer = 1 */
10603 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10604 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10605 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10606 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10607 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10608 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10609
10610 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10611 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10612 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10613 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10614 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10615 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10616
10617 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10618 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10619 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10620 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10621 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010622
Kailang Yangdf694da2005-12-05 19:42:22 +010010623 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10624 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010625
Kailang Yangdf694da2005-12-05 19:42:22 +010010626 /* FIXME: use matrix-type input source selection */
10627 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10628 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10629 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10630 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10631 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10632 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10633 /* Input mixer2 */
10634 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10635 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10636 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10637 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10638 /* Input mixer3 */
10639 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10640 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10641 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010642 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010643
10644 { }
10645};
10646
Kailang Yang4e555fe2008-08-26 13:05:55 +020010647static struct hda_verb alc262_eapd_verbs[] = {
10648 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10649 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10650 { }
10651};
10652
Kailang Yangccc656c2006-10-17 12:32:26 +020010653static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10654 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10655 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10656 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10657
10658 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10659 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10660 {}
10661};
10662
Kailang Yang272a5272007-05-14 11:00:38 +020010663static struct hda_verb alc262_sony_unsol_verbs[] = {
10664 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10665 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10666 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10667
10668 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10669 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010670 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010671};
10672
Kailang Yang4e555fe2008-08-26 13:05:55 +020010673static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10674 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10675 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10676 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10677 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10678 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010679 { } /* end */
10680};
10681
10682static struct hda_verb alc262_toshiba_s06_verbs[] = {
10683 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10684 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10685 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10686 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10687 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10688 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10689 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10690 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10691 {}
10692};
10693
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010694static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020010695{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010696 struct alc_spec *spec = codec->spec;
10697
10698 spec->autocfg.hp_pins[0] = 0x15;
10699 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010700 spec->ext_mic.pin = 0x18;
10701 spec->ext_mic.mux_idx = 0;
10702 spec->int_mic.pin = 0x12;
10703 spec->int_mic.mux_idx = 9;
10704 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020010705}
10706
Takashi Iwai834be882006-03-01 14:16:17 +010010707/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010708 * nec model
10709 * 0x15 = headphone
10710 * 0x16 = internal speaker
10711 * 0x18 = external mic
10712 */
10713
10714static struct snd_kcontrol_new alc262_nec_mixer[] = {
10715 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10716 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10717
10718 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10719 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10720 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10721
10722 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10723 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10724 { } /* end */
10725};
10726
10727static struct hda_verb alc262_nec_verbs[] = {
10728 /* Unmute Speaker */
10729 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10730
10731 /* Headphone */
10732 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10733 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10734
10735 /* External mic to headphone */
10736 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10737 /* External mic to speaker */
10738 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10739 {}
10740};
10741
10742/*
Takashi Iwai834be882006-03-01 14:16:17 +010010743 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010744 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10745 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010746 */
10747
10748#define ALC_HP_EVENT 0x37
10749
10750static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10751 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10752 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010753 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10754 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010755 {}
10756};
10757
Jiang zhe0e31daf2008-03-20 12:12:39 +010010758static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10759 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10760 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10761 {}
10762};
10763
Daniel T Chene2595322009-12-19 18:19:02 -050010764static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
10765 /* Front Mic pin: input vref at 50% */
10766 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10767 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10768 {}
10769};
10770
Takashi Iwai834be882006-03-01 14:16:17 +010010771static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010772 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010773 .items = {
10774 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010775 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010776 { "CD", 0x4 },
10777 },
10778};
10779
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010780static struct hda_input_mux alc262_HP_capture_source = {
10781 .num_items = 5,
10782 .items = {
10783 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010784 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010785 { "Line", 0x2 },
10786 { "CD", 0x4 },
10787 { "AUX IN", 0x6 },
10788 },
10789};
10790
zhejiangaccbe492007-08-31 12:36:05 +020010791static struct hda_input_mux alc262_HP_D7000_capture_source = {
10792 .num_items = 4,
10793 .items = {
10794 { "Mic", 0x0 },
10795 { "Front Mic", 0x2 },
10796 { "Line", 0x1 },
10797 { "CD", 0x4 },
10798 },
10799};
10800
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010801/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010802static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10803{
10804 struct alc_spec *spec = codec->spec;
10805 unsigned int mute;
10806
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010807 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080010808 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
10809 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010010810 spec->sense_updated = 1;
10811 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010812 /* unmute internal speaker only if both HPs are unplugged and
10813 * master switch is on
10814 */
10815 if (spec->jack_present)
10816 mute = HDA_AMP_MUTE;
10817 else
Takashi Iwai834be882006-03-01 14:16:17 +010010818 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010819 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10820 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010821}
10822
10823/* unsolicited event for HP jack sensing */
10824static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10825 unsigned int res)
10826{
10827 if ((res >> 26) != ALC_HP_EVENT)
10828 return;
10829 alc262_fujitsu_automute(codec, 1);
10830}
10831
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010832static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10833{
10834 alc262_fujitsu_automute(codec, 1);
10835}
10836
Takashi Iwai834be882006-03-01 14:16:17 +010010837/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010838static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10839 .ops = &snd_hda_bind_vol,
10840 .values = {
10841 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10842 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10843 0
10844 },
10845};
Takashi Iwai834be882006-03-01 14:16:17 +010010846
Jiang zhe0e31daf2008-03-20 12:12:39 +010010847/* mute/unmute internal speaker according to the hp jack and mute state */
10848static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10849{
10850 struct alc_spec *spec = codec->spec;
10851 unsigned int mute;
10852
10853 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080010854 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010855 spec->sense_updated = 1;
10856 }
10857 if (spec->jack_present) {
10858 /* mute internal speaker */
10859 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10860 HDA_AMP_MUTE, HDA_AMP_MUTE);
10861 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10862 HDA_AMP_MUTE, HDA_AMP_MUTE);
10863 } else {
10864 /* unmute internal speaker if necessary */
10865 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10866 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10867 HDA_AMP_MUTE, mute);
10868 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10869 HDA_AMP_MUTE, mute);
10870 }
10871}
10872
10873/* unsolicited event for HP jack sensing */
10874static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10875 unsigned int res)
10876{
10877 if ((res >> 26) != ALC_HP_EVENT)
10878 return;
10879 alc262_lenovo_3000_automute(codec, 1);
10880}
10881
Takashi Iwai8de56b72009-07-24 16:51:47 +020010882static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10883 int dir, int idx, long *valp)
10884{
10885 int i, change = 0;
10886
10887 for (i = 0; i < 2; i++, valp++)
10888 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10889 HDA_AMP_MUTE,
10890 *valp ? 0 : HDA_AMP_MUTE);
10891 return change;
10892}
10893
Takashi Iwai834be882006-03-01 14:16:17 +010010894/* bind hp and internal speaker mute (with plug check) */
10895static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10896 struct snd_ctl_elem_value *ucontrol)
10897{
10898 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10899 long *valp = ucontrol->value.integer.value;
10900 int change;
10901
Takashi Iwai8de56b72009-07-24 16:51:47 +020010902 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10903 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010904 if (change)
10905 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010906 return change;
10907}
10908
10909static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010910 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010911 {
10912 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10913 .name = "Master Playback Switch",
10914 .info = snd_hda_mixer_amp_switch_info,
10915 .get = snd_hda_mixer_amp_switch_get,
10916 .put = alc262_fujitsu_master_sw_put,
10917 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10918 },
10919 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10920 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10921 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10922 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10923 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010924 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10925 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10926 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010927 { } /* end */
10928};
10929
Jiang zhe0e31daf2008-03-20 12:12:39 +010010930/* bind hp and internal speaker mute (with plug check) */
10931static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10932 struct snd_ctl_elem_value *ucontrol)
10933{
10934 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10935 long *valp = ucontrol->value.integer.value;
10936 int change;
10937
Takashi Iwai8de56b72009-07-24 16:51:47 +020010938 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010939 if (change)
10940 alc262_lenovo_3000_automute(codec, 0);
10941 return change;
10942}
10943
10944static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10945 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10946 {
10947 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10948 .name = "Master Playback Switch",
10949 .info = snd_hda_mixer_amp_switch_info,
10950 .get = snd_hda_mixer_amp_switch_get,
10951 .put = alc262_lenovo_3000_master_sw_put,
10952 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10953 },
10954 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10955 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10956 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10957 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10958 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10959 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10960 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10961 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10962 { } /* end */
10963};
10964
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010965static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10966 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010967 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010968 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10969 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10970 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10971 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10972 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10973 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10974 { } /* end */
10975};
10976
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010977/* additional init verbs for Benq laptops */
10978static struct hda_verb alc262_EAPD_verbs[] = {
10979 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10980 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10981 {}
10982};
10983
Kailang Yang83c34212007-07-05 11:43:05 +020010984static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10985 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10986 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10987
10988 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10989 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10990 {}
10991};
10992
Tobin Davisf651b502007-10-26 12:40:47 +020010993/* Samsung Q1 Ultra Vista model setup */
10994static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010995 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10996 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010997 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10998 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10999 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011000 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011001 { } /* end */
11002};
11003
11004static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011005 /* output mixer */
11006 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11007 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11008 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11009 /* speaker */
11010 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11011 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11012 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11013 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11014 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011015 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011016 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11017 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11018 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11019 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11020 /* internal mic */
11021 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11022 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11023 /* ADC, choose mic */
11024 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11025 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11026 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11027 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11028 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11029 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11030 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11031 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11032 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11033 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011034 {}
11035};
11036
Tobin Davisf651b502007-10-26 12:40:47 +020011037/* mute/unmute internal speaker according to the hp jack and mute state */
11038static void alc262_ultra_automute(struct hda_codec *codec)
11039{
11040 struct alc_spec *spec = codec->spec;
11041 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011042
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011043 mute = 0;
11044 /* auto-mute only when HP is used as HP */
11045 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011046 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011047 if (spec->jack_present)
11048 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011049 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011050 /* mute/unmute internal speaker */
11051 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11052 HDA_AMP_MUTE, mute);
11053 /* mute/unmute HP */
11054 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11055 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011056}
11057
11058/* unsolicited event for HP jack sensing */
11059static void alc262_ultra_unsol_event(struct hda_codec *codec,
11060 unsigned int res)
11061{
11062 if ((res >> 26) != ALC880_HP_EVENT)
11063 return;
11064 alc262_ultra_automute(codec);
11065}
11066
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011067static struct hda_input_mux alc262_ultra_capture_source = {
11068 .num_items = 2,
11069 .items = {
11070 { "Mic", 0x1 },
11071 { "Headphone", 0x7 },
11072 },
11073};
11074
11075static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11076 struct snd_ctl_elem_value *ucontrol)
11077{
11078 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11079 struct alc_spec *spec = codec->spec;
11080 int ret;
11081
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011082 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011083 if (!ret)
11084 return 0;
11085 /* reprogram the HP pin as mic or HP according to the input source */
11086 snd_hda_codec_write_cache(codec, 0x15, 0,
11087 AC_VERB_SET_PIN_WIDGET_CONTROL,
11088 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11089 alc262_ultra_automute(codec); /* mute/unmute HP */
11090 return ret;
11091}
11092
11093static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11094 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11095 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11096 {
11097 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11098 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011099 .info = alc_mux_enum_info,
11100 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011101 .put = alc262_ultra_mux_enum_put,
11102 },
11103 { } /* end */
11104};
11105
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011106/* We use two mixers depending on the output pin; 0x16 is a mono output
11107 * and thus it's bound with a different mixer.
11108 * This function returns which mixer amp should be used.
11109 */
11110static int alc262_check_volbit(hda_nid_t nid)
11111{
11112 if (!nid)
11113 return 0;
11114 else if (nid == 0x16)
11115 return 2;
11116 else
11117 return 1;
11118}
11119
11120static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
11121 const char *pfx, int *vbits)
11122{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011123 unsigned long val;
11124 int vbit;
11125
11126 vbit = alc262_check_volbit(nid);
11127 if (!vbit)
11128 return 0;
11129 if (*vbits & vbit) /* a volume control for this mixer already there */
11130 return 0;
11131 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011132 if (vbit == 2)
11133 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11134 else
11135 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011136 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011137}
11138
11139static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
11140 const char *pfx)
11141{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011142 unsigned long val;
11143
11144 if (!nid)
11145 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011146 if (nid == 0x16)
11147 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11148 else
11149 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011150 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011151}
11152
Kailang Yangdf694da2005-12-05 19:42:22 +010011153/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011154static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11155 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011156{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011157 const char *pfx;
11158 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010011159 int err;
11160
11161 spec->multiout.num_dacs = 1; /* only use one dac */
11162 spec->multiout.dac_nids = spec->private_dac_nids;
11163 spec->multiout.dac_nids[0] = 2;
11164
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011165 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11166 pfx = "Master";
11167 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11168 pfx = "Speaker";
11169 else
11170 pfx = "Front";
11171 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11172 if (err < 0)
11173 return err;
11174 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11175 if (err < 0)
11176 return err;
11177 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11178 if (err < 0)
11179 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011180
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011181 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11182 alc262_check_volbit(cfg->speaker_pins[0]) |
11183 alc262_check_volbit(cfg->hp_pins[0]);
11184 if (vbits == 1 || vbits == 2)
11185 pfx = "Master"; /* only one mixer is used */
11186 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11187 pfx = "Speaker";
11188 else
11189 pfx = "Front";
11190 vbits = 0;
11191 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11192 if (err < 0)
11193 return err;
11194 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11195 &vbits);
11196 if (err < 0)
11197 return err;
11198 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11199 &vbits);
11200 if (err < 0)
11201 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011202 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011203}
11204
Takashi Iwai05f5f472009-08-25 13:10:18 +020011205#define alc262_auto_create_input_ctls \
11206 alc880_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011207
11208/*
11209 * generic initialization of ADC, input mixers and output mixers
11210 */
11211static struct hda_verb alc262_volume_init_verbs[] = {
11212 /*
11213 * Unmute ADC0-2 and set the default input to mic-in
11214 */
11215 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11216 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11217 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11218 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11219 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11220 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11221
Takashi Iwaicb53c622007-08-10 17:21:45 +020011222 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011223 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011224 * Note: PASD motherboards uses the Line In 2 as the input for
11225 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011226 */
11227 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011228 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11229 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11230 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11231 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11232 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011233
11234 /*
11235 * Set up output mixers (0x0c - 0x0f)
11236 */
11237 /* set vol=0 to output mixers */
11238 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11239 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11240 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011241
Kailang Yangdf694da2005-12-05 19:42:22 +010011242 /* set up input amps for analog loopback */
11243 /* Amp Indices: DAC = 0, mixer = 1 */
11244 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11245 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11246 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11247 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11248 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11249 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11250
11251 /* FIXME: use matrix-type input source selection */
11252 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11253 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11254 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11255 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11256 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11257 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11258 /* Input mixer2 */
11259 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11260 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11261 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11262 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11263 /* Input mixer3 */
11264 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11265 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11266 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11267 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11268
11269 { }
11270};
11271
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011272static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11273 /*
11274 * Unmute ADC0-2 and set the default input to mic-in
11275 */
11276 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11277 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11278 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11279 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11280 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11281 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11282
Takashi Iwaicb53c622007-08-10 17:21:45 +020011283 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011284 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011285 * Note: PASD motherboards uses the Line In 2 as the input for
11286 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011287 */
11288 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011289 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11290 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11291 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11292 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11293 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11294 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11295 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011296
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011297 /*
11298 * Set up output mixers (0x0c - 0x0e)
11299 */
11300 /* set vol=0 to output mixers */
11301 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11302 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11303 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11304
11305 /* set up input amps for analog loopback */
11306 /* Amp Indices: DAC = 0, mixer = 1 */
11307 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11308 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11309 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11310 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11311 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11312 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11313
Takashi Iwaice875f02008-01-28 18:17:43 +010011314 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011315 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11316 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11317
11318 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11319 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11320
11321 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11322 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11323
11324 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11325 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11326 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11327 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11328 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11329
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011330 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011331 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11332 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011333 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011334 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11335 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11336
11337
11338 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011339 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11340 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011341 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011342 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11343 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11344 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11345 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11346 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11347 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11348 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11349 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011350 /* Input mixer2 */
11351 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011352 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11353 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11354 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11355 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11356 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11357 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11358 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11359 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011360 /* Input mixer3 */
11361 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011362 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11363 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11364 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11365 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11366 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11367 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11368 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11369 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011370
Takashi Iwaice875f02008-01-28 18:17:43 +010011371 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11372
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011373 { }
11374};
11375
Kailang Yangcd7509a2007-01-26 18:33:17 +010011376static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11377 /*
11378 * Unmute ADC0-2 and set the default input to mic-in
11379 */
11380 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11381 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11382 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11383 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11384 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11385 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11386
Takashi Iwaicb53c622007-08-10 17:21:45 +020011387 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011388 * mixer widget
11389 * Note: PASD motherboards uses the Line In 2 as the input for front
11390 * panel mic (mic 2)
11391 */
11392 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011393 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11394 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11395 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11396 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11397 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11398 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11399 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11400 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011401 /*
11402 * Set up output mixers (0x0c - 0x0e)
11403 */
11404 /* set vol=0 to output mixers */
11405 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11406 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11407 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11408
11409 /* set up input amps for analog loopback */
11410 /* Amp Indices: DAC = 0, mixer = 1 */
11411 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11412 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11413 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11414 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11415 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11416 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11417
11418
11419 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11420 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11421 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11422 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11423 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11424 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11425 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11426
11427 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11428 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11429
11430 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11431 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11432
11433 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11434 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11435 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11436 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11437 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11438 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11439
11440 /* FIXME: use matrix-type input source selection */
11441 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11442 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11443 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11444 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11445 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11446 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11447 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11448 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11449 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11450 /* Input mixer2 */
11451 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11452 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11453 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11454 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11455 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11456 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11457 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11458 /* Input mixer3 */
11459 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11460 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11461 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11462 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11463 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11464 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11465 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11466
Takashi Iwaice875f02008-01-28 18:17:43 +010011467 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11468
Kailang Yangcd7509a2007-01-26 18:33:17 +010011469 { }
11470};
11471
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011472static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11473
11474 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11475 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11476 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11477
11478 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11479 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11480 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11481 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11482
11483 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11484 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11485 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11486 {}
11487};
11488
11489
Takashi Iwaicb53c622007-08-10 17:21:45 +020011490#ifdef CONFIG_SND_HDA_POWER_SAVE
11491#define alc262_loopbacks alc880_loopbacks
11492#endif
11493
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011494/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011495#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11496#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11497#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11498#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11499
11500/*
11501 * BIOS auto configuration
11502 */
11503static int alc262_parse_auto_config(struct hda_codec *codec)
11504{
11505 struct alc_spec *spec = codec->spec;
11506 int err;
11507 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11508
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011509 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11510 alc262_ignore);
11511 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011512 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011513 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011514 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011515 spec->multiout.max_channels = 2;
11516 spec->no_analog = 1;
11517 goto dig_only;
11518 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011519 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011520 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011521 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11522 if (err < 0)
11523 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011524 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011525 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011526 return err;
11527
11528 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11529
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011530 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011531 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011532 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011533 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011534 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011535 if (spec->autocfg.dig_in_pin)
11536 spec->dig_in_nid = ALC262_DIGIN_NID;
11537
Takashi Iwai603c4012008-07-30 15:01:44 +020011538 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011539 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011540
Takashi Iwaid88897e2008-10-31 15:01:37 +010011541 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011542 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011543 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011544
Takashi Iwai776e1842007-08-29 15:07:11 +020011545 err = alc_auto_add_mic_boost(codec);
11546 if (err < 0)
11547 return err;
11548
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011549 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11550
Kailang Yangdf694da2005-12-05 19:42:22 +010011551 return 1;
11552}
11553
11554#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11555#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11556#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011557#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011558
11559
11560/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011561static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011562{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011563 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011564 alc262_auto_init_multi_out(codec);
11565 alc262_auto_init_hp_out(codec);
11566 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011567 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011568 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011569 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011570}
11571
11572/*
11573 * configuration and preset
11574 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011575static const char *alc262_models[ALC262_MODEL_LAST] = {
11576 [ALC262_BASIC] = "basic",
11577 [ALC262_HIPPO] = "hippo",
11578 [ALC262_HIPPO_1] = "hippo_1",
11579 [ALC262_FUJITSU] = "fujitsu",
11580 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011581 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011582 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011583 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011584 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011585 [ALC262_BENQ_T31] = "benq-t31",
11586 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011587 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011588 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011589 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011590 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011591 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011592 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011593 [ALC262_AUTO] = "auto",
11594};
11595
11596static struct snd_pci_quirk alc262_cfg_tbl[] = {
11597 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011598 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011599 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11600 ALC262_HP_BPC),
11601 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11602 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011603 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11604 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011605 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011606 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011607 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011608 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011609 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011610 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011611 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011612 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011613 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11614 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11615 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011616 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11617 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011618 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011619 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011620 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011621 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011622 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011623 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050011624 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010011625 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011626#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010011627 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11628 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011629#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090011630 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011631 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011632 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011633 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011634 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011635 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011636 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11637 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011638 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011639 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011640 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011641 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011642 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011643 {}
11644};
11645
11646static struct alc_config_preset alc262_presets[] = {
11647 [ALC262_BASIC] = {
11648 .mixers = { alc262_base_mixer },
11649 .init_verbs = { alc262_init_verbs },
11650 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11651 .dac_nids = alc262_dac_nids,
11652 .hp_nid = 0x03,
11653 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11654 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011655 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011656 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011657 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011658 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011659 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011660 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11661 .dac_nids = alc262_dac_nids,
11662 .hp_nid = 0x03,
11663 .dig_out_nid = ALC262_DIGOUT_NID,
11664 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11665 .channel_mode = alc262_modes,
11666 .input_mux = &alc262_capture_source,
11667 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011668 .setup = alc262_hippo_setup,
11669 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011670 },
11671 [ALC262_HIPPO_1] = {
11672 .mixers = { alc262_hippo1_mixer },
11673 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11674 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11675 .dac_nids = alc262_dac_nids,
11676 .hp_nid = 0x02,
11677 .dig_out_nid = ALC262_DIGOUT_NID,
11678 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11679 .channel_mode = alc262_modes,
11680 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011681 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011682 .setup = alc262_hippo1_setup,
11683 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011684 },
Takashi Iwai834be882006-03-01 14:16:17 +010011685 [ALC262_FUJITSU] = {
11686 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011687 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11688 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011689 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11690 .dac_nids = alc262_dac_nids,
11691 .hp_nid = 0x03,
11692 .dig_out_nid = ALC262_DIGOUT_NID,
11693 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11694 .channel_mode = alc262_modes,
11695 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011696 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011697 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011698 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011699 [ALC262_HP_BPC] = {
11700 .mixers = { alc262_HP_BPC_mixer },
11701 .init_verbs = { alc262_HP_BPC_init_verbs },
11702 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11703 .dac_nids = alc262_dac_nids,
11704 .hp_nid = 0x03,
11705 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11706 .channel_mode = alc262_modes,
11707 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011708 .unsol_event = alc262_hp_bpc_unsol_event,
11709 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011710 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011711 [ALC262_HP_BPC_D7000_WF] = {
11712 .mixers = { alc262_HP_BPC_WildWest_mixer },
11713 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11714 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11715 .dac_nids = alc262_dac_nids,
11716 .hp_nid = 0x03,
11717 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11718 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011719 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011720 .unsol_event = alc262_hp_wildwest_unsol_event,
11721 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011722 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011723 [ALC262_HP_BPC_D7000_WL] = {
11724 .mixers = { alc262_HP_BPC_WildWest_mixer,
11725 alc262_HP_BPC_WildWest_option_mixer },
11726 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11727 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11728 .dac_nids = alc262_dac_nids,
11729 .hp_nid = 0x03,
11730 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11731 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011732 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011733 .unsol_event = alc262_hp_wildwest_unsol_event,
11734 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011735 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011736 [ALC262_HP_TC_T5735] = {
11737 .mixers = { alc262_hp_t5735_mixer },
11738 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11739 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11740 .dac_nids = alc262_dac_nids,
11741 .hp_nid = 0x03,
11742 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11743 .channel_mode = alc262_modes,
11744 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011745 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011746 .setup = alc262_hp_t5735_setup,
11747 .init_hook = alc_automute_amp,
Kailang Yang8c427222008-01-10 13:03:59 +010011748 },
11749 [ALC262_HP_RP5700] = {
11750 .mixers = { alc262_hp_rp5700_mixer },
11751 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11752 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11753 .dac_nids = alc262_dac_nids,
11754 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11755 .channel_mode = alc262_modes,
11756 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011757 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011758 [ALC262_BENQ_ED8] = {
11759 .mixers = { alc262_base_mixer },
11760 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11761 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11762 .dac_nids = alc262_dac_nids,
11763 .hp_nid = 0x03,
11764 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11765 .channel_mode = alc262_modes,
11766 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011767 },
Kailang Yang272a5272007-05-14 11:00:38 +020011768 [ALC262_SONY_ASSAMD] = {
11769 .mixers = { alc262_sony_mixer },
11770 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11771 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11772 .dac_nids = alc262_dac_nids,
11773 .hp_nid = 0x02,
11774 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11775 .channel_mode = alc262_modes,
11776 .input_mux = &alc262_capture_source,
11777 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011778 .setup = alc262_hippo_setup,
11779 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020011780 },
11781 [ALC262_BENQ_T31] = {
11782 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011783 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
11784 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020011785 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11786 .dac_nids = alc262_dac_nids,
11787 .hp_nid = 0x03,
11788 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11789 .channel_mode = alc262_modes,
11790 .input_mux = &alc262_capture_source,
11791 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011792 .setup = alc262_hippo_setup,
11793 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020011794 },
Tobin Davisf651b502007-10-26 12:40:47 +020011795 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011796 .mixers = { alc262_ultra_mixer },
11797 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011798 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011799 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11800 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011801 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11802 .channel_mode = alc262_modes,
11803 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011804 .adc_nids = alc262_adc_nids, /* ADC0 */
11805 .capsrc_nids = alc262_capsrc_nids,
11806 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011807 .unsol_event = alc262_ultra_unsol_event,
11808 .init_hook = alc262_ultra_automute,
11809 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011810 [ALC262_LENOVO_3000] = {
11811 .mixers = { alc262_lenovo_3000_mixer },
11812 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050011813 alc262_lenovo_3000_unsol_verbs,
11814 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011815 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11816 .dac_nids = alc262_dac_nids,
11817 .hp_nid = 0x03,
11818 .dig_out_nid = ALC262_DIGOUT_NID,
11819 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11820 .channel_mode = alc262_modes,
11821 .input_mux = &alc262_fujitsu_capture_source,
11822 .unsol_event = alc262_lenovo_3000_unsol_event,
11823 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011824 [ALC262_NEC] = {
11825 .mixers = { alc262_nec_mixer },
11826 .init_verbs = { alc262_nec_verbs },
11827 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11828 .dac_nids = alc262_dac_nids,
11829 .hp_nid = 0x03,
11830 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11831 .channel_mode = alc262_modes,
11832 .input_mux = &alc262_capture_source,
11833 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011834 [ALC262_TOSHIBA_S06] = {
11835 .mixers = { alc262_toshiba_s06_mixer },
11836 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11837 alc262_eapd_verbs },
11838 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11839 .capsrc_nids = alc262_dmic_capsrc_nids,
11840 .dac_nids = alc262_dac_nids,
11841 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011842 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011843 .dig_out_nid = ALC262_DIGOUT_NID,
11844 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11845 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011846 .unsol_event = alc_sku_unsol_event,
11847 .setup = alc262_toshiba_s06_setup,
11848 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020011849 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011850 [ALC262_TOSHIBA_RX1] = {
11851 .mixers = { alc262_toshiba_rx1_mixer },
11852 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11853 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11854 .dac_nids = alc262_dac_nids,
11855 .hp_nid = 0x03,
11856 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11857 .channel_mode = alc262_modes,
11858 .input_mux = &alc262_capture_source,
11859 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011860 .setup = alc262_hippo_setup,
11861 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011862 },
Tony Vroonba340e82009-02-02 19:01:30 +000011863 [ALC262_TYAN] = {
11864 .mixers = { alc262_tyan_mixer },
11865 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11866 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11867 .dac_nids = alc262_dac_nids,
11868 .hp_nid = 0x02,
11869 .dig_out_nid = ALC262_DIGOUT_NID,
11870 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11871 .channel_mode = alc262_modes,
11872 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011873 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011874 .setup = alc262_tyan_setup,
11875 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000011876 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011877};
11878
11879static int patch_alc262(struct hda_codec *codec)
11880{
11881 struct alc_spec *spec;
11882 int board_config;
11883 int err;
11884
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011885 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011886 if (spec == NULL)
11887 return -ENOMEM;
11888
11889 codec->spec = spec;
11890#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011891 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11892 * under-run
11893 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011894 {
11895 int tmp;
11896 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11897 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11898 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11899 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11900 }
11901#endif
11902
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011903 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11904
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011905 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11906 alc262_models,
11907 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011908
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011909 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011910 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11911 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011912 board_config = ALC262_AUTO;
11913 }
11914
11915 if (board_config == ALC262_AUTO) {
11916 /* automatic parse from the BIOS config */
11917 err = alc262_parse_auto_config(codec);
11918 if (err < 0) {
11919 alc_free(codec);
11920 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011921 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011922 printk(KERN_INFO
11923 "hda_codec: Cannot set up configuration "
11924 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011925 board_config = ALC262_BASIC;
11926 }
11927 }
11928
Takashi Iwai07eba612009-02-19 08:06:35 +010011929 if (!spec->no_analog) {
11930 err = snd_hda_attach_beep_device(codec, 0x1);
11931 if (err < 0) {
11932 alc_free(codec);
11933 return err;
11934 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011935 }
11936
Kailang Yangdf694da2005-12-05 19:42:22 +010011937 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011938 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011939
Kailang Yangdf694da2005-12-05 19:42:22 +010011940 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11941 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011942
Kailang Yangdf694da2005-12-05 19:42:22 +010011943 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11944 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11945
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011946 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011947 int i;
11948 /* check whether the digital-mic has to be supported */
11949 for (i = 0; i < spec->input_mux->num_items; i++) {
11950 if (spec->input_mux->items[i].index >= 9)
11951 break;
11952 }
11953 if (i < spec->input_mux->num_items) {
11954 /* use only ADC0 */
11955 spec->adc_nids = alc262_dmic_adc_nids;
11956 spec->num_adc_nids = 1;
11957 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011958 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011959 /* all analog inputs */
11960 /* check whether NID 0x07 is valid */
11961 unsigned int wcap = get_wcaps(codec, 0x07);
11962
11963 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011964 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020011965 if (wcap != AC_WID_AUD_IN) {
11966 spec->adc_nids = alc262_adc_nids_alt;
11967 spec->num_adc_nids =
11968 ARRAY_SIZE(alc262_adc_nids_alt);
11969 spec->capsrc_nids = alc262_capsrc_nids_alt;
11970 } else {
11971 spec->adc_nids = alc262_adc_nids;
11972 spec->num_adc_nids =
11973 ARRAY_SIZE(alc262_adc_nids);
11974 spec->capsrc_nids = alc262_capsrc_nids;
11975 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011976 }
11977 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011978 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011979 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011980 if (!spec->no_analog)
11981 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011982
Takashi Iwai2134ea42008-01-10 16:53:55 +010011983 spec->vmaster_nid = 0x0c;
11984
Kailang Yangdf694da2005-12-05 19:42:22 +010011985 codec->patch_ops = alc_patch_ops;
11986 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011987 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011988#ifdef CONFIG_SND_HDA_POWER_SAVE
11989 if (!spec->loopback.amplist)
11990 spec->loopback.amplist = alc262_loopbacks;
11991#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011992 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011993
Kailang Yangdf694da2005-12-05 19:42:22 +010011994 return 0;
11995}
11996
Kailang Yangdf694da2005-12-05 19:42:22 +010011997/*
Kailang Yanga361d842007-06-05 12:30:55 +020011998 * ALC268 channel source setting (2 channel)
11999 */
12000#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12001#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012002
Kailang Yanga361d842007-06-05 12:30:55 +020012003static hda_nid_t alc268_dac_nids[2] = {
12004 /* front, hp */
12005 0x02, 0x03
12006};
12007
12008static hda_nid_t alc268_adc_nids[2] = {
12009 /* ADC0-1 */
12010 0x08, 0x07
12011};
12012
12013static hda_nid_t alc268_adc_nids_alt[1] = {
12014 /* ADC0 */
12015 0x08
12016};
12017
Takashi Iwaie1406342008-02-11 18:32:32 +010012018static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12019
Kailang Yanga361d842007-06-05 12:30:55 +020012020static struct snd_kcontrol_new alc268_base_mixer[] = {
12021 /* output mixer control */
12022 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12023 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12024 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12025 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012026 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12027 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12028 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012029 { }
12030};
12031
Takashi Iwai42171c12009-05-08 14:11:43 +020012032static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12033 /* output mixer control */
12034 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12035 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12036 ALC262_HIPPO_MASTER_SWITCH,
12037 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12038 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12039 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12040 { }
12041};
12042
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012043/* bind Beep switches of both NID 0x0f and 0x10 */
12044static struct hda_bind_ctls alc268_bind_beep_sw = {
12045 .ops = &snd_hda_bind_sw,
12046 .values = {
12047 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12048 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12049 0
12050 },
12051};
12052
12053static struct snd_kcontrol_new alc268_beep_mixer[] = {
12054 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12055 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12056 { }
12057};
12058
Kailang Yangd1a991a2007-08-15 16:21:59 +020012059static struct hda_verb alc268_eapd_verbs[] = {
12060 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12061 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12062 { }
12063};
12064
Takashi Iwaid2738092007-08-16 14:59:45 +020012065/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012066static struct hda_verb alc268_toshiba_verbs[] = {
12067 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12068 { } /* end */
12069};
12070
12071/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012072/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012073static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12074 .ops = &snd_hda_bind_vol,
12075 .values = {
12076 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12077 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12078 0
12079 },
12080};
12081
Takashi Iwai889c4392007-08-23 18:56:52 +020012082/* mute/unmute internal speaker according to the hp jack and mute state */
12083static void alc268_acer_automute(struct hda_codec *codec, int force)
12084{
12085 struct alc_spec *spec = codec->spec;
12086 unsigned int mute;
12087
12088 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012089 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012090 spec->sense_updated = 1;
12091 }
12092 if (spec->jack_present)
12093 mute = HDA_AMP_MUTE; /* mute internal speaker */
12094 else /* unmute internal speaker if necessary */
12095 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12096 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12097 HDA_AMP_MUTE, mute);
12098}
12099
12100
12101/* bind hp and internal speaker mute (with plug check) */
12102static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12103 struct snd_ctl_elem_value *ucontrol)
12104{
12105 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12106 long *valp = ucontrol->value.integer.value;
12107 int change;
12108
Takashi Iwai8de56b72009-07-24 16:51:47 +020012109 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012110 if (change)
12111 alc268_acer_automute(codec, 0);
12112 return change;
12113}
Takashi Iwaid2738092007-08-16 14:59:45 +020012114
Kailang Yang8ef355d2008-08-26 13:10:22 +020012115static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12116 /* output mixer control */
12117 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12118 {
12119 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12120 .name = "Master Playback Switch",
12121 .info = snd_hda_mixer_amp_switch_info,
12122 .get = snd_hda_mixer_amp_switch_get,
12123 .put = alc268_acer_master_sw_put,
12124 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12125 },
12126 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12127 { }
12128};
12129
Takashi Iwaid2738092007-08-16 14:59:45 +020012130static struct snd_kcontrol_new alc268_acer_mixer[] = {
12131 /* output mixer control */
12132 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12133 {
12134 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12135 .name = "Master Playback Switch",
12136 .info = snd_hda_mixer_amp_switch_info,
12137 .get = snd_hda_mixer_amp_switch_get,
12138 .put = alc268_acer_master_sw_put,
12139 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12140 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012141 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12142 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12143 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012144 { }
12145};
12146
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012147static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12148 /* output mixer control */
12149 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12150 {
12151 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12152 .name = "Master Playback Switch",
12153 .info = snd_hda_mixer_amp_switch_info,
12154 .get = snd_hda_mixer_amp_switch_get,
12155 .put = alc268_acer_master_sw_put,
12156 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12157 },
12158 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12159 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12160 { }
12161};
12162
Kailang Yang8ef355d2008-08-26 13:10:22 +020012163static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12164 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12165 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12166 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12167 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12168 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12169 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12170 { }
12171};
12172
Takashi Iwaid2738092007-08-16 14:59:45 +020012173static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012174 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12175 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012176 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12177 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012178 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12179 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012180 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12181 { }
12182};
12183
12184/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012185#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012186#define alc268_toshiba_setup alc262_hippo_setup
12187#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012188
12189static void alc268_acer_unsol_event(struct hda_codec *codec,
12190 unsigned int res)
12191{
Takashi Iwai889c4392007-08-23 18:56:52 +020012192 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012193 return;
12194 alc268_acer_automute(codec, 1);
12195}
12196
Takashi Iwai889c4392007-08-23 18:56:52 +020012197static void alc268_acer_init_hook(struct hda_codec *codec)
12198{
12199 alc268_acer_automute(codec, 1);
12200}
12201
Kailang Yang8ef355d2008-08-26 13:10:22 +020012202/* toggle speaker-output according to the hp-jack state */
12203static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12204{
12205 unsigned int present;
12206 unsigned char bits;
12207
Wu Fengguang864f92b2009-11-18 12:38:02 +080012208 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012209 bits = present ? AMP_IN_MUTE(0) : 0;
12210 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
12211 AMP_IN_MUTE(0), bits);
12212 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
12213 AMP_IN_MUTE(0), bits);
12214}
12215
Kailang Yang8ef355d2008-08-26 13:10:22 +020012216static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12217 unsigned int res)
12218{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012219 switch (res >> 26) {
12220 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012221 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012222 break;
12223 case ALC880_MIC_EVENT:
12224 alc_mic_automute(codec);
12225 break;
12226 }
12227}
12228
12229static void alc268_acer_lc_setup(struct hda_codec *codec)
12230{
12231 struct alc_spec *spec = codec->spec;
12232 spec->ext_mic.pin = 0x18;
12233 spec->ext_mic.mux_idx = 0;
12234 spec->int_mic.pin = 0x12;
12235 spec->int_mic.mux_idx = 6;
12236 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012237}
12238
12239static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12240{
12241 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012242 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012243}
12244
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012245static struct snd_kcontrol_new alc268_dell_mixer[] = {
12246 /* output mixer control */
12247 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12248 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12249 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12250 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12251 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12252 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12253 { }
12254};
12255
12256static struct hda_verb alc268_dell_verbs[] = {
12257 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12258 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12259 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012260 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012261 { }
12262};
12263
12264/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012265static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012266{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012267 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012268
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012269 spec->autocfg.hp_pins[0] = 0x15;
12270 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012271 spec->ext_mic.pin = 0x18;
12272 spec->ext_mic.mux_idx = 0;
12273 spec->int_mic.pin = 0x19;
12274 spec->int_mic.mux_idx = 1;
12275 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012276}
12277
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012278static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12279 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12280 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12281 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12282 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12283 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12284 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12285 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12286 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12287 { }
12288};
12289
12290static struct hda_verb alc267_quanta_il1_verbs[] = {
12291 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12292 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12293 { }
12294};
12295
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012296static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012297{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012298 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012299 spec->autocfg.hp_pins[0] = 0x15;
12300 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012301 spec->ext_mic.pin = 0x18;
12302 spec->ext_mic.mux_idx = 0;
12303 spec->int_mic.pin = 0x19;
12304 spec->int_mic.mux_idx = 1;
12305 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012306}
12307
Kailang Yanga361d842007-06-05 12:30:55 +020012308/*
12309 * generic initialization of ADC, input mixers and output mixers
12310 */
12311static struct hda_verb alc268_base_init_verbs[] = {
12312 /* Unmute DAC0-1 and set vol = 0 */
12313 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012314 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012315
12316 /*
12317 * Set up output mixers (0x0c - 0x0e)
12318 */
12319 /* set vol=0 to output mixers */
12320 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012321 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12322
12323 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12324 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12325
12326 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12327 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12328 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12329 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12330 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12331 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12332 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12333 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12334
12335 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12336 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12337 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12338 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012339 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012340
12341 /* set PCBEEP vol = 0, mute connections */
12342 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12343 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12344 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012345
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012346 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012347
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012348 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12349 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12350 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12351 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012352
Kailang Yanga361d842007-06-05 12:30:55 +020012353 { }
12354};
12355
12356/*
12357 * generic initialization of ADC, input mixers and output mixers
12358 */
12359static struct hda_verb alc268_volume_init_verbs[] = {
12360 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012361 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12362 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012363
12364 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12365 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12366 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12367 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12368 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12369
Kailang Yanga361d842007-06-05 12:30:55 +020012370 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012371 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12372 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12373
12374 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012375 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012376
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012377 /* set PCBEEP vol = 0, mute connections */
12378 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12379 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12380 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012381
12382 { }
12383};
12384
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012385static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12386 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12387 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12388 { } /* end */
12389};
12390
Kailang Yanga361d842007-06-05 12:30:55 +020012391static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12392 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12393 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012394 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012395 { } /* end */
12396};
12397
12398static struct snd_kcontrol_new alc268_capture_mixer[] = {
12399 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12400 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12401 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12402 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012403 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012404 { } /* end */
12405};
12406
12407static struct hda_input_mux alc268_capture_source = {
12408 .num_items = 4,
12409 .items = {
12410 { "Mic", 0x0 },
12411 { "Front Mic", 0x1 },
12412 { "Line", 0x2 },
12413 { "CD", 0x3 },
12414 },
12415};
12416
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012417static struct hda_input_mux alc268_acer_capture_source = {
12418 .num_items = 3,
12419 .items = {
12420 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012421 { "Internal Mic", 0x1 },
12422 { "Line", 0x2 },
12423 },
12424};
12425
12426static struct hda_input_mux alc268_acer_dmic_capture_source = {
12427 .num_items = 3,
12428 .items = {
12429 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012430 { "Internal Mic", 0x6 },
12431 { "Line", 0x2 },
12432 },
12433};
12434
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012435#ifdef CONFIG_SND_DEBUG
12436static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012437 /* Volume widgets */
12438 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12439 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12440 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12441 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12442 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12443 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12444 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12445 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12446 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12447 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12448 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12449 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12450 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012451 /* The below appears problematic on some hardwares */
12452 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012453 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12454 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12455 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12456 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12457
12458 /* Modes for retasking pin widgets */
12459 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12460 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12461 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12462 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12463
12464 /* Controls for GPIO pins, assuming they are configured as outputs */
12465 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12466 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12467 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12468 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12469
12470 /* Switches to allow the digital SPDIF output pin to be enabled.
12471 * The ALC268 does not have an SPDIF input.
12472 */
12473 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12474
12475 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12476 * this output to turn on an external amplifier.
12477 */
12478 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12479 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12480
12481 { } /* end */
12482};
12483#endif
12484
Kailang Yanga361d842007-06-05 12:30:55 +020012485/* create input playback/capture controls for the given pin */
12486static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12487 const char *ctlname, int idx)
12488{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012489 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012490 int err;
12491
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012492 switch (nid) {
12493 case 0x14:
12494 case 0x16:
12495 dac = 0x02;
12496 break;
12497 case 0x15:
12498 dac = 0x03;
12499 break;
12500 default:
12501 return 0;
12502 }
12503 if (spec->multiout.dac_nids[0] != dac &&
12504 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012505 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012506 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012507 HDA_OUTPUT));
12508 if (err < 0)
12509 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012510 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12511 }
12512
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012513 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012514 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020012515 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012516 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012517 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012518 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012519 if (err < 0)
12520 return err;
12521 return 0;
12522}
12523
12524/* add playback controls from the parsed DAC table */
12525static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12526 const struct auto_pin_cfg *cfg)
12527{
12528 hda_nid_t nid;
12529 int err;
12530
Kailang Yanga361d842007-06-05 12:30:55 +020012531 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012532
12533 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012534 if (nid) {
12535 const char *name;
12536 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12537 name = "Speaker";
12538 else
12539 name = "Front";
12540 err = alc268_new_analog_output(spec, nid, name, 0);
12541 if (err < 0)
12542 return err;
12543 }
Kailang Yanga361d842007-06-05 12:30:55 +020012544
12545 nid = cfg->speaker_pins[0];
12546 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012547 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020012548 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12549 if (err < 0)
12550 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012551 } else {
12552 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12553 if (err < 0)
12554 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012555 }
12556 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012557 if (nid) {
12558 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12559 if (err < 0)
12560 return err;
12561 }
Kailang Yanga361d842007-06-05 12:30:55 +020012562
12563 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12564 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012565 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012566 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012567 if (err < 0)
12568 return err;
12569 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012570 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012571}
12572
12573/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020012574static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020012575 const struct auto_pin_cfg *cfg)
12576{
Takashi Iwai05f5f472009-08-25 13:10:18 +020012577 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020012578}
12579
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012580static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12581 hda_nid_t nid, int pin_type)
12582{
12583 int idx;
12584
12585 alc_set_pin_output(codec, nid, pin_type);
12586 if (nid == 0x14 || nid == 0x16)
12587 idx = 0;
12588 else
12589 idx = 1;
12590 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12591}
12592
12593static void alc268_auto_init_multi_out(struct hda_codec *codec)
12594{
12595 struct alc_spec *spec = codec->spec;
12596 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12597 if (nid) {
12598 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12599 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12600 }
12601}
12602
12603static void alc268_auto_init_hp_out(struct hda_codec *codec)
12604{
12605 struct alc_spec *spec = codec->spec;
12606 hda_nid_t pin;
12607
12608 pin = spec->autocfg.hp_pins[0];
12609 if (pin)
12610 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12611 pin = spec->autocfg.speaker_pins[0];
12612 if (pin)
12613 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12614}
12615
Kailang Yanga361d842007-06-05 12:30:55 +020012616static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12617{
12618 struct alc_spec *spec = codec->spec;
12619 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12620 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12621 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12622 unsigned int dac_vol1, dac_vol2;
12623
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012624 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020012625 snd_hda_codec_write(codec, speaker_nid, 0,
12626 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012627 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012628 snd_hda_codec_write(codec, 0x0f, 0,
12629 AC_VERB_SET_AMP_GAIN_MUTE,
12630 AMP_IN_UNMUTE(1));
12631 snd_hda_codec_write(codec, 0x10, 0,
12632 AC_VERB_SET_AMP_GAIN_MUTE,
12633 AMP_IN_UNMUTE(1));
12634 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012635 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012636 snd_hda_codec_write(codec, 0x0f, 0,
12637 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12638 snd_hda_codec_write(codec, 0x10, 0,
12639 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12640 }
12641
12642 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012643 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012644 dac_vol2 = AMP_OUT_ZERO;
12645 else if (line_nid == 0x15)
12646 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012647 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012648 dac_vol2 = AMP_OUT_ZERO;
12649 else if (hp_nid == 0x15)
12650 dac_vol1 = AMP_OUT_ZERO;
12651 if (line_nid != 0x16 || hp_nid != 0x16 ||
12652 spec->autocfg.line_out_pins[1] != 0x16 ||
12653 spec->autocfg.line_out_pins[2] != 0x16)
12654 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12655
12656 snd_hda_codec_write(codec, 0x02, 0,
12657 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12658 snd_hda_codec_write(codec, 0x03, 0,
12659 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12660}
12661
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012662/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012663#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12664#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012665#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012666#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12667
12668/*
12669 * BIOS auto configuration
12670 */
12671static int alc268_parse_auto_config(struct hda_codec *codec)
12672{
12673 struct alc_spec *spec = codec->spec;
12674 int err;
12675 static hda_nid_t alc268_ignore[] = { 0 };
12676
12677 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12678 alc268_ignore);
12679 if (err < 0)
12680 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012681 if (!spec->autocfg.line_outs) {
12682 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12683 spec->multiout.max_channels = 2;
12684 spec->no_analog = 1;
12685 goto dig_only;
12686 }
Kailang Yanga361d842007-06-05 12:30:55 +020012687 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012688 }
Kailang Yanga361d842007-06-05 12:30:55 +020012689 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12690 if (err < 0)
12691 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012692 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020012693 if (err < 0)
12694 return err;
12695
12696 spec->multiout.max_channels = 2;
12697
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012698 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012699 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012700 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012701 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012702 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12703 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012704 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012705 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012706
Takashi Iwai892981f2009-03-02 08:04:35 +010012707 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012708 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012709
Takashi Iwaid88897e2008-10-31 15:01:37 +010012710 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012711 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012712 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012713
Takashi Iwai776e1842007-08-29 15:07:11 +020012714 err = alc_auto_add_mic_boost(codec);
12715 if (err < 0)
12716 return err;
12717
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012718 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12719
Kailang Yanga361d842007-06-05 12:30:55 +020012720 return 1;
12721}
12722
Kailang Yanga361d842007-06-05 12:30:55 +020012723#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12724
12725/* init callback for auto-configuration model -- overriding the default init */
12726static void alc268_auto_init(struct hda_codec *codec)
12727{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012728 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012729 alc268_auto_init_multi_out(codec);
12730 alc268_auto_init_hp_out(codec);
12731 alc268_auto_init_mono_speaker_out(codec);
12732 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012733 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012734 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012735}
12736
12737/*
12738 * configuration and preset
12739 */
12740static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012741 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012742 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012743 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012744 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012745 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012746 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012747 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012748 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012749#ifdef CONFIG_SND_DEBUG
12750 [ALC268_TEST] = "test",
12751#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012752 [ALC268_AUTO] = "auto",
12753};
12754
12755static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012756 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012757 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012758 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012759 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012760 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012761 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12762 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012763 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050012764 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
12765 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020012766 /* almost compatible with toshiba but with optional digital outs;
12767 * auto-probing seems working fine
12768 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012769 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020012770 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020012771 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012772 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012773 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012774 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012775 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012776 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012777 {}
12778};
12779
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012780/* Toshiba laptops have no unique PCI SSID but only codec SSID */
12781static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
12782 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
12783 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
12784 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12785 ALC268_TOSHIBA),
12786 {}
12787};
12788
Kailang Yanga361d842007-06-05 12:30:55 +020012789static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012790 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012791 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
12792 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012793 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12794 alc267_quanta_il1_verbs },
12795 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12796 .dac_nids = alc268_dac_nids,
12797 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12798 .adc_nids = alc268_adc_nids_alt,
12799 .hp_nid = 0x03,
12800 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12801 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012802 .unsol_event = alc_sku_unsol_event,
12803 .setup = alc267_quanta_il1_setup,
12804 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012805 },
Kailang Yanga361d842007-06-05 12:30:55 +020012806 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012807 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12808 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012809 .init_verbs = { alc268_base_init_verbs },
12810 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12811 .dac_nids = alc268_dac_nids,
12812 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12813 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012814 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012815 .hp_nid = 0x03,
12816 .dig_out_nid = ALC268_DIGOUT_NID,
12817 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12818 .channel_mode = alc268_modes,
12819 .input_mux = &alc268_capture_source,
12820 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012821 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012822 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012823 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012824 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12825 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012826 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12827 .dac_nids = alc268_dac_nids,
12828 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12829 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012830 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012831 .hp_nid = 0x03,
12832 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12833 .channel_mode = alc268_modes,
12834 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012835 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012836 .setup = alc268_toshiba_setup,
12837 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020012838 },
12839 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020012840 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012841 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012842 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12843 alc268_acer_verbs },
12844 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12845 .dac_nids = alc268_dac_nids,
12846 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12847 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012848 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012849 .hp_nid = 0x02,
12850 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12851 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012852 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012853 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012854 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012855 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012856 [ALC268_ACER_DMIC] = {
12857 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12858 alc268_beep_mixer },
12859 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12860 alc268_acer_verbs },
12861 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12862 .dac_nids = alc268_dac_nids,
12863 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12864 .adc_nids = alc268_adc_nids_alt,
12865 .capsrc_nids = alc268_capsrc_nids,
12866 .hp_nid = 0x02,
12867 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12868 .channel_mode = alc268_modes,
12869 .input_mux = &alc268_acer_dmic_capture_source,
12870 .unsol_event = alc268_acer_unsol_event,
12871 .init_hook = alc268_acer_init_hook,
12872 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012873 [ALC268_ACER_ASPIRE_ONE] = {
12874 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012875 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012876 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012877 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12878 alc268_acer_aspire_one_verbs },
12879 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12880 .dac_nids = alc268_dac_nids,
12881 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12882 .adc_nids = alc268_adc_nids_alt,
12883 .capsrc_nids = alc268_capsrc_nids,
12884 .hp_nid = 0x03,
12885 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12886 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012887 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012888 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012889 .init_hook = alc268_acer_lc_init_hook,
12890 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012891 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012892 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
12893 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012894 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12895 alc268_dell_verbs },
12896 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12897 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012898 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12899 .adc_nids = alc268_adc_nids_alt,
12900 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012901 .hp_nid = 0x02,
12902 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12903 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012904 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012905 .setup = alc268_dell_setup,
12906 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012907 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012908 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012909 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12910 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012911 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12912 alc268_toshiba_verbs },
12913 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12914 .dac_nids = alc268_dac_nids,
12915 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12916 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012917 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012918 .hp_nid = 0x03,
12919 .dig_out_nid = ALC268_DIGOUT_NID,
12920 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12921 .channel_mode = alc268_modes,
12922 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012923 .setup = alc268_toshiba_setup,
12924 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012925 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012926#ifdef CONFIG_SND_DEBUG
12927 [ALC268_TEST] = {
12928 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12929 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12930 alc268_volume_init_verbs },
12931 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12932 .dac_nids = alc268_dac_nids,
12933 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12934 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012935 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012936 .hp_nid = 0x03,
12937 .dig_out_nid = ALC268_DIGOUT_NID,
12938 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12939 .channel_mode = alc268_modes,
12940 .input_mux = &alc268_capture_source,
12941 },
12942#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012943};
12944
12945static int patch_alc268(struct hda_codec *codec)
12946{
12947 struct alc_spec *spec;
12948 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012949 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012950
Julia Lawallef86f582009-12-19 08:18:03 +010012951 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020012952 if (spec == NULL)
12953 return -ENOMEM;
12954
12955 codec->spec = spec;
12956
12957 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12958 alc268_models,
12959 alc268_cfg_tbl);
12960
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012961 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
12962 board_config = snd_hda_check_board_codec_sid_config(codec,
12963 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
12964
Kailang Yanga361d842007-06-05 12:30:55 +020012965 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012966 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12967 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012968 board_config = ALC268_AUTO;
12969 }
12970
12971 if (board_config == ALC268_AUTO) {
12972 /* automatic parse from the BIOS config */
12973 err = alc268_parse_auto_config(codec);
12974 if (err < 0) {
12975 alc_free(codec);
12976 return err;
12977 } else if (!err) {
12978 printk(KERN_INFO
12979 "hda_codec: Cannot set up configuration "
12980 "from BIOS. Using base mode...\n");
12981 board_config = ALC268_3ST;
12982 }
12983 }
12984
12985 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012986 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020012987
Kailang Yanga361d842007-06-05 12:30:55 +020012988 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12989 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012990 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012991
Kailang Yanga361d842007-06-05 12:30:55 +020012992 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12993
Takashi Iwai22971e32009-02-10 11:56:44 +010012994 has_beep = 0;
12995 for (i = 0; i < spec->num_mixers; i++) {
12996 if (spec->mixers[i] == alc268_beep_mixer) {
12997 has_beep = 1;
12998 break;
12999 }
13000 }
13001
13002 if (has_beep) {
13003 err = snd_hda_attach_beep_device(codec, 0x1);
13004 if (err < 0) {
13005 alc_free(codec);
13006 return err;
13007 }
13008 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13009 /* override the amp caps for beep generator */
13010 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013011 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13012 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13013 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13014 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013015 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013016
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013017 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013018 /* check whether NID 0x07 is valid */
13019 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013020 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013021
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013022 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013023 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013024 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013025 if (spec->auto_mic ||
13026 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013027 spec->adc_nids = alc268_adc_nids_alt;
13028 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013029 if (spec->auto_mic)
13030 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013031 if (spec->auto_mic || spec->input_mux->num_items == 1)
13032 add_mixer(spec, alc268_capture_nosrc_mixer);
13033 else
13034 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013035 } else {
13036 spec->adc_nids = alc268_adc_nids;
13037 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013038 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013039 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013040 /* set default input source */
13041 for (i = 0; i < spec->num_adc_nids; i++)
13042 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13043 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013044 i < spec->num_mux_defs ?
13045 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013046 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013047 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013048
13049 spec->vmaster_nid = 0x02;
13050
Kailang Yanga361d842007-06-05 12:30:55 +020013051 codec->patch_ops = alc_patch_ops;
13052 if (board_config == ALC268_AUTO)
13053 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013054
Takashi Iwaidaead532008-11-28 12:55:36 +010013055 codec->proc_widget_hook = print_realtek_coef;
13056
Kailang Yanga361d842007-06-05 12:30:55 +020013057 return 0;
13058}
13059
13060/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013061 * ALC269 channel source setting (2 channel)
13062 */
13063#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13064
13065#define alc269_dac_nids alc260_dac_nids
13066
13067static hda_nid_t alc269_adc_nids[1] = {
13068 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013069 0x08,
13070};
13071
Takashi Iwaie01bf502008-08-21 16:25:07 +020013072static hda_nid_t alc269_capsrc_nids[1] = {
13073 0x23,
13074};
13075
13076/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
13077 * not a mux!
13078 */
13079
Kailang Yangf6a92242007-12-13 16:52:54 +010013080#define alc269_modes alc260_modes
13081#define alc269_capture_source alc880_lg_lw_capture_source
13082
13083static struct snd_kcontrol_new alc269_base_mixer[] = {
13084 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13085 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13086 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13087 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13088 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13089 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13090 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13091 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13092 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13093 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13094 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13095 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13096 { } /* end */
13097};
13098
Kailang Yang60db6b52008-08-26 13:13:00 +020013099static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13100 /* output mixer control */
13101 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13102 {
13103 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13104 .name = "Master Playback Switch",
13105 .info = snd_hda_mixer_amp_switch_info,
13106 .get = snd_hda_mixer_amp_switch_get,
13107 .put = alc268_acer_master_sw_put,
13108 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13109 },
13110 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13111 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13112 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13113 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13114 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13115 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013116 { }
13117};
13118
Tony Vroon64154832008-11-06 15:08:49 +000013119static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13120 /* output mixer control */
13121 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13122 {
13123 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13124 .name = "Master Playback Switch",
13125 .info = snd_hda_mixer_amp_switch_info,
13126 .get = snd_hda_mixer_amp_switch_get,
13127 .put = alc268_acer_master_sw_put,
13128 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13129 },
13130 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13131 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13132 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13133 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13134 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13135 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13136 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13137 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13138 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013139 { }
13140};
13141
Kailang Yangf53281e2008-07-18 12:36:43 +020013142static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013143 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013144 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013145 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013146 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013147 { } /* end */
13148};
13149
Kailang Yangf6a92242007-12-13 16:52:54 +010013150/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020013151static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
13152 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13153 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013154 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13155 { } /* end */
13156};
13157
13158/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020013159#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013160
Kailang Yang60db6b52008-08-26 13:13:00 +020013161static struct hda_verb alc269_quanta_fl1_verbs[] = {
13162 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13163 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13164 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13165 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13166 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13167 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13168 { }
13169};
13170
Tony Vroon64154832008-11-06 15:08:49 +000013171static struct hda_verb alc269_lifebook_verbs[] = {
13172 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13173 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13174 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13175 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13176 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13177 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13178 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13179 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13180 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13181 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13182 { }
13183};
13184
Kailang Yang60db6b52008-08-26 13:13:00 +020013185/* toggle speaker-output according to the hp-jack state */
13186static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13187{
13188 unsigned int present;
13189 unsigned char bits;
13190
Wu Fengguang864f92b2009-11-18 12:38:02 +080013191 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang60db6b52008-08-26 13:13:00 +020013192 bits = present ? AMP_IN_MUTE(0) : 0;
13193 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13194 AMP_IN_MUTE(0), bits);
13195 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13196 AMP_IN_MUTE(0), bits);
13197
13198 snd_hda_codec_write(codec, 0x20, 0,
13199 AC_VERB_SET_COEF_INDEX, 0x0c);
13200 snd_hda_codec_write(codec, 0x20, 0,
13201 AC_VERB_SET_PROC_COEF, 0x680);
13202
13203 snd_hda_codec_write(codec, 0x20, 0,
13204 AC_VERB_SET_COEF_INDEX, 0x0c);
13205 snd_hda_codec_write(codec, 0x20, 0,
13206 AC_VERB_SET_PROC_COEF, 0x480);
13207}
13208
Tony Vroon64154832008-11-06 15:08:49 +000013209/* toggle speaker-output according to the hp-jacks state */
13210static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13211{
13212 unsigned int present;
13213 unsigned char bits;
13214
13215 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013216 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013217
13218 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013219 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013220
13221 bits = present ? AMP_IN_MUTE(0) : 0;
13222 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13223 AMP_IN_MUTE(0), bits);
13224 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13225 AMP_IN_MUTE(0), bits);
13226
13227 snd_hda_codec_write(codec, 0x20, 0,
13228 AC_VERB_SET_COEF_INDEX, 0x0c);
13229 snd_hda_codec_write(codec, 0x20, 0,
13230 AC_VERB_SET_PROC_COEF, 0x680);
13231
13232 snd_hda_codec_write(codec, 0x20, 0,
13233 AC_VERB_SET_COEF_INDEX, 0x0c);
13234 snd_hda_codec_write(codec, 0x20, 0,
13235 AC_VERB_SET_PROC_COEF, 0x480);
13236}
13237
Tony Vroon64154832008-11-06 15:08:49 +000013238static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13239{
13240 unsigned int present_laptop;
13241 unsigned int present_dock;
13242
Wu Fengguang864f92b2009-11-18 12:38:02 +080013243 present_laptop = snd_hda_jack_detect(codec, 0x18);
13244 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000013245
13246 /* Laptop mic port overrides dock mic port, design decision */
13247 if (present_dock)
13248 snd_hda_codec_write(codec, 0x23, 0,
13249 AC_VERB_SET_CONNECT_SEL, 0x3);
13250 if (present_laptop)
13251 snd_hda_codec_write(codec, 0x23, 0,
13252 AC_VERB_SET_CONNECT_SEL, 0x0);
13253 if (!present_dock && !present_laptop)
13254 snd_hda_codec_write(codec, 0x23, 0,
13255 AC_VERB_SET_CONNECT_SEL, 0x1);
13256}
13257
Kailang Yang60db6b52008-08-26 13:13:00 +020013258static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13259 unsigned int res)
13260{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013261 switch (res >> 26) {
13262 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013263 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013264 break;
13265 case ALC880_MIC_EVENT:
13266 alc_mic_automute(codec);
13267 break;
13268 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013269}
13270
Tony Vroon64154832008-11-06 15:08:49 +000013271static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13272 unsigned int res)
13273{
13274 if ((res >> 26) == ALC880_HP_EVENT)
13275 alc269_lifebook_speaker_automute(codec);
13276 if ((res >> 26) == ALC880_MIC_EVENT)
13277 alc269_lifebook_mic_autoswitch(codec);
13278}
13279
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013280static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13281{
13282 struct alc_spec *spec = codec->spec;
13283 spec->ext_mic.pin = 0x18;
13284 spec->ext_mic.mux_idx = 0;
13285 spec->int_mic.pin = 0x19;
13286 spec->int_mic.mux_idx = 1;
13287 spec->auto_mic = 1;
13288}
13289
Kailang Yang60db6b52008-08-26 13:13:00 +020013290static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13291{
13292 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013293 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013294}
13295
Tony Vroon64154832008-11-06 15:08:49 +000013296static void alc269_lifebook_init_hook(struct hda_codec *codec)
13297{
13298 alc269_lifebook_speaker_automute(codec);
13299 alc269_lifebook_mic_autoswitch(codec);
13300}
13301
Kailang Yang60db6b52008-08-26 13:13:00 +020013302static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
13303 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13304 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13305 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13306 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13307 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13308 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13309 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13310 {}
13311};
13312
13313static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
13314 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13315 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13316 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13317 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13318 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13319 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13320 {}
13321};
13322
13323/* toggle speaker-output according to the hp-jack state */
13324static void alc269_speaker_automute(struct hda_codec *codec)
13325{
Kailang Yangebb83ee2009-12-17 12:23:00 +010013326 struct alc_spec *spec = codec->spec;
13327 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020013328 unsigned int present;
13329 unsigned char bits;
13330
Kailang Yangebb83ee2009-12-17 12:23:00 +010013331 present = snd_hda_jack_detect(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020013332 bits = present ? AMP_IN_MUTE(0) : 0;
13333 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13334 AMP_IN_MUTE(0), bits);
13335 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13336 AMP_IN_MUTE(0), bits);
13337}
13338
Kailang Yang60db6b52008-08-26 13:13:00 +020013339/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013340static void alc269_eeepc_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013341 unsigned int res)
13342{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013343 switch (res >> 26) {
13344 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013345 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013346 break;
13347 case ALC880_MIC_EVENT:
13348 alc_mic_automute(codec);
13349 break;
13350 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013351}
13352
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013353static void alc269_eeepc_dmic_setup(struct hda_codec *codec)
13354{
13355 struct alc_spec *spec = codec->spec;
13356 spec->ext_mic.pin = 0x18;
13357 spec->ext_mic.mux_idx = 0;
13358 spec->int_mic.pin = 0x12;
13359 spec->int_mic.mux_idx = 5;
13360 spec->auto_mic = 1;
13361}
13362
13363static void alc269_eeepc_amic_setup(struct hda_codec *codec)
13364{
13365 struct alc_spec *spec = codec->spec;
13366 spec->ext_mic.pin = 0x18;
13367 spec->ext_mic.mux_idx = 0;
13368 spec->int_mic.pin = 0x19;
13369 spec->int_mic.mux_idx = 1;
13370 spec->auto_mic = 1;
13371}
13372
13373static void alc269_eeepc_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013374{
13375 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013376 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013377}
13378
Kailang Yangf6a92242007-12-13 16:52:54 +010013379/*
13380 * generic initialization of ADC, input mixers and output mixers
13381 */
13382static struct hda_verb alc269_init_verbs[] = {
13383 /*
13384 * Unmute ADC0 and set the default input to mic-in
13385 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013386 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013387
13388 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13389 * analog-loopback mixer widget
13390 * Note: PASD motherboards uses the Line In 2 as the input for
13391 * front panel mic (mic 2)
13392 */
13393 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13394 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13395 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13396 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13397 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13398 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13399
13400 /*
13401 * Set up output mixers (0x0c - 0x0e)
13402 */
13403 /* set vol=0 to output mixers */
13404 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13405 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13406
13407 /* set up input amps for analog loopback */
13408 /* Amp Indices: DAC = 0, mixer = 1 */
13409 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13410 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13411 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13412 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13413 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13414 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13415
13416 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13417 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13418 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13419 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13420 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13421 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13422 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13423
13424 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13425 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13426 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13427 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13428 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13429 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13430 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13431
13432 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13433 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13434
13435 /* FIXME: use matrix-type input source selection */
13436 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13437 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013438 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13439 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013440 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13441 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13442
13443 /* set EAPD */
13444 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13445 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13446 { }
13447};
13448
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013449#define alc269_auto_create_multi_out_ctls \
13450 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020013451#define alc269_auto_create_input_ctls \
13452 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013453
13454#ifdef CONFIG_SND_HDA_POWER_SAVE
13455#define alc269_loopbacks alc880_loopbacks
13456#endif
13457
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013458/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013459#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13460#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13461#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13462#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13463
Takashi Iwaif03d3112009-03-05 14:18:16 +010013464static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13465 .substreams = 1,
13466 .channels_min = 2,
13467 .channels_max = 8,
13468 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13469 /* NID is set in alc_build_pcms */
13470 .ops = {
13471 .open = alc880_playback_pcm_open,
13472 .prepare = alc880_playback_pcm_prepare,
13473 .cleanup = alc880_playback_pcm_cleanup
13474 },
13475};
13476
13477static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13478 .substreams = 1,
13479 .channels_min = 2,
13480 .channels_max = 2,
13481 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13482 /* NID is set in alc_build_pcms */
13483};
13484
Kailang Yangf6a92242007-12-13 16:52:54 +010013485/*
13486 * BIOS auto configuration
13487 */
13488static int alc269_parse_auto_config(struct hda_codec *codec)
13489{
13490 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013491 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013492 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13493
13494 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13495 alc269_ignore);
13496 if (err < 0)
13497 return err;
13498
13499 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13500 if (err < 0)
13501 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013502 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010013503 if (err < 0)
13504 return err;
13505
13506 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13507
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013508 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013509 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13510
Takashi Iwai603c4012008-07-30 15:01:44 +020013511 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013512 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013513
Takashi Iwaid88897e2008-10-31 15:01:37 +010013514 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013515 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013516 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013517 /* set default input source */
13518 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13519 0, AC_VERB_SET_CONNECT_SEL,
13520 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013521
13522 err = alc_auto_add_mic_boost(codec);
13523 if (err < 0)
13524 return err;
13525
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013526 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013527 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013528
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013529 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13530
Kailang Yangf6a92242007-12-13 16:52:54 +010013531 return 1;
13532}
13533
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013534#define alc269_auto_init_multi_out alc268_auto_init_multi_out
13535#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010013536#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13537
13538
13539/* init callback for auto-configuration model -- overriding the default init */
13540static void alc269_auto_init(struct hda_codec *codec)
13541{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013542 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013543 alc269_auto_init_multi_out(codec);
13544 alc269_auto_init_hp_out(codec);
13545 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013546 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013547 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013548}
13549
13550/*
13551 * configuration and preset
13552 */
13553static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013554 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013555 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013556 [ALC269_ASUS_AMIC] = "asus-amic",
13557 [ALC269_ASUS_DMIC] = "asus-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000013558 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020013559 [ALC269_LIFEBOOK] = "lifebook",
13560 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010013561};
13562
13563static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013564 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013565 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013566 ALC269_ASUS_AMIC),
13567 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_ASUS_AMIC),
13568 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80JT", ALC269_ASUS_AMIC),
13569 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_ASUS_AMIC),
13570 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_ASUS_AMIC),
13571 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_ASUS_AMIC),
13572 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_ASUS_AMIC),
13573 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_ASUS_AMIC),
13574 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_ASUS_AMIC),
13575 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_ASUS_AMIC),
13576 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_ASUS_AMIC),
13577 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_ASUS_AMIC),
13578 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_ASUS_AMIC),
13579 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_ASUS_AMIC),
13580 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_ASUS_AMIC),
13581 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_ASUS_AMIC),
13582 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_ASUS_AMIC),
13583 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_ASUS_AMIC),
13584 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_ASUS_AMIC),
13585 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_ASUS_AMIC),
13586 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_ASUS_AMIC),
13587 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_AMIC),
13588 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_ASUS_AMIC),
13589 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_AMIC),
13590 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_DMIC),
13591 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_AMIC),
13592 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_AMIC),
13593 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_AMIC),
13594 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020013595 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013596 ALC269_ASUS_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020013597 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013598 ALC269_ASUS_DMIC),
13599 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_ASUS_DMIC),
13600 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_ASUS_DMIC),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013601 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013602 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013603 {}
13604};
13605
13606static struct alc_config_preset alc269_presets[] = {
13607 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013608 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013609 .init_verbs = { alc269_init_verbs },
13610 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13611 .dac_nids = alc269_dac_nids,
13612 .hp_nid = 0x03,
13613 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13614 .channel_mode = alc269_modes,
13615 .input_mux = &alc269_capture_source,
13616 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013617 [ALC269_QUANTA_FL1] = {
13618 .mixers = { alc269_quanta_fl1_mixer },
13619 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13620 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13621 .dac_nids = alc269_dac_nids,
13622 .hp_nid = 0x03,
13623 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13624 .channel_mode = alc269_modes,
13625 .input_mux = &alc269_capture_source,
13626 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013627 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020013628 .init_hook = alc269_quanta_fl1_init_hook,
13629 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010013630 [ALC269_ASUS_AMIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013631 .mixers = { alc269_eeepc_mixer },
13632 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013633 .init_verbs = { alc269_init_verbs,
13634 alc269_eeepc_amic_init_verbs },
13635 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13636 .dac_nids = alc269_dac_nids,
13637 .hp_nid = 0x03,
13638 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13639 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013640 .unsol_event = alc269_eeepc_unsol_event,
13641 .setup = alc269_eeepc_amic_setup,
13642 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013643 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010013644 [ALC269_ASUS_DMIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013645 .mixers = { alc269_eeepc_mixer },
13646 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013647 .init_verbs = { alc269_init_verbs,
13648 alc269_eeepc_dmic_init_verbs },
13649 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13650 .dac_nids = alc269_dac_nids,
13651 .hp_nid = 0x03,
13652 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13653 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013654 .unsol_event = alc269_eeepc_unsol_event,
13655 .setup = alc269_eeepc_dmic_setup,
13656 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013657 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013658 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013659 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013660 .cap_mixer = alc269_epc_capture_mixer,
13661 .init_verbs = { alc269_init_verbs,
13662 alc269_eeepc_dmic_init_verbs },
13663 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13664 .dac_nids = alc269_dac_nids,
13665 .hp_nid = 0x03,
13666 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13667 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013668 .unsol_event = alc269_eeepc_unsol_event,
13669 .setup = alc269_eeepc_dmic_setup,
13670 .init_hook = alc269_eeepc_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010013671 },
Tony Vroon64154832008-11-06 15:08:49 +000013672 [ALC269_LIFEBOOK] = {
13673 .mixers = { alc269_lifebook_mixer },
13674 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13675 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13676 .dac_nids = alc269_dac_nids,
13677 .hp_nid = 0x03,
13678 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13679 .channel_mode = alc269_modes,
13680 .input_mux = &alc269_capture_source,
13681 .unsol_event = alc269_lifebook_unsol_event,
13682 .init_hook = alc269_lifebook_init_hook,
13683 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013684};
13685
13686static int patch_alc269(struct hda_codec *codec)
13687{
13688 struct alc_spec *spec;
13689 int board_config;
13690 int err;
13691
13692 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13693 if (spec == NULL)
13694 return -ENOMEM;
13695
13696 codec->spec = spec;
13697
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013698 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13699
Kailang Yang274693f2009-12-03 10:07:50 +010013700 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
13701 kfree(codec->chip_name);
13702 codec->chip_name = kstrdup("ALC259", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010013703 if (!codec->chip_name) {
13704 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010013705 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010013706 }
Kailang Yang274693f2009-12-03 10:07:50 +010013707 }
13708
Kailang Yangf6a92242007-12-13 16:52:54 +010013709 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13710 alc269_models,
13711 alc269_cfg_tbl);
13712
13713 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013714 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13715 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013716 board_config = ALC269_AUTO;
13717 }
13718
13719 if (board_config == ALC269_AUTO) {
13720 /* automatic parse from the BIOS config */
13721 err = alc269_parse_auto_config(codec);
13722 if (err < 0) {
13723 alc_free(codec);
13724 return err;
13725 } else if (!err) {
13726 printk(KERN_INFO
13727 "hda_codec: Cannot set up configuration "
13728 "from BIOS. Using base mode...\n");
13729 board_config = ALC269_BASIC;
13730 }
13731 }
13732
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013733 err = snd_hda_attach_beep_device(codec, 0x1);
13734 if (err < 0) {
13735 alc_free(codec);
13736 return err;
13737 }
13738
Kailang Yangf6a92242007-12-13 16:52:54 +010013739 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013740 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010013741
Takashi Iwaif03d3112009-03-05 14:18:16 +010013742 if (codec->subsystem_id == 0x17aa3bf8) {
13743 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13744 * fix the sample rate of analog I/O to 44.1kHz
13745 */
13746 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13747 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13748 } else {
13749 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13750 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13751 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013752 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13753 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13754
13755 spec->adc_nids = alc269_adc_nids;
13756 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013757 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013758 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013759 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013760 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013761
Takashi Iwai100d5eb2009-08-10 11:55:51 +020013762 spec->vmaster_nid = 0x02;
13763
Kailang Yangf6a92242007-12-13 16:52:54 +010013764 codec->patch_ops = alc_patch_ops;
13765 if (board_config == ALC269_AUTO)
13766 spec->init_hook = alc269_auto_init;
13767#ifdef CONFIG_SND_HDA_POWER_SAVE
13768 if (!spec->loopback.amplist)
13769 spec->loopback.amplist = alc269_loopbacks;
13770#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013771 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013772
13773 return 0;
13774}
13775
13776/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013777 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13778 */
13779
13780/*
13781 * set the path ways for 2 channel output
13782 * need to set the codec line out and mic 1 pin widgets to inputs
13783 */
13784static struct hda_verb alc861_threestack_ch2_init[] = {
13785 /* set pin widget 1Ah (line in) for input */
13786 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013787 /* set pin widget 18h (mic1/2) for input, for mic also enable
13788 * the vref
13789 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013790 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13791
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013792 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13793#if 0
13794 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13795 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13796#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013797 { } /* end */
13798};
13799/*
13800 * 6ch mode
13801 * need to set the codec line out and mic 1 pin widgets to outputs
13802 */
13803static struct hda_verb alc861_threestack_ch6_init[] = {
13804 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13805 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13806 /* set pin widget 18h (mic1) for output (CLFE)*/
13807 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13808
13809 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013810 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013811
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013812 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13813#if 0
13814 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13815 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13816#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013817 { } /* end */
13818};
13819
13820static struct hda_channel_mode alc861_threestack_modes[2] = {
13821 { 2, alc861_threestack_ch2_init },
13822 { 6, alc861_threestack_ch6_init },
13823};
Takashi Iwai22309c32006-08-09 16:57:28 +020013824/* Set mic1 as input and unmute the mixer */
13825static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13826 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13827 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13828 { } /* end */
13829};
13830/* Set mic1 as output and mute mixer */
13831static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13832 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13833 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13834 { } /* end */
13835};
13836
13837static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13838 { 2, alc861_uniwill_m31_ch2_init },
13839 { 4, alc861_uniwill_m31_ch4_init },
13840};
Kailang Yangdf694da2005-12-05 19:42:22 +010013841
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013842/* Set mic1 and line-in as input and unmute the mixer */
13843static struct hda_verb alc861_asus_ch2_init[] = {
13844 /* set pin widget 1Ah (line in) for input */
13845 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013846 /* set pin widget 18h (mic1/2) for input, for mic also enable
13847 * the vref
13848 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013849 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13850
13851 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13852#if 0
13853 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13854 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13855#endif
13856 { } /* end */
13857};
13858/* Set mic1 nad line-in as output and mute mixer */
13859static struct hda_verb alc861_asus_ch6_init[] = {
13860 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13861 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13862 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13863 /* set pin widget 18h (mic1) for output (CLFE)*/
13864 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13865 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13866 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13867 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13868
13869 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13870#if 0
13871 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13872 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13873#endif
13874 { } /* end */
13875};
13876
13877static struct hda_channel_mode alc861_asus_modes[2] = {
13878 { 2, alc861_asus_ch2_init },
13879 { 6, alc861_asus_ch6_init },
13880};
13881
Kailang Yangdf694da2005-12-05 19:42:22 +010013882/* patch-ALC861 */
13883
13884static struct snd_kcontrol_new alc861_base_mixer[] = {
13885 /* output mixer control */
13886 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13887 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13888 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13889 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13890 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13891
13892 /*Input mixer control */
13893 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13894 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13895 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13896 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13897 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13898 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13899 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13900 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13901 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13902 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013903
Kailang Yangdf694da2005-12-05 19:42:22 +010013904 { } /* end */
13905};
13906
13907static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13908 /* output mixer control */
13909 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13910 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13911 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13912 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13913 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13914
13915 /* Input mixer control */
13916 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13917 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13918 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13919 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13920 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13921 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13922 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13923 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13924 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13925 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013926
Kailang Yangdf694da2005-12-05 19:42:22 +010013927 {
13928 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13929 .name = "Channel Mode",
13930 .info = alc_ch_mode_info,
13931 .get = alc_ch_mode_get,
13932 .put = alc_ch_mode_put,
13933 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13934 },
13935 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013936};
13937
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013938static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013939 /* output mixer control */
13940 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13941 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13942 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013943
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013944 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013945};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013946
Takashi Iwai22309c32006-08-09 16:57:28 +020013947static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13948 /* output mixer control */
13949 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13950 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13951 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13952 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13953 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13954
13955 /* Input mixer control */
13956 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13957 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13958 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13959 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13960 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13961 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13962 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13963 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13964 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13965 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013966
Takashi Iwai22309c32006-08-09 16:57:28 +020013967 {
13968 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13969 .name = "Channel Mode",
13970 .info = alc_ch_mode_info,
13971 .get = alc_ch_mode_get,
13972 .put = alc_ch_mode_put,
13973 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13974 },
13975 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013976};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013977
13978static struct snd_kcontrol_new alc861_asus_mixer[] = {
13979 /* output mixer control */
13980 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13981 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13982 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13983 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13984 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13985
13986 /* Input mixer control */
13987 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13988 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13989 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13990 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13991 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13992 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13993 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13994 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13995 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013996 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13997
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013998 {
13999 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14000 .name = "Channel Mode",
14001 .info = alc_ch_mode_info,
14002 .get = alc_ch_mode_get,
14003 .put = alc_ch_mode_put,
14004 .private_value = ARRAY_SIZE(alc861_asus_modes),
14005 },
14006 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014007};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014008
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014009/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014010static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014011 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14012 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014013 { }
14014};
14015
Kailang Yangdf694da2005-12-05 19:42:22 +010014016/*
14017 * generic initialization of ADC, input mixers and output mixers
14018 */
14019static struct hda_verb alc861_base_init_verbs[] = {
14020 /*
14021 * Unmute ADC0 and set the default input to mic-in
14022 */
14023 /* port-A for surround (rear panel) */
14024 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14025 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
14026 /* port-B for mic-in (rear panel) with vref */
14027 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14028 /* port-C for line-in (rear panel) */
14029 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14030 /* port-D for Front */
14031 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14032 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14033 /* port-E for HP out (front panel) */
14034 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14035 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014036 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014037 /* port-F for mic-in (front panel) with vref */
14038 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14039 /* port-G for CLFE (rear panel) */
14040 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14041 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
14042 /* port-H for side (rear panel) */
14043 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14044 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
14045 /* CD-in */
14046 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14047 /* route front mic to ADC1*/
14048 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14049 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014050
Kailang Yangdf694da2005-12-05 19:42:22 +010014051 /* Unmute DAC0~3 & spdif out*/
14052 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14053 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14054 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14055 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14056 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014057
Kailang Yangdf694da2005-12-05 19:42:22 +010014058 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14059 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14060 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14061 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14062 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014063
Kailang Yangdf694da2005-12-05 19:42:22 +010014064 /* Unmute Stereo Mixer 15 */
14065 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14066 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14067 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014068 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014069
14070 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14071 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14072 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14073 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14074 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14075 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14076 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14077 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014078 /* hp used DAC 3 (Front) */
14079 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014080 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14081
14082 { }
14083};
14084
14085static struct hda_verb alc861_threestack_init_verbs[] = {
14086 /*
14087 * Unmute ADC0 and set the default input to mic-in
14088 */
14089 /* port-A for surround (rear panel) */
14090 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14091 /* port-B for mic-in (rear panel) with vref */
14092 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14093 /* port-C for line-in (rear panel) */
14094 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14095 /* port-D for Front */
14096 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14097 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14098 /* port-E for HP out (front panel) */
14099 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14100 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014101 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014102 /* port-F for mic-in (front panel) with vref */
14103 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14104 /* port-G for CLFE (rear panel) */
14105 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14106 /* port-H for side (rear panel) */
14107 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14108 /* CD-in */
14109 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14110 /* route front mic to ADC1*/
14111 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14112 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14113 /* Unmute DAC0~3 & spdif out*/
14114 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14115 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14116 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14117 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14118 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014119
Kailang Yangdf694da2005-12-05 19:42:22 +010014120 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14121 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14122 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14123 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14124 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014125
Kailang Yangdf694da2005-12-05 19:42:22 +010014126 /* Unmute Stereo Mixer 15 */
14127 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14128 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14129 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014130 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014131
14132 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14133 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14134 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14135 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14136 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14137 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14138 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14139 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014140 /* hp used DAC 3 (Front) */
14141 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014142 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14143 { }
14144};
Takashi Iwai22309c32006-08-09 16:57:28 +020014145
14146static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
14147 /*
14148 * Unmute ADC0 and set the default input to mic-in
14149 */
14150 /* port-A for surround (rear panel) */
14151 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14152 /* port-B for mic-in (rear panel) with vref */
14153 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14154 /* port-C for line-in (rear panel) */
14155 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14156 /* port-D for Front */
14157 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14158 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14159 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014160 /* this has to be set to VREF80 */
14161 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014162 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014163 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014164 /* port-F for mic-in (front panel) with vref */
14165 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14166 /* port-G for CLFE (rear panel) */
14167 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14168 /* port-H for side (rear panel) */
14169 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14170 /* CD-in */
14171 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14172 /* route front mic to ADC1*/
14173 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14174 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14175 /* Unmute DAC0~3 & spdif out*/
14176 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14177 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14178 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14179 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14180 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014181
Takashi Iwai22309c32006-08-09 16:57:28 +020014182 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14183 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14184 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14185 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14186 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014187
Takashi Iwai22309c32006-08-09 16:57:28 +020014188 /* Unmute Stereo Mixer 15 */
14189 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14190 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14191 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014192 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014193
14194 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14195 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14196 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14197 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14198 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14199 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14200 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14201 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014202 /* hp used DAC 3 (Front) */
14203 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014204 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14205 { }
14206};
14207
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014208static struct hda_verb alc861_asus_init_verbs[] = {
14209 /*
14210 * Unmute ADC0 and set the default input to mic-in
14211 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014212 /* port-A for surround (rear panel)
14213 * according to codec#0 this is the HP jack
14214 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014215 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14216 /* route front PCM to HP */
14217 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14218 /* port-B for mic-in (rear panel) with vref */
14219 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14220 /* port-C for line-in (rear panel) */
14221 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14222 /* port-D for Front */
14223 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14224 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14225 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014226 /* this has to be set to VREF80 */
14227 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014228 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014229 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014230 /* port-F for mic-in (front panel) with vref */
14231 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14232 /* port-G for CLFE (rear panel) */
14233 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14234 /* port-H for side (rear panel) */
14235 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14236 /* CD-in */
14237 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14238 /* route front mic to ADC1*/
14239 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14240 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14241 /* Unmute DAC0~3 & spdif out*/
14242 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14243 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14244 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14245 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14246 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14247 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14248 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14249 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14250 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14251 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014252
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014253 /* Unmute Stereo Mixer 15 */
14254 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14255 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14256 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014257 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014258
14259 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14260 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14261 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14262 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14263 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14264 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14265 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14266 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014267 /* hp used DAC 3 (Front) */
14268 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014269 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14270 { }
14271};
14272
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014273/* additional init verbs for ASUS laptops */
14274static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14275 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14276 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14277 { }
14278};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014279
Kailang Yangdf694da2005-12-05 19:42:22 +010014280/*
14281 * generic initialization of ADC, input mixers and output mixers
14282 */
14283static struct hda_verb alc861_auto_init_verbs[] = {
14284 /*
14285 * Unmute ADC0 and set the default input to mic-in
14286 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014287 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014288 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014289
Kailang Yangdf694da2005-12-05 19:42:22 +010014290 /* Unmute DAC0~3 & spdif out*/
14291 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14292 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14293 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14294 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14295 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014296
Kailang Yangdf694da2005-12-05 19:42:22 +010014297 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14298 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14299 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14300 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14301 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014302
Kailang Yangdf694da2005-12-05 19:42:22 +010014303 /* Unmute Stereo Mixer 15 */
14304 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14305 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14306 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14307 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14308
Takashi Iwai1c209302009-07-22 15:17:45 +020014309 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14310 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14311 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14312 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14313 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14314 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14315 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14316 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014317
14318 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14319 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014320 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14321 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014322 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14323 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014324 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14325 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014326
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014327 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014328
14329 { }
14330};
14331
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014332static struct hda_verb alc861_toshiba_init_verbs[] = {
14333 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014334
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014335 { }
14336};
14337
14338/* toggle speaker-output according to the hp-jack state */
14339static void alc861_toshiba_automute(struct hda_codec *codec)
14340{
Wu Fengguang864f92b2009-11-18 12:38:02 +080014341 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014342
Takashi Iwai47fd8302007-08-10 17:11:07 +020014343 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14344 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14345 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14346 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014347}
14348
14349static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14350 unsigned int res)
14351{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014352 if ((res >> 26) == ALC880_HP_EVENT)
14353 alc861_toshiba_automute(codec);
14354}
14355
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014356/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014357#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14358#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14359#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14360#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14361
14362
14363#define ALC861_DIGOUT_NID 0x07
14364
14365static struct hda_channel_mode alc861_8ch_modes[1] = {
14366 { 8, NULL }
14367};
14368
14369static hda_nid_t alc861_dac_nids[4] = {
14370 /* front, surround, clfe, side */
14371 0x03, 0x06, 0x05, 0x04
14372};
14373
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014374static hda_nid_t alc660_dac_nids[3] = {
14375 /* front, clfe, surround */
14376 0x03, 0x05, 0x06
14377};
14378
Kailang Yangdf694da2005-12-05 19:42:22 +010014379static hda_nid_t alc861_adc_nids[1] = {
14380 /* ADC0-2 */
14381 0x08,
14382};
14383
14384static struct hda_input_mux alc861_capture_source = {
14385 .num_items = 5,
14386 .items = {
14387 { "Mic", 0x0 },
14388 { "Front Mic", 0x3 },
14389 { "Line", 0x1 },
14390 { "CD", 0x4 },
14391 { "Mixer", 0x5 },
14392 },
14393};
14394
Takashi Iwai1c209302009-07-22 15:17:45 +020014395static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14396{
14397 struct alc_spec *spec = codec->spec;
14398 hda_nid_t mix, srcs[5];
14399 int i, j, num;
14400
14401 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14402 return 0;
14403 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14404 if (num < 0)
14405 return 0;
14406 for (i = 0; i < num; i++) {
14407 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014408 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014409 if (type != AC_WID_AUD_OUT)
14410 continue;
14411 for (j = 0; j < spec->multiout.num_dacs; j++)
14412 if (spec->multiout.dac_nids[j] == srcs[i])
14413 break;
14414 if (j >= spec->multiout.num_dacs)
14415 return srcs[i];
14416 }
14417 return 0;
14418}
14419
Kailang Yangdf694da2005-12-05 19:42:22 +010014420/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014421static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014422 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014423{
Takashi Iwai1c209302009-07-22 15:17:45 +020014424 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014425 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014426 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014427
14428 spec->multiout.dac_nids = spec->private_dac_nids;
14429 for (i = 0; i < cfg->line_outs; i++) {
14430 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014431 dac = alc861_look_for_dac(codec, nid);
14432 if (!dac)
14433 continue;
14434 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014435 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014436 return 0;
14437}
14438
Takashi Iwai1c209302009-07-22 15:17:45 +020014439static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14440 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014441{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020014442 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020014443 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14444}
14445
14446/* add playback controls from the parsed DAC table */
14447static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14448 const struct auto_pin_cfg *cfg)
14449{
14450 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014451 static const char *chname[4] = {
14452 "Front", "Surround", NULL /*CLFE*/, "Side"
14453 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014454 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014455 int i, err;
14456
14457 if (cfg->line_outs == 1) {
14458 const char *pfx = NULL;
14459 if (!cfg->hp_outs)
14460 pfx = "Master";
14461 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14462 pfx = "Speaker";
14463 if (pfx) {
14464 nid = spec->multiout.dac_nids[0];
14465 return alc861_create_out_sw(codec, pfx, nid, 3);
14466 }
14467 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014468
14469 for (i = 0; i < cfg->line_outs; i++) {
14470 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014471 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014472 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014473 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014474 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014475 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014476 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014477 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014478 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014479 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014480 return err;
14481 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014482 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014483 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014484 return err;
14485 }
14486 }
14487 return 0;
14488}
14489
Takashi Iwai1c209302009-07-22 15:17:45 +020014490static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014491{
Takashi Iwai1c209302009-07-22 15:17:45 +020014492 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014493 int err;
14494 hda_nid_t nid;
14495
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014496 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014497 return 0;
14498
14499 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014500 nid = alc861_look_for_dac(codec, pin);
14501 if (nid) {
14502 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14503 if (err < 0)
14504 return err;
14505 spec->multiout.hp_nid = nid;
14506 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014507 }
14508 return 0;
14509}
14510
14511/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020014512static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014513 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014514{
Takashi Iwai05f5f472009-08-25 13:10:18 +020014515 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014516}
14517
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014518static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14519 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014520 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014521{
Takashi Iwai1c209302009-07-22 15:17:45 +020014522 hda_nid_t mix, srcs[5];
14523 int i, num;
14524
Jacek Luczak564c5be2008-05-03 18:41:23 +020014525 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14526 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014527 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014528 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014529 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14530 return;
14531 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14532 if (num < 0)
14533 return;
14534 for (i = 0; i < num; i++) {
14535 unsigned int mute;
14536 if (srcs[i] == dac || srcs[i] == 0x15)
14537 mute = AMP_IN_UNMUTE(i);
14538 else
14539 mute = AMP_IN_MUTE(i);
14540 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14541 mute);
14542 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014543}
14544
14545static void alc861_auto_init_multi_out(struct hda_codec *codec)
14546{
14547 struct alc_spec *spec = codec->spec;
14548 int i;
14549
14550 for (i = 0; i < spec->autocfg.line_outs; i++) {
14551 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014552 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014553 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014554 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014555 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014556 }
14557}
14558
14559static void alc861_auto_init_hp_out(struct hda_codec *codec)
14560{
14561 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014562
Takashi Iwai15870f02009-10-05 08:25:13 +020014563 if (spec->autocfg.hp_outs)
14564 alc861_auto_set_output_and_unmute(codec,
14565 spec->autocfg.hp_pins[0],
14566 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014567 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020014568 if (spec->autocfg.speaker_outs)
14569 alc861_auto_set_output_and_unmute(codec,
14570 spec->autocfg.speaker_pins[0],
14571 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020014572 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014573}
14574
14575static void alc861_auto_init_analog_input(struct hda_codec *codec)
14576{
14577 struct alc_spec *spec = codec->spec;
14578 int i;
14579
14580 for (i = 0; i < AUTO_PIN_LAST; i++) {
14581 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014582 if (nid >= 0x0c && nid <= 0x11)
14583 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014584 }
14585}
14586
14587/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014588/* return 1 if successful, 0 if the proper config is not found,
14589 * or a negative error code
14590 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014591static int alc861_parse_auto_config(struct hda_codec *codec)
14592{
14593 struct alc_spec *spec = codec->spec;
14594 int err;
14595 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14596
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014597 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14598 alc861_ignore);
14599 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014600 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014601 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014602 return 0; /* can't find valid BIOS pin config */
14603
Takashi Iwai1c209302009-07-22 15:17:45 +020014604 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014605 if (err < 0)
14606 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014607 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014608 if (err < 0)
14609 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014610 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014611 if (err < 0)
14612 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014613 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014614 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014615 return err;
14616
14617 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14618
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014619 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014620 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14621
Takashi Iwai603c4012008-07-30 15:01:44 +020014622 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014623 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014624
Takashi Iwaid88897e2008-10-31 15:01:37 +010014625 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014626
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014627 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014628 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014629
14630 spec->adc_nids = alc861_adc_nids;
14631 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014632 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014633
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014634 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14635
Kailang Yangdf694da2005-12-05 19:42:22 +010014636 return 1;
14637}
14638
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014639/* additional initialization for auto-configuration model */
14640static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014641{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014642 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014643 alc861_auto_init_multi_out(codec);
14644 alc861_auto_init_hp_out(codec);
14645 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014646 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014647 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014648}
14649
Takashi Iwaicb53c622007-08-10 17:21:45 +020014650#ifdef CONFIG_SND_HDA_POWER_SAVE
14651static struct hda_amp_list alc861_loopbacks[] = {
14652 { 0x15, HDA_INPUT, 0 },
14653 { 0x15, HDA_INPUT, 1 },
14654 { 0x15, HDA_INPUT, 2 },
14655 { 0x15, HDA_INPUT, 3 },
14656 { } /* end */
14657};
14658#endif
14659
Kailang Yangdf694da2005-12-05 19:42:22 +010014660
14661/*
14662 * configuration and preset
14663 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014664static const char *alc861_models[ALC861_MODEL_LAST] = {
14665 [ALC861_3ST] = "3stack",
14666 [ALC660_3ST] = "3stack-660",
14667 [ALC861_3ST_DIG] = "3stack-dig",
14668 [ALC861_6ST_DIG] = "6stack-dig",
14669 [ALC861_UNIWILL_M31] = "uniwill-m31",
14670 [ALC861_TOSHIBA] = "toshiba",
14671 [ALC861_ASUS] = "asus",
14672 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14673 [ALC861_AUTO] = "auto",
14674};
14675
14676static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014677 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014678 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14679 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14680 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014681 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014682 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014683 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014684 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14685 * Any other models that need this preset?
14686 */
14687 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014688 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14689 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014690 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14691 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14692 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14693 /* FIXME: the below seems conflict */
14694 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14695 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14696 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014697 {}
14698};
14699
14700static struct alc_config_preset alc861_presets[] = {
14701 [ALC861_3ST] = {
14702 .mixers = { alc861_3ST_mixer },
14703 .init_verbs = { alc861_threestack_init_verbs },
14704 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14705 .dac_nids = alc861_dac_nids,
14706 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14707 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014708 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014709 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14710 .adc_nids = alc861_adc_nids,
14711 .input_mux = &alc861_capture_source,
14712 },
14713 [ALC861_3ST_DIG] = {
14714 .mixers = { alc861_base_mixer },
14715 .init_verbs = { alc861_threestack_init_verbs },
14716 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14717 .dac_nids = alc861_dac_nids,
14718 .dig_out_nid = ALC861_DIGOUT_NID,
14719 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14720 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014721 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014722 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14723 .adc_nids = alc861_adc_nids,
14724 .input_mux = &alc861_capture_source,
14725 },
14726 [ALC861_6ST_DIG] = {
14727 .mixers = { alc861_base_mixer },
14728 .init_verbs = { alc861_base_init_verbs },
14729 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14730 .dac_nids = alc861_dac_nids,
14731 .dig_out_nid = ALC861_DIGOUT_NID,
14732 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14733 .channel_mode = alc861_8ch_modes,
14734 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14735 .adc_nids = alc861_adc_nids,
14736 .input_mux = &alc861_capture_source,
14737 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014738 [ALC660_3ST] = {
14739 .mixers = { alc861_3ST_mixer },
14740 .init_verbs = { alc861_threestack_init_verbs },
14741 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14742 .dac_nids = alc660_dac_nids,
14743 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14744 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014745 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014746 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14747 .adc_nids = alc861_adc_nids,
14748 .input_mux = &alc861_capture_source,
14749 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014750 [ALC861_UNIWILL_M31] = {
14751 .mixers = { alc861_uniwill_m31_mixer },
14752 .init_verbs = { alc861_uniwill_m31_init_verbs },
14753 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14754 .dac_nids = alc861_dac_nids,
14755 .dig_out_nid = ALC861_DIGOUT_NID,
14756 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14757 .channel_mode = alc861_uniwill_m31_modes,
14758 .need_dac_fix = 1,
14759 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14760 .adc_nids = alc861_adc_nids,
14761 .input_mux = &alc861_capture_source,
14762 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014763 [ALC861_TOSHIBA] = {
14764 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014765 .init_verbs = { alc861_base_init_verbs,
14766 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014767 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14768 .dac_nids = alc861_dac_nids,
14769 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14770 .channel_mode = alc883_3ST_2ch_modes,
14771 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14772 .adc_nids = alc861_adc_nids,
14773 .input_mux = &alc861_capture_source,
14774 .unsol_event = alc861_toshiba_unsol_event,
14775 .init_hook = alc861_toshiba_automute,
14776 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014777 [ALC861_ASUS] = {
14778 .mixers = { alc861_asus_mixer },
14779 .init_verbs = { alc861_asus_init_verbs },
14780 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14781 .dac_nids = alc861_dac_nids,
14782 .dig_out_nid = ALC861_DIGOUT_NID,
14783 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14784 .channel_mode = alc861_asus_modes,
14785 .need_dac_fix = 1,
14786 .hp_nid = 0x06,
14787 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14788 .adc_nids = alc861_adc_nids,
14789 .input_mux = &alc861_capture_source,
14790 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014791 [ALC861_ASUS_LAPTOP] = {
14792 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14793 .init_verbs = { alc861_asus_init_verbs,
14794 alc861_asus_laptop_init_verbs },
14795 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14796 .dac_nids = alc861_dac_nids,
14797 .dig_out_nid = ALC861_DIGOUT_NID,
14798 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14799 .channel_mode = alc883_3ST_2ch_modes,
14800 .need_dac_fix = 1,
14801 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14802 .adc_nids = alc861_adc_nids,
14803 .input_mux = &alc861_capture_source,
14804 },
14805};
Kailang Yangdf694da2005-12-05 19:42:22 +010014806
Takashi Iwaicfc9b062009-12-01 12:19:37 +010014807/* Pin config fixes */
14808enum {
14809 PINFIX_FSC_AMILO_PI1505,
14810};
14811
14812static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = {
14813 { 0x0b, 0x0221101f }, /* HP */
14814 { 0x0f, 0x90170310 }, /* speaker */
14815 { }
14816};
14817
14818static const struct alc_fixup alc861_fixups[] = {
14819 [PINFIX_FSC_AMILO_PI1505] = {
14820 .pins = alc861_fsc_amilo_pi1505_pinfix
14821 },
14822};
14823
14824static struct snd_pci_quirk alc861_fixup_tbl[] = {
14825 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
14826 {}
14827};
Kailang Yangdf694da2005-12-05 19:42:22 +010014828
14829static int patch_alc861(struct hda_codec *codec)
14830{
14831 struct alc_spec *spec;
14832 int board_config;
14833 int err;
14834
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014835 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014836 if (spec == NULL)
14837 return -ENOMEM;
14838
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014839 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014840
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014841 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14842 alc861_models,
14843 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014844
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014845 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014846 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14847 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014848 board_config = ALC861_AUTO;
14849 }
14850
Takashi Iwaicfc9b062009-12-01 12:19:37 +010014851 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups);
14852
Kailang Yangdf694da2005-12-05 19:42:22 +010014853 if (board_config == ALC861_AUTO) {
14854 /* automatic parse from the BIOS config */
14855 err = alc861_parse_auto_config(codec);
14856 if (err < 0) {
14857 alc_free(codec);
14858 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014859 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014860 printk(KERN_INFO
14861 "hda_codec: Cannot set up configuration "
14862 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014863 board_config = ALC861_3ST_DIG;
14864 }
14865 }
14866
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014867 err = snd_hda_attach_beep_device(codec, 0x23);
14868 if (err < 0) {
14869 alc_free(codec);
14870 return err;
14871 }
14872
Kailang Yangdf694da2005-12-05 19:42:22 +010014873 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014874 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014875
Kailang Yangdf694da2005-12-05 19:42:22 +010014876 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14877 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14878
Kailang Yangdf694da2005-12-05 19:42:22 +010014879 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14880 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14881
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014882 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14883
Takashi Iwai2134ea42008-01-10 16:53:55 +010014884 spec->vmaster_nid = 0x03;
14885
Kailang Yangdf694da2005-12-05 19:42:22 +010014886 codec->patch_ops = alc_patch_ops;
14887 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014888 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014889#ifdef CONFIG_SND_HDA_POWER_SAVE
14890 if (!spec->loopback.amplist)
14891 spec->loopback.amplist = alc861_loopbacks;
14892#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014893 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014894
Kailang Yangdf694da2005-12-05 19:42:22 +010014895 return 0;
14896}
14897
14898/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014899 * ALC861-VD support
14900 *
14901 * Based on ALC882
14902 *
14903 * In addition, an independent DAC
14904 */
14905#define ALC861VD_DIGOUT_NID 0x06
14906
14907static hda_nid_t alc861vd_dac_nids[4] = {
14908 /* front, surr, clfe, side surr */
14909 0x02, 0x03, 0x04, 0x05
14910};
14911
14912/* dac_nids for ALC660vd are in a different order - according to
14913 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014914 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014915 * of ALC660vd codecs, but for now there is only 3stack mixer
14916 * - and it is the same as in 861vd.
14917 * adc_nids in ALC660vd are (is) the same as in 861vd
14918 */
14919static hda_nid_t alc660vd_dac_nids[3] = {
14920 /* front, rear, clfe, rear_surr */
14921 0x02, 0x04, 0x03
14922};
14923
14924static hda_nid_t alc861vd_adc_nids[1] = {
14925 /* ADC0 */
14926 0x09,
14927};
14928
Takashi Iwaie1406342008-02-11 18:32:32 +010014929static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14930
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014931/* input MUX */
14932/* FIXME: should be a matrix-type input source selection */
14933static struct hda_input_mux alc861vd_capture_source = {
14934 .num_items = 4,
14935 .items = {
14936 { "Mic", 0x0 },
14937 { "Front Mic", 0x1 },
14938 { "Line", 0x2 },
14939 { "CD", 0x4 },
14940 },
14941};
14942
Kailang Yang272a5272007-05-14 11:00:38 +020014943static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014944 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014945 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014946 { "Ext Mic", 0x0 },
14947 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014948 },
14949};
14950
Kailang Yangd1a991a2007-08-15 16:21:59 +020014951static struct hda_input_mux alc861vd_hp_capture_source = {
14952 .num_items = 2,
14953 .items = {
14954 { "Front Mic", 0x0 },
14955 { "ATAPI Mic", 0x1 },
14956 },
14957};
14958
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014959/*
14960 * 2ch mode
14961 */
14962static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14963 { 2, NULL }
14964};
14965
14966/*
14967 * 6ch mode
14968 */
14969static struct hda_verb alc861vd_6stack_ch6_init[] = {
14970 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14971 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14972 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14973 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14974 { } /* end */
14975};
14976
14977/*
14978 * 8ch mode
14979 */
14980static struct hda_verb alc861vd_6stack_ch8_init[] = {
14981 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14982 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14983 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14984 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14985 { } /* end */
14986};
14987
14988static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14989 { 6, alc861vd_6stack_ch6_init },
14990 { 8, alc861vd_6stack_ch8_init },
14991};
14992
14993static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14994 {
14995 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14996 .name = "Channel Mode",
14997 .info = alc_ch_mode_info,
14998 .get = alc_ch_mode_get,
14999 .put = alc_ch_mode_put,
15000 },
15001 { } /* end */
15002};
15003
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015004/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15005 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15006 */
15007static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
15008 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15009 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15010
15011 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15012 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
15013
15014 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
15015 HDA_OUTPUT),
15016 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
15017 HDA_OUTPUT),
15018 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
15019 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
15020
15021 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
15022 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
15023
15024 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15025
15026 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15027 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15028 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15029
15030 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15031 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15032 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15033
15034 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15035 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15036
15037 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15038 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15039
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015040 { } /* end */
15041};
15042
15043static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
15044 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15045 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15046
15047 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15048
15049 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15050 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15051 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15052
15053 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15054 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15055 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15056
15057 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15058 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15059
15060 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15061 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15062
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015063 { } /* end */
15064};
15065
Kailang Yangbdd148a2007-05-08 15:19:08 +020015066static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
15067 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15068 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
15069 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15070
15071 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15072
15073 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15074 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15075 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15076
15077 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15078 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15079 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15080
15081 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15082 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15083
15084 { } /* end */
15085};
15086
Tobin Davisb419f342008-03-07 11:57:51 +010015087/* Pin assignment: Speaker=0x14, HP = 0x15,
15088 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020015089 */
15090static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010015091 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15092 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015093 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15094 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010015095 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
15096 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15097 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15098 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
15099 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15100 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015101 { } /* end */
15102};
15103
Kailang Yangd1a991a2007-08-15 16:21:59 +020015104/* Pin assignment: Speaker=0x14, Line-out = 0x15,
15105 * Front Mic=0x18, ATAPI Mic = 0x19,
15106 */
15107static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
15108 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15109 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15110 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15111 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
15112 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15113 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15114 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15115 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015116
Kailang Yangd1a991a2007-08-15 16:21:59 +020015117 { } /* end */
15118};
15119
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015120/*
15121 * generic initialization of ADC, input mixers and output mixers
15122 */
15123static struct hda_verb alc861vd_volume_init_verbs[] = {
15124 /*
15125 * Unmute ADC0 and set the default input to mic-in
15126 */
15127 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15128 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15129
15130 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
15131 * the analog-loopback mixer widget
15132 */
15133 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015134 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15135 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15136 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15137 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15138 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015139
15140 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020015141 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15142 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15143 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015144 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015145
15146 /*
15147 * Set up output mixers (0x02 - 0x05)
15148 */
15149 /* set vol=0 to output mixers */
15150 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15151 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15152 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15153 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15154
15155 /* set up input amps for analog loopback */
15156 /* Amp Indices: DAC = 0, mixer = 1 */
15157 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15158 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15159 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15160 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15161 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15162 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15163 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15164 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15165
15166 { }
15167};
15168
15169/*
15170 * 3-stack pin configuration:
15171 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
15172 */
15173static struct hda_verb alc861vd_3stack_init_verbs[] = {
15174 /*
15175 * Set pin mode and muting
15176 */
15177 /* set front pin widgets 0x14 for output */
15178 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15179 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15180 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15181
15182 /* Mic (rear) pin: input vref at 80% */
15183 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15184 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15185 /* Front Mic pin: input vref at 80% */
15186 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15187 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15188 /* Line In pin: input */
15189 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15190 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15191 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15192 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15193 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15194 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15195 /* CD pin widget for input */
15196 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15197
15198 { }
15199};
15200
15201/*
15202 * 6-stack pin configuration:
15203 */
15204static struct hda_verb alc861vd_6stack_init_verbs[] = {
15205 /*
15206 * Set pin mode and muting
15207 */
15208 /* set front pin widgets 0x14 for output */
15209 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15210 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15211 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15212
15213 /* Rear Pin: output 1 (0x0d) */
15214 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15215 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15216 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15217 /* CLFE Pin: output 2 (0x0e) */
15218 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15219 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15220 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15221 /* Side Pin: output 3 (0x0f) */
15222 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15223 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15224 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15225
15226 /* Mic (rear) pin: input vref at 80% */
15227 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15228 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15229 /* Front Mic pin: input vref at 80% */
15230 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15231 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15232 /* Line In pin: input */
15233 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15234 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15235 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15236 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15237 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15238 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15239 /* CD pin widget for input */
15240 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15241
15242 { }
15243};
15244
Kailang Yangbdd148a2007-05-08 15:19:08 +020015245static struct hda_verb alc861vd_eapd_verbs[] = {
15246 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15247 { }
15248};
15249
Kailang Yangf9423e72008-05-27 12:32:25 +020015250static struct hda_verb alc660vd_eapd_verbs[] = {
15251 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15252 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15253 { }
15254};
15255
Kailang Yangbdd148a2007-05-08 15:19:08 +020015256static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15257 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15258 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15259 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15260 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015261 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015262 {}
15263};
15264
Kailang Yangbdd148a2007-05-08 15:19:08 +020015265static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15266{
15267 unsigned int present;
15268 unsigned char bits;
15269
Wu Fengguang864f92b2009-11-18 12:38:02 +080015270 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020015271 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080015272
Takashi Iwai47fd8302007-08-10 17:11:07 +020015273 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15274 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015275}
15276
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015277static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015278{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015279 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015280 spec->autocfg.hp_pins[0] = 0x1b;
15281 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015282}
15283
15284static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15285{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015286 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015287 alc861vd_lenovo_mic_automute(codec);
15288}
15289
15290static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15291 unsigned int res)
15292{
15293 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015294 case ALC880_MIC_EVENT:
15295 alc861vd_lenovo_mic_automute(codec);
15296 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015297 default:
15298 alc_automute_amp_unsol_event(codec, res);
15299 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015300 }
15301}
15302
Kailang Yang272a5272007-05-14 11:00:38 +020015303static struct hda_verb alc861vd_dallas_verbs[] = {
15304 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15305 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15306 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15307 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15308
15309 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15310 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15311 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15312 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15313 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15314 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15315 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15316 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015317
Kailang Yang272a5272007-05-14 11:00:38 +020015318 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15319 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15320 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15321 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15322 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15323 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15324 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15325 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15326
15327 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15328 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15329 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15330 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15331 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15332 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15333 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15334 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15335
15336 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15337 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15338 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15339 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15340
15341 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015342 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015343 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15344
15345 { } /* end */
15346};
15347
15348/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015349static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015350{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015351 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015352
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015353 spec->autocfg.hp_pins[0] = 0x15;
15354 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020015355}
15356
Takashi Iwaicb53c622007-08-10 17:21:45 +020015357#ifdef CONFIG_SND_HDA_POWER_SAVE
15358#define alc861vd_loopbacks alc880_loopbacks
15359#endif
15360
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015361/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015362#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15363#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15364#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15365#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15366
15367/*
15368 * configuration and preset
15369 */
15370static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15371 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015372 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015373 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015374 [ALC861VD_3ST] = "3stack",
15375 [ALC861VD_3ST_DIG] = "3stack-digout",
15376 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015377 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015378 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015379 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015380 [ALC861VD_AUTO] = "auto",
15381};
15382
15383static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015384 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15385 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015386 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015387 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010015388 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015389 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015390 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015391 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015392 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015393 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015394 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015395 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015396 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015397 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015398 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015399 {}
15400};
15401
15402static struct alc_config_preset alc861vd_presets[] = {
15403 [ALC660VD_3ST] = {
15404 .mixers = { alc861vd_3st_mixer },
15405 .init_verbs = { alc861vd_volume_init_verbs,
15406 alc861vd_3stack_init_verbs },
15407 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15408 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015409 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15410 .channel_mode = alc861vd_3stack_2ch_modes,
15411 .input_mux = &alc861vd_capture_source,
15412 },
Mike Crash6963f842007-06-25 12:12:51 +020015413 [ALC660VD_3ST_DIG] = {
15414 .mixers = { alc861vd_3st_mixer },
15415 .init_verbs = { alc861vd_volume_init_verbs,
15416 alc861vd_3stack_init_verbs },
15417 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15418 .dac_nids = alc660vd_dac_nids,
15419 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015420 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15421 .channel_mode = alc861vd_3stack_2ch_modes,
15422 .input_mux = &alc861vd_capture_source,
15423 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015424 [ALC861VD_3ST] = {
15425 .mixers = { alc861vd_3st_mixer },
15426 .init_verbs = { alc861vd_volume_init_verbs,
15427 alc861vd_3stack_init_verbs },
15428 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15429 .dac_nids = alc861vd_dac_nids,
15430 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15431 .channel_mode = alc861vd_3stack_2ch_modes,
15432 .input_mux = &alc861vd_capture_source,
15433 },
15434 [ALC861VD_3ST_DIG] = {
15435 .mixers = { alc861vd_3st_mixer },
15436 .init_verbs = { alc861vd_volume_init_verbs,
15437 alc861vd_3stack_init_verbs },
15438 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15439 .dac_nids = alc861vd_dac_nids,
15440 .dig_out_nid = ALC861VD_DIGOUT_NID,
15441 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15442 .channel_mode = alc861vd_3stack_2ch_modes,
15443 .input_mux = &alc861vd_capture_source,
15444 },
15445 [ALC861VD_6ST_DIG] = {
15446 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15447 .init_verbs = { alc861vd_volume_init_verbs,
15448 alc861vd_6stack_init_verbs },
15449 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15450 .dac_nids = alc861vd_dac_nids,
15451 .dig_out_nid = ALC861VD_DIGOUT_NID,
15452 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15453 .channel_mode = alc861vd_6stack_modes,
15454 .input_mux = &alc861vd_capture_source,
15455 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015456 [ALC861VD_LENOVO] = {
15457 .mixers = { alc861vd_lenovo_mixer },
15458 .init_verbs = { alc861vd_volume_init_verbs,
15459 alc861vd_3stack_init_verbs,
15460 alc861vd_eapd_verbs,
15461 alc861vd_lenovo_unsol_verbs },
15462 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15463 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015464 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15465 .channel_mode = alc861vd_3stack_2ch_modes,
15466 .input_mux = &alc861vd_capture_source,
15467 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015468 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015469 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015470 },
Kailang Yang272a5272007-05-14 11:00:38 +020015471 [ALC861VD_DALLAS] = {
15472 .mixers = { alc861vd_dallas_mixer },
15473 .init_verbs = { alc861vd_dallas_verbs },
15474 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15475 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015476 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15477 .channel_mode = alc861vd_3stack_2ch_modes,
15478 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015479 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015480 .setup = alc861vd_dallas_setup,
15481 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015482 },
15483 [ALC861VD_HP] = {
15484 .mixers = { alc861vd_hp_mixer },
15485 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15486 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15487 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015488 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015489 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15490 .channel_mode = alc861vd_3stack_2ch_modes,
15491 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015492 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015493 .setup = alc861vd_dallas_setup,
15494 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020015495 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015496 [ALC660VD_ASUS_V1S] = {
15497 .mixers = { alc861vd_lenovo_mixer },
15498 .init_verbs = { alc861vd_volume_init_verbs,
15499 alc861vd_3stack_init_verbs,
15500 alc861vd_eapd_verbs,
15501 alc861vd_lenovo_unsol_verbs },
15502 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15503 .dac_nids = alc660vd_dac_nids,
15504 .dig_out_nid = ALC861VD_DIGOUT_NID,
15505 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15506 .channel_mode = alc861vd_3stack_2ch_modes,
15507 .input_mux = &alc861vd_capture_source,
15508 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015509 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015510 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015511 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015512};
15513
15514/*
15515 * BIOS auto configuration
15516 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015517static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15518 const struct auto_pin_cfg *cfg)
15519{
Takashi Iwai9c0afc82010-01-12 14:00:11 +010015520 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x22, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020015521}
15522
15523
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015524static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15525 hda_nid_t nid, int pin_type, int dac_idx)
15526{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015527 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015528}
15529
15530static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15531{
15532 struct alc_spec *spec = codec->spec;
15533 int i;
15534
15535 for (i = 0; i <= HDA_SIDE; i++) {
15536 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015537 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015538 if (nid)
15539 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015540 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015541 }
15542}
15543
15544
15545static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15546{
15547 struct alc_spec *spec = codec->spec;
15548 hda_nid_t pin;
15549
15550 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015551 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015552 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015553 pin = spec->autocfg.speaker_pins[0];
15554 if (pin)
15555 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015556}
15557
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015558#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15559
15560static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15561{
15562 struct alc_spec *spec = codec->spec;
15563 int i;
15564
15565 for (i = 0; i < AUTO_PIN_LAST; i++) {
15566 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020015567 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015568 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015569 if (nid != ALC861VD_PIN_CD_NID &&
15570 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015571 snd_hda_codec_write(codec, nid, 0,
15572 AC_VERB_SET_AMP_GAIN_MUTE,
15573 AMP_OUT_MUTE);
15574 }
15575 }
15576}
15577
Takashi Iwaif511b012008-08-15 16:46:42 +020015578#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15579
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015580#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15581#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15582
15583/* add playback controls from the parsed DAC table */
15584/* Based on ALC880 version. But ALC861VD has separate,
15585 * different NIDs for mute/unmute switch and volume control */
15586static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15587 const struct auto_pin_cfg *cfg)
15588{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015589 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15590 hda_nid_t nid_v, nid_s;
15591 int i, err;
15592
15593 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015594 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015595 continue;
15596 nid_v = alc861vd_idx_to_mixer_vol(
15597 alc880_dac_to_idx(
15598 spec->multiout.dac_nids[i]));
15599 nid_s = alc861vd_idx_to_mixer_switch(
15600 alc880_dac_to_idx(
15601 spec->multiout.dac_nids[i]));
15602
15603 if (i == 2) {
15604 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015605 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
15606 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015607 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15608 HDA_OUTPUT));
15609 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015610 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015611 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
15612 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015613 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15614 HDA_OUTPUT));
15615 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015616 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015617 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
15618 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015619 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15620 HDA_INPUT));
15621 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015622 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015623 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
15624 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015625 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15626 HDA_INPUT));
15627 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015628 return err;
15629 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015630 const char *pfx;
15631 if (cfg->line_outs == 1 &&
15632 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
15633 if (!cfg->hp_pins)
15634 pfx = "Speaker";
15635 else
15636 pfx = "PCM";
15637 } else
15638 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015639 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015640 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15641 HDA_OUTPUT));
15642 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015643 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015644 if (cfg->line_outs == 1 &&
15645 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15646 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015647 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015648 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015649 HDA_INPUT));
15650 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015651 return err;
15652 }
15653 }
15654 return 0;
15655}
15656
15657/* add playback controls for speaker and HP outputs */
15658/* Based on ALC880 version. But ALC861VD has separate,
15659 * different NIDs for mute/unmute switch and volume control */
15660static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15661 hda_nid_t pin, const char *pfx)
15662{
15663 hda_nid_t nid_v, nid_s;
15664 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015665
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015666 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015667 return 0;
15668
15669 if (alc880_is_fixed_pin(pin)) {
15670 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15671 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015672 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015673 spec->multiout.hp_nid = nid_v;
15674 else
15675 spec->multiout.extra_out_nid[0] = nid_v;
15676 /* control HP volume/switch on the output mixer amp */
15677 nid_v = alc861vd_idx_to_mixer_vol(
15678 alc880_fixed_pin_idx(pin));
15679 nid_s = alc861vd_idx_to_mixer_switch(
15680 alc880_fixed_pin_idx(pin));
15681
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015682 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015683 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15684 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015685 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015686 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015687 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15688 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015689 return err;
15690 } else if (alc880_is_multi_pin(pin)) {
15691 /* set manual connection */
15692 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015693 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015694 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15695 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015696 return err;
15697 }
15698 return 0;
15699}
15700
15701/* parse the BIOS configuration and set up the alc_spec
15702 * return 1 if successful, 0 if the proper config is not found,
15703 * or a negative error code
15704 * Based on ALC880 version - had to change it to override
15705 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15706static int alc861vd_parse_auto_config(struct hda_codec *codec)
15707{
15708 struct alc_spec *spec = codec->spec;
15709 int err;
15710 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15711
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015712 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15713 alc861vd_ignore);
15714 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015715 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015716 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015717 return 0; /* can't find valid BIOS pin config */
15718
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015719 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15720 if (err < 0)
15721 return err;
15722 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15723 if (err < 0)
15724 return err;
15725 err = alc861vd_auto_create_extra_out(spec,
15726 spec->autocfg.speaker_pins[0],
15727 "Speaker");
15728 if (err < 0)
15729 return err;
15730 err = alc861vd_auto_create_extra_out(spec,
15731 spec->autocfg.hp_pins[0],
15732 "Headphone");
15733 if (err < 0)
15734 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015735 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015736 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015737 return err;
15738
15739 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15740
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015741 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015742 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15743
Takashi Iwai603c4012008-07-30 15:01:44 +020015744 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015745 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015746
Takashi Iwaid88897e2008-10-31 15:01:37 +010015747 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015748
15749 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015750 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015751
Takashi Iwai776e1842007-08-29 15:07:11 +020015752 err = alc_auto_add_mic_boost(codec);
15753 if (err < 0)
15754 return err;
15755
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015756 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15757
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015758 return 1;
15759}
15760
15761/* additional initialization for auto-configuration model */
15762static void alc861vd_auto_init(struct hda_codec *codec)
15763{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015764 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015765 alc861vd_auto_init_multi_out(codec);
15766 alc861vd_auto_init_hp_out(codec);
15767 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015768 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015769 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015770 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015771}
15772
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015773enum {
15774 ALC660VD_FIX_ASUS_GPIO1
15775};
15776
15777/* reset GPIO1 */
15778static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
15779 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
15780 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
15781 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
15782 { }
15783};
15784
15785static const struct alc_fixup alc861vd_fixups[] = {
15786 [ALC660VD_FIX_ASUS_GPIO1] = {
15787 .verbs = alc660vd_fix_asus_gpio1_verbs,
15788 },
15789};
15790
15791static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
15792 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
15793 {}
15794};
15795
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015796static int patch_alc861vd(struct hda_codec *codec)
15797{
15798 struct alc_spec *spec;
15799 int err, board_config;
15800
15801 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15802 if (spec == NULL)
15803 return -ENOMEM;
15804
15805 codec->spec = spec;
15806
15807 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15808 alc861vd_models,
15809 alc861vd_cfg_tbl);
15810
15811 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015812 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15813 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015814 board_config = ALC861VD_AUTO;
15815 }
15816
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015817 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups);
15818
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015819 if (board_config == ALC861VD_AUTO) {
15820 /* automatic parse from the BIOS config */
15821 err = alc861vd_parse_auto_config(codec);
15822 if (err < 0) {
15823 alc_free(codec);
15824 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015825 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015826 printk(KERN_INFO
15827 "hda_codec: Cannot set up configuration "
15828 "from BIOS. Using base mode...\n");
15829 board_config = ALC861VD_3ST;
15830 }
15831 }
15832
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015833 err = snd_hda_attach_beep_device(codec, 0x23);
15834 if (err < 0) {
15835 alc_free(codec);
15836 return err;
15837 }
15838
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015839 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015840 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015841
Kailang Yang2f893282008-05-27 12:14:47 +020015842 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015843 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015844 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015845 }
15846
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015847 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15848 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15849
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015850 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15851 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15852
Takashi Iwaidd704692009-08-11 08:45:11 +020015853 if (!spec->adc_nids) {
15854 spec->adc_nids = alc861vd_adc_nids;
15855 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15856 }
15857 if (!spec->capsrc_nids)
15858 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015859
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015860 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015861 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015862
Takashi Iwai2134ea42008-01-10 16:53:55 +010015863 spec->vmaster_nid = 0x02;
15864
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015865 codec->patch_ops = alc_patch_ops;
15866
15867 if (board_config == ALC861VD_AUTO)
15868 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015869#ifdef CONFIG_SND_HDA_POWER_SAVE
15870 if (!spec->loopback.amplist)
15871 spec->loopback.amplist = alc861vd_loopbacks;
15872#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015873 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015874
15875 return 0;
15876}
15877
15878/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015879 * ALC662 support
15880 *
15881 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15882 * configuration. Each pin widget can choose any input DACs and a mixer.
15883 * Each ADC is connected from a mixer of all inputs. This makes possible
15884 * 6-channel independent captures.
15885 *
15886 * In addition, an independent DAC for the multi-playback (not used in this
15887 * driver yet).
15888 */
15889#define ALC662_DIGOUT_NID 0x06
15890#define ALC662_DIGIN_NID 0x0a
15891
15892static hda_nid_t alc662_dac_nids[4] = {
15893 /* front, rear, clfe, rear_surr */
15894 0x02, 0x03, 0x04
15895};
15896
Kailang Yang622e84c2009-04-21 07:39:04 +020015897static hda_nid_t alc272_dac_nids[2] = {
15898 0x02, 0x03
15899};
15900
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015901static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015902 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015903 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015904};
Takashi Iwaie1406342008-02-11 18:32:32 +010015905
Kailang Yang622e84c2009-04-21 07:39:04 +020015906static hda_nid_t alc272_adc_nids[1] = {
15907 /* ADC1-2 */
15908 0x08,
15909};
15910
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015911static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015912static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15913
Takashi Iwaie1406342008-02-11 18:32:32 +010015914
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015915/* input MUX */
15916/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015917static struct hda_input_mux alc662_capture_source = {
15918 .num_items = 4,
15919 .items = {
15920 { "Mic", 0x0 },
15921 { "Front Mic", 0x1 },
15922 { "Line", 0x2 },
15923 { "CD", 0x4 },
15924 },
15925};
15926
15927static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15928 .num_items = 2,
15929 .items = {
15930 { "Mic", 0x1 },
15931 { "Line", 0x2 },
15932 },
15933};
Kailang Yang291702f2007-10-16 14:28:03 +020015934
Kailang Yang6dda9f42008-05-27 12:05:31 +020015935static struct hda_input_mux alc663_capture_source = {
15936 .num_items = 3,
15937 .items = {
15938 { "Mic", 0x0 },
15939 { "Front Mic", 0x1 },
15940 { "Line", 0x2 },
15941 },
15942};
15943
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015944#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020015945static struct hda_input_mux alc272_nc10_capture_source = {
15946 .num_items = 16,
15947 .items = {
15948 { "Autoselect Mic", 0x0 },
15949 { "Internal Mic", 0x1 },
15950 { "In-0x02", 0x2 },
15951 { "In-0x03", 0x3 },
15952 { "In-0x04", 0x4 },
15953 { "In-0x05", 0x5 },
15954 { "In-0x06", 0x6 },
15955 { "In-0x07", 0x7 },
15956 { "In-0x08", 0x8 },
15957 { "In-0x09", 0x9 },
15958 { "In-0x0a", 0x0a },
15959 { "In-0x0b", 0x0b },
15960 { "In-0x0c", 0x0c },
15961 { "In-0x0d", 0x0d },
15962 { "In-0x0e", 0x0e },
15963 { "In-0x0f", 0x0f },
15964 },
15965};
15966#endif
15967
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015968/*
15969 * 2ch mode
15970 */
15971static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15972 { 2, NULL }
15973};
15974
15975/*
15976 * 2ch mode
15977 */
15978static struct hda_verb alc662_3ST_ch2_init[] = {
15979 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15980 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15981 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15982 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15983 { } /* end */
15984};
15985
15986/*
15987 * 6ch mode
15988 */
15989static struct hda_verb alc662_3ST_ch6_init[] = {
15990 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15991 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15992 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15993 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15994 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15995 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15996 { } /* end */
15997};
15998
15999static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
16000 { 2, alc662_3ST_ch2_init },
16001 { 6, alc662_3ST_ch6_init },
16002};
16003
16004/*
16005 * 2ch mode
16006 */
16007static struct hda_verb alc662_sixstack_ch6_init[] = {
16008 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16009 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16010 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16011 { } /* end */
16012};
16013
16014/*
16015 * 6ch mode
16016 */
16017static struct hda_verb alc662_sixstack_ch8_init[] = {
16018 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16019 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16020 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16021 { } /* end */
16022};
16023
16024static struct hda_channel_mode alc662_5stack_modes[2] = {
16025 { 2, alc662_sixstack_ch6_init },
16026 { 6, alc662_sixstack_ch8_init },
16027};
16028
16029/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16030 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16031 */
16032
16033static struct snd_kcontrol_new alc662_base_mixer[] = {
16034 /* output mixer control */
16035 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016036 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016037 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016038 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016039 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16040 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016041 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16042 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016043 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16044
16045 /*Input mixer control */
16046 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
16047 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
16048 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
16049 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
16050 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
16051 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
16052 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
16053 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016054 { } /* end */
16055};
16056
16057static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
16058 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016059 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016060 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16061 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16062 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16063 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16064 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16065 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16066 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16067 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16068 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016069 { } /* end */
16070};
16071
16072static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
16073 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016074 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016075 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016076 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016077 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16078 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016079 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16080 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016081 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16082 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16083 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16084 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16085 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16086 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16087 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16088 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16089 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016090 { } /* end */
16091};
16092
16093static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
16094 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16095 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010016096 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16097 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016098 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16099 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16100 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16101 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16102 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016103 { } /* end */
16104};
16105
Kailang Yang291702f2007-10-16 14:28:03 +020016106static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016107 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16108 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020016109
16110 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
16111 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16112 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16113
16114 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16115 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16116 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16117 { } /* end */
16118};
16119
Kailang Yang8c427222008-01-10 13:03:59 +010016120static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016121 ALC262_HIPPO_MASTER_SWITCH,
16122 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016123 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016124 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16125 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016126 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
16127 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16128 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16129 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16130 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16131 { } /* end */
16132};
16133
Kailang Yangf1d4e282008-08-26 14:03:29 +020016134static struct hda_bind_ctls alc663_asus_bind_master_vol = {
16135 .ops = &snd_hda_bind_vol,
16136 .values = {
16137 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16138 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
16139 0
16140 },
16141};
16142
16143static struct hda_bind_ctls alc663_asus_one_bind_switch = {
16144 .ops = &snd_hda_bind_sw,
16145 .values = {
16146 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16147 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16148 0
16149 },
16150};
16151
Kailang Yang6dda9f42008-05-27 12:05:31 +020016152static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016153 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16154 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
16155 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16156 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16157 { } /* end */
16158};
16159
16160static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
16161 .ops = &snd_hda_bind_sw,
16162 .values = {
16163 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16164 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16165 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16166 0
16167 },
16168};
16169
16170static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
16171 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16172 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
16173 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16174 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16175 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16176 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16177
16178 { } /* end */
16179};
16180
16181static struct hda_bind_ctls alc663_asus_four_bind_switch = {
16182 .ops = &snd_hda_bind_sw,
16183 .values = {
16184 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16185 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16186 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16187 0
16188 },
16189};
16190
16191static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
16192 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16193 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
16194 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16195 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16196 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16197 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16198 { } /* end */
16199};
16200
16201static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016202 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16203 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016204 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16205 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16206 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16207 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16208 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16209 { } /* end */
16210};
16211
16212static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
16213 .ops = &snd_hda_bind_vol,
16214 .values = {
16215 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16216 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16217 0
16218 },
16219};
16220
16221static struct hda_bind_ctls alc663_asus_two_bind_switch = {
16222 .ops = &snd_hda_bind_sw,
16223 .values = {
16224 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16225 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
16226 0
16227 },
16228};
16229
16230static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16231 HDA_BIND_VOL("Master Playback Volume",
16232 &alc663_asus_two_bind_master_vol),
16233 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16234 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016235 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16236 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16237 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016238 { } /* end */
16239};
16240
16241static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16242 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16243 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16244 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16245 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16246 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16247 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016248 { } /* end */
16249};
16250
16251static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16252 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16253 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16254 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16255 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16256 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16257
16258 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16259 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16260 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16261 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16262 { } /* end */
16263};
16264
16265static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16266 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16267 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16268 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16269
16270 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16271 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16272 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16273 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16274 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16275 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16276 { } /* end */
16277};
16278
Kailang Yangebb83ee2009-12-17 12:23:00 +010016279static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
16280 .ops = &snd_hda_bind_sw,
16281 .values = {
16282 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16283 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16284 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16285 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16286 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16287 0
16288 },
16289};
16290
16291static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
16292 .ops = &snd_hda_bind_sw,
16293 .values = {
16294 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16295 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16296 0
16297 },
16298};
16299
16300static struct snd_kcontrol_new alc663_mode7_mixer[] = {
16301 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16302 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16303 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16304 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16305 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16306 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16307 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16308 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16309 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16310 { } /* end */
16311};
16312
16313static struct snd_kcontrol_new alc663_mode8_mixer[] = {
16314 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16315 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16316 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16317 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16318 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16319 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16320 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16321 { } /* end */
16322};
16323
16324
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016325static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16326 {
16327 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16328 .name = "Channel Mode",
16329 .info = alc_ch_mode_info,
16330 .get = alc_ch_mode_get,
16331 .put = alc_ch_mode_put,
16332 },
16333 { } /* end */
16334};
16335
16336static struct hda_verb alc662_init_verbs[] = {
16337 /* ADC: mute amp left and right */
16338 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16339 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16340 /* Front mixer: unmute input/output amp left and right (volume = 0) */
16341
Takashi Iwaicb53c622007-08-10 17:21:45 +020016342 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16343 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16344 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16345 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16346 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016347
Kailang Yangb60dd392007-09-20 12:50:29 +020016348 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16349 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16350 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16351 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16352 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16353 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016354
16355 /* Front Pin: output 0 (0x0c) */
16356 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16357 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16358
16359 /* Rear Pin: output 1 (0x0d) */
16360 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16361 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16362
16363 /* CLFE Pin: output 2 (0x0e) */
16364 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16365 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16366
16367 /* Mic (rear) pin: input vref at 80% */
16368 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16369 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16370 /* Front Mic pin: input vref at 80% */
16371 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16372 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16373 /* Line In pin: input */
16374 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16375 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16376 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16377 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16378 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16379 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16380 /* CD pin widget for input */
16381 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16382
16383 /* FIXME: use matrix-type input source selection */
16384 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16385 /* Input mixer */
16386 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016387 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016388
16389 /* always trun on EAPD */
16390 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16391 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16392
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016393 { }
16394};
16395
16396static struct hda_verb alc662_sue_init_verbs[] = {
16397 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16398 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016399 {}
16400};
16401
16402static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16403 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16404 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16405 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016406};
16407
Kailang Yang8c427222008-01-10 13:03:59 +010016408/* Set Unsolicited Event*/
16409static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16410 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16411 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16412 {}
16413};
16414
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016415/*
16416 * generic initialization of ADC, input mixers and output mixers
16417 */
16418static struct hda_verb alc662_auto_init_verbs[] = {
16419 /*
16420 * Unmute ADC and set the default input to mic-in
16421 */
16422 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16423 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16424
16425 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16426 * mixer widget
16427 * Note: PASD motherboards uses the Line In 2 as the input for front
16428 * panel mic (mic 2)
16429 */
16430 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016431 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16432 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16433 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16434 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16435 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016436
16437 /*
16438 * Set up output mixers (0x0c - 0x0f)
16439 */
16440 /* set vol=0 to output mixers */
16441 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16442 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16443 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16444
16445 /* set up input amps for analog loopback */
16446 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020016447 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16448 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16449 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16450 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16451 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16452 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016453
16454
16455 /* FIXME: use matrix-type input source selection */
16456 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16457 /* Input mixer */
16458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016459 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016460 { }
16461};
16462
Takashi Iwai24fb9172008-09-02 14:48:20 +020016463/* additional verbs for ALC663 */
16464static struct hda_verb alc663_auto_init_verbs[] = {
16465 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16466 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16467 { }
16468};
16469
Kailang Yang6dda9f42008-05-27 12:05:31 +020016470static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016471 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16472 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016473 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16474 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016475 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16476 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16477 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016478 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16479 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16480 {}
16481};
16482
Kailang Yangf1d4e282008-08-26 14:03:29 +020016483static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16484 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16485 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16486 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16487 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16488 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16489 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16490 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16491 {}
16492};
16493
16494static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16495 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16496 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16497 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16498 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16499 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16500 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16501 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16502 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16503 {}
16504};
16505
16506static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16507 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16508 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16509 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16510 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16511 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16512 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16513 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16514 {}
16515};
16516
16517static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16518 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16519 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16520 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16521 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16522 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16523 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16524 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16525 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16526 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16527 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16528 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16529 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16530 {}
16531};
16532
16533static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16534 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16535 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16536 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16537 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16538 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16539 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16540 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16541 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16542 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16543 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16544 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16545 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16546 {}
16547};
16548
Kailang Yang6dda9f42008-05-27 12:05:31 +020016549static struct hda_verb alc663_g71v_init_verbs[] = {
16550 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16551 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16552 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16553
16554 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16555 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16556 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16557
16558 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16559 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16560 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16561 {}
16562};
16563
16564static struct hda_verb alc663_g50v_init_verbs[] = {
16565 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16566 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16567 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16568
16569 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16570 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16571 {}
16572};
16573
Kailang Yangf1d4e282008-08-26 14:03:29 +020016574static struct hda_verb alc662_ecs_init_verbs[] = {
16575 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16576 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16577 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16578 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16579 {}
16580};
16581
Kailang Yang622e84c2009-04-21 07:39:04 +020016582static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16583 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16584 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16585 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16586 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16587 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16588 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16589 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16590 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16591 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16592 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16593 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16594 {}
16595};
16596
16597static struct hda_verb alc272_dell_init_verbs[] = {
16598 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16599 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16600 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16601 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16602 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16603 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16604 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16605 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16606 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16607 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16608 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16609 {}
16610};
16611
Kailang Yangebb83ee2009-12-17 12:23:00 +010016612static struct hda_verb alc663_mode7_init_verbs[] = {
16613 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16614 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16615 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16616 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16617 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16618 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16619 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
16620 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16621 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16622 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16623 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16624 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16625 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16626 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16627 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16628 {}
16629};
16630
16631static struct hda_verb alc663_mode8_init_verbs[] = {
16632 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16633 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16634 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16635 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16636 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16637 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16638 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16639 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16640 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16641 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16642 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16643 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16644 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16645 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16646 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16647 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16648 {}
16649};
16650
Kailang Yangf1d4e282008-08-26 14:03:29 +020016651static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16652 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16653 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16654 { } /* end */
16655};
16656
Kailang Yang622e84c2009-04-21 07:39:04 +020016657static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16658 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16659 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16660 { } /* end */
16661};
16662
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016663static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16664{
16665 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016666 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016667
Wu Fengguang864f92b2009-11-18 12:38:02 +080016668 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016669 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016670
Takashi Iwai47fd8302007-08-10 17:11:07 +020016671 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16672 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016673}
16674
16675static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16676{
16677 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016678 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016679
Wu Fengguang864f92b2009-11-18 12:38:02 +080016680 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016681 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016682
Takashi Iwai47fd8302007-08-10 17:11:07 +020016683 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16684 HDA_AMP_MUTE, bits);
16685 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16686 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016687}
16688
16689static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16690 unsigned int res)
16691{
16692 if ((res >> 26) == ALC880_HP_EVENT)
16693 alc662_lenovo_101e_all_automute(codec);
16694 if ((res >> 26) == ALC880_FRONT_EVENT)
16695 alc662_lenovo_101e_ispeaker_automute(codec);
16696}
16697
Kailang Yang291702f2007-10-16 14:28:03 +020016698/* unsolicited event for HP jack sensing */
16699static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16700 unsigned int res)
16701{
Kailang Yang291702f2007-10-16 14:28:03 +020016702 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016703 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016704 else
16705 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016706}
16707
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016708static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020016709{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016710 struct alc_spec *spec = codec->spec;
16711
16712 alc262_hippo1_setup(codec);
16713 spec->ext_mic.pin = 0x18;
16714 spec->ext_mic.mux_idx = 0;
16715 spec->int_mic.pin = 0x19;
16716 spec->int_mic.mux_idx = 1;
16717 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020016718}
16719
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016720static void alc662_eeepc_inithook(struct hda_codec *codec)
16721{
16722 alc262_hippo_automute(codec);
16723 alc_mic_automute(codec);
16724}
16725
16726static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010016727{
Takashi Iwai42171c12009-05-08 14:11:43 +020016728 struct alc_spec *spec = codec->spec;
16729
16730 spec->autocfg.hp_pins[0] = 0x14;
16731 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010016732}
16733
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016734#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
16735
Kailang Yang6dda9f42008-05-27 12:05:31 +020016736static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16737{
16738 unsigned int present;
16739 unsigned char bits;
16740
Wu Fengguang864f92b2009-11-18 12:38:02 +080016741 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016742 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016743 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16744 AMP_IN_MUTE(0), bits);
16745 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16746 AMP_IN_MUTE(0), bits);
16747}
16748
16749static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16750{
16751 unsigned int present;
16752 unsigned char bits;
16753
Wu Fengguang864f92b2009-11-18 12:38:02 +080016754 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016755 bits = present ? HDA_AMP_MUTE : 0;
16756 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16757 AMP_IN_MUTE(0), bits);
16758 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16759 AMP_IN_MUTE(0), bits);
16760 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16761 AMP_IN_MUTE(0), bits);
16762 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16763 AMP_IN_MUTE(0), bits);
16764}
16765
16766static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16767{
16768 unsigned int present;
16769 unsigned char bits;
16770
Wu Fengguang864f92b2009-11-18 12:38:02 +080016771 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016772 bits = present ? HDA_AMP_MUTE : 0;
16773 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16774 AMP_IN_MUTE(0), bits);
16775 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16776 AMP_IN_MUTE(0), bits);
16777 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16778 AMP_IN_MUTE(0), bits);
16779 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16780 AMP_IN_MUTE(0), bits);
16781}
16782
16783static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16784{
16785 unsigned int present;
16786 unsigned char bits;
16787
Wu Fengguang864f92b2009-11-18 12:38:02 +080016788 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016789 bits = present ? 0 : PIN_OUT;
16790 snd_hda_codec_write(codec, 0x14, 0,
16791 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16792}
16793
16794static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16795{
16796 unsigned int present1, present2;
16797
Wu Fengguang864f92b2009-11-18 12:38:02 +080016798 present1 = snd_hda_jack_detect(codec, 0x21);
16799 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016800
16801 if (present1 || present2) {
16802 snd_hda_codec_write_cache(codec, 0x14, 0,
16803 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16804 } else {
16805 snd_hda_codec_write_cache(codec, 0x14, 0,
16806 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16807 }
16808}
16809
16810static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16811{
16812 unsigned int present1, present2;
16813
Wu Fengguang864f92b2009-11-18 12:38:02 +080016814 present1 = snd_hda_jack_detect(codec, 0x1b);
16815 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016816
16817 if (present1 || present2) {
16818 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16819 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16820 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16821 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16822 } else {
16823 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16824 AMP_IN_MUTE(0), 0);
16825 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16826 AMP_IN_MUTE(0), 0);
16827 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016828}
16829
Kailang Yangebb83ee2009-12-17 12:23:00 +010016830static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
16831{
16832 unsigned int present1, present2;
16833
16834 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16835 AC_VERB_GET_PIN_SENSE, 0)
16836 & AC_PINSENSE_PRESENCE;
16837 present2 = snd_hda_codec_read(codec, 0x21, 0,
16838 AC_VERB_GET_PIN_SENSE, 0)
16839 & AC_PINSENSE_PRESENCE;
16840
16841 if (present1 || present2) {
16842 snd_hda_codec_write_cache(codec, 0x14, 0,
16843 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16844 snd_hda_codec_write_cache(codec, 0x17, 0,
16845 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16846 } else {
16847 snd_hda_codec_write_cache(codec, 0x14, 0,
16848 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16849 snd_hda_codec_write_cache(codec, 0x17, 0,
16850 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16851 }
16852}
16853
16854static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
16855{
16856 unsigned int present1, present2;
16857
16858 present1 = snd_hda_codec_read(codec, 0x21, 0,
16859 AC_VERB_GET_PIN_SENSE, 0)
16860 & AC_PINSENSE_PRESENCE;
16861 present2 = snd_hda_codec_read(codec, 0x15, 0,
16862 AC_VERB_GET_PIN_SENSE, 0)
16863 & AC_PINSENSE_PRESENCE;
16864
16865 if (present1 || present2) {
16866 snd_hda_codec_write_cache(codec, 0x14, 0,
16867 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16868 snd_hda_codec_write_cache(codec, 0x17, 0,
16869 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16870 } else {
16871 snd_hda_codec_write_cache(codec, 0x14, 0,
16872 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16873 snd_hda_codec_write_cache(codec, 0x17, 0,
16874 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16875 }
16876}
16877
Kailang Yang6dda9f42008-05-27 12:05:31 +020016878static void alc663_m51va_unsol_event(struct hda_codec *codec,
16879 unsigned int res)
16880{
16881 switch (res >> 26) {
16882 case ALC880_HP_EVENT:
16883 alc663_m51va_speaker_automute(codec);
16884 break;
16885 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016886 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016887 break;
16888 }
16889}
16890
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016891static void alc663_m51va_setup(struct hda_codec *codec)
16892{
16893 struct alc_spec *spec = codec->spec;
16894 spec->ext_mic.pin = 0x18;
16895 spec->ext_mic.mux_idx = 0;
16896 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010016897 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016898 spec->auto_mic = 1;
16899}
16900
Kailang Yang6dda9f42008-05-27 12:05:31 +020016901static void alc663_m51va_inithook(struct hda_codec *codec)
16902{
16903 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016904 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016905}
16906
Kailang Yangf1d4e282008-08-26 14:03:29 +020016907/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016908#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010016909
16910static void alc663_mode1_setup(struct hda_codec *codec)
16911{
16912 struct alc_spec *spec = codec->spec;
16913 spec->ext_mic.pin = 0x18;
16914 spec->ext_mic.mux_idx = 0;
16915 spec->int_mic.pin = 0x19;
16916 spec->int_mic.mux_idx = 1;
16917 spec->auto_mic = 1;
16918}
16919
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016920#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020016921
Kailang Yangf1d4e282008-08-26 14:03:29 +020016922/* ***************** Mode2 ******************************/
16923static void alc662_mode2_unsol_event(struct hda_codec *codec,
16924 unsigned int res)
16925{
16926 switch (res >> 26) {
16927 case ALC880_HP_EVENT:
16928 alc662_f5z_speaker_automute(codec);
16929 break;
16930 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016931 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016932 break;
16933 }
16934}
16935
Kailang Yangebb83ee2009-12-17 12:23:00 +010016936#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016937
Kailang Yangf1d4e282008-08-26 14:03:29 +020016938static void alc662_mode2_inithook(struct hda_codec *codec)
16939{
16940 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016941 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016942}
16943/* ***************** Mode3 ******************************/
16944static void alc663_mode3_unsol_event(struct hda_codec *codec,
16945 unsigned int res)
16946{
16947 switch (res >> 26) {
16948 case ALC880_HP_EVENT:
16949 alc663_two_hp_m1_speaker_automute(codec);
16950 break;
16951 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016952 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016953 break;
16954 }
16955}
16956
Kailang Yangebb83ee2009-12-17 12:23:00 +010016957#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016958
Kailang Yangf1d4e282008-08-26 14:03:29 +020016959static void alc663_mode3_inithook(struct hda_codec *codec)
16960{
16961 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016962 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016963}
16964/* ***************** Mode4 ******************************/
16965static void alc663_mode4_unsol_event(struct hda_codec *codec,
16966 unsigned int res)
16967{
16968 switch (res >> 26) {
16969 case ALC880_HP_EVENT:
16970 alc663_21jd_two_speaker_automute(codec);
16971 break;
16972 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016973 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016974 break;
16975 }
16976}
16977
Kailang Yangebb83ee2009-12-17 12:23:00 +010016978#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016979
Kailang Yangf1d4e282008-08-26 14:03:29 +020016980static void alc663_mode4_inithook(struct hda_codec *codec)
16981{
16982 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016983 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016984}
16985/* ***************** Mode5 ******************************/
16986static void alc663_mode5_unsol_event(struct hda_codec *codec,
16987 unsigned int res)
16988{
16989 switch (res >> 26) {
16990 case ALC880_HP_EVENT:
16991 alc663_15jd_two_speaker_automute(codec);
16992 break;
16993 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016994 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016995 break;
16996 }
16997}
16998
Kailang Yangebb83ee2009-12-17 12:23:00 +010016999#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017000
Kailang Yangf1d4e282008-08-26 14:03:29 +020017001static void alc663_mode5_inithook(struct hda_codec *codec)
17002{
17003 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017004 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017005}
17006/* ***************** Mode6 ******************************/
17007static void alc663_mode6_unsol_event(struct hda_codec *codec,
17008 unsigned int res)
17009{
17010 switch (res >> 26) {
17011 case ALC880_HP_EVENT:
17012 alc663_two_hp_m2_speaker_automute(codec);
17013 break;
17014 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017015 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017016 break;
17017 }
17018}
17019
Kailang Yangebb83ee2009-12-17 12:23:00 +010017020#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017021
Kailang Yangf1d4e282008-08-26 14:03:29 +020017022static void alc663_mode6_inithook(struct hda_codec *codec)
17023{
17024 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017025 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017026}
17027
Kailang Yangebb83ee2009-12-17 12:23:00 +010017028/* ***************** Mode7 ******************************/
17029static void alc663_mode7_unsol_event(struct hda_codec *codec,
17030 unsigned int res)
17031{
17032 switch (res >> 26) {
17033 case ALC880_HP_EVENT:
17034 alc663_two_hp_m7_speaker_automute(codec);
17035 break;
17036 case ALC880_MIC_EVENT:
17037 alc_mic_automute(codec);
17038 break;
17039 }
17040}
17041
17042#define alc663_mode7_setup alc663_mode1_setup
17043
17044static void alc663_mode7_inithook(struct hda_codec *codec)
17045{
17046 alc663_two_hp_m7_speaker_automute(codec);
17047 alc_mic_automute(codec);
17048}
17049
17050/* ***************** Mode8 ******************************/
17051static void alc663_mode8_unsol_event(struct hda_codec *codec,
17052 unsigned int res)
17053{
17054 switch (res >> 26) {
17055 case ALC880_HP_EVENT:
17056 alc663_two_hp_m8_speaker_automute(codec);
17057 break;
17058 case ALC880_MIC_EVENT:
17059 alc_mic_automute(codec);
17060 break;
17061 }
17062}
17063
17064#define alc663_mode8_setup alc663_m51va_setup
17065
17066static void alc663_mode8_inithook(struct hda_codec *codec)
17067{
17068 alc663_two_hp_m8_speaker_automute(codec);
17069 alc_mic_automute(codec);
17070}
17071
Kailang Yang6dda9f42008-05-27 12:05:31 +020017072static void alc663_g71v_hp_automute(struct hda_codec *codec)
17073{
17074 unsigned int present;
17075 unsigned char bits;
17076
Wu Fengguang864f92b2009-11-18 12:38:02 +080017077 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017078 bits = present ? HDA_AMP_MUTE : 0;
17079 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17080 HDA_AMP_MUTE, bits);
17081 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17082 HDA_AMP_MUTE, bits);
17083}
17084
17085static void alc663_g71v_front_automute(struct hda_codec *codec)
17086{
17087 unsigned int present;
17088 unsigned char bits;
17089
Wu Fengguang864f92b2009-11-18 12:38:02 +080017090 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017091 bits = present ? HDA_AMP_MUTE : 0;
17092 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17093 HDA_AMP_MUTE, bits);
17094}
17095
17096static void alc663_g71v_unsol_event(struct hda_codec *codec,
17097 unsigned int res)
17098{
17099 switch (res >> 26) {
17100 case ALC880_HP_EVENT:
17101 alc663_g71v_hp_automute(codec);
17102 break;
17103 case ALC880_FRONT_EVENT:
17104 alc663_g71v_front_automute(codec);
17105 break;
17106 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017107 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017108 break;
17109 }
17110}
17111
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017112#define alc663_g71v_setup alc663_m51va_setup
17113
Kailang Yang6dda9f42008-05-27 12:05:31 +020017114static void alc663_g71v_inithook(struct hda_codec *codec)
17115{
17116 alc663_g71v_front_automute(codec);
17117 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017118 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017119}
17120
17121static void alc663_g50v_unsol_event(struct hda_codec *codec,
17122 unsigned int res)
17123{
17124 switch (res >> 26) {
17125 case ALC880_HP_EVENT:
17126 alc663_m51va_speaker_automute(codec);
17127 break;
17128 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017129 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017130 break;
17131 }
17132}
17133
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017134#define alc663_g50v_setup alc663_m51va_setup
17135
Kailang Yang6dda9f42008-05-27 12:05:31 +020017136static void alc663_g50v_inithook(struct hda_codec *codec)
17137{
17138 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017139 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017140}
17141
Kailang Yangf1d4e282008-08-26 14:03:29 +020017142static struct snd_kcontrol_new alc662_ecs_mixer[] = {
17143 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020017144 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017145
17146 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
17147 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
17148 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
17149
17150 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17151 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17152 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17153 { } /* end */
17154};
17155
Chris Pockelé9541ba12009-05-12 08:08:53 +020017156static struct snd_kcontrol_new alc272_nc10_mixer[] = {
17157 /* Master Playback automatically created from Speaker and Headphone */
17158 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17159 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17160 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17161 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17162
17163 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17164 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17165 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
17166
17167 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17168 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17169 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
17170 { } /* end */
17171};
17172
Takashi Iwaicb53c622007-08-10 17:21:45 +020017173#ifdef CONFIG_SND_HDA_POWER_SAVE
17174#define alc662_loopbacks alc880_loopbacks
17175#endif
17176
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017177
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017178/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017179#define alc662_pcm_analog_playback alc880_pcm_analog_playback
17180#define alc662_pcm_analog_capture alc880_pcm_analog_capture
17181#define alc662_pcm_digital_playback alc880_pcm_digital_playback
17182#define alc662_pcm_digital_capture alc880_pcm_digital_capture
17183
17184/*
17185 * configuration and preset
17186 */
17187static const char *alc662_models[ALC662_MODEL_LAST] = {
17188 [ALC662_3ST_2ch_DIG] = "3stack-dig",
17189 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
17190 [ALC662_3ST_6ch] = "3stack-6ch",
17191 [ALC662_5ST_DIG] = "6stack-dig",
17192 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020017193 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010017194 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017195 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020017196 [ALC663_ASUS_M51VA] = "m51va",
17197 [ALC663_ASUS_G71V] = "g71v",
17198 [ALC663_ASUS_H13] = "h13",
17199 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017200 [ALC663_ASUS_MODE1] = "asus-mode1",
17201 [ALC662_ASUS_MODE2] = "asus-mode2",
17202 [ALC663_ASUS_MODE3] = "asus-mode3",
17203 [ALC663_ASUS_MODE4] = "asus-mode4",
17204 [ALC663_ASUS_MODE5] = "asus-mode5",
17205 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010017206 [ALC663_ASUS_MODE7] = "asus-mode7",
17207 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020017208 [ALC272_DELL] = "dell",
17209 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020017210 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017211 [ALC662_AUTO] = "auto",
17212};
17213
17214static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010017215 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020017216 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
17217 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017218 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
17219 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
17220 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
17221 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
17222 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
17223 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017224 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
17225 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017226 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017227 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
17228 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
17229 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
17230 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
17231 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017232 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017233 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
17234 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017235 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
17236 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
17237 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
17238 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017239 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017240 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
17241 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
17242 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017243 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
17244 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
17245 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
17246 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017247 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017248 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
17249 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017250 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017251 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
17252 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
17253 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017254 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
17255 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
17256 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017257 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
17258 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
17259 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017260 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017261 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
17262 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017263 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017264 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020017265 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017266 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
17267 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
17268 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017269 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017270 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
17271 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010017272 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020017273 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010017274 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017275 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030017276 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
17277 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010017278 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020017279 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030017280 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
17281 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020017282 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020017283 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017284 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020017285 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020017286 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017287 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
17288 ALC663_ASUS_H13),
David Santinoli7aee6742009-12-09 12:34:26 +010017289 SND_PCI_QUIRK(0x8086, 0xd604, "Intel mobo", ALC662_3ST_2ch_DIG),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017290 {}
17291};
17292
17293static struct alc_config_preset alc662_presets[] = {
17294 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017295 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017296 .init_verbs = { alc662_init_verbs },
17297 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17298 .dac_nids = alc662_dac_nids,
17299 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017300 .dig_in_nid = ALC662_DIGIN_NID,
17301 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17302 .channel_mode = alc662_3ST_2ch_modes,
17303 .input_mux = &alc662_capture_source,
17304 },
17305 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017306 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017307 .init_verbs = { alc662_init_verbs },
17308 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17309 .dac_nids = alc662_dac_nids,
17310 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017311 .dig_in_nid = ALC662_DIGIN_NID,
17312 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17313 .channel_mode = alc662_3ST_6ch_modes,
17314 .need_dac_fix = 1,
17315 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017316 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017317 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017318 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017319 .init_verbs = { alc662_init_verbs },
17320 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17321 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017322 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17323 .channel_mode = alc662_3ST_6ch_modes,
17324 .need_dac_fix = 1,
17325 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017326 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017327 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017328 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017329 .init_verbs = { alc662_init_verbs },
17330 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17331 .dac_nids = alc662_dac_nids,
17332 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017333 .dig_in_nid = ALC662_DIGIN_NID,
17334 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
17335 .channel_mode = alc662_5stack_modes,
17336 .input_mux = &alc662_capture_source,
17337 },
17338 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017339 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017340 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
17341 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17342 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017343 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17344 .channel_mode = alc662_3ST_2ch_modes,
17345 .input_mux = &alc662_lenovo_101e_capture_source,
17346 .unsol_event = alc662_lenovo_101e_unsol_event,
17347 .init_hook = alc662_lenovo_101e_all_automute,
17348 },
Kailang Yang291702f2007-10-16 14:28:03 +020017349 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017350 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020017351 .init_verbs = { alc662_init_verbs,
17352 alc662_eeepc_sue_init_verbs },
17353 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17354 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020017355 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17356 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020017357 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017358 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020017359 .init_hook = alc662_eeepc_inithook,
17360 },
Kailang Yang8c427222008-01-10 13:03:59 +010017361 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017362 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010017363 alc662_chmode_mixer },
17364 .init_verbs = { alc662_init_verbs,
17365 alc662_eeepc_ep20_sue_init_verbs },
17366 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17367 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010017368 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17369 .channel_mode = alc662_3ST_6ch_modes,
17370 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020017371 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017372 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010017373 .init_hook = alc662_eeepc_ep20_inithook,
17374 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017375 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017376 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017377 .init_verbs = { alc662_init_verbs,
17378 alc662_ecs_init_verbs },
17379 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17380 .dac_nids = alc662_dac_nids,
17381 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17382 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017383 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017384 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017385 .init_hook = alc662_eeepc_inithook,
17386 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017387 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017388 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017389 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17390 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17391 .dac_nids = alc662_dac_nids,
17392 .dig_out_nid = ALC662_DIGOUT_NID,
17393 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17394 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017395 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017396 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017397 .init_hook = alc663_m51va_inithook,
17398 },
17399 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017400 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017401 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
17402 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17403 .dac_nids = alc662_dac_nids,
17404 .dig_out_nid = ALC662_DIGOUT_NID,
17405 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17406 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017407 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017408 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017409 .init_hook = alc663_g71v_inithook,
17410 },
17411 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017412 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017413 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17414 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17415 .dac_nids = alc662_dac_nids,
17416 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17417 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017418 .unsol_event = alc663_m51va_unsol_event,
17419 .init_hook = alc663_m51va_inithook,
17420 },
17421 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017422 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017423 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17424 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17425 .dac_nids = alc662_dac_nids,
17426 .dig_out_nid = ALC662_DIGOUT_NID,
17427 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17428 .channel_mode = alc662_3ST_6ch_modes,
17429 .input_mux = &alc663_capture_source,
17430 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017431 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017432 .init_hook = alc663_g50v_inithook,
17433 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017434 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017435 .mixers = { alc663_m51va_mixer },
17436 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017437 .init_verbs = { alc662_init_verbs,
17438 alc663_21jd_amic_init_verbs },
17439 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17440 .hp_nid = 0x03,
17441 .dac_nids = alc662_dac_nids,
17442 .dig_out_nid = ALC662_DIGOUT_NID,
17443 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17444 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017445 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017446 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017447 .init_hook = alc663_mode1_inithook,
17448 },
17449 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017450 .mixers = { alc662_1bjd_mixer },
17451 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017452 .init_verbs = { alc662_init_verbs,
17453 alc662_1bjd_amic_init_verbs },
17454 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17455 .dac_nids = alc662_dac_nids,
17456 .dig_out_nid = ALC662_DIGOUT_NID,
17457 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17458 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017459 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017460 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017461 .init_hook = alc662_mode2_inithook,
17462 },
17463 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017464 .mixers = { alc663_two_hp_m1_mixer },
17465 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017466 .init_verbs = { alc662_init_verbs,
17467 alc663_two_hp_amic_m1_init_verbs },
17468 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17469 .hp_nid = 0x03,
17470 .dac_nids = alc662_dac_nids,
17471 .dig_out_nid = ALC662_DIGOUT_NID,
17472 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17473 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017474 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017475 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017476 .init_hook = alc663_mode3_inithook,
17477 },
17478 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017479 .mixers = { alc663_asus_21jd_clfe_mixer },
17480 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017481 .init_verbs = { alc662_init_verbs,
17482 alc663_21jd_amic_init_verbs},
17483 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17484 .hp_nid = 0x03,
17485 .dac_nids = alc662_dac_nids,
17486 .dig_out_nid = ALC662_DIGOUT_NID,
17487 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17488 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017489 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017490 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017491 .init_hook = alc663_mode4_inithook,
17492 },
17493 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017494 .mixers = { alc663_asus_15jd_clfe_mixer },
17495 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017496 .init_verbs = { alc662_init_verbs,
17497 alc663_15jd_amic_init_verbs },
17498 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17499 .hp_nid = 0x03,
17500 .dac_nids = alc662_dac_nids,
17501 .dig_out_nid = ALC662_DIGOUT_NID,
17502 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17503 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017504 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017505 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017506 .init_hook = alc663_mode5_inithook,
17507 },
17508 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017509 .mixers = { alc663_two_hp_m2_mixer },
17510 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017511 .init_verbs = { alc662_init_verbs,
17512 alc663_two_hp_amic_m2_init_verbs },
17513 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17514 .hp_nid = 0x03,
17515 .dac_nids = alc662_dac_nids,
17516 .dig_out_nid = ALC662_DIGOUT_NID,
17517 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17518 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017519 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017520 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017521 .init_hook = alc663_mode6_inithook,
17522 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010017523 [ALC663_ASUS_MODE7] = {
17524 .mixers = { alc663_mode7_mixer },
17525 .cap_mixer = alc662_auto_capture_mixer,
17526 .init_verbs = { alc662_init_verbs,
17527 alc663_mode7_init_verbs },
17528 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17529 .hp_nid = 0x03,
17530 .dac_nids = alc662_dac_nids,
17531 .dig_out_nid = ALC662_DIGOUT_NID,
17532 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17533 .channel_mode = alc662_3ST_2ch_modes,
17534 .unsol_event = alc663_mode7_unsol_event,
17535 .setup = alc663_mode7_setup,
17536 .init_hook = alc663_mode7_inithook,
17537 },
17538 [ALC663_ASUS_MODE8] = {
17539 .mixers = { alc663_mode8_mixer },
17540 .cap_mixer = alc662_auto_capture_mixer,
17541 .init_verbs = { alc662_init_verbs,
17542 alc663_mode8_init_verbs },
17543 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17544 .hp_nid = 0x03,
17545 .dac_nids = alc662_dac_nids,
17546 .dig_out_nid = ALC662_DIGOUT_NID,
17547 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17548 .channel_mode = alc662_3ST_2ch_modes,
17549 .unsol_event = alc663_mode8_unsol_event,
17550 .setup = alc663_mode8_setup,
17551 .init_hook = alc663_mode8_inithook,
17552 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017553 [ALC272_DELL] = {
17554 .mixers = { alc663_m51va_mixer },
17555 .cap_mixer = alc272_auto_capture_mixer,
17556 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17557 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17558 .dac_nids = alc662_dac_nids,
17559 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17560 .adc_nids = alc272_adc_nids,
17561 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17562 .capsrc_nids = alc272_capsrc_nids,
17563 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017564 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017565 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017566 .init_hook = alc663_m51va_inithook,
17567 },
17568 [ALC272_DELL_ZM1] = {
17569 .mixers = { alc663_m51va_mixer },
17570 .cap_mixer = alc662_auto_capture_mixer,
17571 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17572 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17573 .dac_nids = alc662_dac_nids,
17574 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17575 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017576 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020017577 .capsrc_nids = alc662_capsrc_nids,
17578 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017579 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017580 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017581 .init_hook = alc663_m51va_inithook,
17582 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017583 [ALC272_SAMSUNG_NC10] = {
17584 .mixers = { alc272_nc10_mixer },
17585 .init_verbs = { alc662_init_verbs,
17586 alc663_21jd_amic_init_verbs },
17587 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17588 .dac_nids = alc272_dac_nids,
17589 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17590 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017591 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020017592 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017593 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020017594 .init_hook = alc663_mode4_inithook,
17595 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017596};
17597
17598
17599/*
17600 * BIOS auto configuration
17601 */
17602
Takashi Iwai7085ec12009-10-02 09:03:58 +020017603/* convert from MIX nid to DAC */
17604static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
17605{
17606 if (nid == 0x0f)
17607 return 0x02;
17608 else if (nid >= 0x0c && nid <= 0x0e)
17609 return nid - 0x0c + 0x02;
17610 else
17611 return 0;
17612}
17613
17614/* get MIX nid connected to the given pin targeted to DAC */
17615static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
17616 hda_nid_t dac)
17617{
17618 hda_nid_t mix[4];
17619 int i, num;
17620
17621 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
17622 for (i = 0; i < num; i++) {
17623 if (alc662_mix_to_dac(mix[i]) == dac)
17624 return mix[i];
17625 }
17626 return 0;
17627}
17628
17629/* look for an empty DAC slot */
17630static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
17631{
17632 struct alc_spec *spec = codec->spec;
17633 hda_nid_t srcs[5];
17634 int i, j, num;
17635
17636 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
17637 if (num < 0)
17638 return 0;
17639 for (i = 0; i < num; i++) {
17640 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
17641 if (!nid)
17642 continue;
17643 for (j = 0; j < spec->multiout.num_dacs; j++)
17644 if (spec->multiout.dac_nids[j] == nid)
17645 break;
17646 if (j >= spec->multiout.num_dacs)
17647 return nid;
17648 }
17649 return 0;
17650}
17651
17652/* fill in the dac_nids table from the parsed pin configuration */
17653static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
17654 const struct auto_pin_cfg *cfg)
17655{
17656 struct alc_spec *spec = codec->spec;
17657 int i;
17658 hda_nid_t dac;
17659
17660 spec->multiout.dac_nids = spec->private_dac_nids;
17661 for (i = 0; i < cfg->line_outs; i++) {
17662 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
17663 if (!dac)
17664 continue;
17665 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
17666 }
17667 return 0;
17668}
17669
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017670static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017671 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017672{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017673 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017674 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
17675}
17676
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017677static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017678 hda_nid_t nid, unsigned int chs)
17679{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017680 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017681 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
17682}
17683
17684#define alc662_add_stereo_vol(spec, pfx, nid) \
17685 alc662_add_vol_ctl(spec, pfx, nid, 3)
17686#define alc662_add_stereo_sw(spec, pfx, nid) \
17687 alc662_add_sw_ctl(spec, pfx, nid, 3)
17688
17689/* add playback controls from the parsed DAC table */
17690static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
17691 const struct auto_pin_cfg *cfg)
17692{
17693 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017694 static const char *chname[4] = {
17695 "Front", "Surround", NULL /*CLFE*/, "Side"
17696 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020017697 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017698 int i, err;
17699
17700 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017701 nid = spec->multiout.dac_nids[i];
17702 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017703 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017704 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
17705 if (!mix)
17706 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017707 if (i == 2) {
17708 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017709 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017710 if (err < 0)
17711 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017712 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017713 if (err < 0)
17714 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017715 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017716 if (err < 0)
17717 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017718 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017719 if (err < 0)
17720 return err;
17721 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017722 const char *pfx;
17723 if (cfg->line_outs == 1 &&
17724 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017725 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017726 pfx = "Speaker";
17727 else
17728 pfx = "PCM";
17729 } else
17730 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017731 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017732 if (err < 0)
17733 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017734 if (cfg->line_outs == 1 &&
17735 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
17736 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020017737 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017738 if (err < 0)
17739 return err;
17740 }
17741 }
17742 return 0;
17743}
17744
17745/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017746/* return DAC nid if any new DAC is assigned */
17747static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017748 const char *pfx)
17749{
Takashi Iwai7085ec12009-10-02 09:03:58 +020017750 struct alc_spec *spec = codec->spec;
17751 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017752 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017753
17754 if (!pin)
17755 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017756 nid = alc662_look_for_dac(codec, pin);
17757 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017758 /* the corresponding DAC is already occupied */
17759 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
17760 return 0; /* no way */
17761 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017762 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017763 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17764 }
17765
17766 mix = alc662_dac_to_mix(codec, pin, nid);
17767 if (!mix)
17768 return 0;
17769 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
17770 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020017771 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017772 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
17773 if (err < 0)
17774 return err;
17775 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017776}
17777
17778/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017779#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020017780 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017781
17782static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17783 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017784 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017785{
Takashi Iwai7085ec12009-10-02 09:03:58 +020017786 int i, num;
17787 hda_nid_t srcs[4];
17788
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017789 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017790 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017791 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
17792 if (num <= 1)
17793 return;
17794 for (i = 0; i < num; i++) {
17795 if (alc662_mix_to_dac(srcs[i]) != dac)
17796 continue;
17797 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
17798 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017799 }
17800}
17801
17802static void alc662_auto_init_multi_out(struct hda_codec *codec)
17803{
17804 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017805 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017806 int i;
17807
17808 for (i = 0; i <= HDA_SIDE; i++) {
17809 hda_nid_t nid = spec->autocfg.line_out_pins[i];
17810 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017811 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017812 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017813 }
17814}
17815
17816static void alc662_auto_init_hp_out(struct hda_codec *codec)
17817{
17818 struct alc_spec *spec = codec->spec;
17819 hda_nid_t pin;
17820
17821 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017822 if (pin)
17823 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
17824 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017825 pin = spec->autocfg.speaker_pins[0];
17826 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020017827 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
17828 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017829}
17830
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017831#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17832
17833static void alc662_auto_init_analog_input(struct hda_codec *codec)
17834{
17835 struct alc_spec *spec = codec->spec;
17836 int i;
17837
17838 for (i = 0; i < AUTO_PIN_LAST; i++) {
17839 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020017840 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017841 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017842 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017843 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017844 snd_hda_codec_write(codec, nid, 0,
17845 AC_VERB_SET_AMP_GAIN_MUTE,
17846 AMP_OUT_MUTE);
17847 }
17848 }
17849}
17850
Takashi Iwaif511b012008-08-15 16:46:42 +020017851#define alc662_auto_init_input_src alc882_auto_init_input_src
17852
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017853static int alc662_parse_auto_config(struct hda_codec *codec)
17854{
17855 struct alc_spec *spec = codec->spec;
17856 int err;
17857 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17858
17859 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17860 alc662_ignore);
17861 if (err < 0)
17862 return err;
17863 if (!spec->autocfg.line_outs)
17864 return 0; /* can't find valid BIOS pin config */
17865
Takashi Iwai7085ec12009-10-02 09:03:58 +020017866 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017867 if (err < 0)
17868 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017869 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017870 if (err < 0)
17871 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017872 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017873 spec->autocfg.speaker_pins[0],
17874 "Speaker");
17875 if (err < 0)
17876 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017877 if (err)
17878 spec->multiout.extra_out_nid[0] = err;
17879 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017880 "Headphone");
17881 if (err < 0)
17882 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017883 if (err)
17884 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017885 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017886 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017887 return err;
17888
17889 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17890
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017891 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017892 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17893
Takashi Iwai603c4012008-07-30 15:01:44 +020017894 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017895 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017896
17897 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017898 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017899
Takashi Iwaid88897e2008-10-31 15:01:37 +010017900 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017901 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017902 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017903
17904 err = alc_auto_add_mic_boost(codec);
17905 if (err < 0)
17906 return err;
17907
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017908 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17909
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017910 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017911}
17912
17913/* additional initialization for auto-configuration model */
17914static void alc662_auto_init(struct hda_codec *codec)
17915{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017916 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017917 alc662_auto_init_multi_out(codec);
17918 alc662_auto_init_hp_out(codec);
17919 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017920 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017921 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017922 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017923}
17924
17925static int patch_alc662(struct hda_codec *codec)
17926{
17927 struct alc_spec *spec;
17928 int err, board_config;
17929
17930 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17931 if (!spec)
17932 return -ENOMEM;
17933
17934 codec->spec = spec;
17935
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017936 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17937
Kailang Yang274693f2009-12-03 10:07:50 +010017938 if (alc_read_coef_idx(codec, 0)==0x8020){
17939 kfree(codec->chip_name);
17940 codec->chip_name = kstrdup("ALC661", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017941 if (!codec->chip_name) {
17942 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010017943 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017944 }
Kailang Yang274693f2009-12-03 10:07:50 +010017945 }
17946
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017947 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17948 alc662_models,
17949 alc662_cfg_tbl);
17950 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017951 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17952 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017953 board_config = ALC662_AUTO;
17954 }
17955
17956 if (board_config == ALC662_AUTO) {
17957 /* automatic parse from the BIOS config */
17958 err = alc662_parse_auto_config(codec);
17959 if (err < 0) {
17960 alc_free(codec);
17961 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017962 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017963 printk(KERN_INFO
17964 "hda_codec: Cannot set up configuration "
17965 "from BIOS. Using base mode...\n");
17966 board_config = ALC662_3ST_2ch_DIG;
17967 }
17968 }
17969
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017970 err = snd_hda_attach_beep_device(codec, 0x1);
17971 if (err < 0) {
17972 alc_free(codec);
17973 return err;
17974 }
17975
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017976 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017977 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017978
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017979 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17980 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17981
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017982 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17983 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17984
Takashi Iwaidd704692009-08-11 08:45:11 +020017985 if (!spec->adc_nids) {
17986 spec->adc_nids = alc662_adc_nids;
17987 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17988 }
17989 if (!spec->capsrc_nids)
17990 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017991
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017992 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017993 set_capture_mixer(codec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017994 if (codec->vendor_id == 0x10ec0662)
17995 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17996 else
17997 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017998
Takashi Iwai2134ea42008-01-10 16:53:55 +010017999 spec->vmaster_nid = 0x02;
18000
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018001 codec->patch_ops = alc_patch_ops;
18002 if (board_config == ALC662_AUTO)
18003 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020018004#ifdef CONFIG_SND_HDA_POWER_SAVE
18005 if (!spec->loopback.amplist)
18006 spec->loopback.amplist = alc662_loopbacks;
18007#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010018008 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018009
18010 return 0;
18011}
18012
Kailang Yang274693f2009-12-03 10:07:50 +010018013static int patch_alc888(struct hda_codec *codec)
18014{
18015 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
18016 kfree(codec->chip_name);
18017 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018018 if (!codec->chip_name) {
18019 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018020 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018021 }
18022 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018023 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018024 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018025}
18026
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018027/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070018028 * patch entries
18029 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018030static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070018031 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018032 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018033 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020018034 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018035 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018036 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020018037 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018038 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018039 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018040 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018041 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
18042 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
18043 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018044 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018045 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018046 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
18047 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018048 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018049 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018050 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018051 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020018052 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018053 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020018054 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018055 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018056 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018057 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020018058 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018059 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018060 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018061 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018062 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018063 {} /* terminator */
18064};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018065
18066MODULE_ALIAS("snd-hda-codec-id:10ec*");
18067
18068MODULE_LICENSE("GPL");
18069MODULE_DESCRIPTION("Realtek HD-audio codec");
18070
18071static struct hda_codec_preset_list realtek_list = {
18072 .preset = snd_hda_preset_realtek,
18073 .owner = THIS_MODULE,
18074};
18075
18076static int __init patch_realtek_init(void)
18077{
18078 return snd_hda_add_codec_preset(&realtek_list);
18079}
18080
18081static void __exit patch_realtek_exit(void)
18082{
18083 snd_hda_delete_codec_preset(&realtek_list);
18084}
18085
18086module_init(patch_realtek_init)
18087module_exit(patch_realtek_exit)