blob: 84bc2c7c4421133420289907a4e3ac907535cfbe [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ünther3e1647c2009-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);
340
Takashi Iwai834be882006-03-01 14:16:17 +0100341 /* for pin sensing */
342 unsigned int sense_updated: 1;
343 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100344 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200345 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200346
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100347 /* other flags */
348 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200349 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100350
Takashi Iwai2134ea42008-01-10 16:53:55 +0100351 /* for virtual master */
352 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200353#ifdef CONFIG_SND_HDA_POWER_SAVE
354 struct hda_loopback_check loopback;
355#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200356
357 /* for PLL fix */
358 hda_nid_t pll_nid;
359 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100360};
361
362/*
363 * configuration template - to be copied to the spec instance
364 */
365struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200366 struct snd_kcontrol_new *mixers[5]; /* should be identical size
367 * with spec
368 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100369 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100370 const struct hda_verb *init_verbs[5];
371 unsigned int num_dacs;
372 hda_nid_t *dac_nids;
373 hda_nid_t dig_out_nid; /* optional */
374 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800375 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100376 unsigned int num_adc_nids;
377 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100378 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100379 hda_nid_t dig_in_nid;
380 unsigned int num_channel_mode;
381 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200382 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200383 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200384 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100385 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100386 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200387 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100388 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200389#ifdef CONFIG_SND_HDA_POWER_SAVE
390 struct hda_amp_list *loopbacks;
391#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392};
393
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394
395/*
396 * input MUX handling
397 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200398static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
399 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400{
401 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
402 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200403 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
404 if (mux_idx >= spec->num_mux_defs)
405 mux_idx = 0;
406 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407}
408
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200409static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
410 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411{
412 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
413 struct alc_spec *spec = codec->spec;
414 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
415
416 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
417 return 0;
418}
419
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200420static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
421 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422{
423 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
424 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100425 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100427 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100428 hda_nid_t nid = spec->capsrc_nids ?
429 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200430 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431
Takashi Iwaicd896c32008-11-18 12:36:33 +0100432 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
433 imux = &spec->input_mux[mux_idx];
434
Takashi Iwaia22d5432009-07-27 12:54:26 +0200435 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200436 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100437 /* Matrix-mixer style (e.g. ALC882) */
438 unsigned int *cur_val = &spec->cur_mux[adc_idx];
439 unsigned int i, idx;
440
441 idx = ucontrol->value.enumerated.item[0];
442 if (idx >= imux->num_items)
443 idx = imux->num_items - 1;
444 if (*cur_val == idx)
445 return 0;
446 for (i = 0; i < imux->num_items; i++) {
447 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
448 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
449 imux->items[i].index,
450 HDA_AMP_MUTE, v);
451 }
452 *cur_val = idx;
453 return 1;
454 } else {
455 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100456 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100457 &spec->cur_mux[adc_idx]);
458 }
459}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200460
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461/*
462 * channel mode setting
463 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200464static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
465 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466{
467 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
468 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100469 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
470 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471}
472
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200473static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
474 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475{
476 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
477 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100478 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200479 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200480 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481}
482
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200483static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
484 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485{
486 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
487 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200488 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
489 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200490 &spec->ext_channel_count);
491 if (err >= 0 && !spec->const_channel_count) {
492 spec->multiout.max_channels = spec->ext_channel_count;
493 if (spec->need_dac_fix)
494 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
495 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200496 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497}
498
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100500 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200501 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100502 * being part of a format specifier. Maximum allowed length of a value is
503 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100504 *
505 * Note: some retasking pin complexes seem to ignore requests for input
506 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
507 * are requested. Therefore order this list so that this behaviour will not
508 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200509 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
510 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200511 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100512static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100513 "Mic 50pc bias", "Mic 80pc bias",
514 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100515};
516static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100517 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100518};
519/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200520 * in the pin being assumed to be exclusively an input or an output pin. In
521 * addition, "input" pins may or may not process the mic bias option
522 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
523 * accept requests for bias as of chip versions up to March 2006) and/or
524 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100525 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200526#define ALC_PIN_DIR_IN 0x00
527#define ALC_PIN_DIR_OUT 0x01
528#define ALC_PIN_DIR_INOUT 0x02
529#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
530#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100531
Kailang Yangea1fb292008-08-26 12:58:38 +0200532/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100533 * For each direction the minimum and maximum values are given.
534 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200535static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100536 { 0, 2 }, /* ALC_PIN_DIR_IN */
537 { 3, 4 }, /* ALC_PIN_DIR_OUT */
538 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200539 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
540 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100541};
542#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
543#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
544#define alc_pin_mode_n_items(_dir) \
545 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
546
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200547static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
548 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200549{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100550 unsigned int item_num = uinfo->value.enumerated.item;
551 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
552
553 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200554 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100555 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
556
557 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
558 item_num = alc_pin_mode_min(dir);
559 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200560 return 0;
561}
562
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200563static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
564 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200565{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100566 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200567 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
568 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100569 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200570 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200571 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
572 AC_VERB_GET_PIN_WIDGET_CONTROL,
573 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200574
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100575 /* Find enumerated value for current pinctl setting */
576 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200577 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100578 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200579 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100580 return 0;
581}
582
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200583static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
584 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100585{
586 signed int change;
587 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
588 hda_nid_t nid = kcontrol->private_value & 0xffff;
589 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
590 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200591 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
592 AC_VERB_GET_PIN_WIDGET_CONTROL,
593 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100594
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200595 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100596 val = alc_pin_mode_min(dir);
597
598 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100599 if (change) {
600 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200601 snd_hda_codec_write_cache(codec, nid, 0,
602 AC_VERB_SET_PIN_WIDGET_CONTROL,
603 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100604
Kailang Yangea1fb292008-08-26 12:58:38 +0200605 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100606 * for the requested pin mode. Enum values of 2 or less are
607 * input modes.
608 *
609 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200610 * reduces noise slightly (particularly on input) so we'll
611 * do it. However, having both input and output buffers
612 * enabled simultaneously doesn't seem to be problematic if
613 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100614 */
615 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200616 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
617 HDA_AMP_MUTE, HDA_AMP_MUTE);
618 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
619 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100620 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200621 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
622 HDA_AMP_MUTE, HDA_AMP_MUTE);
623 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
624 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100625 }
626 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200627 return change;
628}
629
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100630#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200631 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100632 .info = alc_pin_mode_info, \
633 .get = alc_pin_mode_get, \
634 .put = alc_pin_mode_put, \
635 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100636
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100637/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
638 * together using a mask with more than one bit set. This control is
639 * currently used only by the ALC260 test model. At this stage they are not
640 * needed for any "production" models.
641 */
642#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200643#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200644
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200645static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
646 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100647{
648 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
649 hda_nid_t nid = kcontrol->private_value & 0xffff;
650 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
651 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200652 unsigned int val = snd_hda_codec_read(codec, nid, 0,
653 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100654
655 *valp = (val & mask) != 0;
656 return 0;
657}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200658static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
659 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100660{
661 signed int change;
662 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
663 hda_nid_t nid = kcontrol->private_value & 0xffff;
664 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
665 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200666 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
667 AC_VERB_GET_GPIO_DATA,
668 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100669
670 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200671 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
672 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100673 gpio_data &= ~mask;
674 else
675 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200676 snd_hda_codec_write_cache(codec, nid, 0,
677 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100678
679 return change;
680}
681#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
682 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
683 .info = alc_gpio_data_info, \
684 .get = alc_gpio_data_get, \
685 .put = alc_gpio_data_put, \
686 .private_value = nid | (mask<<16) }
687#endif /* CONFIG_SND_DEBUG */
688
Jonathan Woithe92621f12006-02-28 11:47:47 +0100689/* A switch control to allow the enabling of the digital IO pins on the
690 * ALC260. This is incredibly simplistic; the intention of this control is
691 * to provide something in the test model allowing digital outputs to be
692 * identified if present. If models are found which can utilise these
693 * outputs a more complete mixer control can be devised for those models if
694 * necessary.
695 */
696#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200697#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200698
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200699static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
700 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100701{
702 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
703 hda_nid_t nid = kcontrol->private_value & 0xffff;
704 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
705 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200706 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100707 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100708
709 *valp = (val & mask) != 0;
710 return 0;
711}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200712static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
713 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100714{
715 signed int change;
716 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
717 hda_nid_t nid = kcontrol->private_value & 0xffff;
718 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
719 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200720 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100721 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200722 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100723
724 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200725 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100726 if (val==0)
727 ctrl_data &= ~mask;
728 else
729 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200730 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
731 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100732
733 return change;
734}
735#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
736 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
737 .info = alc_spdif_ctrl_info, \
738 .get = alc_spdif_ctrl_get, \
739 .put = alc_spdif_ctrl_put, \
740 .private_value = nid | (mask<<16) }
741#endif /* CONFIG_SND_DEBUG */
742
Jonathan Woithef8225f62008-01-08 12:16:54 +0100743/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
744 * Again, this is only used in the ALC26x test models to help identify when
745 * the EAPD line must be asserted for features to work.
746 */
747#ifdef CONFIG_SND_DEBUG
748#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
749
750static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
751 struct snd_ctl_elem_value *ucontrol)
752{
753 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
754 hda_nid_t nid = kcontrol->private_value & 0xffff;
755 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
756 long *valp = ucontrol->value.integer.value;
757 unsigned int val = snd_hda_codec_read(codec, nid, 0,
758 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
759
760 *valp = (val & mask) != 0;
761 return 0;
762}
763
764static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
765 struct snd_ctl_elem_value *ucontrol)
766{
767 int change;
768 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
769 hda_nid_t nid = kcontrol->private_value & 0xffff;
770 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
771 long val = *ucontrol->value.integer.value;
772 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
773 AC_VERB_GET_EAPD_BTLENABLE,
774 0x00);
775
776 /* Set/unset the masked control bit(s) as needed */
777 change = (!val ? 0 : mask) != (ctrl_data & mask);
778 if (!val)
779 ctrl_data &= ~mask;
780 else
781 ctrl_data |= mask;
782 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
783 ctrl_data);
784
785 return change;
786}
787
788#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
789 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
790 .info = alc_eapd_ctrl_info, \
791 .get = alc_eapd_ctrl_get, \
792 .put = alc_eapd_ctrl_put, \
793 .private_value = nid | (mask<<16) }
794#endif /* CONFIG_SND_DEBUG */
795
Kailang Yangdf694da2005-12-05 19:42:22 +0100796/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100797 * set up the input pin config (depending on the given auto-pin type)
798 */
799static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
800 int auto_pin_type)
801{
802 unsigned int val = PIN_IN;
803
804 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
805 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100806 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100807 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
808 if (pincap & AC_PINCAP_VREF_80)
809 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200810 else if (pincap & AC_PINCAP_VREF_50)
811 val = PIN_VREF50;
812 else if (pincap & AC_PINCAP_VREF_100)
813 val = PIN_VREF100;
814 else if (pincap & AC_PINCAP_VREF_GRD)
815 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100816 }
817 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
818}
819
820/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100821 */
822static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
823{
824 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
825 return;
826 spec->mixers[spec->num_mixers++] = mix;
827}
828
829static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
830{
831 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
832 return;
833 spec->init_verbs[spec->num_init_verbs++] = verb;
834}
835
Takashi Iwaidaead532008-11-28 12:55:36 +0100836#ifdef CONFIG_PROC_FS
837/*
838 * hook for proc
839 */
840static void print_realtek_coef(struct snd_info_buffer *buffer,
841 struct hda_codec *codec, hda_nid_t nid)
842{
843 int coeff;
844
845 if (nid != 0x20)
846 return;
847 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
848 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
849 coeff = snd_hda_codec_read(codec, nid, 0,
850 AC_VERB_GET_COEF_INDEX, 0);
851 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
852}
853#else
854#define print_realtek_coef NULL
855#endif
856
Takashi Iwaid88897e2008-10-31 15:01:37 +0100857/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100858 * set up from the preset table
859 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200860static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200861 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100862{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200863 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100864 int i;
865
866 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100867 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100868 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200869 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
870 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100871 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200872
Kailang Yangdf694da2005-12-05 19:42:22 +0100873 spec->channel_mode = preset->channel_mode;
874 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200875 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200876 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100877
Hector Martin3b315d72009-06-02 10:54:19 +0200878 if (preset->const_channel_count)
879 spec->multiout.max_channels = preset->const_channel_count;
880 else
881 spec->multiout.max_channels = spec->channel_mode[0].channels;
882 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100883
884 spec->multiout.num_dacs = preset->num_dacs;
885 spec->multiout.dac_nids = preset->dac_nids;
886 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800887 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100888 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200889
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200890 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200891 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200892 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100893 spec->input_mux = preset->input_mux;
894
895 spec->num_adc_nids = preset->num_adc_nids;
896 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100897 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100898 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100899
900 spec->unsol_event = preset->unsol_event;
901 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200902#ifdef CONFIG_SND_HDA_POWER_SAVE
903 spec->loopback.amplist = preset->loopbacks;
904#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200905
906 if (preset->setup)
907 preset->setup(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100908}
909
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200910/* Enable GPIO mask and set output */
911static struct hda_verb alc_gpio1_init_verbs[] = {
912 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
913 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
914 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
915 { }
916};
917
918static struct hda_verb alc_gpio2_init_verbs[] = {
919 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
920 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
921 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
922 { }
923};
924
Kailang Yangbdd148a2007-05-08 15:19:08 +0200925static struct hda_verb alc_gpio3_init_verbs[] = {
926 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
927 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
928 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
929 { }
930};
931
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200932/*
933 * Fix hardware PLL issue
934 * On some codecs, the analog PLL gating control must be off while
935 * the default value is 1.
936 */
937static void alc_fix_pll(struct hda_codec *codec)
938{
939 struct alc_spec *spec = codec->spec;
940 unsigned int val;
941
942 if (!spec->pll_nid)
943 return;
944 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
945 spec->pll_coef_idx);
946 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
947 AC_VERB_GET_PROC_COEF, 0);
948 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
949 spec->pll_coef_idx);
950 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
951 val & ~(1 << spec->pll_coef_bit));
952}
953
954static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
955 unsigned int coef_idx, unsigned int coef_bit)
956{
957 struct alc_spec *spec = codec->spec;
958 spec->pll_nid = nid;
959 spec->pll_coef_idx = coef_idx;
960 spec->pll_coef_bit = coef_bit;
961 alc_fix_pll(codec);
962}
963
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200964static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200965{
966 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200967 unsigned int nid = spec->autocfg.hp_pins[0];
968 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200969
Takashi Iwaiad87c642009-11-02 14:23:15 +0100970 if (!nid)
971 return;
Wu Fengguang864f92b2009-11-18 12:38:02 +0800972 spec->jack_present = snd_hda_jack_detect(codec, nid);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200973 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
974 nid = spec->autocfg.speaker_pins[i];
975 if (!nid)
976 break;
977 snd_hda_codec_write(codec, nid, 0,
978 AC_VERB_SET_PIN_WIDGET_CONTROL,
979 spec->jack_present ? 0 : PIN_OUT);
980 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200981}
982
Takashi Iwai6c819492009-08-10 18:47:44 +0200983static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
984 hda_nid_t nid)
985{
986 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
987 int i, nums;
988
989 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
990 for (i = 0; i < nums; i++)
991 if (conn[i] == nid)
992 return i;
993 return -1;
994}
995
Kailang Yang7fb0d782008-10-15 11:12:35 +0200996static void alc_mic_automute(struct hda_codec *codec)
997{
998 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +0200999 struct alc_mic_route *dead, *alive;
1000 unsigned int present, type;
1001 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001002
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001003 if (!spec->auto_mic)
1004 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001005 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1006 return;
1007 if (snd_BUG_ON(!spec->adc_nids))
1008 return;
1009
1010 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1011
Wu Fengguang864f92b2009-11-18 12:38:02 +08001012 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001013 if (present) {
1014 alive = &spec->ext_mic;
1015 dead = &spec->int_mic;
1016 } else {
1017 alive = &spec->int_mic;
1018 dead = &spec->ext_mic;
1019 }
1020
Takashi Iwai6c819492009-08-10 18:47:44 +02001021 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1022 if (type == AC_WID_AUD_MIX) {
1023 /* Matrix-mixer style (e.g. ALC882) */
1024 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1025 alive->mux_idx,
1026 HDA_AMP_MUTE, 0);
1027 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1028 dead->mux_idx,
1029 HDA_AMP_MUTE, HDA_AMP_MUTE);
1030 } else {
1031 /* MUX style (e.g. ALC880) */
1032 snd_hda_codec_write_cache(codec, cap_nid, 0,
1033 AC_VERB_SET_CONNECT_SEL,
1034 alive->mux_idx);
1035 }
1036
1037 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001038}
1039
Kailang Yangc9b58002007-10-16 14:30:01 +02001040/* unsolicited event for HP jack sensing */
1041static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1042{
1043 if (codec->vendor_id == 0x10ec0880)
1044 res >>= 28;
1045 else
1046 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001047 switch (res) {
1048 case ALC880_HP_EVENT:
1049 alc_automute_pin(codec);
1050 break;
1051 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001052 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001053 break;
1054 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001055}
1056
1057static void alc_inithook(struct hda_codec *codec)
1058{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001059 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001060 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001061}
1062
Kailang Yangf9423e72008-05-27 12:32:25 +02001063/* additional initialization for ALC888 variants */
1064static void alc888_coef_init(struct hda_codec *codec)
1065{
1066 unsigned int tmp;
1067
1068 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1069 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1070 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001071 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001072 /* alc888S-VC */
1073 snd_hda_codec_read(codec, 0x20, 0,
1074 AC_VERB_SET_PROC_COEF, 0x830);
1075 else
1076 /* alc888-VB */
1077 snd_hda_codec_read(codec, 0x20, 0,
1078 AC_VERB_SET_PROC_COEF, 0x3030);
1079}
1080
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001081static void alc889_coef_init(struct hda_codec *codec)
1082{
1083 unsigned int tmp;
1084
1085 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1086 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1087 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1088 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1089}
1090
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001091static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001092{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001093 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001094
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001095 switch (type) {
1096 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001097 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1098 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001099 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001100 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1101 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001102 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001103 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1104 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001105 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001106 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001107 case 0x10ec0260:
1108 snd_hda_codec_write(codec, 0x0f, 0,
1109 AC_VERB_SET_EAPD_BTLENABLE, 2);
1110 snd_hda_codec_write(codec, 0x10, 0,
1111 AC_VERB_SET_EAPD_BTLENABLE, 2);
1112 break;
1113 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001114 case 0x10ec0267:
1115 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001116 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001117 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001118 case 0x10ec0660:
1119 case 0x10ec0662:
1120 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001121 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001122 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001123 snd_hda_codec_write(codec, 0x14, 0,
1124 AC_VERB_SET_EAPD_BTLENABLE, 2);
1125 snd_hda_codec_write(codec, 0x15, 0,
1126 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001127 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001128 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001129 switch (codec->vendor_id) {
1130 case 0x10ec0260:
1131 snd_hda_codec_write(codec, 0x1a, 0,
1132 AC_VERB_SET_COEF_INDEX, 7);
1133 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1134 AC_VERB_GET_PROC_COEF, 0);
1135 snd_hda_codec_write(codec, 0x1a, 0,
1136 AC_VERB_SET_COEF_INDEX, 7);
1137 snd_hda_codec_write(codec, 0x1a, 0,
1138 AC_VERB_SET_PROC_COEF,
1139 tmp | 0x2010);
1140 break;
1141 case 0x10ec0262:
1142 case 0x10ec0880:
1143 case 0x10ec0882:
1144 case 0x10ec0883:
1145 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001146 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001147 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001148 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001149 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001150 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001151 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001152 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001153 case 0x10ec0267:
1154 case 0x10ec0268:
1155 snd_hda_codec_write(codec, 0x20, 0,
1156 AC_VERB_SET_COEF_INDEX, 7);
1157 tmp = snd_hda_codec_read(codec, 0x20, 0,
1158 AC_VERB_GET_PROC_COEF, 0);
1159 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001160 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001161 snd_hda_codec_write(codec, 0x20, 0,
1162 AC_VERB_SET_PROC_COEF,
1163 tmp | 0x3000);
1164 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001165 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001166 break;
1167 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001168}
Kailang Yangea1fb292008-08-26 12:58:38 +02001169
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001170static void alc_init_auto_hp(struct hda_codec *codec)
1171{
1172 struct alc_spec *spec = codec->spec;
1173
1174 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001175 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001176
Kailang Yangc9b58002007-10-16 14:30:01 +02001177 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001178 if (spec->autocfg.line_out_pins[0] &&
1179 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001180 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001181 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001182 else
1183 return;
1184 }
1185
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001186 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1187 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001188 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1189 AC_VERB_SET_UNSOLICITED_ENABLE,
1190 AC_USRSP_EN | ALC880_HP_EVENT);
1191 spec->unsol_event = alc_sku_unsol_event;
1192}
1193
Takashi Iwai6c819492009-08-10 18:47:44 +02001194static void alc_init_auto_mic(struct hda_codec *codec)
1195{
1196 struct alc_spec *spec = codec->spec;
1197 struct auto_pin_cfg *cfg = &spec->autocfg;
1198 hda_nid_t fixed, ext;
1199 int i;
1200
1201 /* there must be only two mic inputs exclusively */
1202 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1203 if (cfg->input_pins[i])
1204 return;
1205
1206 fixed = ext = 0;
1207 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1208 hda_nid_t nid = cfg->input_pins[i];
1209 unsigned int defcfg;
1210 if (!nid)
1211 return;
1212 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1213 switch (get_defcfg_connect(defcfg)) {
1214 case AC_JACK_PORT_FIXED:
1215 if (fixed)
1216 return; /* already occupied */
1217 fixed = nid;
1218 break;
1219 case AC_JACK_PORT_COMPLEX:
1220 if (ext)
1221 return; /* already occupied */
1222 ext = nid;
1223 break;
1224 default:
1225 return; /* invalid entry */
1226 }
1227 }
1228 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1229 return; /* no unsol support */
1230 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1231 ext, fixed);
1232 spec->ext_mic.pin = ext;
1233 spec->int_mic.pin = fixed;
1234 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1235 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1236 spec->auto_mic = 1;
1237 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1238 AC_VERB_SET_UNSOLICITED_ENABLE,
1239 AC_USRSP_EN | ALC880_MIC_EVENT);
1240 spec->unsol_event = alc_sku_unsol_event;
1241}
1242
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001243/* check subsystem ID and set up device-specific initialization;
1244 * return 1 if initialized, 0 if invalid SSID
1245 */
1246/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1247 * 31 ~ 16 : Manufacture ID
1248 * 15 ~ 8 : SKU ID
1249 * 7 ~ 0 : Assembly ID
1250 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1251 */
1252static int alc_subsystem_id(struct hda_codec *codec,
1253 hda_nid_t porta, hda_nid_t porte,
1254 hda_nid_t portd)
1255{
1256 unsigned int ass, tmp, i;
1257 unsigned nid;
1258 struct alc_spec *spec = codec->spec;
1259
1260 ass = codec->subsystem_id & 0xffff;
1261 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1262 goto do_sku;
1263
1264 /* invalid SSID, check the special NID pin defcfg instead */
1265 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001266 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001267 * 29~21 : reserve
1268 * 20 : PCBEEP input
1269 * 19~16 : Check sum (15:1)
1270 * 15~1 : Custom
1271 * 0 : override
1272 */
1273 nid = 0x1d;
1274 if (codec->vendor_id == 0x10ec0260)
1275 nid = 0x17;
1276 ass = snd_hda_codec_get_pincfg(codec, nid);
1277 snd_printd("realtek: No valid SSID, "
1278 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001279 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001280 if (!(ass & 1) && !(ass & 0x100000))
1281 return 0;
1282 if ((ass >> 30) != 1) /* no physical connection */
1283 return 0;
1284
1285 /* check sum */
1286 tmp = 0;
1287 for (i = 1; i < 16; i++) {
1288 if ((ass >> i) & 1)
1289 tmp++;
1290 }
1291 if (((ass >> 16) & 0xf) != tmp)
1292 return 0;
1293do_sku:
1294 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1295 ass & 0xffff, codec->vendor_id);
1296 /*
1297 * 0 : override
1298 * 1 : Swap Jack
1299 * 2 : 0 --> Desktop, 1 --> Laptop
1300 * 3~5 : External Amplifier control
1301 * 7~6 : Reserved
1302 */
1303 tmp = (ass & 0x38) >> 3; /* external Amp control */
1304 switch (tmp) {
1305 case 1:
1306 spec->init_amp = ALC_INIT_GPIO1;
1307 break;
1308 case 3:
1309 spec->init_amp = ALC_INIT_GPIO2;
1310 break;
1311 case 7:
1312 spec->init_amp = ALC_INIT_GPIO3;
1313 break;
1314 case 5:
1315 spec->init_amp = ALC_INIT_DEFAULT;
1316 break;
1317 }
1318
1319 /* is laptop or Desktop and enable the function "Mute internal speaker
1320 * when the external headphone out jack is plugged"
1321 */
1322 if (!(ass & 0x8000))
1323 return 1;
1324 /*
1325 * 10~8 : Jack location
1326 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1327 * 14~13: Resvered
1328 * 15 : 1 --> enable the function "Mute internal speaker
1329 * when the external headphone out jack is plugged"
1330 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001331 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001332 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001333 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1334 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001335 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001336 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001337 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001338 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001339 nid = portd;
Kailang Yangc9b58002007-10-16 14:30:01 +02001340 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001341 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001342 for (i = 0; i < spec->autocfg.line_outs; i++)
1343 if (spec->autocfg.line_out_pins[i] == nid)
1344 return 1;
1345 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001346 }
1347
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001348 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001349 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001350 return 1;
1351}
Kailang Yangea1fb292008-08-26 12:58:38 +02001352
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001353static void alc_ssid_check(struct hda_codec *codec,
1354 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1355{
1356 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1357 struct alc_spec *spec = codec->spec;
1358 snd_printd("realtek: "
1359 "Enable default setup for auto mode as fallback\n");
1360 spec->init_amp = ALC_INIT_DEFAULT;
1361 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001362 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001363 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001364}
1365
Takashi Iwai41e41f12005-06-08 14:48:49 +02001366/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001367 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001368 */
1369
1370struct alc_pincfg {
1371 hda_nid_t nid;
1372 u32 val;
1373};
1374
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001375struct alc_fixup {
1376 const struct alc_pincfg *pins;
1377 const struct hda_verb *verbs;
1378};
1379
1380static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001381 const struct snd_pci_quirk *quirk,
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001382 const struct alc_fixup *fix)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001383{
1384 const struct alc_pincfg *cfg;
1385
1386 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1387 if (!quirk)
1388 return;
1389
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001390 fix += quirk->value;
1391 cfg = fix->pins;
1392 if (cfg) {
1393 for (; cfg->nid; cfg++)
1394 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1395 }
1396 if (fix->verbs)
1397 add_verb(codec->spec, fix->verbs);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001398}
1399
Kailang Yang274693f2009-12-03 10:07:50 +01001400static int alc_read_coef_idx(struct hda_codec *codec,
1401 unsigned int coef_idx)
1402{
1403 unsigned int val;
1404 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1405 coef_idx);
1406 val = snd_hda_codec_read(codec, 0x20, 0,
1407 AC_VERB_GET_PROC_COEF, 0);
1408 return val;
1409}
1410
Takashi Iwaif95474e2007-07-10 00:47:43 +02001411/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001412 * ALC888
1413 */
1414
1415/*
1416 * 2ch mode
1417 */
1418static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1419/* Mic-in jack as mic in */
1420 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1421 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1422/* Line-in jack as Line in */
1423 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1424 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1425/* Line-Out as Front */
1426 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1427 { } /* end */
1428};
1429
1430/*
1431 * 4ch mode
1432 */
1433static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1434/* Mic-in jack as mic in */
1435 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1436 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1437/* Line-in jack as Surround */
1438 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1439 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1440/* Line-Out as Front */
1441 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1442 { } /* end */
1443};
1444
1445/*
1446 * 6ch mode
1447 */
1448static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1449/* Mic-in jack as CLFE */
1450 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1451 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1452/* Line-in jack as Surround */
1453 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1454 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1455/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1456 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1457 { } /* end */
1458};
1459
1460/*
1461 * 8ch mode
1462 */
1463static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1464/* Mic-in jack as CLFE */
1465 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1466 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1467/* Line-in jack as Surround */
1468 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1469 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1470/* Line-Out as Side */
1471 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1472 { } /* end */
1473};
1474
1475static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1476 { 2, alc888_4ST_ch2_intel_init },
1477 { 4, alc888_4ST_ch4_intel_init },
1478 { 6, alc888_4ST_ch6_intel_init },
1479 { 8, alc888_4ST_ch8_intel_init },
1480};
1481
1482/*
1483 * ALC888 Fujitsu Siemens Amillo xa3530
1484 */
1485
1486static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1487/* Front Mic: set to PIN_IN (empty by default) */
1488 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1489/* Connect Internal HP to Front */
1490 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1491 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1492 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1493/* Connect Bass HP to Front */
1494 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1495 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1496 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1497/* Connect Line-Out side jack (SPDIF) to Side */
1498 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1499 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1500 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1501/* Connect Mic jack to CLFE */
1502 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1503 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1504 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1505/* Connect Line-in jack to Surround */
1506 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1507 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1508 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1509/* Connect HP out jack to Front */
1510 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1511 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1512 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1513/* Enable unsolicited event for HP jack and Line-out jack */
1514 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1515 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1516 {}
1517};
1518
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001519static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001520{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001521 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001522 unsigned int mute;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001523 hda_nid_t nid;
1524 int i;
1525
1526 spec->jack_present = 0;
1527 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1528 nid = spec->autocfg.hp_pins[i];
1529 if (!nid)
1530 break;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001531 if (snd_hda_jack_detect(codec, nid)) {
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001532 spec->jack_present = 1;
1533 break;
1534 }
1535 }
1536
1537 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001538 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001539 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1540 nid = spec->autocfg.speaker_pins[i];
1541 if (!nid)
1542 break;
1543 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1544 HDA_AMP_MUTE, mute);
1545 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001546}
1547
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001548static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1549 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001550{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001551 if (codec->vendor_id == 0x10ec0880)
1552 res >>= 28;
1553 else
1554 res >>= 26;
1555 if (res == ALC880_HP_EVENT)
1556 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001557}
1558
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001559static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001560{
1561 struct alc_spec *spec = codec->spec;
1562
1563 spec->autocfg.hp_pins[0] = 0x15;
1564 spec->autocfg.speaker_pins[0] = 0x14;
1565 spec->autocfg.speaker_pins[1] = 0x16;
1566 spec->autocfg.speaker_pins[2] = 0x17;
1567 spec->autocfg.speaker_pins[3] = 0x19;
1568 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001569}
1570
1571static void alc889_intel_init_hook(struct hda_codec *codec)
1572{
1573 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001574 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001575}
1576
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001577static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001578{
1579 struct alc_spec *spec = codec->spec;
1580
1581 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1582 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1583 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1584 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001585}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001586
1587/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001588 * ALC888 Acer Aspire 4930G model
1589 */
1590
1591static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1592/* Front Mic: set to PIN_IN (empty by default) */
1593 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1594/* Unselect Front Mic by default in input mixer 3 */
1595 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001596/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001597 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1598/* Connect Internal HP to front */
1599 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1600 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1601 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1602/* Connect HP out to front */
1603 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1604 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1605 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1606 { }
1607};
1608
Hector Martin3b315d72009-06-02 10:54:19 +02001609/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001610 * ALC888 Acer Aspire 6530G model
1611 */
1612
1613static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1614/* Bias voltage on for external mic port */
1615 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001616/* Front Mic: set to PIN_IN (empty by default) */
1617 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1618/* Unselect Front Mic by default in input mixer 3 */
1619 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001620/* Enable unsolicited event for HP jack */
1621 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1622/* Enable speaker output */
1623 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1624 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1625/* Enable headphone output */
1626 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1627 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1628 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1629 { }
1630};
1631
1632/*
Hector Martin018df412009-06-04 00:13:40 +02001633 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001634 */
1635
Hector Martin018df412009-06-04 00:13:40 +02001636static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001637/* Front Mic: set to PIN_IN (empty by default) */
1638 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1639/* Unselect Front Mic by default in input mixer 3 */
1640 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1641/* Enable unsolicited event for HP jack */
1642 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1643/* Connect Internal Front to Front */
1644 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1645 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1646 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1647/* Connect Internal Rear to Rear */
1648 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1649 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1650 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1651/* Connect Internal CLFE to CLFE */
1652 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1653 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1654 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1655/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001656 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001657 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1658 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1659/* Enable all DACs */
1660/* DAC DISABLE/MUTE 1? */
1661/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1662 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1663 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1664/* DAC DISABLE/MUTE 2? */
1665/* some bit here disables the other DACs. Init=0x4900 */
1666 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1667 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1668/* Enable amplifiers */
1669 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1670 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
Hector Martin018df412009-06-04 00:13:40 +02001671/* DMIC fix
1672 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1673 * which makes the stereo useless. However, either the mic or the ALC889
1674 * makes the signal become a difference/sum signal instead of standard
1675 * stereo, which is annoying. So instead we flip this bit which makes the
1676 * codec replicate the sum signal to both channels, turning it into a
1677 * normal mono mic.
1678 */
1679/* DMIC_CONTROL? Init value = 0x0001 */
1680 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1681 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001682 { }
1683};
1684
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001685static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001686 /* Front mic only available on one ADC */
1687 {
1688 .num_items = 4,
1689 .items = {
1690 { "Mic", 0x0 },
1691 { "Line", 0x2 },
1692 { "CD", 0x4 },
1693 { "Front Mic", 0xb },
1694 },
1695 },
1696 {
1697 .num_items = 3,
1698 .items = {
1699 { "Mic", 0x0 },
1700 { "Line", 0x2 },
1701 { "CD", 0x4 },
1702 },
1703 }
1704};
1705
Tony Vroond2fd4b02009-06-21 00:40:10 +01001706static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1707 /* Interal mic only available on one ADC */
1708 {
Tony Vroon684a8842009-06-26 09:27:50 +01001709 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001710 .items = {
1711 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001712 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001713 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001714 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001715 { "Int Mic", 0xb },
1716 },
1717 },
1718 {
Tony Vroon684a8842009-06-26 09:27:50 +01001719 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001720 .items = {
1721 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001722 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001723 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001724 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001725 },
1726 }
1727};
1728
Hector Martin018df412009-06-04 00:13:40 +02001729static struct hda_input_mux alc889_capture_sources[3] = {
1730 /* Digital mic only available on first "ADC" */
1731 {
1732 .num_items = 5,
1733 .items = {
1734 { "Mic", 0x0 },
1735 { "Line", 0x2 },
1736 { "CD", 0x4 },
1737 { "Front Mic", 0xb },
1738 { "Input Mix", 0xa },
1739 },
1740 },
1741 {
1742 .num_items = 4,
1743 .items = {
1744 { "Mic", 0x0 },
1745 { "Line", 0x2 },
1746 { "CD", 0x4 },
1747 { "Input Mix", 0xa },
1748 },
1749 },
1750 {
1751 .num_items = 4,
1752 .items = {
1753 { "Mic", 0x0 },
1754 { "Line", 0x2 },
1755 { "CD", 0x4 },
1756 { "Input Mix", 0xa },
1757 },
1758 }
1759};
1760
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001761static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001762 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1763 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1764 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1765 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1766 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1767 HDA_OUTPUT),
1768 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1769 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1770 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1771 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1772 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1773 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1774 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1775 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1776 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1777 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1778 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1779 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001780 { } /* end */
1781};
1782
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001783static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001784{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001785 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001786
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001787 spec->autocfg.hp_pins[0] = 0x15;
1788 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01001789 spec->autocfg.speaker_pins[1] = 0x16;
1790 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001791}
1792
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001793static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001794{
1795 struct alc_spec *spec = codec->spec;
1796
1797 spec->autocfg.hp_pins[0] = 0x15;
1798 spec->autocfg.speaker_pins[0] = 0x14;
1799 spec->autocfg.speaker_pins[1] = 0x16;
1800 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001801}
1802
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001803static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001804{
1805 struct alc_spec *spec = codec->spec;
1806
1807 spec->autocfg.hp_pins[0] = 0x15;
1808 spec->autocfg.speaker_pins[0] = 0x14;
1809 spec->autocfg.speaker_pins[1] = 0x16;
1810 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001811}
1812
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001813/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001814 * ALC880 3-stack model
1815 *
1816 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001817 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1818 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001819 */
1820
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001821static hda_nid_t alc880_dac_nids[4] = {
1822 /* front, rear, clfe, rear_surr */
1823 0x02, 0x05, 0x04, 0x03
1824};
1825
1826static hda_nid_t alc880_adc_nids[3] = {
1827 /* ADC0-2 */
1828 0x07, 0x08, 0x09,
1829};
1830
1831/* The datasheet says the node 0x07 is connected from inputs,
1832 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001833 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001834 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001835static hda_nid_t alc880_adc_nids_alt[2] = {
1836 /* ADC1-2 */
1837 0x08, 0x09,
1838};
1839
1840#define ALC880_DIGOUT_NID 0x06
1841#define ALC880_DIGIN_NID 0x0a
1842
1843static struct hda_input_mux alc880_capture_source = {
1844 .num_items = 4,
1845 .items = {
1846 { "Mic", 0x0 },
1847 { "Front Mic", 0x3 },
1848 { "Line", 0x2 },
1849 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001850 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001851};
1852
1853/* channel source setting (2/6 channel selection for 3-stack) */
1854/* 2ch mode */
1855static struct hda_verb alc880_threestack_ch2_init[] = {
1856 /* set line-in to input, mute it */
1857 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1858 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1859 /* set mic-in to input vref 80%, mute it */
1860 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1861 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001862 { } /* end */
1863};
1864
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001865/* 6ch mode */
1866static struct hda_verb alc880_threestack_ch6_init[] = {
1867 /* set line-in to output, unmute it */
1868 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1869 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1870 /* set mic-in to output, unmute it */
1871 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1872 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1873 { } /* end */
1874};
1875
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001876static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001877 { 2, alc880_threestack_ch2_init },
1878 { 6, alc880_threestack_ch6_init },
1879};
1880
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001881static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001882 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001883 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001884 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001885 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001886 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1887 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001888 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1889 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001890 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1891 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1892 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1893 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1894 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1895 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1896 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1897 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001898 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001899 {
1900 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1901 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001902 .info = alc_ch_mode_info,
1903 .get = alc_ch_mode_get,
1904 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001905 },
1906 { } /* end */
1907};
1908
1909/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001910static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1911 struct snd_ctl_elem_info *uinfo)
1912{
1913 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1914 struct alc_spec *spec = codec->spec;
1915 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001916
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001917 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001918 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1919 HDA_INPUT);
1920 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001921 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001922 return err;
1923}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001924
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001925static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1926 unsigned int size, unsigned int __user *tlv)
1927{
1928 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1929 struct alc_spec *spec = codec->spec;
1930 int err;
1931
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001932 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001933 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1934 HDA_INPUT);
1935 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001936 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001937 return err;
1938}
1939
1940typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1941 struct snd_ctl_elem_value *ucontrol);
1942
1943static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1944 struct snd_ctl_elem_value *ucontrol,
1945 getput_call_t func)
1946{
1947 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1948 struct alc_spec *spec = codec->spec;
1949 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1950 int err;
1951
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001952 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001953 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1954 3, 0, HDA_INPUT);
1955 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001956 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001957 return err;
1958}
1959
1960static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1961 struct snd_ctl_elem_value *ucontrol)
1962{
1963 return alc_cap_getput_caller(kcontrol, ucontrol,
1964 snd_hda_mixer_amp_volume_get);
1965}
1966
1967static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1968 struct snd_ctl_elem_value *ucontrol)
1969{
1970 return alc_cap_getput_caller(kcontrol, ucontrol,
1971 snd_hda_mixer_amp_volume_put);
1972}
1973
1974/* capture mixer elements */
1975#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1976
1977static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1978 struct snd_ctl_elem_value *ucontrol)
1979{
1980 return alc_cap_getput_caller(kcontrol, ucontrol,
1981 snd_hda_mixer_amp_switch_get);
1982}
1983
1984static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1985 struct snd_ctl_elem_value *ucontrol)
1986{
1987 return alc_cap_getput_caller(kcontrol, ucontrol,
1988 snd_hda_mixer_amp_switch_put);
1989}
1990
Takashi Iwaia23b6882009-03-23 15:21:36 +01001991#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001992 { \
1993 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1994 .name = "Capture Switch", \
1995 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1996 .count = num, \
1997 .info = alc_cap_sw_info, \
1998 .get = alc_cap_sw_get, \
1999 .put = alc_cap_sw_put, \
2000 }, \
2001 { \
2002 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2003 .name = "Capture Volume", \
2004 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2005 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2006 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2007 .count = num, \
2008 .info = alc_cap_vol_info, \
2009 .get = alc_cap_vol_get, \
2010 .put = alc_cap_vol_put, \
2011 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002012 }
2013
2014#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002015 { \
2016 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2017 /* .name = "Capture Source", */ \
2018 .name = "Input Source", \
2019 .count = num, \
2020 .info = alc_mux_enum_info, \
2021 .get = alc_mux_enum_get, \
2022 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002023 }
2024
2025#define DEFINE_CAPMIX(num) \
2026static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2027 _DEFINE_CAPMIX(num), \
2028 _DEFINE_CAPSRC(num), \
2029 { } /* end */ \
2030}
2031
2032#define DEFINE_CAPMIX_NOSRC(num) \
2033static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2034 _DEFINE_CAPMIX(num), \
2035 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002036}
2037
2038/* up to three ADCs */
2039DEFINE_CAPMIX(1);
2040DEFINE_CAPMIX(2);
2041DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002042DEFINE_CAPMIX_NOSRC(1);
2043DEFINE_CAPMIX_NOSRC(2);
2044DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002045
2046/*
2047 * ALC880 5-stack model
2048 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002049 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2050 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002051 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2052 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2053 */
2054
2055/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002056static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002057 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002058 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002059 { } /* end */
2060};
2061
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002062/* channel source setting (6/8 channel selection for 5-stack) */
2063/* 6ch mode */
2064static struct hda_verb alc880_fivestack_ch6_init[] = {
2065 /* set line-in to input, mute it */
2066 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2067 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002068 { } /* end */
2069};
2070
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002071/* 8ch mode */
2072static struct hda_verb alc880_fivestack_ch8_init[] = {
2073 /* set line-in to output, unmute it */
2074 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2075 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2076 { } /* end */
2077};
2078
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002079static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002080 { 6, alc880_fivestack_ch6_init },
2081 { 8, alc880_fivestack_ch8_init },
2082};
2083
2084
2085/*
2086 * ALC880 6-stack model
2087 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002088 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2089 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002090 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2091 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2092 */
2093
2094static hda_nid_t alc880_6st_dac_nids[4] = {
2095 /* front, rear, clfe, rear_surr */
2096 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002097};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002098
2099static struct hda_input_mux alc880_6stack_capture_source = {
2100 .num_items = 4,
2101 .items = {
2102 { "Mic", 0x0 },
2103 { "Front Mic", 0x1 },
2104 { "Line", 0x2 },
2105 { "CD", 0x4 },
2106 },
2107};
2108
2109/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002110static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002111 { 8, NULL },
2112};
2113
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002114static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002115 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002116 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002117 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002118 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002119 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2120 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002121 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2122 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002123 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002124 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002125 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2126 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2127 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2128 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2129 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2130 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2131 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2132 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002133 {
2134 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2135 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002136 .info = alc_ch_mode_info,
2137 .get = alc_ch_mode_get,
2138 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002139 },
2140 { } /* end */
2141};
2142
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002143
2144/*
2145 * ALC880 W810 model
2146 *
2147 * W810 has rear IO for:
2148 * Front (DAC 02)
2149 * Surround (DAC 03)
2150 * Center/LFE (DAC 04)
2151 * Digital out (06)
2152 *
2153 * The system also has a pair of internal speakers, and a headphone jack.
2154 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002155 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002156 * There is a variable resistor to control the speaker or headphone
2157 * volume. This is a hardware-only device without a software API.
2158 *
2159 * Plugging headphones in will disable the internal speakers. This is
2160 * implemented in hardware, not via the driver using jack sense. In
2161 * a similar fashion, plugging into the rear socket marked "front" will
2162 * disable both the speakers and headphones.
2163 *
2164 * For input, there's a microphone jack, and an "audio in" jack.
2165 * These may not do anything useful with this driver yet, because I
2166 * haven't setup any initialization verbs for these yet...
2167 */
2168
2169static hda_nid_t alc880_w810_dac_nids[3] = {
2170 /* front, rear/surround, clfe */
2171 0x02, 0x03, 0x04
2172};
2173
2174/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002175static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002176 { 6, NULL }
2177};
2178
2179/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002180static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002181 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002182 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002183 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002184 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002185 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2186 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002187 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2188 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002189 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2190 { } /* end */
2191};
2192
2193
2194/*
2195 * Z710V model
2196 *
2197 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002198 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2199 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002200 */
2201
2202static hda_nid_t alc880_z71v_dac_nids[1] = {
2203 0x02
2204};
2205#define ALC880_Z71V_HP_DAC 0x03
2206
2207/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002208static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002209 { 2, NULL }
2210};
2211
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002212static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002213 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002214 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002215 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002216 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002217 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2218 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2219 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2220 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2221 { } /* end */
2222};
2223
2224
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002225/*
2226 * ALC880 F1734 model
2227 *
2228 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2229 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2230 */
2231
2232static hda_nid_t alc880_f1734_dac_nids[1] = {
2233 0x03
2234};
2235#define ALC880_F1734_HP_DAC 0x02
2236
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002237static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002238 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002239 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002240 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2241 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002242 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2243 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002244 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2245 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002246 { } /* end */
2247};
2248
Takashi Iwai937b4162008-02-11 14:52:36 +01002249static struct hda_input_mux alc880_f1734_capture_source = {
2250 .num_items = 2,
2251 .items = {
2252 { "Mic", 0x1 },
2253 { "CD", 0x4 },
2254 },
2255};
2256
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002257
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002258/*
2259 * ALC880 ASUS model
2260 *
2261 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2262 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2263 * Mic = 0x18, Line = 0x1a
2264 */
2265
2266#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2267#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2268
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002269static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002270 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002271 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002272 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002273 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002274 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2275 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002276 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2277 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002278 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2279 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2280 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2281 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2282 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2283 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002284 {
2285 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2286 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002287 .info = alc_ch_mode_info,
2288 .get = alc_ch_mode_get,
2289 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002290 },
2291 { } /* end */
2292};
2293
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002294/*
2295 * ALC880 ASUS W1V model
2296 *
2297 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2298 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2299 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2300 */
2301
2302/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002303static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002304 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2305 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002306 { } /* end */
2307};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002308
Kailang Yangdf694da2005-12-05 19:42:22 +01002309/* TCL S700 */
2310static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2311 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2312 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2313 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2314 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2315 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2316 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2317 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2318 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2319 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002320 { } /* end */
2321};
2322
Kailang Yangccc656c2006-10-17 12:32:26 +02002323/* Uniwill */
2324static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002325 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2326 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2327 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2328 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002329 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2330 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2331 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2332 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2333 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2334 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2335 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2336 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2337 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2338 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2339 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2340 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002341 {
2342 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2343 .name = "Channel Mode",
2344 .info = alc_ch_mode_info,
2345 .get = alc_ch_mode_get,
2346 .put = alc_ch_mode_put,
2347 },
2348 { } /* end */
2349};
2350
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002351static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2352 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2353 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2354 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2355 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2356 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2357 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2358 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2359 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2360 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2361 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2362 { } /* end */
2363};
2364
Kailang Yangccc656c2006-10-17 12:32:26 +02002365static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002366 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2367 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2368 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2369 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002370 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2371 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2372 { } /* end */
2373};
2374
Linus Torvalds1da177e2005-04-16 15:20:36 -07002375/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002376 * virtual master controls
2377 */
2378
2379/*
2380 * slave controls for virtual master
2381 */
2382static const char *alc_slave_vols[] = {
2383 "Front Playback Volume",
2384 "Surround Playback Volume",
2385 "Center Playback Volume",
2386 "LFE Playback Volume",
2387 "Side Playback Volume",
2388 "Headphone Playback Volume",
2389 "Speaker Playback Volume",
2390 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002391 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002392 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002393 NULL,
2394};
2395
2396static const char *alc_slave_sws[] = {
2397 "Front Playback Switch",
2398 "Surround Playback Switch",
2399 "Center Playback Switch",
2400 "LFE Playback Switch",
2401 "Side Playback Switch",
2402 "Headphone Playback Switch",
2403 "Speaker Playback Switch",
2404 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002405 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002406 "Line-Out Playback Switch",
2407 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002408 NULL,
2409};
2410
2411/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002412 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002413 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002414
2415static void alc_free_kctls(struct hda_codec *codec);
2416
Takashi Iwai67d634c2009-11-16 15:35:59 +01002417#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002418/* additional beep mixers; the actual parameters are overwritten at build */
2419static struct snd_kcontrol_new alc_beep_mixer[] = {
2420 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002421 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002422 { } /* end */
2423};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002424#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002425
Linus Torvalds1da177e2005-04-16 15:20:36 -07002426static int alc_build_controls(struct hda_codec *codec)
2427{
2428 struct alc_spec *spec = codec->spec;
2429 int err;
2430 int i;
2431
2432 for (i = 0; i < spec->num_mixers; i++) {
2433 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2434 if (err < 0)
2435 return err;
2436 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002437 if (spec->cap_mixer) {
2438 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2439 if (err < 0)
2440 return err;
2441 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002442 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002443 err = snd_hda_create_spdif_out_ctls(codec,
2444 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002445 if (err < 0)
2446 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002447 if (!spec->no_analog) {
2448 err = snd_hda_create_spdif_share_sw(codec,
2449 &spec->multiout);
2450 if (err < 0)
2451 return err;
2452 spec->multiout.share_spdif = 1;
2453 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002454 }
2455 if (spec->dig_in_nid) {
2456 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2457 if (err < 0)
2458 return err;
2459 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002460
Takashi Iwai67d634c2009-11-16 15:35:59 +01002461#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002462 /* create beep controls if needed */
2463 if (spec->beep_amp) {
2464 struct snd_kcontrol_new *knew;
2465 for (knew = alc_beep_mixer; knew->name; knew++) {
2466 struct snd_kcontrol *kctl;
2467 kctl = snd_ctl_new1(knew, codec);
2468 if (!kctl)
2469 return -ENOMEM;
2470 kctl->private_value = spec->beep_amp;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01002471 err = snd_hda_ctl_add(codec,
2472 get_amp_nid_(spec->beep_amp), kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002473 if (err < 0)
2474 return err;
2475 }
2476 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002477#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002478
Takashi Iwai2134ea42008-01-10 16:53:55 +01002479 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002480 if (!spec->no_analog &&
2481 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002482 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002483 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002484 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002485 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002486 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002487 if (err < 0)
2488 return err;
2489 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002490 if (!spec->no_analog &&
2491 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002492 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2493 NULL, alc_slave_sws);
2494 if (err < 0)
2495 return err;
2496 }
2497
Takashi Iwai603c4012008-07-30 15:01:44 +02002498 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002499 return 0;
2500}
2501
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002502
Linus Torvalds1da177e2005-04-16 15:20:36 -07002503/*
2504 * initialize the codec volumes, etc
2505 */
2506
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002507/*
2508 * generic initialization of ADC, input mixers and output mixers
2509 */
2510static struct hda_verb alc880_volume_init_verbs[] = {
2511 /*
2512 * Unmute ADC0-2 and set the default input to mic-in
2513 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002514 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002515 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002516 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002517 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002518 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002519 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002520
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002521 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2522 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002523 * Note: PASD motherboards uses the Line In 2 as the input for front
2524 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002525 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002526 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002527 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2528 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2529 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2530 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2531 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2532 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2533 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002534
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002535 /*
2536 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002537 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002538 /* set vol=0 to output mixers */
2539 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2540 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2541 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2542 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2543 /* set up input amps for analog loopback */
2544 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002545 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2546 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002547 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2548 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002549 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2550 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002551 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2552 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002553
2554 { }
2555};
2556
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002557/*
2558 * 3-stack pin configuration:
2559 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2560 */
2561static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2562 /*
2563 * preset connection lists of input pins
2564 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2565 */
2566 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2567 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2568 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2569
2570 /*
2571 * Set pin mode and muting
2572 */
2573 /* set front pin widgets 0x14 for output */
2574 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2575 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2576 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2577 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2578 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2579 /* Mic2 (as headphone out) for HP output */
2580 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2581 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2582 /* Line In pin widget for input */
2583 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2584 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2585 /* Line2 (as front mic) pin widget for input and vref at 80% */
2586 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2587 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2588 /* CD pin widget for input */
2589 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2590
2591 { }
2592};
2593
2594/*
2595 * 5-stack pin configuration:
2596 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2597 * line-in/side = 0x1a, f-mic = 0x1b
2598 */
2599static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2600 /*
2601 * preset connection lists of input pins
2602 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2603 */
2604 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2605 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2606
2607 /*
2608 * Set pin mode and muting
2609 */
2610 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002611 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2612 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2613 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2614 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002615 /* unmute pins for output (no gain on this amp) */
2616 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2617 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2618 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2619 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2620
Linus Torvalds1da177e2005-04-16 15:20:36 -07002621 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002622 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002623 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2624 /* Mic2 (as headphone out) for HP output */
2625 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002626 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002627 /* Line In pin widget for input */
2628 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2629 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2630 /* Line2 (as front mic) pin widget for input and vref at 80% */
2631 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2632 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2633 /* CD pin widget for input */
2634 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002635
2636 { }
2637};
2638
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002639/*
2640 * W810 pin configuration:
2641 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2642 */
2643static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002644 /* hphone/speaker input selector: front DAC */
2645 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2646
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002647 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2648 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2649 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2650 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2651 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2652 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2653
2654 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002655 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002656
Linus Torvalds1da177e2005-04-16 15:20:36 -07002657 { }
2658};
2659
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002660/*
2661 * Z71V pin configuration:
2662 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2663 */
2664static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002665 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002666 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002667 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002668 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002669
Takashi Iwai16ded522005-06-10 19:58:24 +02002670 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002671 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002672 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002673 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002674
2675 { }
2676};
2677
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002678/*
2679 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002680 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2681 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002682 */
2683static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2684 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2685
Takashi Iwai16ded522005-06-10 19:58:24 +02002686 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002687 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002688 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002689 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002690 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002691 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002692 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002693 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2694
Takashi Iwai16ded522005-06-10 19:58:24 +02002695 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002696 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002697 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002698 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002699 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002700 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002701 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002702 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002703 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002704
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002705 { }
2706};
Takashi Iwai16ded522005-06-10 19:58:24 +02002707
Kailang Yangccc656c2006-10-17 12:32:26 +02002708/*
2709 * Uniwill pin configuration:
2710 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2711 * line = 0x1a
2712 */
2713static struct hda_verb alc880_uniwill_init_verbs[] = {
2714 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2715
2716 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2717 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2718 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2719 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2720 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2721 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2722 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2723 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2724 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2725 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2726 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2727 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2728 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2729 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2730
2731 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2732 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2733 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2734 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2735 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2736 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2737 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2738 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2739 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2740
2741 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2742 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2743
2744 { }
2745};
2746
2747/*
2748* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002749* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002750 */
2751static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2752 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2753
2754 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2755 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2756 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2757 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2758 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2759 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2760 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2761 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2762 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2763 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2764 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2765 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2766
2767 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2768 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2769 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2770 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2771 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2772 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2773
2774 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2775 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2776
2777 { }
2778};
2779
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002780static struct hda_verb alc880_beep_init_verbs[] = {
2781 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2782 { }
2783};
2784
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002785/* auto-toggle front mic */
2786static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2787{
2788 unsigned int present;
2789 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002790
Wu Fengguang864f92b2009-11-18 12:38:02 +08002791 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002792 bits = present ? HDA_AMP_MUTE : 0;
2793 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002794}
2795
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002796static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002797{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002798 struct alc_spec *spec = codec->spec;
2799
2800 spec->autocfg.hp_pins[0] = 0x14;
2801 spec->autocfg.speaker_pins[0] = 0x15;
2802 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002803}
2804
2805static void alc880_uniwill_init_hook(struct hda_codec *codec)
2806{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002807 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002808 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002809}
2810
2811static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2812 unsigned int res)
2813{
2814 /* Looks like the unsol event is incompatible with the standard
2815 * definition. 4bit tag is placed at 28 bit!
2816 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002817 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002818 case ALC880_MIC_EVENT:
2819 alc880_uniwill_mic_automute(codec);
2820 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002821 default:
2822 alc_automute_amp_unsol_event(codec, res);
2823 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002824 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002825}
2826
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002827static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002828{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002829 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002830
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002831 spec->autocfg.hp_pins[0] = 0x14;
2832 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02002833}
2834
2835static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2836{
2837 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002838
Kailang Yangccc656c2006-10-17 12:32:26 +02002839 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002840 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2841 present &= HDA_AMP_VOLMASK;
2842 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2843 HDA_AMP_VOLMASK, present);
2844 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2845 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002846}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002847
Kailang Yangccc656c2006-10-17 12:32:26 +02002848static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2849 unsigned int res)
2850{
2851 /* Looks like the unsol event is incompatible with the standard
2852 * definition. 4bit tag is placed at 28 bit!
2853 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002854 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002855 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002856 else
2857 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002858}
2859
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002860/*
2861 * F1734 pin configuration:
2862 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2863 */
2864static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002865 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002866 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2867 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2868 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2869 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2870
2871 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2872 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2873 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2874 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2875
2876 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2877 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002878 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002879 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2880 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2881 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2882 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2883 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2884 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002885
Takashi Iwai937b4162008-02-11 14:52:36 +01002886 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2887 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2888
Takashi Iwai16ded522005-06-10 19:58:24 +02002889 { }
2890};
2891
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002892/*
2893 * ASUS pin configuration:
2894 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2895 */
2896static struct hda_verb alc880_pin_asus_init_verbs[] = {
2897 {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 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2906 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2907 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2908 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2909 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2910
2911 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2912 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2913 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2914 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2915 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2916 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2917 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2918 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2919 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002920
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002921 { }
2922};
2923
2924/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002925#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2926#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02002927#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002928
Kailang Yangdf694da2005-12-05 19:42:22 +01002929/* Clevo m520g init */
2930static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2931 /* headphone output */
2932 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2933 /* line-out */
2934 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2935 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2936 /* Line-in */
2937 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2938 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2939 /* CD */
2940 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2941 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2942 /* Mic1 (rear panel) */
2943 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2944 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2945 /* Mic2 (front panel) */
2946 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2947 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2948 /* headphone */
2949 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2950 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2951 /* change to EAPD mode */
2952 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2953 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2954
2955 { }
2956};
2957
2958static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002959 /* change to EAPD mode */
2960 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2961 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2962
Kailang Yangdf694da2005-12-05 19:42:22 +01002963 /* Headphone output */
2964 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2965 /* Front output*/
2966 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2967 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2968
2969 /* Line In pin widget for input */
2970 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2971 /* CD pin widget for input */
2972 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2973 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2974 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2975
2976 /* change to EAPD mode */
2977 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2978 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2979
2980 { }
2981};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002982
2983/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002984 * LG m1 express dual
2985 *
2986 * Pin assignment:
2987 * Rear Line-In/Out (blue): 0x14
2988 * Build-in Mic-In: 0x15
2989 * Speaker-out: 0x17
2990 * HP-Out (green): 0x1b
2991 * Mic-In/Out (red): 0x19
2992 * SPDIF-Out: 0x1e
2993 */
2994
2995/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2996static hda_nid_t alc880_lg_dac_nids[3] = {
2997 0x05, 0x02, 0x03
2998};
2999
3000/* seems analog CD is not working */
3001static struct hda_input_mux alc880_lg_capture_source = {
3002 .num_items = 3,
3003 .items = {
3004 { "Mic", 0x1 },
3005 { "Line", 0x5 },
3006 { "Internal Mic", 0x6 },
3007 },
3008};
3009
3010/* 2,4,6 channel modes */
3011static struct hda_verb alc880_lg_ch2_init[] = {
3012 /* set line-in and mic-in to input */
3013 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3014 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3015 { }
3016};
3017
3018static struct hda_verb alc880_lg_ch4_init[] = {
3019 /* set line-in to out and mic-in to input */
3020 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3021 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3022 { }
3023};
3024
3025static struct hda_verb alc880_lg_ch6_init[] = {
3026 /* set line-in and mic-in to output */
3027 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3028 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3029 { }
3030};
3031
3032static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3033 { 2, alc880_lg_ch2_init },
3034 { 4, alc880_lg_ch4_init },
3035 { 6, alc880_lg_ch6_init },
3036};
3037
3038static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003039 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3040 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003041 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3042 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3043 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3044 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3045 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3046 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3047 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3048 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3049 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3050 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3051 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3052 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3053 {
3054 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3055 .name = "Channel Mode",
3056 .info = alc_ch_mode_info,
3057 .get = alc_ch_mode_get,
3058 .put = alc_ch_mode_put,
3059 },
3060 { } /* end */
3061};
3062
3063static struct hda_verb alc880_lg_init_verbs[] = {
3064 /* set capture source to mic-in */
3065 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3066 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3067 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3068 /* mute all amp mixer inputs */
3069 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003070 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3071 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003072 /* line-in to input */
3073 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3074 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3075 /* built-in mic */
3076 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3077 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3078 /* speaker-out */
3079 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3080 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3081 /* mic-in to input */
3082 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3083 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3084 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3085 /* HP-out */
3086 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3087 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3088 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3089 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003090 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003091 { }
3092};
3093
3094/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003095static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003096{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003097 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003098
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003099 spec->autocfg.hp_pins[0] = 0x1b;
3100 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003101}
3102
3103/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003104 * LG LW20
3105 *
3106 * Pin assignment:
3107 * Speaker-out: 0x14
3108 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003109 * Built-in Mic-In: 0x19
3110 * Line-In: 0x1b
3111 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003112 * SPDIF-Out: 0x1e
3113 */
3114
Takashi Iwaid6815182006-03-23 16:06:23 +01003115static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003116 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003117 .items = {
3118 { "Mic", 0x0 },
3119 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003120 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003121 },
3122};
3123
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003124#define alc880_lg_lw_modes alc880_threestack_modes
3125
Takashi Iwaid6815182006-03-23 16:06:23 +01003126static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003127 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3128 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3129 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3130 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3131 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3132 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3133 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3134 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3135 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3136 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003137 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3138 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3139 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3140 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003141 {
3142 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3143 .name = "Channel Mode",
3144 .info = alc_ch_mode_info,
3145 .get = alc_ch_mode_get,
3146 .put = alc_ch_mode_put,
3147 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003148 { } /* end */
3149};
3150
3151static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003152 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3153 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3154 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3155
Takashi Iwaid6815182006-03-23 16:06:23 +01003156 /* set capture source to mic-in */
3157 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3158 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3159 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003160 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003161 /* speaker-out */
3162 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3163 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3164 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003165 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3166 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3167 /* mic-in to input */
3168 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3169 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3170 /* built-in mic */
3171 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3172 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3173 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003174 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003175 { }
3176};
3177
3178/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003179static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003180{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003181 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003182
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003183 spec->autocfg.hp_pins[0] = 0x1b;
3184 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003185}
3186
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003187static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3188 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3189 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3190 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3191 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3192 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3193 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3194 { } /* end */
3195};
3196
3197static struct hda_input_mux alc880_medion_rim_capture_source = {
3198 .num_items = 2,
3199 .items = {
3200 { "Mic", 0x0 },
3201 { "Internal Mic", 0x1 },
3202 },
3203};
3204
3205static struct hda_verb alc880_medion_rim_init_verbs[] = {
3206 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3207
3208 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3209 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3210
3211 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3212 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3213 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3214 /* Mic2 (as headphone out) for HP output */
3215 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3216 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3217 /* Internal Speaker */
3218 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3219 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3220
3221 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3222 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3223
3224 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3225 { }
3226};
3227
3228/* toggle speaker-output according to the hp-jack state */
3229static void alc880_medion_rim_automute(struct hda_codec *codec)
3230{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003231 struct alc_spec *spec = codec->spec;
3232 alc_automute_amp(codec);
3233 /* toggle EAPD */
3234 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003235 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3236 else
3237 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3238}
3239
3240static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3241 unsigned int res)
3242{
3243 /* Looks like the unsol event is incompatible with the standard
3244 * definition. 4bit tag is placed at 28 bit!
3245 */
3246 if ((res >> 28) == ALC880_HP_EVENT)
3247 alc880_medion_rim_automute(codec);
3248}
3249
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003250static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003251{
3252 struct alc_spec *spec = codec->spec;
3253
3254 spec->autocfg.hp_pins[0] = 0x14;
3255 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003256}
3257
Takashi Iwaicb53c622007-08-10 17:21:45 +02003258#ifdef CONFIG_SND_HDA_POWER_SAVE
3259static struct hda_amp_list alc880_loopbacks[] = {
3260 { 0x0b, HDA_INPUT, 0 },
3261 { 0x0b, HDA_INPUT, 1 },
3262 { 0x0b, HDA_INPUT, 2 },
3263 { 0x0b, HDA_INPUT, 3 },
3264 { 0x0b, HDA_INPUT, 4 },
3265 { } /* end */
3266};
3267
3268static struct hda_amp_list alc880_lg_loopbacks[] = {
3269 { 0x0b, HDA_INPUT, 1 },
3270 { 0x0b, HDA_INPUT, 6 },
3271 { 0x0b, HDA_INPUT, 7 },
3272 { } /* end */
3273};
3274#endif
3275
Takashi Iwaid6815182006-03-23 16:06:23 +01003276/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003277 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003278 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003279
Linus Torvalds1da177e2005-04-16 15:20:36 -07003280static int alc_init(struct hda_codec *codec)
3281{
3282 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003283 unsigned int i;
3284
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003285 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003286 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003287
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003288 for (i = 0; i < spec->num_init_verbs; i++)
3289 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003290
3291 if (spec->init_hook)
3292 spec->init_hook(codec);
3293
Linus Torvalds1da177e2005-04-16 15:20:36 -07003294 return 0;
3295}
3296
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003297static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3298{
3299 struct alc_spec *spec = codec->spec;
3300
3301 if (spec->unsol_event)
3302 spec->unsol_event(codec, res);
3303}
3304
Takashi Iwaicb53c622007-08-10 17:21:45 +02003305#ifdef CONFIG_SND_HDA_POWER_SAVE
3306static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3307{
3308 struct alc_spec *spec = codec->spec;
3309 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3310}
3311#endif
3312
Linus Torvalds1da177e2005-04-16 15:20:36 -07003313/*
3314 * Analog playback callbacks
3315 */
3316static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3317 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003318 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003319{
3320 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003321 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3322 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003323}
3324
3325static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3326 struct hda_codec *codec,
3327 unsigned int stream_tag,
3328 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003329 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003330{
3331 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003332 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3333 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003334}
3335
3336static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3337 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003338 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003339{
3340 struct alc_spec *spec = codec->spec;
3341 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3342}
3343
3344/*
3345 * Digital out
3346 */
3347static int alc880_dig_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;
3352 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3353}
3354
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003355static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3356 struct hda_codec *codec,
3357 unsigned int stream_tag,
3358 unsigned int format,
3359 struct snd_pcm_substream *substream)
3360{
3361 struct alc_spec *spec = codec->spec;
3362 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3363 stream_tag, format, substream);
3364}
3365
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003366static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3367 struct hda_codec *codec,
3368 struct snd_pcm_substream *substream)
3369{
3370 struct alc_spec *spec = codec->spec;
3371 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3372}
3373
Linus Torvalds1da177e2005-04-16 15:20:36 -07003374static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3375 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003376 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003377{
3378 struct alc_spec *spec = codec->spec;
3379 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3380}
3381
3382/*
3383 * Analog capture
3384 */
Takashi Iwai63300792008-01-24 15:31:36 +01003385static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003386 struct hda_codec *codec,
3387 unsigned int stream_tag,
3388 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003389 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003390{
3391 struct alc_spec *spec = codec->spec;
3392
Takashi Iwai63300792008-01-24 15:31:36 +01003393 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003394 stream_tag, 0, format);
3395 return 0;
3396}
3397
Takashi Iwai63300792008-01-24 15:31:36 +01003398static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003399 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003400 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003401{
3402 struct alc_spec *spec = codec->spec;
3403
Takashi Iwai888afa12008-03-18 09:57:50 +01003404 snd_hda_codec_cleanup_stream(codec,
3405 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003406 return 0;
3407}
3408
3409
3410/*
3411 */
3412static struct hda_pcm_stream alc880_pcm_analog_playback = {
3413 .substreams = 1,
3414 .channels_min = 2,
3415 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003416 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003417 .ops = {
3418 .open = alc880_playback_pcm_open,
3419 .prepare = alc880_playback_pcm_prepare,
3420 .cleanup = alc880_playback_pcm_cleanup
3421 },
3422};
3423
3424static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003425 .substreams = 1,
3426 .channels_min = 2,
3427 .channels_max = 2,
3428 /* NID is set in alc_build_pcms */
3429};
3430
3431static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3432 .substreams = 1,
3433 .channels_min = 2,
3434 .channels_max = 2,
3435 /* NID is set in alc_build_pcms */
3436};
3437
3438static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3439 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003440 .channels_min = 2,
3441 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003442 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003443 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003444 .prepare = alc880_alt_capture_pcm_prepare,
3445 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003446 },
3447};
3448
3449static struct hda_pcm_stream alc880_pcm_digital_playback = {
3450 .substreams = 1,
3451 .channels_min = 2,
3452 .channels_max = 2,
3453 /* NID is set in alc_build_pcms */
3454 .ops = {
3455 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003456 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003457 .prepare = alc880_dig_playback_pcm_prepare,
3458 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003459 },
3460};
3461
3462static struct hda_pcm_stream alc880_pcm_digital_capture = {
3463 .substreams = 1,
3464 .channels_min = 2,
3465 .channels_max = 2,
3466 /* NID is set in alc_build_pcms */
3467};
3468
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003469/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003470static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003471 .substreams = 0,
3472 .channels_min = 0,
3473 .channels_max = 0,
3474};
3475
Linus Torvalds1da177e2005-04-16 15:20:36 -07003476static int alc_build_pcms(struct hda_codec *codec)
3477{
3478 struct alc_spec *spec = codec->spec;
3479 struct hda_pcm *info = spec->pcm_rec;
3480 int i;
3481
3482 codec->num_pcms = 1;
3483 codec->pcm_info = info;
3484
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003485 if (spec->no_analog)
3486 goto skip_analog;
3487
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003488 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3489 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003490 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003491
Takashi Iwai4a471b72005-12-07 13:56:29 +01003492 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003493 if (snd_BUG_ON(!spec->multiout.dac_nids))
3494 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003495 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3496 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3497 }
3498 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003499 if (snd_BUG_ON(!spec->adc_nids))
3500 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003501 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3502 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3503 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003504
Takashi Iwai4a471b72005-12-07 13:56:29 +01003505 if (spec->channel_mode) {
3506 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3507 for (i = 0; i < spec->num_channel_mode; i++) {
3508 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3509 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3510 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003511 }
3512 }
3513
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003514 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003515 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003516 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003517 snprintf(spec->stream_name_digital,
3518 sizeof(spec->stream_name_digital),
3519 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003520 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003521 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003522 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003523 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003524 if (spec->dig_out_type)
3525 info->pcm_type = spec->dig_out_type;
3526 else
3527 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003528 if (spec->multiout.dig_out_nid &&
3529 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003530 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3531 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3532 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003533 if (spec->dig_in_nid &&
3534 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003535 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3536 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3537 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003538 /* FIXME: do we need this for all Realtek codec models? */
3539 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003540 }
3541
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003542 if (spec->no_analog)
3543 return 0;
3544
Takashi Iwaie08a0072006-09-07 17:52:14 +02003545 /* If the use of more than one ADC is requested for the current
3546 * model, configure a second analog capture-only PCM.
3547 */
3548 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003549 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3550 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003551 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003552 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003553 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003554 if (spec->alt_dac_nid) {
3555 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3556 *spec->stream_analog_alt_playback;
3557 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3558 spec->alt_dac_nid;
3559 } else {
3560 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3561 alc_pcm_null_stream;
3562 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3563 }
3564 if (spec->num_adc_nids > 1) {
3565 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3566 *spec->stream_analog_alt_capture;
3567 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3568 spec->adc_nids[1];
3569 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3570 spec->num_adc_nids - 1;
3571 } else {
3572 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3573 alc_pcm_null_stream;
3574 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003575 }
3576 }
3577
Linus Torvalds1da177e2005-04-16 15:20:36 -07003578 return 0;
3579}
3580
Takashi Iwai603c4012008-07-30 15:01:44 +02003581static void alc_free_kctls(struct hda_codec *codec)
3582{
3583 struct alc_spec *spec = codec->spec;
3584
3585 if (spec->kctls.list) {
3586 struct snd_kcontrol_new *kctl = spec->kctls.list;
3587 int i;
3588 for (i = 0; i < spec->kctls.used; i++)
3589 kfree(kctl[i].name);
3590 }
3591 snd_array_free(&spec->kctls);
3592}
3593
Linus Torvalds1da177e2005-04-16 15:20:36 -07003594static void alc_free(struct hda_codec *codec)
3595{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003596 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003597
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003598 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003599 return;
3600
Takashi Iwai603c4012008-07-30 15:01:44 +02003601 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003602 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003603 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003604}
3605
Takashi Iwaie044c392008-10-27 16:56:24 +01003606#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003607static int alc_resume(struct hda_codec *codec)
3608{
Takashi Iwaie044c392008-10-27 16:56:24 +01003609 codec->patch_ops.init(codec);
3610 snd_hda_codec_resume_amp(codec);
3611 snd_hda_codec_resume_cache(codec);
3612 return 0;
3613}
Takashi Iwaie044c392008-10-27 16:56:24 +01003614#endif
3615
Linus Torvalds1da177e2005-04-16 15:20:36 -07003616/*
3617 */
3618static struct hda_codec_ops alc_patch_ops = {
3619 .build_controls = alc_build_controls,
3620 .build_pcms = alc_build_pcms,
3621 .init = alc_init,
3622 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003623 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003624#ifdef SND_HDA_NEEDS_RESUME
3625 .resume = alc_resume,
3626#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003627#ifdef CONFIG_SND_HDA_POWER_SAVE
3628 .check_power_status = alc_check_power_status,
3629#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003630};
3631
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003632
3633/*
3634 * Test configuration for debugging
3635 *
3636 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3637 * enum controls.
3638 */
3639#ifdef CONFIG_SND_DEBUG
3640static hda_nid_t alc880_test_dac_nids[4] = {
3641 0x02, 0x03, 0x04, 0x05
3642};
3643
3644static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003645 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003646 .items = {
3647 { "In-1", 0x0 },
3648 { "In-2", 0x1 },
3649 { "In-3", 0x2 },
3650 { "In-4", 0x3 },
3651 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003652 { "Front", 0x5 },
3653 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003654 },
3655};
3656
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003657static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003658 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003659 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003660 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003661 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003662};
3663
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003664static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3665 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003666{
3667 static char *texts[] = {
3668 "N/A", "Line Out", "HP Out",
3669 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3670 };
3671 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3672 uinfo->count = 1;
3673 uinfo->value.enumerated.items = 8;
3674 if (uinfo->value.enumerated.item >= 8)
3675 uinfo->value.enumerated.item = 7;
3676 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3677 return 0;
3678}
3679
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003680static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3681 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003682{
3683 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3684 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3685 unsigned int pin_ctl, item = 0;
3686
3687 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3688 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3689 if (pin_ctl & AC_PINCTL_OUT_EN) {
3690 if (pin_ctl & AC_PINCTL_HP_EN)
3691 item = 2;
3692 else
3693 item = 1;
3694 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3695 switch (pin_ctl & AC_PINCTL_VREFEN) {
3696 case AC_PINCTL_VREF_HIZ: item = 3; break;
3697 case AC_PINCTL_VREF_50: item = 4; break;
3698 case AC_PINCTL_VREF_GRD: item = 5; break;
3699 case AC_PINCTL_VREF_80: item = 6; break;
3700 case AC_PINCTL_VREF_100: item = 7; break;
3701 }
3702 }
3703 ucontrol->value.enumerated.item[0] = item;
3704 return 0;
3705}
3706
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003707static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3708 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003709{
3710 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3711 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3712 static unsigned int ctls[] = {
3713 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3714 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3715 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3716 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3717 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3718 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3719 };
3720 unsigned int old_ctl, new_ctl;
3721
3722 old_ctl = snd_hda_codec_read(codec, nid, 0,
3723 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3724 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3725 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003726 int val;
3727 snd_hda_codec_write_cache(codec, nid, 0,
3728 AC_VERB_SET_PIN_WIDGET_CONTROL,
3729 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003730 val = ucontrol->value.enumerated.item[0] >= 3 ?
3731 HDA_AMP_MUTE : 0;
3732 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3733 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003734 return 1;
3735 }
3736 return 0;
3737}
3738
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003739static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3740 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003741{
3742 static char *texts[] = {
3743 "Front", "Surround", "CLFE", "Side"
3744 };
3745 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3746 uinfo->count = 1;
3747 uinfo->value.enumerated.items = 4;
3748 if (uinfo->value.enumerated.item >= 4)
3749 uinfo->value.enumerated.item = 3;
3750 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3751 return 0;
3752}
3753
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003754static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3755 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003756{
3757 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3758 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3759 unsigned int sel;
3760
3761 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3762 ucontrol->value.enumerated.item[0] = sel & 3;
3763 return 0;
3764}
3765
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003766static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3767 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003768{
3769 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3770 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3771 unsigned int sel;
3772
3773 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3774 if (ucontrol->value.enumerated.item[0] != sel) {
3775 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003776 snd_hda_codec_write_cache(codec, nid, 0,
3777 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003778 return 1;
3779 }
3780 return 0;
3781}
3782
3783#define PIN_CTL_TEST(xname,nid) { \
3784 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3785 .name = xname, \
3786 .info = alc_test_pin_ctl_info, \
3787 .get = alc_test_pin_ctl_get, \
3788 .put = alc_test_pin_ctl_put, \
3789 .private_value = nid \
3790 }
3791
3792#define PIN_SRC_TEST(xname,nid) { \
3793 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3794 .name = xname, \
3795 .info = alc_test_pin_src_info, \
3796 .get = alc_test_pin_src_get, \
3797 .put = alc_test_pin_src_put, \
3798 .private_value = nid \
3799 }
3800
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003801static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003802 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3803 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3804 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3805 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003806 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3807 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3808 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3809 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003810 PIN_CTL_TEST("Front Pin Mode", 0x14),
3811 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3812 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3813 PIN_CTL_TEST("Side Pin Mode", 0x17),
3814 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3815 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3816 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3817 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3818 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3819 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3820 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3821 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3822 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3823 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3824 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3825 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3826 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3827 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3828 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3829 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3830 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3831 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003832 {
3833 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3834 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003835 .info = alc_ch_mode_info,
3836 .get = alc_ch_mode_get,
3837 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003838 },
3839 { } /* end */
3840};
3841
3842static struct hda_verb alc880_test_init_verbs[] = {
3843 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003844 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3845 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3846 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3847 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3848 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3849 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3850 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3851 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003852 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003853 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3854 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3855 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3856 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003857 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003858 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3859 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3860 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3861 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003862 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003863 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3864 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3865 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3866 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003867 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003868 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3869 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003870 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3871 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3872 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003873 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003874 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3875 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3876 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3877 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003878 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003879 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003880 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003881 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003882 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003883 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003884 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003885 /* Analog input/passthru */
3886 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3887 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3888 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3889 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3890 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003891 { }
3892};
3893#endif
3894
Linus Torvalds1da177e2005-04-16 15:20:36 -07003895/*
3896 */
3897
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003898static const char *alc880_models[ALC880_MODEL_LAST] = {
3899 [ALC880_3ST] = "3stack",
3900 [ALC880_TCL_S700] = "tcl",
3901 [ALC880_3ST_DIG] = "3stack-digout",
3902 [ALC880_CLEVO] = "clevo",
3903 [ALC880_5ST] = "5stack",
3904 [ALC880_5ST_DIG] = "5stack-digout",
3905 [ALC880_W810] = "w810",
3906 [ALC880_Z71V] = "z71v",
3907 [ALC880_6ST] = "6stack",
3908 [ALC880_6ST_DIG] = "6stack-digout",
3909 [ALC880_ASUS] = "asus",
3910 [ALC880_ASUS_W1V] = "asus-w1v",
3911 [ALC880_ASUS_DIG] = "asus-dig",
3912 [ALC880_ASUS_DIG2] = "asus-dig2",
3913 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003914 [ALC880_UNIWILL_P53] = "uniwill-p53",
3915 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003916 [ALC880_F1734] = "F1734",
3917 [ALC880_LG] = "lg",
3918 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003919 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003920#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003921 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003922#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003923 [ALC880_AUTO] = "auto",
3924};
3925
3926static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003927 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003928 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3929 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3930 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3931 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3932 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3933 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3934 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3935 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003936 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3937 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003938 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3939 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3940 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3941 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3942 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3943 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3944 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3945 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3946 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3947 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003948 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003949 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3950 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3951 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003952 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003953 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003954 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3955 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003956 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3957 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003958 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3959 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3960 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3961 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003962 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3963 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003964 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003965 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003966 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003967 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003968 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3969 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003970 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003971 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003972 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003973 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003974 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003975 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003976 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003977 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003978 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003979 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3980 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003981 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003982 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3983 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3984 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3985 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003986 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3987 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003988 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003989 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003990 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3991 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003992 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3993 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3994 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003995 /* default Intel */
3996 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003997 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3998 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003999 {}
4000};
4001
Takashi Iwai16ded522005-06-10 19:58:24 +02004002/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004003 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004004 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004005static struct alc_config_preset alc880_presets[] = {
4006 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004007 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004008 .init_verbs = { alc880_volume_init_verbs,
4009 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004010 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004011 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004012 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4013 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004014 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004015 .input_mux = &alc880_capture_source,
4016 },
4017 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004018 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004019 .init_verbs = { alc880_volume_init_verbs,
4020 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004021 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004022 .dac_nids = alc880_dac_nids,
4023 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004024 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4025 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004026 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004027 .input_mux = &alc880_capture_source,
4028 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004029 [ALC880_TCL_S700] = {
4030 .mixers = { alc880_tcl_s700_mixer },
4031 .init_verbs = { alc880_volume_init_verbs,
4032 alc880_pin_tcl_S700_init_verbs,
4033 alc880_gpio2_init_verbs },
4034 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4035 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004036 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4037 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004038 .hp_nid = 0x03,
4039 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4040 .channel_mode = alc880_2_jack_modes,
4041 .input_mux = &alc880_capture_source,
4042 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004043 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004044 .mixers = { alc880_three_stack_mixer,
4045 alc880_five_stack_mixer},
4046 .init_verbs = { alc880_volume_init_verbs,
4047 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004048 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4049 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004050 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4051 .channel_mode = alc880_fivestack_modes,
4052 .input_mux = &alc880_capture_source,
4053 },
4054 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004055 .mixers = { alc880_three_stack_mixer,
4056 alc880_five_stack_mixer },
4057 .init_verbs = { alc880_volume_init_verbs,
4058 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004059 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4060 .dac_nids = alc880_dac_nids,
4061 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004062 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4063 .channel_mode = alc880_fivestack_modes,
4064 .input_mux = &alc880_capture_source,
4065 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004066 [ALC880_6ST] = {
4067 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004068 .init_verbs = { alc880_volume_init_verbs,
4069 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004070 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4071 .dac_nids = alc880_6st_dac_nids,
4072 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4073 .channel_mode = alc880_sixstack_modes,
4074 .input_mux = &alc880_6stack_capture_source,
4075 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004076 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004077 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004078 .init_verbs = { alc880_volume_init_verbs,
4079 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004080 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4081 .dac_nids = alc880_6st_dac_nids,
4082 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004083 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4084 .channel_mode = alc880_sixstack_modes,
4085 .input_mux = &alc880_6stack_capture_source,
4086 },
4087 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004088 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004089 .init_verbs = { alc880_volume_init_verbs,
4090 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004091 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004092 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4093 .dac_nids = alc880_w810_dac_nids,
4094 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004095 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4096 .channel_mode = alc880_w810_modes,
4097 .input_mux = &alc880_capture_source,
4098 },
4099 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004100 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004101 .init_verbs = { alc880_volume_init_verbs,
4102 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004103 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4104 .dac_nids = alc880_z71v_dac_nids,
4105 .dig_out_nid = ALC880_DIGOUT_NID,
4106 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004107 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4108 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004109 .input_mux = &alc880_capture_source,
4110 },
4111 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004112 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004113 .init_verbs = { alc880_volume_init_verbs,
4114 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004115 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4116 .dac_nids = alc880_f1734_dac_nids,
4117 .hp_nid = 0x02,
4118 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4119 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004120 .input_mux = &alc880_f1734_capture_source,
4121 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004122 .setup = alc880_uniwill_p53_setup,
4123 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004124 },
4125 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004126 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004127 .init_verbs = { alc880_volume_init_verbs,
4128 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004129 alc880_gpio1_init_verbs },
4130 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4131 .dac_nids = alc880_asus_dac_nids,
4132 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4133 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004134 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004135 .input_mux = &alc880_capture_source,
4136 },
4137 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004138 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004139 .init_verbs = { alc880_volume_init_verbs,
4140 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004141 alc880_gpio1_init_verbs },
4142 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4143 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004144 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004145 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4146 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004147 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004148 .input_mux = &alc880_capture_source,
4149 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004150 [ALC880_ASUS_DIG2] = {
4151 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004152 .init_verbs = { alc880_volume_init_verbs,
4153 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004154 alc880_gpio2_init_verbs }, /* use GPIO2 */
4155 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4156 .dac_nids = alc880_asus_dac_nids,
4157 .dig_out_nid = ALC880_DIGOUT_NID,
4158 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4159 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004160 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004161 .input_mux = &alc880_capture_source,
4162 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004163 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004164 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004165 .init_verbs = { alc880_volume_init_verbs,
4166 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004167 alc880_gpio1_init_verbs },
4168 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4169 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004170 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004171 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4172 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004173 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004174 .input_mux = &alc880_capture_source,
4175 },
4176 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004177 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004178 .init_verbs = { alc880_volume_init_verbs,
4179 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004180 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4181 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004182 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004183 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4184 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004185 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004186 .input_mux = &alc880_capture_source,
4187 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004188 [ALC880_UNIWILL] = {
4189 .mixers = { alc880_uniwill_mixer },
4190 .init_verbs = { alc880_volume_init_verbs,
4191 alc880_uniwill_init_verbs },
4192 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4193 .dac_nids = alc880_asus_dac_nids,
4194 .dig_out_nid = ALC880_DIGOUT_NID,
4195 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4196 .channel_mode = alc880_threestack_modes,
4197 .need_dac_fix = 1,
4198 .input_mux = &alc880_capture_source,
4199 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004200 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004201 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004202 },
4203 [ALC880_UNIWILL_P53] = {
4204 .mixers = { alc880_uniwill_p53_mixer },
4205 .init_verbs = { alc880_volume_init_verbs,
4206 alc880_uniwill_p53_init_verbs },
4207 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4208 .dac_nids = alc880_asus_dac_nids,
4209 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004210 .channel_mode = alc880_threestack_modes,
4211 .input_mux = &alc880_capture_source,
4212 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004213 .setup = alc880_uniwill_p53_setup,
4214 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004215 },
4216 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004217 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004218 .init_verbs = { alc880_volume_init_verbs,
4219 alc880_uniwill_p53_init_verbs,
4220 alc880_beep_init_verbs },
4221 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4222 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004223 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004224 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4225 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004226 .input_mux = &alc880_capture_source,
4227 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004228 .setup = alc880_uniwill_p53_setup,
4229 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004230 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004231 [ALC880_CLEVO] = {
4232 .mixers = { alc880_three_stack_mixer },
4233 .init_verbs = { alc880_volume_init_verbs,
4234 alc880_pin_clevo_init_verbs },
4235 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4236 .dac_nids = alc880_dac_nids,
4237 .hp_nid = 0x03,
4238 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4239 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004240 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004241 .input_mux = &alc880_capture_source,
4242 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004243 [ALC880_LG] = {
4244 .mixers = { alc880_lg_mixer },
4245 .init_verbs = { alc880_volume_init_verbs,
4246 alc880_lg_init_verbs },
4247 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4248 .dac_nids = alc880_lg_dac_nids,
4249 .dig_out_nid = ALC880_DIGOUT_NID,
4250 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4251 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004252 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004253 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004254 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004255 .setup = alc880_lg_setup,
4256 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004257#ifdef CONFIG_SND_HDA_POWER_SAVE
4258 .loopbacks = alc880_lg_loopbacks,
4259#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004260 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004261 [ALC880_LG_LW] = {
4262 .mixers = { alc880_lg_lw_mixer },
4263 .init_verbs = { alc880_volume_init_verbs,
4264 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004265 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004266 .dac_nids = alc880_dac_nids,
4267 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004268 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4269 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004270 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004271 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004272 .setup = alc880_lg_lw_setup,
4273 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004274 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004275 [ALC880_MEDION_RIM] = {
4276 .mixers = { alc880_medion_rim_mixer },
4277 .init_verbs = { alc880_volume_init_verbs,
4278 alc880_medion_rim_init_verbs,
4279 alc_gpio2_init_verbs },
4280 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4281 .dac_nids = alc880_dac_nids,
4282 .dig_out_nid = ALC880_DIGOUT_NID,
4283 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4284 .channel_mode = alc880_2_jack_modes,
4285 .input_mux = &alc880_medion_rim_capture_source,
4286 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004287 .setup = alc880_medion_rim_setup,
4288 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004289 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004290#ifdef CONFIG_SND_DEBUG
4291 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004292 .mixers = { alc880_test_mixer },
4293 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004294 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4295 .dac_nids = alc880_test_dac_nids,
4296 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004297 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4298 .channel_mode = alc880_test_modes,
4299 .input_mux = &alc880_test_capture_source,
4300 },
4301#endif
4302};
4303
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004304/*
4305 * Automatic parse of I/O pins from the BIOS configuration
4306 */
4307
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004308enum {
4309 ALC_CTL_WIDGET_VOL,
4310 ALC_CTL_WIDGET_MUTE,
4311 ALC_CTL_BIND_MUTE,
4312};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004313static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004314 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4315 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004316 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004317};
4318
4319/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004320static int add_control(struct alc_spec *spec, int type, const char *name,
4321 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004322{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004323 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004324
Takashi Iwai603c4012008-07-30 15:01:44 +02004325 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4326 knew = snd_array_new(&spec->kctls);
4327 if (!knew)
4328 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004329 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004330 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004331 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004332 return -ENOMEM;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004333 if (get_amp_nid_(val))
Takashi Iwai9c96fa52009-11-16 11:25:33 +01004334 knew->subdevice = HDA_SUBDEV_NID_FLAG | get_amp_nid_(val);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004335 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004336 return 0;
4337}
4338
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004339static int add_control_with_pfx(struct alc_spec *spec, int type,
4340 const char *pfx, const char *dir,
4341 const char *sfx, unsigned long val)
4342{
4343 char name[32];
4344 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
4345 return add_control(spec, type, name, val);
4346}
4347
4348#define add_pb_vol_ctrl(spec, type, pfx, val) \
4349 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val)
4350#define add_pb_sw_ctrl(spec, type, pfx, val) \
4351 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val)
4352
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004353#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4354#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4355#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4356#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004357#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4358#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4359#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4360#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4361#define ALC880_PIN_CD_NID 0x1c
4362
4363/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004364static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4365 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004366{
4367 hda_nid_t nid;
4368 int assigned[4];
4369 int i, j;
4370
4371 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004372 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004373
4374 /* check the pins hardwired to audio widget */
4375 for (i = 0; i < cfg->line_outs; i++) {
4376 nid = cfg->line_out_pins[i];
4377 if (alc880_is_fixed_pin(nid)) {
4378 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004379 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004380 assigned[idx] = 1;
4381 }
4382 }
4383 /* left pins can be connect to any audio widget */
4384 for (i = 0; i < cfg->line_outs; i++) {
4385 nid = cfg->line_out_pins[i];
4386 if (alc880_is_fixed_pin(nid))
4387 continue;
4388 /* search for an empty channel */
4389 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004390 if (!assigned[j]) {
4391 spec->multiout.dac_nids[i] =
4392 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004393 assigned[j] = 1;
4394 break;
4395 }
4396 }
4397 }
4398 spec->multiout.num_dacs = cfg->line_outs;
4399 return 0;
4400}
4401
4402/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004403static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4404 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004405{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004406 static const char *chname[4] = {
4407 "Front", "Surround", NULL /*CLFE*/, "Side"
4408 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004409 hda_nid_t nid;
4410 int i, err;
4411
4412 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004413 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004414 continue;
4415 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4416 if (i == 2) {
4417 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004418 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4419 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004420 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4421 HDA_OUTPUT));
4422 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004423 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004424 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4425 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004426 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4427 HDA_OUTPUT));
4428 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004429 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004430 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4431 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004432 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4433 HDA_INPUT));
4434 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004435 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004436 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4437 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004438 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4439 HDA_INPUT));
4440 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004441 return err;
4442 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004443 const char *pfx;
4444 if (cfg->line_outs == 1 &&
4445 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4446 pfx = "Speaker";
4447 else
4448 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004449 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004450 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4451 HDA_OUTPUT));
4452 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004453 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004454 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004455 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4456 HDA_INPUT));
4457 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004458 return err;
4459 }
4460 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004461 return 0;
4462}
4463
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004464/* add playback controls for speaker and HP outputs */
4465static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4466 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004467{
4468 hda_nid_t nid;
4469 int err;
4470
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004471 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004472 return 0;
4473
4474 if (alc880_is_fixed_pin(pin)) {
4475 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004476 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004477 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004478 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004479 else
4480 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004481 /* control HP volume/switch on the output mixer amp */
4482 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004483 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004484 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4485 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004486 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004487 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004488 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4489 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004490 return err;
4491 } else if (alc880_is_multi_pin(pin)) {
4492 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004493 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004494 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004495 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4496 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004497 return err;
4498 }
4499 return 0;
4500}
4501
4502/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004503static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4504 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004505 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004506{
Kailang Yangdf694da2005-12-05 19:42:22 +01004507 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004508
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004509 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004510 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4511 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004512 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004513 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004514 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4515 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004516 return err;
4517 return 0;
4518}
4519
Takashi Iwai05f5f472009-08-25 13:10:18 +02004520static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004521{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004522 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4523 return (pincap & AC_PINCAP_IN) != 0;
4524}
4525
4526/* create playback/capture controls for input pins */
4527static int alc_auto_create_input_ctls(struct hda_codec *codec,
4528 const struct auto_pin_cfg *cfg,
4529 hda_nid_t mixer,
4530 hda_nid_t cap1, hda_nid_t cap2)
4531{
4532 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004533 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004534 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004535
4536 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004537 hda_nid_t pin;
4538
4539 pin = cfg->input_pins[i];
4540 if (!alc_is_input_pin(codec, pin))
4541 continue;
4542
4543 if (mixer) {
4544 idx = get_connection_index(codec, mixer, pin);
4545 if (idx >= 0) {
4546 err = new_analog_input(spec, pin,
4547 auto_pin_cfg_labels[i],
4548 idx, mixer);
4549 if (err < 0)
4550 return err;
4551 }
4552 }
4553
4554 if (!cap1)
4555 continue;
4556 idx = get_connection_index(codec, cap1, pin);
4557 if (idx < 0 && cap2)
4558 idx = get_connection_index(codec, cap2, pin);
4559 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004560 imux->items[imux->num_items].label =
4561 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004562 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004563 imux->num_items++;
4564 }
4565 }
4566 return 0;
4567}
4568
Takashi Iwai05f5f472009-08-25 13:10:18 +02004569static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4570 const struct auto_pin_cfg *cfg)
4571{
4572 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4573}
4574
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004575static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4576 unsigned int pin_type)
4577{
4578 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4579 pin_type);
4580 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004581 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4582 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004583}
4584
Kailang Yangdf694da2005-12-05 19:42:22 +01004585static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4586 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004587 int dac_idx)
4588{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004589 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004590 /* need the manual connection? */
4591 if (alc880_is_multi_pin(nid)) {
4592 struct alc_spec *spec = codec->spec;
4593 int idx = alc880_multi_pin_idx(nid);
4594 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4595 AC_VERB_SET_CONNECT_SEL,
4596 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4597 }
4598}
4599
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004600static int get_pin_type(int line_out_type)
4601{
4602 if (line_out_type == AUTO_PIN_HP_OUT)
4603 return PIN_HP;
4604 else
4605 return PIN_OUT;
4606}
4607
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004608static void alc880_auto_init_multi_out(struct hda_codec *codec)
4609{
4610 struct alc_spec *spec = codec->spec;
4611 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004612
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004613 for (i = 0; i < spec->autocfg.line_outs; i++) {
4614 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004615 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4616 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004617 }
4618}
4619
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004620static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004621{
4622 struct alc_spec *spec = codec->spec;
4623 hda_nid_t pin;
4624
Takashi Iwai82bc9552006-03-21 11:24:42 +01004625 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004626 if (pin) /* connect to front */
4627 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004628 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004629 if (pin) /* connect to front */
4630 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4631}
4632
4633static void alc880_auto_init_analog_input(struct hda_codec *codec)
4634{
4635 struct alc_spec *spec = codec->spec;
4636 int i;
4637
4638 for (i = 0; i < AUTO_PIN_LAST; i++) {
4639 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004640 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004641 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004642 if (nid != ALC880_PIN_CD_NID &&
4643 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004644 snd_hda_codec_write(codec, nid, 0,
4645 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004646 AMP_OUT_MUTE);
4647 }
4648 }
4649}
4650
4651/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004652/* return 1 if successful, 0 if the proper config is not found,
4653 * or a negative error code
4654 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004655static int alc880_parse_auto_config(struct hda_codec *codec)
4656{
4657 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004658 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004659 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004660
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004661 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4662 alc880_ignore);
4663 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004664 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004665 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004666 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004667
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004668 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4669 if (err < 0)
4670 return err;
4671 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4672 if (err < 0)
4673 return err;
4674 err = alc880_auto_create_extra_out(spec,
4675 spec->autocfg.speaker_pins[0],
4676 "Speaker");
4677 if (err < 0)
4678 return err;
4679 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4680 "Headphone");
4681 if (err < 0)
4682 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004683 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004684 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004685 return err;
4686
4687 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4688
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004689 /* check multiple SPDIF-out (for recent codecs) */
4690 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4691 hda_nid_t dig_nid;
4692 err = snd_hda_get_connections(codec,
4693 spec->autocfg.dig_out_pins[i],
4694 &dig_nid, 1);
4695 if (err < 0)
4696 continue;
4697 if (!i)
4698 spec->multiout.dig_out_nid = dig_nid;
4699 else {
4700 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004701 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004702 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004703 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004704 }
4705 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004706 if (spec->autocfg.dig_in_pin)
4707 spec->dig_in_nid = ALC880_DIGIN_NID;
4708
Takashi Iwai603c4012008-07-30 15:01:44 +02004709 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004710 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004711
Takashi Iwaid88897e2008-10-31 15:01:37 +01004712 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004713
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004714 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004715 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004716
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004717 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4718
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004719 return 1;
4720}
4721
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004722/* additional initialization for auto-configuration model */
4723static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004724{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004725 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004726 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004727 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004728 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004729 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004730 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004731}
4732
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004733/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4734 * one of two digital mic pins, e.g. on ALC272
4735 */
4736static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004737{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004738 struct alc_spec *spec = codec->spec;
4739 int i;
4740
4741 for (i = 0; i < spec->num_adc_nids; i++) {
4742 hda_nid_t cap = spec->capsrc_nids ?
4743 spec->capsrc_nids[i] : spec->adc_nids[i];
4744 int iidx, eidx;
4745
4746 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4747 if (iidx < 0)
4748 continue;
4749 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4750 if (eidx < 0)
4751 continue;
4752 spec->int_mic.mux_idx = iidx;
4753 spec->ext_mic.mux_idx = eidx;
4754 if (spec->capsrc_nids)
4755 spec->capsrc_nids += i;
4756 spec->adc_nids += i;
4757 spec->num_adc_nids = 1;
4758 return;
4759 }
4760 snd_printd(KERN_INFO "hda_codec: %s: "
4761 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4762 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4763 spec->auto_mic = 0; /* disable auto-mic to be sure */
4764}
4765
4766static void set_capture_mixer(struct hda_codec *codec)
4767{
4768 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01004769 static struct snd_kcontrol_new *caps[2][3] = {
4770 { alc_capture_mixer_nosrc1,
4771 alc_capture_mixer_nosrc2,
4772 alc_capture_mixer_nosrc3 },
4773 { alc_capture_mixer1,
4774 alc_capture_mixer2,
4775 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004776 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004777 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4778 int mux;
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004779 if (spec->auto_mic) {
4780 mux = 0;
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004781 fixup_automic_adc(codec);
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004782 } else if (spec->input_mux && spec->input_mux->num_items > 1)
Takashi Iwaia23b6882009-03-23 15:21:36 +01004783 mux = 1;
4784 else
4785 mux = 0;
4786 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4787 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004788}
4789
Takashi Iwai67d634c2009-11-16 15:35:59 +01004790#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004791#define set_beep_amp(spec, nid, idx, dir) \
4792 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwai67d634c2009-11-16 15:35:59 +01004793#else
4794#define set_beep_amp(spec, nid, idx, dir) /* NOP */
4795#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004796
4797/*
4798 * OK, here we have finally the patch for ALC880
4799 */
4800
Linus Torvalds1da177e2005-04-16 15:20:36 -07004801static int patch_alc880(struct hda_codec *codec)
4802{
4803 struct alc_spec *spec;
4804 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004805 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004806
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004807 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004808 if (spec == NULL)
4809 return -ENOMEM;
4810
4811 codec->spec = spec;
4812
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004813 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4814 alc880_models,
4815 alc880_cfg_tbl);
4816 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004817 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4818 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004819 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004820 }
4821
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004822 if (board_config == ALC880_AUTO) {
4823 /* automatic parse from the BIOS config */
4824 err = alc880_parse_auto_config(codec);
4825 if (err < 0) {
4826 alc_free(codec);
4827 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004828 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004829 printk(KERN_INFO
4830 "hda_codec: Cannot set up configuration "
4831 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004832 board_config = ALC880_3ST;
4833 }
4834 }
4835
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004836 err = snd_hda_attach_beep_device(codec, 0x1);
4837 if (err < 0) {
4838 alc_free(codec);
4839 return err;
4840 }
4841
Kailang Yangdf694da2005-12-05 19:42:22 +01004842 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02004843 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004844
Linus Torvalds1da177e2005-04-16 15:20:36 -07004845 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4846 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004847 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004848
Linus Torvalds1da177e2005-04-16 15:20:36 -07004849 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4850 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4851
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004852 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004853 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004854 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004855 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02004856 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004857 if (wcap != AC_WID_AUD_IN) {
4858 spec->adc_nids = alc880_adc_nids_alt;
4859 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004860 } else {
4861 spec->adc_nids = alc880_adc_nids;
4862 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004863 }
4864 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004865 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004866 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004867
Takashi Iwai2134ea42008-01-10 16:53:55 +01004868 spec->vmaster_nid = 0x0c;
4869
Linus Torvalds1da177e2005-04-16 15:20:36 -07004870 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004871 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004872 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004873#ifdef CONFIG_SND_HDA_POWER_SAVE
4874 if (!spec->loopback.amplist)
4875 spec->loopback.amplist = alc880_loopbacks;
4876#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004877 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004878
4879 return 0;
4880}
4881
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004882
Linus Torvalds1da177e2005-04-16 15:20:36 -07004883/*
4884 * ALC260 support
4885 */
4886
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004887static hda_nid_t alc260_dac_nids[1] = {
4888 /* front */
4889 0x02,
4890};
4891
4892static hda_nid_t alc260_adc_nids[1] = {
4893 /* ADC0 */
4894 0x04,
4895};
4896
Kailang Yangdf694da2005-12-05 19:42:22 +01004897static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004898 /* ADC1 */
4899 0x05,
4900};
4901
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004902/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4903 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4904 */
4905static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004906 /* ADC0, ADC1 */
4907 0x04, 0x05
4908};
4909
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004910#define ALC260_DIGOUT_NID 0x03
4911#define ALC260_DIGIN_NID 0x06
4912
4913static struct hda_input_mux alc260_capture_source = {
4914 .num_items = 4,
4915 .items = {
4916 { "Mic", 0x0 },
4917 { "Front Mic", 0x1 },
4918 { "Line", 0x2 },
4919 { "CD", 0x4 },
4920 },
4921};
4922
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004923/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004924 * headphone jack and the internal CD lines since these are the only pins at
4925 * which audio can appear. For flexibility, also allow the option of
4926 * recording the mixer output on the second ADC (ADC0 doesn't have a
4927 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004928 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004929static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4930 {
4931 .num_items = 3,
4932 .items = {
4933 { "Mic/Line", 0x0 },
4934 { "CD", 0x4 },
4935 { "Headphone", 0x2 },
4936 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004937 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004938 {
4939 .num_items = 4,
4940 .items = {
4941 { "Mic/Line", 0x0 },
4942 { "CD", 0x4 },
4943 { "Headphone", 0x2 },
4944 { "Mixer", 0x5 },
4945 },
4946 },
4947
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004948};
4949
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004950/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4951 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004952 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004953static struct hda_input_mux alc260_acer_capture_sources[2] = {
4954 {
4955 .num_items = 4,
4956 .items = {
4957 { "Mic", 0x0 },
4958 { "Line", 0x2 },
4959 { "CD", 0x4 },
4960 { "Headphone", 0x5 },
4961 },
4962 },
4963 {
4964 .num_items = 5,
4965 .items = {
4966 { "Mic", 0x0 },
4967 { "Line", 0x2 },
4968 { "CD", 0x4 },
4969 { "Headphone", 0x6 },
4970 { "Mixer", 0x5 },
4971 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004972 },
4973};
Michael Schwingencc959482009-02-22 18:58:45 +01004974
4975/* Maxdata Favorit 100XS */
4976static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4977 {
4978 .num_items = 2,
4979 .items = {
4980 { "Line/Mic", 0x0 },
4981 { "CD", 0x4 },
4982 },
4983 },
4984 {
4985 .num_items = 3,
4986 .items = {
4987 { "Line/Mic", 0x0 },
4988 { "CD", 0x4 },
4989 { "Mixer", 0x5 },
4990 },
4991 },
4992};
4993
Linus Torvalds1da177e2005-04-16 15:20:36 -07004994/*
4995 * This is just place-holder, so there's something for alc_build_pcms to look
4996 * at when it calculates the maximum number of channels. ALC260 has no mixer
4997 * element which allows changing the channel mode, so the verb list is
4998 * never used.
4999 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005000static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005001 { 2, NULL },
5002};
5003
Kailang Yangdf694da2005-12-05 19:42:22 +01005004
5005/* Mixer combinations
5006 *
5007 * basic: base_output + input + pc_beep + capture
5008 * HP: base_output + input + capture_alt
5009 * HP_3013: hp_3013 + input + capture
5010 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005011 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005012 */
5013
5014static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005015 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005016 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005017 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5018 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5019 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5020 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5021 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005022};
Kailang Yangdf694da2005-12-05 19:42:22 +01005023
5024static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005025 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5026 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5027 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5028 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5029 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5030 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5031 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5032 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005033 { } /* end */
5034};
5035
Takashi Iwaibec15c32008-01-28 18:16:30 +01005036/* update HP, line and mono out pins according to the master switch */
5037static void alc260_hp_master_update(struct hda_codec *codec,
5038 hda_nid_t hp, hda_nid_t line,
5039 hda_nid_t mono)
5040{
5041 struct alc_spec *spec = codec->spec;
5042 unsigned int val = spec->master_sw ? PIN_HP : 0;
5043 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005044 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005045 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005046 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005047 val);
5048 /* mono (speaker) depending on the HP jack sense */
5049 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005050 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005051 val);
5052}
5053
5054static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5055 struct snd_ctl_elem_value *ucontrol)
5056{
5057 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5058 struct alc_spec *spec = codec->spec;
5059 *ucontrol->value.integer.value = spec->master_sw;
5060 return 0;
5061}
5062
5063static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5064 struct snd_ctl_elem_value *ucontrol)
5065{
5066 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5067 struct alc_spec *spec = codec->spec;
5068 int val = !!*ucontrol->value.integer.value;
5069 hda_nid_t hp, line, mono;
5070
5071 if (val == spec->master_sw)
5072 return 0;
5073 spec->master_sw = val;
5074 hp = (kcontrol->private_value >> 16) & 0xff;
5075 line = (kcontrol->private_value >> 8) & 0xff;
5076 mono = kcontrol->private_value & 0xff;
5077 alc260_hp_master_update(codec, hp, line, mono);
5078 return 1;
5079}
5080
5081static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5082 {
5083 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5084 .name = "Master Playback Switch",
5085 .info = snd_ctl_boolean_mono_info,
5086 .get = alc260_hp_master_sw_get,
5087 .put = alc260_hp_master_sw_put,
5088 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5089 },
5090 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5091 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5092 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5093 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5094 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5095 HDA_OUTPUT),
5096 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5097 { } /* end */
5098};
5099
5100static struct hda_verb alc260_hp_unsol_verbs[] = {
5101 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5102 {},
5103};
5104
5105static void alc260_hp_automute(struct hda_codec *codec)
5106{
5107 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005108
Wu Fengguang864f92b2009-11-18 12:38:02 +08005109 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005110 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5111}
5112
5113static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5114{
5115 if ((res >> 26) == ALC880_HP_EVENT)
5116 alc260_hp_automute(codec);
5117}
5118
Kailang Yangdf694da2005-12-05 19:42:22 +01005119static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005120 {
5121 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5122 .name = "Master Playback Switch",
5123 .info = snd_ctl_boolean_mono_info,
5124 .get = alc260_hp_master_sw_get,
5125 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005126 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005127 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005128 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5129 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5130 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5131 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5132 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5133 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005134 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5135 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005136 { } /* end */
5137};
5138
Kailang Yang3f878302008-08-26 13:02:23 +02005139static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5140 .ops = &snd_hda_bind_vol,
5141 .values = {
5142 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5143 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5144 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5145 0
5146 },
5147};
5148
5149static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5150 .ops = &snd_hda_bind_sw,
5151 .values = {
5152 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5153 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5154 0
5155 },
5156};
5157
5158static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5159 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5160 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5161 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5162 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5163 { } /* end */
5164};
5165
Takashi Iwaibec15c32008-01-28 18:16:30 +01005166static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5167 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5168 {},
5169};
5170
5171static void alc260_hp_3013_automute(struct hda_codec *codec)
5172{
5173 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005174
Wu Fengguang864f92b2009-11-18 12:38:02 +08005175 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005176 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005177}
5178
5179static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5180 unsigned int res)
5181{
5182 if ((res >> 26) == ALC880_HP_EVENT)
5183 alc260_hp_3013_automute(codec);
5184}
5185
Kailang Yang3f878302008-08-26 13:02:23 +02005186static void alc260_hp_3012_automute(struct hda_codec *codec)
5187{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005188 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005189
Kailang Yang3f878302008-08-26 13:02:23 +02005190 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5191 bits);
5192 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5193 bits);
5194 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5195 bits);
5196}
5197
5198static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5199 unsigned int res)
5200{
5201 if ((res >> 26) == ALC880_HP_EVENT)
5202 alc260_hp_3012_automute(codec);
5203}
5204
5205/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005206 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5207 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005208static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005209 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005210 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005211 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005212 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5213 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5214 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5215 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005216 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005217 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5218 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005219 { } /* end */
5220};
5221
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005222/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5223 * versions of the ALC260 don't act on requests to enable mic bias from NID
5224 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5225 * datasheet doesn't mention this restriction. At this stage it's not clear
5226 * whether this behaviour is intentional or is a hardware bug in chip
5227 * revisions available in early 2006. Therefore for now allow the
5228 * "Headphone Jack Mode" control to span all choices, but if it turns out
5229 * that the lack of mic bias for this NID is intentional we could change the
5230 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5231 *
5232 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5233 * don't appear to make the mic bias available from the "line" jack, even
5234 * though the NID used for this jack (0x14) can supply it. The theory is
5235 * that perhaps Acer have included blocking capacitors between the ALC260
5236 * and the output jack. If this turns out to be the case for all such
5237 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5238 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005239 *
5240 * The C20x Tablet series have a mono internal speaker which is controlled
5241 * via the chip's Mono sum widget and pin complex, so include the necessary
5242 * controls for such models. On models without a "mono speaker" the control
5243 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005244 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005245static struct snd_kcontrol_new alc260_acer_mixer[] = {
5246 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5247 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005248 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005249 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005250 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005251 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005252 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005253 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5254 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5255 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5256 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5257 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5258 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5259 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5260 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005261 { } /* end */
5262};
5263
Michael Schwingencc959482009-02-22 18:58:45 +01005264/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5265 */
5266static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5267 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5268 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5269 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5270 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5271 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5272 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5273 { } /* end */
5274};
5275
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005276/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5277 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5278 */
5279static struct snd_kcontrol_new alc260_will_mixer[] = {
5280 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5281 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5282 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5283 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5284 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5285 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5286 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5287 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5288 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5289 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005290 { } /* end */
5291};
5292
5293/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5294 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5295 */
5296static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5297 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5298 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5299 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5300 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5301 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5302 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5303 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5304 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5305 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5306 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5307 { } /* end */
5308};
5309
Kailang Yangdf694da2005-12-05 19:42:22 +01005310/*
5311 * initialization verbs
5312 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005313static struct hda_verb alc260_init_verbs[] = {
5314 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005315 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005316 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005317 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005318 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005319 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005320 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005321 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005322 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005323 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005324 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005325 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005326 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005327 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005328 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005329 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005330 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005331 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5332 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005333 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005334 /* set connection select to line in (default select for this ADC) */
5335 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005336 /* mute capture amp left and right */
5337 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5338 /* set connection select to line in (default select for this ADC) */
5339 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005340 /* set vol=0 Line-Out mixer amp left and right */
5341 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5342 /* unmute pin widget amp left and right (no gain on this amp) */
5343 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5344 /* set vol=0 HP mixer amp left and right */
5345 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5346 /* unmute pin widget amp left and right (no gain on this amp) */
5347 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5348 /* set vol=0 Mono mixer amp left and right */
5349 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5350 /* unmute pin widget amp left and right (no gain on this amp) */
5351 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5352 /* unmute LINE-2 out pin */
5353 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005354 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5355 * Line In 2 = 0x03
5356 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005357 /* mute analog inputs */
5358 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5359 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5360 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5361 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5362 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005363 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005364 /* mute Front out path */
5365 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5366 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5367 /* mute Headphone out path */
5368 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5369 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5370 /* mute Mono out path */
5371 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5372 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005373 { }
5374};
5375
Takashi Iwai474167d2006-05-17 17:17:43 +02005376#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005377static struct hda_verb alc260_hp_init_verbs[] = {
5378 /* Headphone and output */
5379 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5380 /* mono output */
5381 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5382 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5383 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5384 /* Mic2 (front panel) pin widget for input and vref at 80% */
5385 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5386 /* Line In pin widget for input */
5387 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5388 /* Line-2 pin widget for output */
5389 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5390 /* CD pin widget for input */
5391 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5392 /* unmute amp left and right */
5393 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5394 /* set connection select to line in (default select for this ADC) */
5395 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5396 /* unmute Line-Out mixer amp left and right (volume = 0) */
5397 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5398 /* mute pin widget amp left and right (no gain on this amp) */
5399 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5400 /* unmute HP mixer amp left and right (volume = 0) */
5401 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5402 /* mute pin widget amp left and right (no gain on this amp) */
5403 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005404 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5405 * Line In 2 = 0x03
5406 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005407 /* mute analog inputs */
5408 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5409 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5410 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5411 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5412 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005413 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5414 /* Unmute Front out path */
5415 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5416 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5417 /* Unmute Headphone out path */
5418 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5419 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5420 /* Unmute Mono out path */
5421 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5422 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5423 { }
5424};
Takashi Iwai474167d2006-05-17 17:17:43 +02005425#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005426
5427static struct hda_verb alc260_hp_3013_init_verbs[] = {
5428 /* Line out and output */
5429 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5430 /* mono output */
5431 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5432 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5433 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5434 /* Mic2 (front panel) pin widget for input and vref at 80% */
5435 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5436 /* Line In pin widget for input */
5437 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5438 /* Headphone pin widget for output */
5439 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5440 /* CD pin widget for input */
5441 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5442 /* unmute amp left and right */
5443 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5444 /* set connection select to line in (default select for this ADC) */
5445 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5446 /* unmute Line-Out mixer amp left and right (volume = 0) */
5447 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5448 /* mute pin widget amp left and right (no gain on this amp) */
5449 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5450 /* unmute HP mixer amp left and right (volume = 0) */
5451 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5452 /* mute pin widget amp left and right (no gain on this amp) */
5453 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005454 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5455 * Line In 2 = 0x03
5456 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005457 /* mute analog inputs */
5458 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5459 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5461 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5462 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005463 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5464 /* Unmute Front out path */
5465 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5466 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5467 /* Unmute Headphone out path */
5468 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5469 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5470 /* Unmute Mono out path */
5471 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5472 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5473 { }
5474};
5475
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005476/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005477 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5478 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005479 */
5480static struct hda_verb alc260_fujitsu_init_verbs[] = {
5481 /* Disable all GPIOs */
5482 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5483 /* Internal speaker is connected to headphone pin */
5484 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5485 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5486 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005487 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5488 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5489 /* Ensure all other unused pins are disabled and muted. */
5490 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5491 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005492 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005493 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005494 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005495 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5496 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5497 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005498
Jonathan Woithef7ace402006-02-28 11:46:14 +01005499 /* Disable digital (SPDIF) pins */
5500 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5501 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005502
Kailang Yangea1fb292008-08-26 12:58:38 +02005503 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005504 * when acting as an output.
5505 */
5506 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5507
5508 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005509 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5510 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5511 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5512 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5513 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5514 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5515 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5516 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5517 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005518
Jonathan Woithef7ace402006-02-28 11:46:14 +01005519 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5520 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5521 /* Unmute Line1 pin widget output buffer since it starts as an output.
5522 * If the pin mode is changed by the user the pin mode control will
5523 * take care of enabling the pin's input/output buffers as needed.
5524 * Therefore there's no need to enable the input buffer at this
5525 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005526 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005527 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005528 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005529 * mixer ctrl)
5530 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005531 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005532
Jonathan Woithef7ace402006-02-28 11:46:14 +01005533 /* Mute capture amp left and right */
5534 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005535 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005536 * in (on mic1 pin)
5537 */
5538 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005539
Jonathan Woithef7ace402006-02-28 11:46:14 +01005540 /* Do the same for the second ADC: mute capture input amp and
5541 * set ADC connection to line in (on mic1 pin)
5542 */
5543 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5544 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005545
Jonathan Woithef7ace402006-02-28 11:46:14 +01005546 /* Mute all inputs to mixer widget (even unconnected ones) */
5547 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5548 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5549 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5550 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5551 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5552 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5553 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5554 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005555
5556 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005557};
5558
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005559/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5560 * similar laptops (adapted from Fujitsu init verbs).
5561 */
5562static struct hda_verb alc260_acer_init_verbs[] = {
5563 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5564 * the headphone jack. Turn this on and rely on the standard mute
5565 * methods whenever the user wants to turn these outputs off.
5566 */
5567 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5568 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5569 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5570 /* Internal speaker/Headphone jack is connected to Line-out pin */
5571 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5572 /* Internal microphone/Mic jack is connected to Mic1 pin */
5573 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5574 /* Line In jack is connected to Line1 pin */
5575 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005576 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5577 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005578 /* Ensure all other unused pins are disabled and muted. */
5579 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5580 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005581 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5582 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5583 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5584 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5585 /* Disable digital (SPDIF) pins */
5586 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5587 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5588
Kailang Yangea1fb292008-08-26 12:58:38 +02005589 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005590 * bus when acting as outputs.
5591 */
5592 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5593 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5594
5595 /* Start with output sum widgets muted and their output gains at min */
5596 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5597 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5598 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5599 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5600 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5601 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5602 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5603 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5604 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5605
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005606 /* Unmute Line-out pin widget amp left and right
5607 * (no equiv mixer ctrl)
5608 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005609 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005610 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5611 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005612 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5613 * inputs. If the pin mode is changed by the user the pin mode control
5614 * will take care of enabling the pin's input/output buffers as needed.
5615 * Therefore there's no need to enable the input buffer at this
5616 * stage.
5617 */
5618 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5619 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5620
5621 /* Mute capture amp left and right */
5622 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5623 /* Set ADC connection select to match default mixer setting - mic
5624 * (on mic1 pin)
5625 */
5626 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5627
5628 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005629 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005630 */
5631 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005632 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005633
5634 /* Mute all inputs to mixer widget (even unconnected ones) */
5635 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5636 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5637 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5638 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5639 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5640 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5641 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5642 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5643
5644 { }
5645};
5646
Michael Schwingencc959482009-02-22 18:58:45 +01005647/* Initialisation sequence for Maxdata Favorit 100XS
5648 * (adapted from Acer init verbs).
5649 */
5650static struct hda_verb alc260_favorit100_init_verbs[] = {
5651 /* GPIO 0 enables the output jack.
5652 * Turn this on and rely on the standard mute
5653 * methods whenever the user wants to turn these outputs off.
5654 */
5655 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5656 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5657 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5658 /* Line/Mic input jack is connected to Mic1 pin */
5659 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5660 /* Ensure all other unused pins are disabled and muted. */
5661 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5662 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5663 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5664 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5665 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5666 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5667 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5668 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5669 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5670 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5671 /* Disable digital (SPDIF) pins */
5672 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5673 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5674
5675 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5676 * bus when acting as outputs.
5677 */
5678 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5679 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5680
5681 /* Start with output sum widgets muted and their output gains at min */
5682 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5683 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5684 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5685 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5686 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5687 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5688 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5689 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5690 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5691
5692 /* Unmute Line-out pin widget amp left and right
5693 * (no equiv mixer ctrl)
5694 */
5695 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5696 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5697 * inputs. If the pin mode is changed by the user the pin mode control
5698 * will take care of enabling the pin's input/output buffers as needed.
5699 * Therefore there's no need to enable the input buffer at this
5700 * stage.
5701 */
5702 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5703
5704 /* Mute capture amp left and right */
5705 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5706 /* Set ADC connection select to match default mixer setting - mic
5707 * (on mic1 pin)
5708 */
5709 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5710
5711 /* Do similar with the second ADC: mute capture input amp and
5712 * set ADC connection to mic to match ALSA's default state.
5713 */
5714 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5715 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5716
5717 /* Mute all inputs to mixer widget (even unconnected ones) */
5718 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5719 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5720 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5721 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5722 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5723 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5724 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5725 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5726
5727 { }
5728};
5729
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005730static struct hda_verb alc260_will_verbs[] = {
5731 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5732 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5733 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5734 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5735 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5736 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5737 {}
5738};
5739
5740static struct hda_verb alc260_replacer_672v_verbs[] = {
5741 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5742 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5743 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5744
5745 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5746 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5747 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5748
5749 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5750 {}
5751};
5752
5753/* toggle speaker-output according to the hp-jack state */
5754static void alc260_replacer_672v_automute(struct hda_codec *codec)
5755{
5756 unsigned int present;
5757
5758 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08005759 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005760 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005761 snd_hda_codec_write_cache(codec, 0x01, 0,
5762 AC_VERB_SET_GPIO_DATA, 1);
5763 snd_hda_codec_write_cache(codec, 0x0f, 0,
5764 AC_VERB_SET_PIN_WIDGET_CONTROL,
5765 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005766 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005767 snd_hda_codec_write_cache(codec, 0x01, 0,
5768 AC_VERB_SET_GPIO_DATA, 0);
5769 snd_hda_codec_write_cache(codec, 0x0f, 0,
5770 AC_VERB_SET_PIN_WIDGET_CONTROL,
5771 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005772 }
5773}
5774
5775static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5776 unsigned int res)
5777{
5778 if ((res >> 26) == ALC880_HP_EVENT)
5779 alc260_replacer_672v_automute(codec);
5780}
5781
Kailang Yang3f878302008-08-26 13:02:23 +02005782static struct hda_verb alc260_hp_dc7600_verbs[] = {
5783 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5784 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5785 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5786 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5787 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5788 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5789 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5790 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5791 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5792 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5793 {}
5794};
5795
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005796/* Test configuration for debugging, modelled after the ALC880 test
5797 * configuration.
5798 */
5799#ifdef CONFIG_SND_DEBUG
5800static hda_nid_t alc260_test_dac_nids[1] = {
5801 0x02,
5802};
5803static hda_nid_t alc260_test_adc_nids[2] = {
5804 0x04, 0x05,
5805};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005806/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005807 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005808 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005809 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005810static struct hda_input_mux alc260_test_capture_sources[2] = {
5811 {
5812 .num_items = 7,
5813 .items = {
5814 { "MIC1 pin", 0x0 },
5815 { "MIC2 pin", 0x1 },
5816 { "LINE1 pin", 0x2 },
5817 { "LINE2 pin", 0x3 },
5818 { "CD pin", 0x4 },
5819 { "LINE-OUT pin", 0x5 },
5820 { "HP-OUT pin", 0x6 },
5821 },
5822 },
5823 {
5824 .num_items = 8,
5825 .items = {
5826 { "MIC1 pin", 0x0 },
5827 { "MIC2 pin", 0x1 },
5828 { "LINE1 pin", 0x2 },
5829 { "LINE2 pin", 0x3 },
5830 { "CD pin", 0x4 },
5831 { "Mixer", 0x5 },
5832 { "LINE-OUT pin", 0x6 },
5833 { "HP-OUT pin", 0x7 },
5834 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005835 },
5836};
5837static struct snd_kcontrol_new alc260_test_mixer[] = {
5838 /* Output driver widgets */
5839 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5840 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5841 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5842 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5843 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5844 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5845
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005846 /* Modes for retasking pin widgets
5847 * Note: the ALC260 doesn't seem to act on requests to enable mic
5848 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5849 * mention this restriction. At this stage it's not clear whether
5850 * this behaviour is intentional or is a hardware bug in chip
5851 * revisions available at least up until early 2006. Therefore for
5852 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5853 * choices, but if it turns out that the lack of mic bias for these
5854 * NIDs is intentional we could change their modes from
5855 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5856 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005857 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5858 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5859 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5860 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5861 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5862 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5863
5864 /* Loopback mixer controls */
5865 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5866 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5867 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5868 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5869 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5870 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5871 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5872 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5873 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5874 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005875 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5876 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5877 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5878 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005879
5880 /* Controls for GPIO pins, assuming they are configured as outputs */
5881 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5882 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5883 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5884 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5885
Jonathan Woithe92621f12006-02-28 11:47:47 +01005886 /* Switches to allow the digital IO pins to be enabled. The datasheet
5887 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005888 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005889 */
5890 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5891 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5892
Jonathan Woithef8225f62008-01-08 12:16:54 +01005893 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5894 * this output to turn on an external amplifier.
5895 */
5896 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5897 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5898
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005899 { } /* end */
5900};
5901static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005902 /* Enable all GPIOs as outputs with an initial value of 0 */
5903 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5904 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5905 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5906
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005907 /* Enable retasking pins as output, initially without power amp */
5908 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5909 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5910 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5911 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5912 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5913 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5914
Jonathan Woithe92621f12006-02-28 11:47:47 +01005915 /* Disable digital (SPDIF) pins initially, but users can enable
5916 * them via a mixer switch. In the case of SPDIF-out, this initverb
5917 * payload also sets the generation to 0, output to be in "consumer"
5918 * PCM format, copyright asserted, no pre-emphasis and no validity
5919 * control.
5920 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005921 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5922 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5923
Kailang Yangea1fb292008-08-26 12:58:38 +02005924 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005925 * OUT1 sum bus when acting as an output.
5926 */
5927 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5928 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5929 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5930 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5931
5932 /* Start with output sum widgets muted and their output gains at min */
5933 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5934 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5935 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5936 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5937 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5938 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5939 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5940 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5941 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5942
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005943 /* Unmute retasking pin widget output buffers since the default
5944 * state appears to be output. As the pin mode is changed by the
5945 * user the pin mode control will take care of enabling the pin's
5946 * input/output buffers as needed.
5947 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005948 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5949 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5950 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5951 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5952 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5953 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5954 /* Also unmute the mono-out pin widget */
5955 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5956
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005957 /* Mute capture amp left and right */
5958 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005959 /* Set ADC connection select to match default mixer setting (mic1
5960 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005961 */
5962 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5963
5964 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005965 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005966 */
5967 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5968 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5969
5970 /* Mute all inputs to mixer widget (even unconnected ones) */
5971 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5972 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5973 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5974 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5975 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5976 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5977 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5978 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5979
5980 { }
5981};
5982#endif
5983
Takashi Iwai63300792008-01-24 15:31:36 +01005984#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5985#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005986
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005987#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5988#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5989
Kailang Yangdf694da2005-12-05 19:42:22 +01005990/*
5991 * for BIOS auto-configuration
5992 */
5993
5994static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005995 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005996{
5997 hda_nid_t nid_vol;
5998 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01005999 int err;
6000
6001 if (nid >= 0x0f && nid < 0x11) {
6002 nid_vol = nid - 0x7;
6003 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6004 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6005 } else if (nid == 0x11) {
6006 nid_vol = nid - 0x7;
6007 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6008 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6009 } else if (nid >= 0x12 && nid <= 0x15) {
6010 nid_vol = 0x08;
6011 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6012 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6013 } else
6014 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006015
Takashi Iwai863b4512008-10-21 17:01:47 +02006016 if (!(*vol_bits & (1 << nid_vol))) {
6017 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006018 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006019 if (err < 0)
6020 return err;
6021 *vol_bits |= (1 << nid_vol);
6022 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006023 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006024 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006025 return err;
6026 return 1;
6027}
6028
6029/* add playback controls from the parsed DAC table */
6030static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6031 const struct auto_pin_cfg *cfg)
6032{
6033 hda_nid_t nid;
6034 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006035 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006036
6037 spec->multiout.num_dacs = 1;
6038 spec->multiout.dac_nids = spec->private_dac_nids;
6039 spec->multiout.dac_nids[0] = 0x02;
6040
6041 nid = cfg->line_out_pins[0];
6042 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006043 const char *pfx;
6044 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6045 pfx = "Master";
6046 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6047 pfx = "Speaker";
6048 else
6049 pfx = "Front";
6050 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006051 if (err < 0)
6052 return err;
6053 }
6054
Takashi Iwai82bc9552006-03-21 11:24:42 +01006055 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006056 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006057 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006058 if (err < 0)
6059 return err;
6060 }
6061
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006062 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006063 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006064 err = alc260_add_playback_controls(spec, nid, "Headphone",
6065 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006066 if (err < 0)
6067 return err;
6068 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006069 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006070}
6071
6072/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006073static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006074 const struct auto_pin_cfg *cfg)
6075{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006076 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006077}
6078
6079static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6080 hda_nid_t nid, int pin_type,
6081 int sel_idx)
6082{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006083 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006084 /* need the manual connection? */
6085 if (nid >= 0x12) {
6086 int idx = nid - 0x12;
6087 snd_hda_codec_write(codec, idx + 0x0b, 0,
6088 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006089 }
6090}
6091
6092static void alc260_auto_init_multi_out(struct hda_codec *codec)
6093{
6094 struct alc_spec *spec = codec->spec;
6095 hda_nid_t nid;
6096
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006097 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006098 if (nid) {
6099 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6100 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6101 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006102
Takashi Iwai82bc9552006-03-21 11:24:42 +01006103 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006104 if (nid)
6105 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6106
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006107 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006108 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006109 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006110}
Kailang Yangdf694da2005-12-05 19:42:22 +01006111
6112#define ALC260_PIN_CD_NID 0x16
6113static void alc260_auto_init_analog_input(struct hda_codec *codec)
6114{
6115 struct alc_spec *spec = codec->spec;
6116 int i;
6117
6118 for (i = 0; i < AUTO_PIN_LAST; i++) {
6119 hda_nid_t nid = spec->autocfg.input_pins[i];
6120 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006121 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006122 if (nid != ALC260_PIN_CD_NID &&
6123 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006124 snd_hda_codec_write(codec, nid, 0,
6125 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006126 AMP_OUT_MUTE);
6127 }
6128 }
6129}
6130
6131/*
6132 * generic initialization of ADC, input mixers and output mixers
6133 */
6134static struct hda_verb alc260_volume_init_verbs[] = {
6135 /*
6136 * Unmute ADC0-1 and set the default input to mic-in
6137 */
6138 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6139 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6140 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6141 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006142
Kailang Yangdf694da2005-12-05 19:42:22 +01006143 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6144 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006145 * Note: PASD motherboards uses the Line In 2 as the input for
6146 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006147 */
6148 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006149 /* mute analog inputs */
6150 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6151 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6152 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6153 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6154 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006155
6156 /*
6157 * Set up output mixers (0x08 - 0x0a)
6158 */
6159 /* set vol=0 to output mixers */
6160 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6161 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6162 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6163 /* set up input amps for analog loopback */
6164 /* Amp Indices: DAC = 0, mixer = 1 */
6165 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6166 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6167 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6168 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6169 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6170 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006171
Kailang Yangdf694da2005-12-05 19:42:22 +01006172 { }
6173};
6174
6175static int alc260_parse_auto_config(struct hda_codec *codec)
6176{
6177 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006178 int err;
6179 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6180
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006181 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6182 alc260_ignore);
6183 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006184 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006185 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6186 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006187 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006188 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006189 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006190 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006191 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006192 return err;
6193
6194 spec->multiout.max_channels = 2;
6195
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006196 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006197 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006198 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006199 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006200
Takashi Iwaid88897e2008-10-31 15:01:37 +01006201 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006202
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006203 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006204 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006205
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006206 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6207
Kailang Yangdf694da2005-12-05 19:42:22 +01006208 return 1;
6209}
6210
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006211/* additional initialization for auto-configuration model */
6212static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006213{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006214 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006215 alc260_auto_init_multi_out(codec);
6216 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006217 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006218 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006219}
6220
Takashi Iwaicb53c622007-08-10 17:21:45 +02006221#ifdef CONFIG_SND_HDA_POWER_SAVE
6222static struct hda_amp_list alc260_loopbacks[] = {
6223 { 0x07, HDA_INPUT, 0 },
6224 { 0x07, HDA_INPUT, 1 },
6225 { 0x07, HDA_INPUT, 2 },
6226 { 0x07, HDA_INPUT, 3 },
6227 { 0x07, HDA_INPUT, 4 },
6228 { } /* end */
6229};
6230#endif
6231
Kailang Yangdf694da2005-12-05 19:42:22 +01006232/*
6233 * ALC260 configurations
6234 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006235static const char *alc260_models[ALC260_MODEL_LAST] = {
6236 [ALC260_BASIC] = "basic",
6237 [ALC260_HP] = "hp",
6238 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006239 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006240 [ALC260_FUJITSU_S702X] = "fujitsu",
6241 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006242 [ALC260_WILL] = "will",
6243 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006244 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006245#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006246 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006247#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006248 [ALC260_AUTO] = "auto",
6249};
6250
6251static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006252 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006253 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006254 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006255 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006256 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006257 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006258 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006259 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006260 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006261 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6262 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6263 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6264 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6265 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6266 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6267 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6268 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6269 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006270 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006271 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006272 {}
6273};
6274
Kailang Yangdf694da2005-12-05 19:42:22 +01006275static struct alc_config_preset alc260_presets[] = {
6276 [ALC260_BASIC] = {
6277 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006278 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006279 .init_verbs = { alc260_init_verbs },
6280 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6281 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006282 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006283 .adc_nids = alc260_adc_nids,
6284 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6285 .channel_mode = alc260_modes,
6286 .input_mux = &alc260_capture_source,
6287 },
6288 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006289 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006290 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006291 .init_verbs = { alc260_init_verbs,
6292 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006293 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6294 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006295 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6296 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006297 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6298 .channel_mode = alc260_modes,
6299 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006300 .unsol_event = alc260_hp_unsol_event,
6301 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006302 },
Kailang Yang3f878302008-08-26 13:02:23 +02006303 [ALC260_HP_DC7600] = {
6304 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006305 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006306 .init_verbs = { alc260_init_verbs,
6307 alc260_hp_dc7600_verbs },
6308 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6309 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006310 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6311 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006312 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6313 .channel_mode = alc260_modes,
6314 .input_mux = &alc260_capture_source,
6315 .unsol_event = alc260_hp_3012_unsol_event,
6316 .init_hook = alc260_hp_3012_automute,
6317 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006318 [ALC260_HP_3013] = {
6319 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006320 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006321 .init_verbs = { alc260_hp_3013_init_verbs,
6322 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006323 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6324 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006325 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6326 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006327 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6328 .channel_mode = alc260_modes,
6329 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006330 .unsol_event = alc260_hp_3013_unsol_event,
6331 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006332 },
6333 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006334 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006335 .init_verbs = { alc260_fujitsu_init_verbs },
6336 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6337 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006338 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6339 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006340 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6341 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006342 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6343 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006344 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006345 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006346 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006347 .init_verbs = { alc260_acer_init_verbs },
6348 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6349 .dac_nids = alc260_dac_nids,
6350 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6351 .adc_nids = alc260_dual_adc_nids,
6352 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6353 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006354 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6355 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006356 },
Michael Schwingencc959482009-02-22 18:58:45 +01006357 [ALC260_FAVORIT100] = {
6358 .mixers = { alc260_favorit100_mixer },
6359 .init_verbs = { alc260_favorit100_init_verbs },
6360 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6361 .dac_nids = alc260_dac_nids,
6362 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6363 .adc_nids = alc260_dual_adc_nids,
6364 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6365 .channel_mode = alc260_modes,
6366 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6367 .input_mux = alc260_favorit100_capture_sources,
6368 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006369 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006370 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006371 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6372 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6373 .dac_nids = alc260_dac_nids,
6374 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6375 .adc_nids = alc260_adc_nids,
6376 .dig_out_nid = ALC260_DIGOUT_NID,
6377 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6378 .channel_mode = alc260_modes,
6379 .input_mux = &alc260_capture_source,
6380 },
6381 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006382 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006383 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6384 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6385 .dac_nids = alc260_dac_nids,
6386 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6387 .adc_nids = alc260_adc_nids,
6388 .dig_out_nid = ALC260_DIGOUT_NID,
6389 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6390 .channel_mode = alc260_modes,
6391 .input_mux = &alc260_capture_source,
6392 .unsol_event = alc260_replacer_672v_unsol_event,
6393 .init_hook = alc260_replacer_672v_automute,
6394 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006395#ifdef CONFIG_SND_DEBUG
6396 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006397 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006398 .init_verbs = { alc260_test_init_verbs },
6399 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6400 .dac_nids = alc260_test_dac_nids,
6401 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6402 .adc_nids = alc260_test_adc_nids,
6403 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6404 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006405 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6406 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006407 },
6408#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006409};
6410
Linus Torvalds1da177e2005-04-16 15:20:36 -07006411static int patch_alc260(struct hda_codec *codec)
6412{
6413 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006414 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006415
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006416 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006417 if (spec == NULL)
6418 return -ENOMEM;
6419
6420 codec->spec = spec;
6421
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006422 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6423 alc260_models,
6424 alc260_cfg_tbl);
6425 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006426 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006427 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006428 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006429 }
6430
Kailang Yangdf694da2005-12-05 19:42:22 +01006431 if (board_config == ALC260_AUTO) {
6432 /* automatic parse from the BIOS config */
6433 err = alc260_parse_auto_config(codec);
6434 if (err < 0) {
6435 alc_free(codec);
6436 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006437 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006438 printk(KERN_INFO
6439 "hda_codec: Cannot set up configuration "
6440 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006441 board_config = ALC260_BASIC;
6442 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006443 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006444
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006445 err = snd_hda_attach_beep_device(codec, 0x1);
6446 if (err < 0) {
6447 alc_free(codec);
6448 return err;
6449 }
6450
Kailang Yangdf694da2005-12-05 19:42:22 +01006451 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006452 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006453
Linus Torvalds1da177e2005-04-16 15:20:36 -07006454 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6455 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6456
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006457 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6458 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6459
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006460 if (!spec->adc_nids && spec->input_mux) {
6461 /* check whether NID 0x04 is valid */
6462 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006463 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006464 /* get type */
6465 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6466 spec->adc_nids = alc260_adc_nids_alt;
6467 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6468 } else {
6469 spec->adc_nids = alc260_adc_nids;
6470 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6471 }
6472 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006473 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006474 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006475
Takashi Iwai2134ea42008-01-10 16:53:55 +01006476 spec->vmaster_nid = 0x08;
6477
Linus Torvalds1da177e2005-04-16 15:20:36 -07006478 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006479 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006480 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006481#ifdef CONFIG_SND_HDA_POWER_SAVE
6482 if (!spec->loopback.amplist)
6483 spec->loopback.amplist = alc260_loopbacks;
6484#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006485 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006486
6487 return 0;
6488}
6489
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006490
Linus Torvalds1da177e2005-04-16 15:20:36 -07006491/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006492 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006493 *
6494 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6495 * configuration. Each pin widget can choose any input DACs and a mixer.
6496 * Each ADC is connected from a mixer of all inputs. This makes possible
6497 * 6-channel independent captures.
6498 *
6499 * In addition, an independent DAC for the multi-playback (not used in this
6500 * driver yet).
6501 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006502#define ALC882_DIGOUT_NID 0x06
6503#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006504#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6505#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6506#define ALC1200_DIGOUT_NID 0x10
6507
Linus Torvalds1da177e2005-04-16 15:20:36 -07006508
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006509static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006510 { 8, NULL }
6511};
6512
Takashi Iwai4953550a2009-06-30 15:28:30 +02006513/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006514static hda_nid_t alc882_dac_nids[4] = {
6515 /* front, rear, clfe, rear_surr */
6516 0x02, 0x03, 0x04, 0x05
6517};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006518#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006519
Takashi Iwai4953550a2009-06-30 15:28:30 +02006520/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006521#define alc882_adc_nids alc880_adc_nids
6522#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006523#define alc883_adc_nids alc882_adc_nids_alt
6524static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6525static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6526#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006527
Takashi Iwaie1406342008-02-11 18:32:32 +01006528static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6529static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006530#define alc883_capsrc_nids alc882_capsrc_nids_alt
6531static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6532#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006533
Linus Torvalds1da177e2005-04-16 15:20:36 -07006534/* input MUX */
6535/* FIXME: should be a matrix-type input source selection */
6536
6537static struct hda_input_mux alc882_capture_source = {
6538 .num_items = 4,
6539 .items = {
6540 { "Mic", 0x0 },
6541 { "Front Mic", 0x1 },
6542 { "Line", 0x2 },
6543 { "CD", 0x4 },
6544 },
6545};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006546
Takashi Iwai4953550a2009-06-30 15:28:30 +02006547#define alc883_capture_source alc882_capture_source
6548
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006549static struct hda_input_mux alc889_capture_source = {
6550 .num_items = 3,
6551 .items = {
6552 { "Front Mic", 0x0 },
6553 { "Mic", 0x3 },
6554 { "Line", 0x2 },
6555 },
6556};
6557
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006558static struct hda_input_mux mb5_capture_source = {
6559 .num_items = 3,
6560 .items = {
6561 { "Mic", 0x1 },
6562 { "Line", 0x2 },
6563 { "CD", 0x4 },
6564 },
6565};
6566
Takashi Iwai4953550a2009-06-30 15:28:30 +02006567static struct hda_input_mux alc883_3stack_6ch_intel = {
6568 .num_items = 4,
6569 .items = {
6570 { "Mic", 0x1 },
6571 { "Front Mic", 0x0 },
6572 { "Line", 0x2 },
6573 { "CD", 0x4 },
6574 },
6575};
6576
6577static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6578 .num_items = 2,
6579 .items = {
6580 { "Mic", 0x1 },
6581 { "Line", 0x2 },
6582 },
6583};
6584
6585static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6586 .num_items = 4,
6587 .items = {
6588 { "Mic", 0x0 },
6589 { "iMic", 0x1 },
6590 { "Line", 0x2 },
6591 { "CD", 0x4 },
6592 },
6593};
6594
6595static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6596 .num_items = 2,
6597 .items = {
6598 { "Mic", 0x0 },
6599 { "Int Mic", 0x1 },
6600 },
6601};
6602
6603static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6604 .num_items = 3,
6605 .items = {
6606 { "Mic", 0x0 },
6607 { "Front Mic", 0x1 },
6608 { "Line", 0x4 },
6609 },
6610};
6611
6612static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6613 .num_items = 2,
6614 .items = {
6615 { "Mic", 0x0 },
6616 { "Line", 0x2 },
6617 },
6618};
6619
6620static struct hda_input_mux alc889A_mb31_capture_source = {
6621 .num_items = 2,
6622 .items = {
6623 { "Mic", 0x0 },
6624 /* Front Mic (0x01) unused */
6625 { "Line", 0x2 },
6626 /* Line 2 (0x03) unused */
6627 /* CD (0x04) unsused? */
6628 },
6629};
6630
6631/*
6632 * 2ch mode
6633 */
6634static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6635 { 2, NULL }
6636};
6637
Kailang Yangdf694da2005-12-05 19:42:22 +01006638/*
Kailang Yang272a5272007-05-14 11:00:38 +02006639 * 2ch mode
6640 */
6641static struct hda_verb alc882_3ST_ch2_init[] = {
6642 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6643 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6644 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6645 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6646 { } /* end */
6647};
6648
6649/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006650 * 4ch mode
6651 */
6652static struct hda_verb alc882_3ST_ch4_init[] = {
6653 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6654 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6655 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6656 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6657 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6658 { } /* end */
6659};
6660
6661/*
Kailang Yang272a5272007-05-14 11:00:38 +02006662 * 6ch mode
6663 */
6664static struct hda_verb alc882_3ST_ch6_init[] = {
6665 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6666 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6667 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6668 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6669 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6670 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6671 { } /* end */
6672};
6673
Takashi Iwai4953550a2009-06-30 15:28:30 +02006674static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006675 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006676 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006677 { 6, alc882_3ST_ch6_init },
6678};
6679
Takashi Iwai4953550a2009-06-30 15:28:30 +02006680#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6681
Kailang Yang272a5272007-05-14 11:00:38 +02006682/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04306683 * 2ch mode
6684 */
6685static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6686 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6687 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6688 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6689 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6690 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6691 { } /* end */
6692};
6693
6694/*
6695 * 4ch mode
6696 */
6697static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
6698 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6699 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6700 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6701 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6702 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6703 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6704 { } /* end */
6705};
6706
6707/*
6708 * 6ch mode
6709 */
6710static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
6711 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6712 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6713 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6714 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6715 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6716 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6717 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6718 { } /* end */
6719};
6720
6721static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
6722 { 2, alc883_3ST_ch2_clevo_init },
6723 { 4, alc883_3ST_ch4_clevo_init },
6724 { 6, alc883_3ST_ch6_clevo_init },
6725};
6726
6727
6728/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006729 * 6ch mode
6730 */
6731static struct hda_verb alc882_sixstack_ch6_init[] = {
6732 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6733 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6734 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6735 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6736 { } /* end */
6737};
6738
6739/*
6740 * 8ch mode
6741 */
6742static struct hda_verb alc882_sixstack_ch8_init[] = {
6743 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6744 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6745 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6746 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6747 { } /* end */
6748};
6749
6750static struct hda_channel_mode alc882_sixstack_modes[2] = {
6751 { 6, alc882_sixstack_ch6_init },
6752 { 8, alc882_sixstack_ch8_init },
6753};
6754
Takashi Iwai87350ad2007-08-16 18:19:38 +02006755/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006756 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006757 */
6758
6759/*
6760 * 2ch mode
6761 */
6762static struct hda_verb alc885_mbp_ch2_init[] = {
6763 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6764 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6765 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6766 { } /* end */
6767};
6768
6769/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006770 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02006771 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006772static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006773 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6774 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6775 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6776 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6777 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6778 { } /* end */
6779};
6780
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006781static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006782 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006783 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006784};
6785
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006786/*
6787 * 2ch
6788 * Speakers/Woofer/HP = Front
6789 * LineIn = Input
6790 */
6791static struct hda_verb alc885_mb5_ch2_init[] = {
6792 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6793 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6794 { } /* end */
6795};
6796
6797/*
6798 * 6ch mode
6799 * Speakers/HP = Front
6800 * Woofer = LFE
6801 * LineIn = Surround
6802 */
6803static struct hda_verb alc885_mb5_ch6_init[] = {
6804 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6805 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6806 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6807 { } /* end */
6808};
6809
6810static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6811 { 2, alc885_mb5_ch2_init },
6812 { 6, alc885_mb5_ch6_init },
6813};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006814
Takashi Iwai4953550a2009-06-30 15:28:30 +02006815
6816/*
6817 * 2ch mode
6818 */
6819static struct hda_verb alc883_4ST_ch2_init[] = {
6820 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6821 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6822 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6823 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6824 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6825 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6826 { } /* end */
6827};
6828
6829/*
6830 * 4ch mode
6831 */
6832static struct hda_verb alc883_4ST_ch4_init[] = {
6833 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6834 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6835 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6836 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6837 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6838 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6839 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6840 { } /* end */
6841};
6842
6843/*
6844 * 6ch mode
6845 */
6846static struct hda_verb alc883_4ST_ch6_init[] = {
6847 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6848 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6849 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6850 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6851 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6852 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6853 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6854 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6855 { } /* end */
6856};
6857
6858/*
6859 * 8ch mode
6860 */
6861static struct hda_verb alc883_4ST_ch8_init[] = {
6862 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6863 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6864 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6865 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6866 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6867 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6868 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6869 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6870 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6871 { } /* end */
6872};
6873
6874static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6875 { 2, alc883_4ST_ch2_init },
6876 { 4, alc883_4ST_ch4_init },
6877 { 6, alc883_4ST_ch6_init },
6878 { 8, alc883_4ST_ch8_init },
6879};
6880
6881
6882/*
6883 * 2ch mode
6884 */
6885static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6886 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6887 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6888 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6889 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6890 { } /* end */
6891};
6892
6893/*
6894 * 4ch mode
6895 */
6896static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6897 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6898 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6899 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6900 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6901 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6902 { } /* end */
6903};
6904
6905/*
6906 * 6ch mode
6907 */
6908static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6909 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6910 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6911 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6912 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6913 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6914 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6915 { } /* end */
6916};
6917
6918static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6919 { 2, alc883_3ST_ch2_intel_init },
6920 { 4, alc883_3ST_ch4_intel_init },
6921 { 6, alc883_3ST_ch6_intel_init },
6922};
6923
6924/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006925 * 2ch mode
6926 */
6927static struct hda_verb alc889_ch2_intel_init[] = {
6928 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6929 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
6930 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
6931 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
6932 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6933 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6934 { } /* end */
6935};
6936
6937/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006938 * 6ch mode
6939 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006940static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006941 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6942 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6943 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6944 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6945 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006946 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6947 { } /* end */
6948};
6949
6950/*
6951 * 8ch mode
6952 */
6953static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006954 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6955 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6956 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6957 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6958 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006959 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6960 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006961 { } /* end */
6962};
6963
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006964static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
6965 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006966 { 6, alc889_ch6_intel_init },
6967 { 8, alc889_ch8_intel_init },
6968};
6969
6970/*
6971 * 6ch mode
6972 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006973static struct hda_verb alc883_sixstack_ch6_init[] = {
6974 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6975 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6976 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6977 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6978 { } /* end */
6979};
6980
6981/*
6982 * 8ch mode
6983 */
6984static struct hda_verb alc883_sixstack_ch8_init[] = {
6985 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6986 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6987 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6988 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6989 { } /* end */
6990};
6991
6992static struct hda_channel_mode alc883_sixstack_modes[2] = {
6993 { 6, alc883_sixstack_ch6_init },
6994 { 8, alc883_sixstack_ch8_init },
6995};
6996
6997
Linus Torvalds1da177e2005-04-16 15:20:36 -07006998/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6999 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7000 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007001static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007002 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007003 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007004 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007005 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007006 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7007 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007008 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7009 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007010 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007011 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007012 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7013 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7014 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7015 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7016 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7017 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007018 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007019 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7020 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007021 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007022 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007023 { } /* end */
7024};
7025
Takashi Iwai87350ad2007-08-16 18:19:38 +02007026static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007027 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7028 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7029 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7030 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7031 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007032 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7033 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007034 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7035 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007036 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007037 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7038 { } /* end */
7039};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007040
7041static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007042 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7043 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7044 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7045 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7046 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7047 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7048 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7049 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007050 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7051 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7052 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7053 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7054 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7055 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7056 { } /* end */
7057};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007058
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007059static struct snd_kcontrol_new alc885_imac91_mixer[] = {
7060 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7061 HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
7062 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
7063 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
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, 0x00, HDA_INPUT),
7067 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7068 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7069 { } /* end */
7070};
7071
7072
Kailang Yangbdd148a2007-05-08 15:19:08 +02007073static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7074 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7075 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7076 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7077 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7078 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7079 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7080 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7081 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7082 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007083 { } /* end */
7084};
7085
Kailang Yang272a5272007-05-14 11:00:38 +02007086static struct snd_kcontrol_new alc882_targa_mixer[] = {
7087 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7088 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7089 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7090 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7091 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7092 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7093 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7094 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7095 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007096 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007097 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7098 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007099 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007100 { } /* end */
7101};
7102
7103/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7104 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7105 */
7106static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7107 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7108 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7109 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7110 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7111 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7112 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
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("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7116 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7117 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7118 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007119 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007120 { } /* end */
7121};
7122
Takashi Iwai914759b2007-09-06 14:52:04 +02007123static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7124 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7125 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7126 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7127 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7128 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7129 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7130 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7131 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7132 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7133 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007134 { } /* end */
7135};
7136
Kailang Yangdf694da2005-12-05 19:42:22 +01007137static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7138 {
7139 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7140 .name = "Channel Mode",
7141 .info = alc_ch_mode_info,
7142 .get = alc_ch_mode_get,
7143 .put = alc_ch_mode_put,
7144 },
7145 { } /* end */
7146};
7147
Takashi Iwai4953550a2009-06-30 15:28:30 +02007148static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007149 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007150 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7151 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7152 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007153 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007154 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7155 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7156 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007157 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007158 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7159 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7160 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007161 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007162 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7163 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7164 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007165
Takashi Iwaicb638122009-07-03 10:56:10 +02007166 /* mute analog input loopbacks */
7167 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7168 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7169 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7170 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7171 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7172
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007173 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007174 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007175 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007176 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007177 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007178 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007179 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007180 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007181 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007182 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007183 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007184 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007185 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007186 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007187 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007188 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007189 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007190 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007191 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7192 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007193 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007194 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7195 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007196 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007197 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7198 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7199 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7200 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7201 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007202 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007203 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007204
7205 /* FIXME: use matrix-type input source selection */
7206 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007207 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007208 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7209 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7210 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7211 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007212 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007213 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7214 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7215 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7216 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007217 /* ADC2: mute amp left and right */
7218 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007219 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007220 /* ADC3: mute amp left and right */
7221 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007222 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007223
7224 { }
7225};
7226
Takashi Iwai4953550a2009-06-30 15:28:30 +02007227static struct hda_verb alc882_adc1_init_verbs[] = {
7228 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7229 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7230 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7231 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7232 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7233 /* ADC1: mute amp left and right */
7234 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7235 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7236 { }
7237};
7238
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007239static struct hda_verb alc882_eapd_verbs[] = {
7240 /* change to EAPD mode */
7241 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007242 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007243 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007244};
7245
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007246static struct hda_verb alc889_eapd_verbs[] = {
7247 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7248 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7249 { }
7250};
7251
Wu Fengguang6732bd02009-07-30 09:19:14 +02007252static struct hda_verb alc_hp15_unsol_verbs[] = {
7253 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7254 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7255 {}
7256};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007257
7258static struct hda_verb alc885_init_verbs[] = {
7259 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7260 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7261 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7262 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7263 /* Rear mixer */
7264 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7265 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7266 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7267 /* CLFE mixer */
7268 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7269 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7270 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7271 /* Side mixer */
7272 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7273 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7274 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7275
7276 /* mute analog input loopbacks */
7277 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7278 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7279 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7280
7281 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007282 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007283 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7284 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7285 /* Front Pin: output 0 (0x0c) */
7286 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7287 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7288 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7289 /* Rear Pin: output 1 (0x0d) */
7290 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7291 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7292 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7293 /* CLFE Pin: output 2 (0x0e) */
7294 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7295 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7296 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7297 /* Side Pin: output 3 (0x0f) */
7298 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7299 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7300 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7301 /* Mic (rear) pin: input vref at 80% */
7302 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7303 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7304 /* Front Mic pin: input vref at 80% */
7305 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7306 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7307 /* Line In pin: input */
7308 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7309 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7310
7311 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7312 /* Input mixer1 */
7313 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7314 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7315 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7316 /* Input mixer2 */
7317 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7318 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7319 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7320 /* Input mixer3 */
7321 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7322 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7323 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7324 /* ADC2: mute amp left and right */
7325 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7326 /* ADC3: mute amp left and right */
7327 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7328
7329 { }
7330};
7331
7332static struct hda_verb alc885_init_input_verbs[] = {
7333 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7334 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7335 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7336 { }
7337};
7338
7339
7340/* Unmute Selector 24h and set the default input to front mic */
7341static struct hda_verb alc889_init_input_verbs[] = {
7342 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7343 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7344 { }
7345};
7346
7347
Takashi Iwai4953550a2009-06-30 15:28:30 +02007348#define alc883_init_verbs alc882_base_init_verbs
7349
Tobin Davis9102cd12006-12-15 10:02:12 +01007350/* Mac Pro test */
7351static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7352 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7353 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7354 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7355 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7356 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007357 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007358 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7359 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007360 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007361 { } /* end */
7362};
7363
7364static struct hda_verb alc882_macpro_init_verbs[] = {
7365 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7366 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7367 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7368 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7369 /* Front Pin: output 0 (0x0c) */
7370 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7371 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7372 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7373 /* Front Mic pin: input vref at 80% */
7374 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7375 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7376 /* Speaker: output */
7377 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7378 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7379 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7380 /* Headphone output (output 0 - 0x0c) */
7381 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7382 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7383 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7384
7385 /* FIXME: use matrix-type input source selection */
7386 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7387 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7388 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7389 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7390 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7391 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7392 /* Input mixer2 */
7393 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7394 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7395 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7396 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7397 /* Input mixer3 */
7398 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7399 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7400 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7401 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7402 /* ADC1: mute amp left and right */
7403 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7404 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7405 /* ADC2: mute amp left and right */
7406 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7407 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7408 /* ADC3: mute amp left and right */
7409 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7410 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7411
7412 { }
7413};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007414
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007415/* Macbook 5,1 */
7416static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007417 /* DACs */
7418 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7419 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7420 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7421 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007422 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007423 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7424 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7425 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007426 /* Surround mixer */
7427 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7428 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7429 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7430 /* LFE mixer */
7431 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7432 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7433 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7434 /* HP mixer */
7435 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7436 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7437 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7438 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007439 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7440 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007441 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7442 /* LFE Pin (0x0e) */
7443 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7444 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7445 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7446 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007447 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7448 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007449 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007450 /* Front Mic pin: input vref at 80% */
7451 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7452 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7453 /* Line In pin */
7454 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7455 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7456
7457 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7458 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7459 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7460 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7461 { }
7462};
7463
Takashi Iwai87350ad2007-08-16 18:19:38 +02007464/* Macbook Pro rev3 */
7465static struct hda_verb alc885_mbp3_init_verbs[] = {
7466 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7467 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7468 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7469 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7470 /* Rear mixer */
7471 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7472 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7473 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007474 /* HP mixer */
7475 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7476 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7477 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007478 /* Front Pin: output 0 (0x0c) */
7479 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7480 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7481 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007482 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007483 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007484 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7485 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007486 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7487 /* Mic (rear) pin: input vref at 80% */
7488 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7489 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7490 /* Front Mic pin: input vref at 80% */
7491 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7492 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7493 /* Line In pin: use output 1 when in LineOut mode */
7494 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7495 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7496 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7497
7498 /* FIXME: use matrix-type input source selection */
7499 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7500 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7501 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7502 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7503 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7504 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7505 /* Input mixer2 */
7506 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7507 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7508 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7509 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7510 /* Input mixer3 */
7511 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7512 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7513 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7514 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7515 /* ADC1: mute amp left and right */
7516 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7517 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7518 /* ADC2: mute amp left and right */
7519 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7520 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7521 /* ADC3: mute amp left and right */
7522 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7523 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7524
7525 { }
7526};
7527
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007528/* iMac 9,1 */
7529static struct hda_verb alc885_imac91_init_verbs[] = {
7530 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
7531 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7532 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7533 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7534 /* Rear mixer */
7535 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7536 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7537 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7538 /* HP Pin: output 0 (0x0c) */
7539 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7540 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7541 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7542 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7543 /* Internal Speakers: output 0 (0x0d) */
7544 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7545 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7546 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7547 /* Mic (rear) pin: input vref at 80% */
7548 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7549 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7550 /* Front Mic pin: input vref at 80% */
7551 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7552 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7553 /* Line In pin: use output 1 when in LineOut mode */
7554 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7555 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7556 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7557
7558 /* FIXME: use matrix-type input source selection */
7559 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7560 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7561 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7562 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7563 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7564 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7565 /* Input mixer2 */
7566 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7567 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7568 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7569 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7570 /* Input mixer3 */
7571 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7572 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7573 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7574 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7575 /* ADC1: mute amp left and right */
7576 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7577 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7578 /* ADC2: mute amp left and right */
7579 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7580 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7581 /* ADC3: mute amp left and right */
7582 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7583 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7584
7585 { }
7586};
7587
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007588/* iMac 24 mixer. */
7589static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7590 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7591 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7592 { } /* end */
7593};
7594
7595/* iMac 24 init verbs. */
7596static struct hda_verb alc885_imac24_init_verbs[] = {
7597 /* Internal speakers: output 0 (0x0c) */
7598 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7599 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7600 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7601 /* Internal speakers: output 0 (0x0c) */
7602 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7603 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7604 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7605 /* Headphone: output 0 (0x0c) */
7606 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7607 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7608 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7609 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7610 /* Front Mic: input vref at 80% */
7611 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7612 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7613 { }
7614};
7615
7616/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007617static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007618{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007619 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007620
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007621 spec->autocfg.hp_pins[0] = 0x14;
7622 spec->autocfg.speaker_pins[0] = 0x18;
7623 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007624}
7625
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007626static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007627{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007628 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007629
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007630 spec->autocfg.hp_pins[0] = 0x15;
7631 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02007632}
7633
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007634static void alc885_imac91_automute(struct hda_codec *codec)
7635{
7636 unsigned int present;
7637
7638 present = snd_hda_codec_read(codec, 0x14, 0,
7639 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7640 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7641 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7642 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
7643 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7644
7645}
7646
7647static void alc885_imac91_unsol_event(struct hda_codec *codec,
7648 unsigned int res)
7649{
7650 /* Headphone insertion or removal. */
7651 if ((res >> 26) == ALC880_HP_EVENT)
7652 alc885_imac91_automute(codec);
7653}
Takashi Iwai87350ad2007-08-16 18:19:38 +02007654
Kailang Yang272a5272007-05-14 11:00:38 +02007655static struct hda_verb alc882_targa_verbs[] = {
7656 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7657 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7658
7659 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7660 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007661
Kailang Yang272a5272007-05-14 11:00:38 +02007662 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7663 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7664 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7665
7666 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007667 { } /* end */
7668};
7669
7670/* toggle speaker-output according to the hp-jack state */
7671static void alc882_targa_automute(struct hda_codec *codec)
7672{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007673 struct alc_spec *spec = codec->spec;
7674 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007675 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007676 spec->jack_present ? 1 : 3);
7677}
7678
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007679static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007680{
7681 struct alc_spec *spec = codec->spec;
7682
7683 spec->autocfg.hp_pins[0] = 0x14;
7684 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02007685}
7686
7687static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7688{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007689 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007690 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007691}
7692
7693static struct hda_verb alc882_asus_a7j_verbs[] = {
7694 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7695 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7696
7697 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7698 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7699 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007700
Kailang Yang272a5272007-05-14 11:00:38 +02007701 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7702 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7703 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7704
7705 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7706 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7707 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7708 { } /* end */
7709};
7710
Takashi Iwai914759b2007-09-06 14:52:04 +02007711static struct hda_verb alc882_asus_a7m_verbs[] = {
7712 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7713 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7714
7715 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7716 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7717 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007718
Takashi Iwai914759b2007-09-06 14:52:04 +02007719 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7720 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7721 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7722
7723 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7724 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7725 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7726 { } /* end */
7727};
7728
Tobin Davis9102cd12006-12-15 10:02:12 +01007729static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7730{
7731 unsigned int gpiostate, gpiomask, gpiodir;
7732
7733 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7734 AC_VERB_GET_GPIO_DATA, 0);
7735
7736 if (!muted)
7737 gpiostate |= (1 << pin);
7738 else
7739 gpiostate &= ~(1 << pin);
7740
7741 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7742 AC_VERB_GET_GPIO_MASK, 0);
7743 gpiomask |= (1 << pin);
7744
7745 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7746 AC_VERB_GET_GPIO_DIRECTION, 0);
7747 gpiodir |= (1 << pin);
7748
7749
7750 snd_hda_codec_write(codec, codec->afg, 0,
7751 AC_VERB_SET_GPIO_MASK, gpiomask);
7752 snd_hda_codec_write(codec, codec->afg, 0,
7753 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7754
7755 msleep(1);
7756
7757 snd_hda_codec_write(codec, codec->afg, 0,
7758 AC_VERB_SET_GPIO_DATA, gpiostate);
7759}
7760
Takashi Iwai7debbe52007-08-16 15:01:03 +02007761/* set up GPIO at initialization */
7762static void alc885_macpro_init_hook(struct hda_codec *codec)
7763{
7764 alc882_gpio_mute(codec, 0, 0);
7765 alc882_gpio_mute(codec, 1, 0);
7766}
7767
7768/* set up GPIO and update auto-muting at initialization */
7769static void alc885_imac24_init_hook(struct hda_codec *codec)
7770{
7771 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007772 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007773}
7774
Kailang Yangdf694da2005-12-05 19:42:22 +01007775/*
7776 * generic initialization of ADC, input mixers and output mixers
7777 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007778static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007779 /*
7780 * Unmute ADC0-2 and set the default input to mic-in
7781 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007782 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7783 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7784 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7785 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7786
Takashi Iwaicb53c622007-08-10 17:21:45 +02007787 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007788 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007789 * Note: PASD motherboards uses the Line In 2 as the input for
7790 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007791 */
7792 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007793 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7794 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7795 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7796 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7797 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007798
7799 /*
7800 * Set up output mixers (0x0c - 0x0f)
7801 */
7802 /* set vol=0 to output mixers */
7803 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7804 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7805 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7806 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7807 /* set up input amps for analog loopback */
7808 /* Amp Indices: DAC = 0, mixer = 1 */
7809 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7810 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7811 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7812 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7813 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7814 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7815 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7816 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7817 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7818 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7819
7820 /* FIXME: use matrix-type input source selection */
7821 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01007822 /* Input mixer2 */
7823 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7824 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7825 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7826 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7827 /* Input mixer3 */
7828 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7829 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7830 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7831 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7832
7833 { }
7834};
7835
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007836/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7837static struct hda_verb alc889A_mb31_ch2_init[] = {
7838 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7839 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7840 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7841 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7842 { } /* end */
7843};
7844
7845/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7846static struct hda_verb alc889A_mb31_ch4_init[] = {
7847 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7848 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7849 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7850 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7851 { } /* end */
7852};
7853
7854/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7855static struct hda_verb alc889A_mb31_ch5_init[] = {
7856 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7857 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7858 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7859 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7860 { } /* end */
7861};
7862
7863/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7864static struct hda_verb alc889A_mb31_ch6_init[] = {
7865 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7866 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7867 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7868 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7869 { } /* end */
7870};
7871
7872static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7873 { 2, alc889A_mb31_ch2_init },
7874 { 4, alc889A_mb31_ch4_init },
7875 { 5, alc889A_mb31_ch5_init },
7876 { 6, alc889A_mb31_ch6_init },
7877};
7878
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007879static struct hda_verb alc883_medion_eapd_verbs[] = {
7880 /* eanable EAPD on medion laptop */
7881 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7882 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7883 { }
7884};
7885
Takashi Iwai4953550a2009-06-30 15:28:30 +02007886#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007887
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007888static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7889 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7890 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7891 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7892 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7893 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7894 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7895 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7896 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7897 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7898 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7899 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7900 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7901 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007902 { } /* end */
7903};
7904
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007905static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007906 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7907 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7908 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7909 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7910 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7911 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7912 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7913 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7914 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7915 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007916 { } /* end */
7917};
7918
Jiang zhefb97dc62008-03-06 11:07:11 +01007919static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7920 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7921 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7922 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7923 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7924 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7925 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7926 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7927 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7928 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7929 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007930 { } /* end */
7931};
7932
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007933static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7934 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7935 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7936 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7937 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7938 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7939 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7940 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7941 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007942 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007943 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7944 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007945 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007946 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007947 { } /* end */
7948};
7949
7950static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7951 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7952 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7953 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7954 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7955 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7956 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7957 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7958 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7959 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7960 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7961 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7962 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7963 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7964 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007965 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007966 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7967 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007968 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007969 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007970 { } /* end */
7971};
7972
Jiang zhe17bba1b2008-06-04 12:11:07 +02007973static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7974 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7975 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7976 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7977 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7978 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7979 HDA_OUTPUT),
7980 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7981 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7982 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7983 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7984 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7985 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7986 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7987 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7988 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7989 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7990 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7991 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7992 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7993 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007994 { } /* end */
7995};
7996
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007997static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
7998 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7999 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8000 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8001 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8002 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8003 HDA_OUTPUT),
8004 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8005 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8006 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8007 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8008 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8009 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
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, 0x3, HDA_INPUT),
8013 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8014 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8015 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8016 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8017 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8018 { } /* end */
8019};
8020
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008021static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008022 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008023 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008024 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008025 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008026 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),
Takashi Iwai0701e062008-06-27 16:30:57 +02008028 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),
Tobin Davisc07584c2006-10-13 12:32:16 +02008030 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),
Tobin Davisc07584c2006-10-13 12:32:16 +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),
Tobin Davisc07584c2006-10-13 12:32:16 +02008040 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008041 { } /* end */
8042};
8043
Sasha Alexandrc2592492009-06-16 14:52:54 -04008044static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008045 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008046 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008047 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008048 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008049 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8050 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8051 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8052 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8053 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8054 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
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, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008060 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008061 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008062 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008063};
Kailang Yangccc656c2006-10-17 12:32:26 +02008064
Sasha Alexandrc2592492009-06-16 14:52:54 -04008065static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008066 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008067 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008068 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008069 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008070 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8071 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8072 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008073 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008074 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008075 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8076 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8077 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008078 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008079};
Kailang Yangccc656c2006-10-17 12:32:26 +02008080
Takashi Iwaib99dba32009-09-17 18:23:00 +02008081static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8082 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8083 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8084 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8085 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8086 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8087 { } /* end */
8088};
8089
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008090static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8091 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8092 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008093 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8094 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008095 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8096 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8097 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8098 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008099 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008100};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008101
Kailang Yang272a5272007-05-14 11:00:38 +02008102static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8103 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8104 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8105 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8106 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8107 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8108 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8109 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8110 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8111 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008112 { } /* end */
8113};
8114
8115static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8116 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8117 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8118 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8119 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8120 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8121 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8122 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8123 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8124 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008125 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008126};
Kailang Yang272a5272007-05-14 11:00:38 +02008127
Tobin Davis2880a862007-08-07 11:50:26 +02008128static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008129 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8130 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008131 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008132 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8133 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008134 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8135 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8136 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008137 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008138};
Tobin Davis2880a862007-08-07 11:50:26 +02008139
Tony Vroond2fd4b02009-06-21 00:40:10 +01008140static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8141 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8142 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8143 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8144 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008145 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8146 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008147 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8148 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8149 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8150 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8151 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8152 { } /* end */
8153};
8154
Kailang Yange2757d52008-08-26 13:17:46 +02008155static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8156 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8157 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8158 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8159 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8160 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8161 0x0d, 1, 0x0, HDA_OUTPUT),
8162 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8163 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8164 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8165 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8166 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008167 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8168 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8169 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8170 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8171 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8172 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8173 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8174 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8175 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8176 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008177 { } /* end */
8178};
8179
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008180static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8181 /* Output mixers */
8182 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8183 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8184 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8185 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8186 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8187 HDA_OUTPUT),
8188 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8189 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8190 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8191 /* Output switches */
8192 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8193 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8194 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8195 /* Boost mixers */
8196 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8197 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8198 /* Input mixers */
8199 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8200 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8201 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8202 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8203 { } /* end */
8204};
8205
Guido Günther3e1647c2009-06-05 00:47:26 +02008206static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8207 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8208 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8209 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8210 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8211 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8212 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8213 { } /* end */
8214};
8215
Kailang Yange2757d52008-08-26 13:17:46 +02008216static struct hda_bind_ctls alc883_bind_cap_vol = {
8217 .ops = &snd_hda_bind_vol,
8218 .values = {
8219 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8220 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8221 0
8222 },
8223};
8224
8225static struct hda_bind_ctls alc883_bind_cap_switch = {
8226 .ops = &snd_hda_bind_sw,
8227 .values = {
8228 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8229 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8230 0
8231 },
8232};
8233
8234static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8235 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8236 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8237 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8238 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8239 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8240 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8241 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8242 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008243 { } /* end */
8244};
8245
8246static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008247 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8248 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8249 {
8250 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8251 /* .name = "Capture Source", */
8252 .name = "Input Source",
8253 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008254 .info = alc_mux_enum_info,
8255 .get = alc_mux_enum_get,
8256 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008257 },
8258 { } /* end */
8259};
8260
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008261static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8262 {
8263 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8264 .name = "Channel Mode",
8265 .info = alc_ch_mode_info,
8266 .get = alc_ch_mode_get,
8267 .put = alc_ch_mode_put,
8268 },
8269 { } /* end */
8270};
8271
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008272/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008273static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008274{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008275 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008276
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008277 spec->autocfg.hp_pins[0] = 0x15;
8278 spec->autocfg.speaker_pins[0] = 0x14;
8279 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008280}
8281
8282/* auto-toggle front mic */
8283/*
8284static void alc883_mitac_mic_automute(struct hda_codec *codec)
8285{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008286 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008287
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008288 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8289}
8290*/
8291
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008292static struct hda_verb alc883_mitac_verbs[] = {
8293 /* HP */
8294 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8295 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8296 /* Subwoofer */
8297 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8298 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8299
8300 /* enable unsolicited event */
8301 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8302 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8303
8304 { } /* end */
8305};
8306
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308307static struct hda_verb alc883_clevo_m540r_verbs[] = {
8308 /* HP */
8309 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8310 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8311 /* Int speaker */
8312 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8313
8314 /* enable unsolicited event */
8315 /*
8316 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8317 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8318 */
8319
8320 { } /* end */
8321};
8322
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008323static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008324 /* HP */
8325 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8326 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8327 /* Int speaker */
8328 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8329 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8330
8331 /* enable unsolicited event */
8332 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008333 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008334
8335 { } /* end */
8336};
8337
Jiang zhefb97dc62008-03-06 11:07:11 +01008338static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8339 /* HP */
8340 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8341 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8342 /* Subwoofer */
8343 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8344 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8345
8346 /* enable unsolicited event */
8347 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8348
8349 { } /* end */
8350};
8351
Sasha Alexandrc2592492009-06-16 14:52:54 -04008352static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008353 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8354 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8355
8356 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8357 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008358
David Heidelberger64a8be72009-06-08 16:15:18 +02008359/* Connect Line-Out side jack (SPDIF) to Side */
8360 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8361 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8362 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8363/* Connect Mic jack to CLFE */
8364 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8365 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8366 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8367/* Connect Line-in jack to Surround */
8368 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8369 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8370 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8371/* Connect HP out jack to Front */
8372 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8373 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8374 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008375
8376 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008377
8378 { } /* end */
8379};
8380
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008381static struct hda_verb alc883_lenovo_101e_verbs[] = {
8382 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8383 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8384 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8385 { } /* end */
8386};
8387
Kailang Yang272a5272007-05-14 11:00:38 +02008388static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8389 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8390 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8391 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8392 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8393 { } /* end */
8394};
8395
8396static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8397 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8398 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8399 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8400 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8401 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8402 { } /* end */
8403};
8404
Kailang Yang189609a2007-08-20 11:31:23 +02008405static struct hda_verb alc883_haier_w66_verbs[] = {
8406 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8407 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8408
8409 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8410
8411 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8412 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8413 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8414 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8415 { } /* end */
8416};
8417
Kailang Yange2757d52008-08-26 13:17:46 +02008418static struct hda_verb alc888_lenovo_sky_verbs[] = {
8419 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8420 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8421 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8422 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8423 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8424 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8425 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8426 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8427 { } /* end */
8428};
8429
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008430static struct hda_verb alc888_6st_dell_verbs[] = {
8431 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8432 { }
8433};
8434
Guido Günther3e1647c2009-06-05 00:47:26 +02008435static struct hda_verb alc883_vaiott_verbs[] = {
8436 /* HP */
8437 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8438 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8439
8440 /* enable unsolicited event */
8441 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8442
8443 { } /* end */
8444};
8445
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008446static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008447{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008448 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008449
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008450 spec->autocfg.hp_pins[0] = 0x1b;
8451 spec->autocfg.speaker_pins[0] = 0x14;
8452 spec->autocfg.speaker_pins[1] = 0x16;
8453 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008454}
8455
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008456static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008457 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008458 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8459 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008460 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008461 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008462};
8463
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008464/*
8465 * 2ch mode
8466 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008467static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008468 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8469 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8470 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8471 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008472 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008473};
8474
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008475/*
8476 * 4ch mode
8477 */
8478static struct hda_verb alc888_3st_hp_4ch_init[] = {
8479 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8480 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8481 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8482 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8483 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8484 { } /* end */
8485};
8486
8487/*
8488 * 6ch mode
8489 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008490static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008491 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8492 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008493 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008494 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8495 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008496 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8497 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008498};
8499
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008500static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008501 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008502 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008503 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008504};
8505
Kailang Yang272a5272007-05-14 11:00:38 +02008506/* toggle front-jack and RCA according to the hp-jack state */
8507static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8508{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008509 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02008510
Takashi Iwai47fd8302007-08-10 17:11:07 +02008511 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8512 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8513 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8514 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008515}
8516
8517/* toggle RCA according to the front-jack state */
8518static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8519{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008520 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02008521
Takashi Iwai47fd8302007-08-10 17:11:07 +02008522 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8523 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008524}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008525
Kailang Yang272a5272007-05-14 11:00:38 +02008526static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8527 unsigned int res)
8528{
8529 if ((res >> 26) == ALC880_HP_EVENT)
8530 alc888_lenovo_ms7195_front_automute(codec);
8531 if ((res >> 26) == ALC880_FRONT_EVENT)
8532 alc888_lenovo_ms7195_rca_automute(codec);
8533}
8534
8535static struct hda_verb alc883_medion_md2_verbs[] = {
8536 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8537 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8538
8539 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8540
8541 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8542 { } /* end */
8543};
8544
8545/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008546static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008547{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008548 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008549
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008550 spec->autocfg.hp_pins[0] = 0x14;
8551 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008552}
8553
Kailang Yangccc656c2006-10-17 12:32:26 +02008554/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008555#define alc883_targa_init_hook alc882_targa_init_hook
8556#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008557
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008558static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8559{
8560 unsigned int present;
8561
Takashi Iwaid56757a2009-11-18 08:00:14 +01008562 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008563 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8564 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8565}
8566
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008567static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008568{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008569 struct alc_spec *spec = codec->spec;
8570
8571 spec->autocfg.hp_pins[0] = 0x15;
8572 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008573}
8574
8575static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8576{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008577 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008578 alc883_clevo_m720_mic_automute(codec);
8579}
8580
8581static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008582 unsigned int res)
8583{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008584 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008585 case ALC880_MIC_EVENT:
8586 alc883_clevo_m720_mic_automute(codec);
8587 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008588 default:
8589 alc_automute_amp_unsol_event(codec, res);
8590 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008591 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008592}
8593
Jiang zhefb97dc62008-03-06 11:07:11 +01008594/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008595static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008596{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008597 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008598
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008599 spec->autocfg.hp_pins[0] = 0x14;
8600 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01008601}
8602
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008603static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008604{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008605 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008606
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008607 spec->autocfg.hp_pins[0] = 0x1b;
8608 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02008609}
8610
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008611static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8612{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008613 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008614
Takashi Iwai47fd8302007-08-10 17:11:07 +02008615 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8616 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008617}
8618
8619static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8620{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008621 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008622
Takashi Iwai47fd8302007-08-10 17:11:07 +02008623 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8624 HDA_AMP_MUTE, bits);
8625 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8626 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008627}
8628
8629static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8630 unsigned int res)
8631{
8632 if ((res >> 26) == ALC880_HP_EVENT)
8633 alc883_lenovo_101e_all_automute(codec);
8634 if ((res >> 26) == ALC880_FRONT_EVENT)
8635 alc883_lenovo_101e_ispeaker_automute(codec);
8636}
8637
Takashi Iwai676a9b52007-08-16 15:23:35 +02008638/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008639static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008640{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008641 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008642
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008643 spec->autocfg.hp_pins[0] = 0x14;
8644 spec->autocfg.speaker_pins[0] = 0x15;
8645 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02008646}
8647
Kailang Yangd1a991a2007-08-15 16:21:59 +02008648static struct hda_verb alc883_acer_eapd_verbs[] = {
8649 /* HP Pin: output 0 (0x0c) */
8650 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8651 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8652 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8653 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008654 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8655 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008656 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008657 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8658 /* eanable EAPD on medion laptop */
8659 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8660 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008661 /* enable unsolicited event */
8662 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008663 { }
8664};
8665
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008666static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8667 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8668 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8669 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8670 { } /* end */
8671};
8672
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008673static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008674{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008675 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008676
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008677 spec->autocfg.hp_pins[0] = 0x1b;
8678 spec->autocfg.speaker_pins[0] = 0x14;
8679 spec->autocfg.speaker_pins[1] = 0x15;
8680 spec->autocfg.speaker_pins[2] = 0x16;
8681 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008682}
8683
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008684static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008685{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008686 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008687
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008688 spec->autocfg.hp_pins[0] = 0x1b;
8689 spec->autocfg.speaker_pins[0] = 0x14;
8690 spec->autocfg.speaker_pins[1] = 0x15;
8691 spec->autocfg.speaker_pins[2] = 0x16;
8692 spec->autocfg.speaker_pins[3] = 0x17;
8693 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02008694}
8695
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008696static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02008697{
8698 struct alc_spec *spec = codec->spec;
8699
8700 spec->autocfg.hp_pins[0] = 0x15;
8701 spec->autocfg.speaker_pins[0] = 0x14;
8702 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02008703}
8704
Kailang Yange2757d52008-08-26 13:17:46 +02008705static struct hda_verb alc888_asus_m90v_verbs[] = {
8706 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8707 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8708 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8709 /* enable unsolicited event */
8710 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8711 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8712 { } /* end */
8713};
8714
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008715static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008716{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008717 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008718
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008719 spec->autocfg.hp_pins[0] = 0x1b;
8720 spec->autocfg.speaker_pins[0] = 0x14;
8721 spec->autocfg.speaker_pins[1] = 0x15;
8722 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008723 spec->ext_mic.pin = 0x18;
8724 spec->int_mic.pin = 0x19;
8725 spec->ext_mic.mux_idx = 0;
8726 spec->int_mic.mux_idx = 1;
8727 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02008728}
8729
8730static struct hda_verb alc888_asus_eee1601_verbs[] = {
8731 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8732 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8733 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8734 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8735 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8736 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8737 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8738 /* enable unsolicited event */
8739 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8740 { } /* end */
8741};
8742
Kailang Yange2757d52008-08-26 13:17:46 +02008743static void alc883_eee1601_inithook(struct hda_codec *codec)
8744{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008745 struct alc_spec *spec = codec->spec;
8746
8747 spec->autocfg.hp_pins[0] = 0x14;
8748 spec->autocfg.speaker_pins[0] = 0x1b;
8749 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008750}
8751
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008752static struct hda_verb alc889A_mb31_verbs[] = {
8753 /* Init rear pin (used as headphone output) */
8754 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8755 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8756 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8757 /* Init line pin (used as output in 4ch and 6ch mode) */
8758 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8759 /* Init line 2 pin (used as headphone out by default) */
8760 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8761 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8762 { } /* end */
8763};
8764
8765/* Mute speakers according to the headphone jack state */
8766static void alc889A_mb31_automute(struct hda_codec *codec)
8767{
8768 unsigned int present;
8769
8770 /* Mute only in 2ch or 4ch mode */
8771 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8772 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08008773 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008774 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8775 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8776 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8777 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8778 }
8779}
8780
8781static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8782{
8783 if ((res >> 26) == ALC880_HP_EVENT)
8784 alc889A_mb31_automute(codec);
8785}
8786
Takashi Iwai4953550a2009-06-30 15:28:30 +02008787
Takashi Iwaicb53c622007-08-10 17:21:45 +02008788#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02008789#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02008790#endif
8791
Sasha Alexandrdef319f2009-06-16 16:00:15 -04008792/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008793#define alc882_pcm_analog_playback alc880_pcm_analog_playback
8794#define alc882_pcm_analog_capture alc880_pcm_analog_capture
8795#define alc882_pcm_digital_playback alc880_pcm_digital_playback
8796#define alc882_pcm_digital_capture alc880_pcm_digital_capture
8797
8798static hda_nid_t alc883_slave_dig_outs[] = {
8799 ALC1200_DIGOUT_NID, 0,
8800};
8801
8802static hda_nid_t alc1200_slave_dig_outs[] = {
8803 ALC883_DIGOUT_NID, 0,
8804};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008805
8806/*
8807 * configuration and preset
8808 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008809static const char *alc882_models[ALC882_MODEL_LAST] = {
8810 [ALC882_3ST_DIG] = "3stack-dig",
8811 [ALC882_6ST_DIG] = "6stack-dig",
8812 [ALC882_ARIMA] = "arima",
8813 [ALC882_W2JC] = "w2jc",
8814 [ALC882_TARGA] = "targa",
8815 [ALC882_ASUS_A7J] = "asus-a7j",
8816 [ALC882_ASUS_A7M] = "asus-a7m",
8817 [ALC885_MACPRO] = "macpro",
8818 [ALC885_MB5] = "mb5",
8819 [ALC885_MBP3] = "mbp3",
8820 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008821 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008822 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008823 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8824 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008825 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008826 [ALC883_TARGA_DIG] = "targa-dig",
8827 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02008828 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008829 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008830 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008831 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02008832 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02008833 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008834 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008835 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008836 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008837 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008838 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008839 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8840 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008841 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008842 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008843 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008844 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008845 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308846 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008847 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008848 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008849 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008850 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008851 [ALC889A_INTEL] = "intel-alc889a",
8852 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008853 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008854 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02008855 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008856 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008857};
8858
Takashi Iwai4953550a2009-06-30 15:28:30 +02008859static struct snd_pci_quirk alc882_cfg_tbl[] = {
8860 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8861
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008862 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008863 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008864 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008865 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8866 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008867 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008868 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8869 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008870 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01008871 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02008872 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8873 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02008874 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
8875 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008876 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
8877 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008878 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02008879 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008880 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01008881 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008882 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
8883 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02008884 /* default Acer -- disabled as it causes more problems.
8885 * model=auto should work fine now
8886 */
8887 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008888
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008889 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008890
Tobin Davisfebe3372007-06-12 11:27:46 +02008891 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008892 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8893 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008894 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008895 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008896 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008897
8898 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8899 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8900 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008901 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008902 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8903 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8904 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008905 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008906 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008907 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008908 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008909
8910 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02008911 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008912 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008913 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008914 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8915 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008916 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008917 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008918 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8919
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008920 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8921 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8922 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008923 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01008924 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008925 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008926 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008927 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008928 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8929 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8930 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8931 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8932 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8933 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008934 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008935 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8936 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8937 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02008938 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008939 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8940 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008941 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008942 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008943 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008944 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008945 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04008946 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008947 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008948 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008949
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008950 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008951 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8952 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308953 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008954 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008955 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008956 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008957 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008958 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008959 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008960 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008961 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008962 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008963 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008964 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8965 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008966 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008967 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008968 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008969 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008970 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008971
Jiang zhe17bba1b2008-06-04 12:11:07 +02008972 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8973 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008974 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008975 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
8976 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
8977 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008978 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008979
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008980 {}
8981};
8982
Takashi Iwai4953550a2009-06-30 15:28:30 +02008983/* codec SSID table for Intel Mac */
8984static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
8985 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
8986 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
8987 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
8988 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
8989 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
8990 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
8991 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
8992 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
8993 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
8994 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008995 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008996 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05008997 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
8998 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02008999 */
9000 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009001 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009002 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009003};
9004
Takashi Iwai4953550a2009-06-30 15:28:30 +02009005static struct alc_config_preset alc882_presets[] = {
9006 [ALC882_3ST_DIG] = {
9007 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009008 .init_verbs = { alc882_base_init_verbs,
9009 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009010 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9011 .dac_nids = alc882_dac_nids,
9012 .dig_out_nid = ALC882_DIGOUT_NID,
9013 .dig_in_nid = ALC882_DIGIN_NID,
9014 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9015 .channel_mode = alc882_ch_modes,
9016 .need_dac_fix = 1,
9017 .input_mux = &alc882_capture_source,
9018 },
9019 [ALC882_6ST_DIG] = {
9020 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009021 .init_verbs = { alc882_base_init_verbs,
9022 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009023 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9024 .dac_nids = alc882_dac_nids,
9025 .dig_out_nid = ALC882_DIGOUT_NID,
9026 .dig_in_nid = ALC882_DIGIN_NID,
9027 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9028 .channel_mode = alc882_sixstack_modes,
9029 .input_mux = &alc882_capture_source,
9030 },
9031 [ALC882_ARIMA] = {
9032 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009033 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9034 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009035 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9036 .dac_nids = alc882_dac_nids,
9037 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9038 .channel_mode = alc882_sixstack_modes,
9039 .input_mux = &alc882_capture_source,
9040 },
9041 [ALC882_W2JC] = {
9042 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009043 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9044 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009045 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9046 .dac_nids = alc882_dac_nids,
9047 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9048 .channel_mode = alc880_threestack_modes,
9049 .need_dac_fix = 1,
9050 .input_mux = &alc882_capture_source,
9051 .dig_out_nid = ALC882_DIGOUT_NID,
9052 },
9053 [ALC885_MBP3] = {
9054 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9055 .init_verbs = { alc885_mbp3_init_verbs,
9056 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009057 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009058 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009059 .hp_nid = 0x04,
9060 .channel_mode = alc885_mbp_4ch_modes,
9061 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009062 .input_mux = &alc882_capture_source,
9063 .dig_out_nid = ALC882_DIGOUT_NID,
9064 .dig_in_nid = ALC882_DIGIN_NID,
9065 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009066 .setup = alc885_mbp3_setup,
9067 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009068 },
9069 [ALC885_MB5] = {
9070 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9071 .init_verbs = { alc885_mb5_init_verbs,
9072 alc880_gpio1_init_verbs },
9073 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9074 .dac_nids = alc882_dac_nids,
9075 .channel_mode = alc885_mb5_6ch_modes,
9076 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9077 .input_mux = &mb5_capture_source,
9078 .dig_out_nid = ALC882_DIGOUT_NID,
9079 .dig_in_nid = ALC882_DIGIN_NID,
9080 },
9081 [ALC885_MACPRO] = {
9082 .mixers = { alc882_macpro_mixer },
9083 .init_verbs = { alc882_macpro_init_verbs },
9084 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9085 .dac_nids = alc882_dac_nids,
9086 .dig_out_nid = ALC882_DIGOUT_NID,
9087 .dig_in_nid = ALC882_DIGIN_NID,
9088 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9089 .channel_mode = alc882_ch_modes,
9090 .input_mux = &alc882_capture_source,
9091 .init_hook = alc885_macpro_init_hook,
9092 },
9093 [ALC885_IMAC24] = {
9094 .mixers = { alc885_imac24_mixer },
9095 .init_verbs = { alc885_imac24_init_verbs },
9096 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9097 .dac_nids = alc882_dac_nids,
9098 .dig_out_nid = ALC882_DIGOUT_NID,
9099 .dig_in_nid = ALC882_DIGIN_NID,
9100 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9101 .channel_mode = alc882_ch_modes,
9102 .input_mux = &alc882_capture_source,
9103 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009104 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009105 .init_hook = alc885_imac24_init_hook,
9106 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009107 [ALC885_IMAC91] = {
9108 .mixers = { alc885_imac91_mixer, alc882_chmode_mixer },
9109 .init_verbs = { alc885_imac91_init_verbs,
9110 alc880_gpio1_init_verbs },
9111 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9112 .dac_nids = alc882_dac_nids,
9113 .channel_mode = alc885_mbp_4ch_modes,
9114 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
9115 .input_mux = &alc882_capture_source,
9116 .dig_out_nid = ALC882_DIGOUT_NID,
9117 .dig_in_nid = ALC882_DIGIN_NID,
9118 .unsol_event = alc885_imac91_unsol_event,
9119 .init_hook = alc885_imac91_automute,
9120 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009121 [ALC882_TARGA] = {
9122 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009123 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009124 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009125 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9126 .dac_nids = alc882_dac_nids,
9127 .dig_out_nid = ALC882_DIGOUT_NID,
9128 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9129 .adc_nids = alc882_adc_nids,
9130 .capsrc_nids = alc882_capsrc_nids,
9131 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9132 .channel_mode = alc882_3ST_6ch_modes,
9133 .need_dac_fix = 1,
9134 .input_mux = &alc882_capture_source,
9135 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009136 .setup = alc882_targa_setup,
9137 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009138 },
9139 [ALC882_ASUS_A7J] = {
9140 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009141 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9142 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009143 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9144 .dac_nids = alc882_dac_nids,
9145 .dig_out_nid = ALC882_DIGOUT_NID,
9146 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9147 .adc_nids = alc882_adc_nids,
9148 .capsrc_nids = alc882_capsrc_nids,
9149 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9150 .channel_mode = alc882_3ST_6ch_modes,
9151 .need_dac_fix = 1,
9152 .input_mux = &alc882_capture_source,
9153 },
9154 [ALC882_ASUS_A7M] = {
9155 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009156 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9157 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009158 alc882_asus_a7m_verbs },
9159 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9160 .dac_nids = alc882_dac_nids,
9161 .dig_out_nid = ALC882_DIGOUT_NID,
9162 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9163 .channel_mode = alc880_threestack_modes,
9164 .need_dac_fix = 1,
9165 .input_mux = &alc882_capture_source,
9166 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009167 [ALC883_3ST_2ch_DIG] = {
9168 .mixers = { alc883_3ST_2ch_mixer },
9169 .init_verbs = { alc883_init_verbs },
9170 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9171 .dac_nids = alc883_dac_nids,
9172 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009173 .dig_in_nid = ALC883_DIGIN_NID,
9174 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9175 .channel_mode = alc883_3ST_2ch_modes,
9176 .input_mux = &alc883_capture_source,
9177 },
9178 [ALC883_3ST_6ch_DIG] = {
9179 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9180 .init_verbs = { alc883_init_verbs },
9181 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9182 .dac_nids = alc883_dac_nids,
9183 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009184 .dig_in_nid = ALC883_DIGIN_NID,
9185 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9186 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009187 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009188 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009189 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009190 [ALC883_3ST_6ch] = {
9191 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9192 .init_verbs = { alc883_init_verbs },
9193 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9194 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009195 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9196 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009197 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009198 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009199 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009200 [ALC883_3ST_6ch_INTEL] = {
9201 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9202 .init_verbs = { alc883_init_verbs },
9203 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9204 .dac_nids = alc883_dac_nids,
9205 .dig_out_nid = ALC883_DIGOUT_NID,
9206 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009207 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009208 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9209 .channel_mode = alc883_3ST_6ch_intel_modes,
9210 .need_dac_fix = 1,
9211 .input_mux = &alc883_3stack_6ch_intel,
9212 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009213 [ALC889A_INTEL] = {
9214 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009215 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9216 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009217 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9218 .dac_nids = alc883_dac_nids,
9219 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9220 .adc_nids = alc889_adc_nids,
9221 .dig_out_nid = ALC883_DIGOUT_NID,
9222 .dig_in_nid = ALC883_DIGIN_NID,
9223 .slave_dig_outs = alc883_slave_dig_outs,
9224 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9225 .channel_mode = alc889_8ch_intel_modes,
9226 .capsrc_nids = alc889_capsrc_nids,
9227 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009228 .setup = alc889_automute_setup,
9229 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009230 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009231 .need_dac_fix = 1,
9232 },
9233 [ALC889_INTEL] = {
9234 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9235 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009236 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009237 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9238 .dac_nids = alc883_dac_nids,
9239 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9240 .adc_nids = alc889_adc_nids,
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009241 .capsrc_nids = alc889_capsrc_nids,
9242 .capsrc_nids = alc889_capsrc_nids,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009243 .dig_out_nid = ALC883_DIGOUT_NID,
9244 .dig_in_nid = ALC883_DIGIN_NID,
9245 .slave_dig_outs = alc883_slave_dig_outs,
9246 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9247 .channel_mode = alc889_8ch_intel_modes,
9248 .capsrc_nids = alc889_capsrc_nids,
9249 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009250 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009251 .init_hook = alc889_intel_init_hook,
9252 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009253 .need_dac_fix = 1,
9254 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009255 [ALC883_6ST_DIG] = {
9256 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9257 .init_verbs = { alc883_init_verbs },
9258 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9259 .dac_nids = alc883_dac_nids,
9260 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009261 .dig_in_nid = ALC883_DIGIN_NID,
9262 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9263 .channel_mode = alc883_sixstack_modes,
9264 .input_mux = &alc883_capture_source,
9265 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009266 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009267 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009268 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9269 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009270 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9271 .dac_nids = alc883_dac_nids,
9272 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009273 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9274 .channel_mode = alc883_3ST_6ch_modes,
9275 .need_dac_fix = 1,
9276 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009277 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009278 .setup = alc882_targa_setup,
9279 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009280 },
9281 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009282 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009283 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9284 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009285 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9286 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009287 .adc_nids = alc883_adc_nids_alt,
9288 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009289 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +02009290 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009291 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9292 .channel_mode = alc883_3ST_2ch_modes,
9293 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009294 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009295 .setup = alc882_targa_setup,
9296 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009297 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009298 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009299 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9300 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +02009301 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009302 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009303 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9304 .dac_nids = alc883_dac_nids,
9305 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9306 .adc_nids = alc883_adc_nids_rev,
9307 .capsrc_nids = alc883_capsrc_nids_rev,
9308 .dig_out_nid = ALC883_DIGOUT_NID,
9309 .dig_in_nid = ALC883_DIGIN_NID,
9310 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9311 .channel_mode = alc883_4ST_8ch_modes,
9312 .need_dac_fix = 1,
9313 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009314 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009315 .setup = alc882_targa_setup,
9316 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009317 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009318 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009319 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009320 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9321 * and the headphone jack. Turn this on and rely on the
9322 * standard mute methods whenever the user wants to turn
9323 * these outputs off.
9324 */
9325 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9326 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9327 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009328 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9329 .channel_mode = alc883_3ST_2ch_modes,
9330 .input_mux = &alc883_capture_source,
9331 },
Tobin Davis2880a862007-08-07 11:50:26 +02009332 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009333 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009334 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009335 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9336 .dac_nids = alc883_dac_nids,
9337 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009338 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9339 .channel_mode = alc883_3ST_2ch_modes,
9340 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009341 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009342 .setup = alc883_acer_aspire_setup,
9343 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009344 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009345 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009346 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009347 alc883_chmode_mixer },
9348 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9349 alc888_acer_aspire_4930g_verbs },
9350 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9351 .dac_nids = alc883_dac_nids,
9352 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9353 .adc_nids = alc883_adc_nids_rev,
9354 .capsrc_nids = alc883_capsrc_nids_rev,
9355 .dig_out_nid = ALC883_DIGOUT_NID,
9356 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9357 .channel_mode = alc883_3ST_6ch_modes,
9358 .need_dac_fix = 1,
9359 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009360 ARRAY_SIZE(alc888_2_capture_sources),
9361 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009362 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009363 .setup = alc888_acer_aspire_4930g_setup,
9364 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009365 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009366 [ALC888_ACER_ASPIRE_6530G] = {
9367 .mixers = { alc888_acer_aspire_6530_mixer },
9368 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9369 alc888_acer_aspire_6530g_verbs },
9370 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9371 .dac_nids = alc883_dac_nids,
9372 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9373 .adc_nids = alc883_adc_nids_rev,
9374 .capsrc_nids = alc883_capsrc_nids_rev,
9375 .dig_out_nid = ALC883_DIGOUT_NID,
9376 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9377 .channel_mode = alc883_3ST_2ch_modes,
9378 .num_mux_defs =
9379 ARRAY_SIZE(alc888_2_capture_sources),
9380 .input_mux = alc888_acer_aspire_6530_sources,
9381 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009382 .setup = alc888_acer_aspire_6530g_setup,
9383 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009384 },
Hector Martin3b315d72009-06-02 10:54:19 +02009385 [ALC888_ACER_ASPIRE_8930G] = {
9386 .mixers = { alc888_base_mixer,
9387 alc883_chmode_mixer },
9388 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin018df412009-06-04 00:13:40 +02009389 alc889_acer_aspire_8930g_verbs },
Hector Martin3b315d72009-06-02 10:54:19 +02009390 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9391 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009392 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9393 .adc_nids = alc889_adc_nids,
9394 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009395 .dig_out_nid = ALC883_DIGOUT_NID,
9396 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9397 .channel_mode = alc883_3ST_6ch_modes,
9398 .need_dac_fix = 1,
9399 .const_channel_count = 6,
9400 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009401 ARRAY_SIZE(alc889_capture_sources),
9402 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009403 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009404 .setup = alc889_acer_aspire_8930g_setup,
9405 .init_hook = alc_automute_amp,
Hector Martin3b315d72009-06-02 10:54:19 +02009406 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009407 [ALC888_ACER_ASPIRE_7730G] = {
9408 .mixers = { alc883_3ST_6ch_mixer,
9409 alc883_chmode_mixer },
9410 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9411 alc888_acer_aspire_7730G_verbs },
9412 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9413 .dac_nids = alc883_dac_nids,
9414 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9415 .adc_nids = alc883_adc_nids_rev,
9416 .capsrc_nids = alc883_capsrc_nids_rev,
9417 .dig_out_nid = ALC883_DIGOUT_NID,
9418 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9419 .channel_mode = alc883_3ST_6ch_modes,
9420 .need_dac_fix = 1,
9421 .const_channel_count = 6,
9422 .input_mux = &alc883_capture_source,
9423 .unsol_event = alc_automute_amp_unsol_event,
9424 .setup = alc888_acer_aspire_6530g_setup,
9425 .init_hook = alc_automute_amp,
9426 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009427 [ALC883_MEDION] = {
9428 .mixers = { alc883_fivestack_mixer,
9429 alc883_chmode_mixer },
9430 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009431 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009432 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9433 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009434 .adc_nids = alc883_adc_nids_alt,
9435 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009436 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02009437 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9438 .channel_mode = alc883_sixstack_modes,
9439 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009440 },
Kailang Yang272a5272007-05-14 11:00:38 +02009441 [ALC883_MEDION_MD2] = {
9442 .mixers = { alc883_medion_md2_mixer},
9443 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9444 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9445 .dac_nids = alc883_dac_nids,
9446 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009447 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9448 .channel_mode = alc883_3ST_2ch_modes,
9449 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009450 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009451 .setup = alc883_medion_md2_setup,
9452 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009453 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009454 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009455 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009456 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9457 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9458 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009459 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9460 .channel_mode = alc883_3ST_2ch_modes,
9461 .input_mux = &alc883_capture_source,
9462 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309463 [ALC883_CLEVO_M540R] = {
9464 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9465 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9466 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9467 .dac_nids = alc883_dac_nids,
9468 .dig_out_nid = ALC883_DIGOUT_NID,
9469 .dig_in_nid = ALC883_DIGIN_NID,
9470 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9471 .channel_mode = alc883_3ST_6ch_clevo_modes,
9472 .need_dac_fix = 1,
9473 .input_mux = &alc883_capture_source,
9474 /* This machine has the hardware HP auto-muting, thus
9475 * we need no software mute via unsol event
9476 */
9477 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009478 [ALC883_CLEVO_M720] = {
9479 .mixers = { alc883_clevo_m720_mixer },
9480 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009481 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9482 .dac_nids = alc883_dac_nids,
9483 .dig_out_nid = ALC883_DIGOUT_NID,
9484 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9485 .channel_mode = alc883_3ST_2ch_modes,
9486 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009487 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009488 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009489 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009490 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009491 [ALC883_LENOVO_101E_2ch] = {
9492 .mixers = { alc883_lenovo_101e_2ch_mixer},
9493 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9494 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9495 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009496 .adc_nids = alc883_adc_nids_alt,
9497 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009498 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009499 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9500 .channel_mode = alc883_3ST_2ch_modes,
9501 .input_mux = &alc883_lenovo_101e_capture_source,
9502 .unsol_event = alc883_lenovo_101e_unsol_event,
9503 .init_hook = alc883_lenovo_101e_all_automute,
9504 },
Kailang Yang272a5272007-05-14 11:00:38 +02009505 [ALC883_LENOVO_NB0763] = {
9506 .mixers = { alc883_lenovo_nb0763_mixer },
9507 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9508 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9509 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009510 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9511 .channel_mode = alc883_3ST_2ch_modes,
9512 .need_dac_fix = 1,
9513 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009514 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009515 .setup = alc883_medion_md2_setup,
9516 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009517 },
9518 [ALC888_LENOVO_MS7195_DIG] = {
9519 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9520 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9521 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9522 .dac_nids = alc883_dac_nids,
9523 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009524 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9525 .channel_mode = alc883_3ST_6ch_modes,
9526 .need_dac_fix = 1,
9527 .input_mux = &alc883_capture_source,
9528 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9529 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009530 },
9531 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009532 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009533 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9534 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9535 .dac_nids = alc883_dac_nids,
9536 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009537 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9538 .channel_mode = alc883_3ST_2ch_modes,
9539 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009540 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009541 .setup = alc883_haier_w66_setup,
9542 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009543 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009544 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009545 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009546 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009547 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9548 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009549 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9550 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009551 .need_dac_fix = 1,
9552 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009553 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009554 .setup = alc888_3st_hp_setup,
9555 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009556 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009557 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009558 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009559 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9560 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9561 .dac_nids = alc883_dac_nids,
9562 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009563 .dig_in_nid = ALC883_DIGIN_NID,
9564 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9565 .channel_mode = alc883_sixstack_modes,
9566 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009567 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009568 .setup = alc888_6st_dell_setup,
9569 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009570 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009571 [ALC883_MITAC] = {
9572 .mixers = { alc883_mitac_mixer },
9573 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9574 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9575 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009576 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9577 .channel_mode = alc883_3ST_2ch_modes,
9578 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009579 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009580 .setup = alc883_mitac_setup,
9581 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009582 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009583 [ALC883_FUJITSU_PI2515] = {
9584 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9585 .init_verbs = { alc883_init_verbs,
9586 alc883_2ch_fujitsu_pi2515_verbs},
9587 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9588 .dac_nids = alc883_dac_nids,
9589 .dig_out_nid = ALC883_DIGOUT_NID,
9590 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9591 .channel_mode = alc883_3ST_2ch_modes,
9592 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009593 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009594 .setup = alc883_2ch_fujitsu_pi2515_setup,
9595 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +01009596 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009597 [ALC888_FUJITSU_XA3530] = {
9598 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9599 .init_verbs = { alc883_init_verbs,
9600 alc888_fujitsu_xa3530_verbs },
9601 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9602 .dac_nids = alc883_dac_nids,
9603 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9604 .adc_nids = alc883_adc_nids_rev,
9605 .capsrc_nids = alc883_capsrc_nids_rev,
9606 .dig_out_nid = ALC883_DIGOUT_NID,
9607 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9608 .channel_mode = alc888_4ST_8ch_intel_modes,
9609 .num_mux_defs =
9610 ARRAY_SIZE(alc888_2_capture_sources),
9611 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009612 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009613 .setup = alc888_fujitsu_xa3530_setup,
9614 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009615 },
Kailang Yange2757d52008-08-26 13:17:46 +02009616 [ALC888_LENOVO_SKY] = {
9617 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9618 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9619 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9620 .dac_nids = alc883_dac_nids,
9621 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009622 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9623 .channel_mode = alc883_sixstack_modes,
9624 .need_dac_fix = 1,
9625 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009626 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009627 .setup = alc888_lenovo_sky_setup,
9628 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +02009629 },
9630 [ALC888_ASUS_M90V] = {
9631 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9632 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9633 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9634 .dac_nids = alc883_dac_nids,
9635 .dig_out_nid = ALC883_DIGOUT_NID,
9636 .dig_in_nid = ALC883_DIGIN_NID,
9637 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9638 .channel_mode = alc883_3ST_6ch_modes,
9639 .need_dac_fix = 1,
9640 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009641 .unsol_event = alc_sku_unsol_event,
9642 .setup = alc883_mode2_setup,
9643 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +02009644 },
9645 [ALC888_ASUS_EEE1601] = {
9646 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009647 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009648 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9649 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9650 .dac_nids = alc883_dac_nids,
9651 .dig_out_nid = ALC883_DIGOUT_NID,
9652 .dig_in_nid = ALC883_DIGIN_NID,
9653 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9654 .channel_mode = alc883_3ST_2ch_modes,
9655 .need_dac_fix = 1,
9656 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009657 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009658 .init_hook = alc883_eee1601_inithook,
9659 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009660 [ALC1200_ASUS_P5Q] = {
9661 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9662 .init_verbs = { alc883_init_verbs },
9663 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9664 .dac_nids = alc883_dac_nids,
9665 .dig_out_nid = ALC1200_DIGOUT_NID,
9666 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009667 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009668 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9669 .channel_mode = alc883_sixstack_modes,
9670 .input_mux = &alc883_capture_source,
9671 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009672 [ALC889A_MB31] = {
9673 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9674 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9675 alc880_gpio1_init_verbs },
9676 .adc_nids = alc883_adc_nids,
9677 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009678 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009679 .dac_nids = alc883_dac_nids,
9680 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9681 .channel_mode = alc889A_mb31_6ch_modes,
9682 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9683 .input_mux = &alc889A_mb31_capture_source,
9684 .dig_out_nid = ALC883_DIGOUT_NID,
9685 .unsol_event = alc889A_mb31_unsol_event,
9686 .init_hook = alc889A_mb31_automute,
9687 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009688 [ALC883_SONY_VAIO_TT] = {
9689 .mixers = { alc883_vaiott_mixer },
9690 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9691 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9692 .dac_nids = alc883_dac_nids,
9693 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9694 .channel_mode = alc883_3ST_2ch_modes,
9695 .input_mux = &alc883_capture_source,
9696 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009697 .setup = alc883_vaiott_setup,
9698 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +02009699 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009700};
9701
9702
9703/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02009704 * Pin config fixes
9705 */
9706enum {
9707 PINFIX_ABIT_AW9D_MAX
9708};
9709
9710static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9711 { 0x15, 0x01080104 }, /* side */
9712 { 0x16, 0x01011012 }, /* rear */
9713 { 0x17, 0x01016011 }, /* clfe */
9714 { }
9715};
9716
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009717static const struct alc_fixup alc882_fixups[] = {
9718 [PINFIX_ABIT_AW9D_MAX] = {
9719 .pins = alc882_abit_aw9d_pinfix
9720 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009721};
9722
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009723static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009724 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9725 {}
9726};
9727
9728/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009729 * BIOS auto configuration
9730 */
Takashi Iwai05f5f472009-08-25 13:10:18 +02009731static int alc882_auto_create_input_ctls(struct hda_codec *codec,
9732 const struct auto_pin_cfg *cfg)
9733{
9734 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
9735}
9736
Takashi Iwai4953550a2009-06-30 15:28:30 +02009737static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009738 hda_nid_t nid, int pin_type,
9739 int dac_idx)
9740{
9741 /* set as output */
9742 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009743 int idx;
9744
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009745 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009746 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9747 idx = 4;
9748 else
9749 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009750 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9751
9752}
9753
Takashi Iwai4953550a2009-06-30 15:28:30 +02009754static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009755{
9756 struct alc_spec *spec = codec->spec;
9757 int i;
9758
9759 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009760 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009761 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009762 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009763 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009764 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009765 }
9766}
9767
Takashi Iwai4953550a2009-06-30 15:28:30 +02009768static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009769{
9770 struct alc_spec *spec = codec->spec;
9771 hda_nid_t pin;
9772
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009773 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009774 if (pin) /* connect to front */
9775 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009776 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009777 pin = spec->autocfg.speaker_pins[0];
9778 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009779 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009780}
9781
Takashi Iwai4953550a2009-06-30 15:28:30 +02009782static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009783{
9784 struct alc_spec *spec = codec->spec;
9785 int i;
9786
9787 for (i = 0; i < AUTO_PIN_LAST; i++) {
9788 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +02009789 if (!nid)
9790 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +02009791 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009792 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9793 snd_hda_codec_write(codec, nid, 0,
9794 AC_VERB_SET_AMP_GAIN_MUTE,
9795 AMP_OUT_MUTE);
9796 }
9797}
9798
9799static void alc882_auto_init_input_src(struct hda_codec *codec)
9800{
9801 struct alc_spec *spec = codec->spec;
9802 int c;
9803
9804 for (c = 0; c < spec->num_adc_nids; c++) {
9805 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9806 hda_nid_t nid = spec->capsrc_nids[c];
9807 unsigned int mux_idx;
9808 const struct hda_input_mux *imux;
9809 int conns, mute, idx, item;
9810
9811 conns = snd_hda_get_connections(codec, nid, conn_list,
9812 ARRAY_SIZE(conn_list));
9813 if (conns < 0)
9814 continue;
9815 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9816 imux = &spec->input_mux[mux_idx];
9817 for (idx = 0; idx < conns; idx++) {
9818 /* if the current connection is the selected one,
9819 * unmute it as default - otherwise mute it
9820 */
9821 mute = AMP_IN_MUTE(idx);
9822 for (item = 0; item < imux->num_items; item++) {
9823 if (imux->items[item].index == idx) {
9824 if (spec->cur_mux[c] == item)
9825 mute = AMP_IN_UNMUTE(idx);
9826 break;
9827 }
9828 }
9829 /* check if we have a selector or mixer
9830 * we could check for the widget type instead, but
9831 * just check for Amp-In presence (in case of mixer
9832 * without amp-in there is something wrong, this
9833 * function shouldn't be used or capsrc nid is wrong)
9834 */
9835 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009836 snd_hda_codec_write(codec, nid, 0,
9837 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009838 mute);
9839 else if (mute != AMP_IN_MUTE(idx))
9840 snd_hda_codec_write(codec, nid, 0,
9841 AC_VERB_SET_CONNECT_SEL,
9842 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009843 }
9844 }
9845}
9846
Takashi Iwai4953550a2009-06-30 15:28:30 +02009847/* add mic boosts if needed */
9848static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009849{
9850 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009851 int err;
9852 hda_nid_t nid;
9853
9854 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9855 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9856 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9857 "Mic Boost",
9858 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9859 if (err < 0)
9860 return err;
9861 }
9862 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9863 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9864 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9865 "Front Mic Boost",
9866 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9867 if (err < 0)
9868 return err;
9869 }
9870 return 0;
9871}
9872
9873/* almost identical with ALC880 parser... */
9874static int alc882_parse_auto_config(struct hda_codec *codec)
9875{
9876 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009877 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
9878 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009879
Takashi Iwai05f5f472009-08-25 13:10:18 +02009880 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9881 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009882 if (err < 0)
9883 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009884 if (!spec->autocfg.line_outs)
9885 return 0; /* can't find valid BIOS pin config */
9886
9887 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
9888 if (err < 0)
9889 return err;
9890 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
9891 if (err < 0)
9892 return err;
9893 err = alc880_auto_create_extra_out(spec,
9894 spec->autocfg.speaker_pins[0],
9895 "Speaker");
9896 if (err < 0)
9897 return err;
9898 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
9899 "Headphone");
9900 if (err < 0)
9901 return err;
9902 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
9903 if (err < 0)
9904 return err;
9905
9906 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9907
9908 /* check multiple SPDIF-out (for recent codecs) */
9909 for (i = 0; i < spec->autocfg.dig_outs; i++) {
9910 hda_nid_t dig_nid;
9911 err = snd_hda_get_connections(codec,
9912 spec->autocfg.dig_out_pins[i],
9913 &dig_nid, 1);
9914 if (err < 0)
9915 continue;
9916 if (!i)
9917 spec->multiout.dig_out_nid = dig_nid;
9918 else {
9919 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01009920 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai05f5f472009-08-25 13:10:18 +02009921 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01009922 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009923 }
9924 }
9925 if (spec->autocfg.dig_in_pin)
9926 spec->dig_in_nid = ALC880_DIGIN_NID;
9927
9928 if (spec->kctls.list)
9929 add_mixer(spec, spec->kctls.list);
9930
9931 add_verb(spec, alc883_auto_init_verbs);
9932 /* if ADC 0x07 is available, initialize it, too */
9933 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
9934 add_verb(spec, alc882_adc1_init_verbs);
9935
9936 spec->num_mux_defs = 1;
9937 spec->input_mux = &spec->private_imux[0];
9938
9939 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
Takashi Iwai776e1842007-08-29 15:07:11 +02009940
9941 err = alc_auto_add_mic_boost(codec);
9942 if (err < 0)
9943 return err;
9944
Takashi Iwai776e1842007-08-29 15:07:11 +02009945 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009946}
9947
9948/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009949static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009950{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009951 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009952 alc882_auto_init_multi_out(codec);
9953 alc882_auto_init_hp_out(codec);
9954 alc882_auto_init_analog_input(codec);
9955 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009956 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009957 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009958}
9959
Takashi Iwai4953550a2009-06-30 15:28:30 +02009960static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009961{
9962 struct alc_spec *spec;
9963 int err, board_config;
9964
9965 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9966 if (spec == NULL)
9967 return -ENOMEM;
9968
9969 codec->spec = spec;
9970
Takashi Iwai4953550a2009-06-30 15:28:30 +02009971 switch (codec->vendor_id) {
9972 case 0x10ec0882:
9973 case 0x10ec0885:
9974 break;
9975 default:
9976 /* ALC883 and variants */
9977 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9978 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009979 }
9980
Takashi Iwai4953550a2009-06-30 15:28:30 +02009981 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
9982 alc882_models,
9983 alc882_cfg_tbl);
9984
9985 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
9986 board_config = snd_hda_check_board_codec_sid_config(codec,
9987 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
9988
9989 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02009990 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009991 codec->chip_name);
9992 board_config = ALC882_AUTO;
9993 }
9994
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009995 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009996
9997 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009998 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009999 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010000 if (err < 0) {
10001 alc_free(codec);
10002 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010003 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010004 printk(KERN_INFO
10005 "hda_codec: Cannot set up configuration "
10006 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010007 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010008 }
10009 }
10010
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010011 err = snd_hda_attach_beep_device(codec, 0x1);
10012 if (err < 0) {
10013 alc_free(codec);
10014 return err;
10015 }
10016
Takashi Iwai4953550a2009-06-30 15:28:30 +020010017 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010018 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010019
Takashi Iwai4953550a2009-06-30 15:28:30 +020010020 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10021 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10022 /* FIXME: setup DAC5 */
10023 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10024 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10025
10026 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10027 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10028
10029 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010030 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010031
10032 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010033 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010034 spec->num_adc_nids = 0;
10035 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010036 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010037 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010038 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010039 hda_nid_t nid = alc882_adc_nids[i];
10040 unsigned int wcap = get_wcaps(codec, nid);
10041 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010042 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010043 if (wcap != AC_WID_AUD_IN)
10044 continue;
10045 spec->private_adc_nids[spec->num_adc_nids] = nid;
10046 err = snd_hda_get_connections(codec, nid, &cap, 1);
10047 if (err < 0)
10048 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010049 err = snd_hda_get_connections(codec, cap, items,
10050 ARRAY_SIZE(items));
10051 if (err < 0)
10052 continue;
10053 for (j = 0; j < imux->num_items; j++)
10054 if (imux->items[j].index >= err)
10055 break;
10056 if (j < imux->num_items)
10057 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010058 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10059 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010060 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010061 spec->adc_nids = spec->private_adc_nids;
10062 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010063 }
10064
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010065 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010010066 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010067
Takashi Iwai2134ea42008-01-10 16:53:55 +010010068 spec->vmaster_nid = 0x0c;
10069
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010070 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010071 if (board_config == ALC882_AUTO)
10072 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010073#ifdef CONFIG_SND_HDA_POWER_SAVE
10074 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010075 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010076#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010010077 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010078
10079 return 0;
10080}
10081
Takashi Iwai4953550a2009-06-30 15:28:30 +020010082
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010083/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010084 * ALC262 support
10085 */
10086
10087#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10088#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10089
10090#define alc262_dac_nids alc260_dac_nids
10091#define alc262_adc_nids alc882_adc_nids
10092#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010093#define alc262_capsrc_nids alc882_capsrc_nids
10094#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010095
10096#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010097#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010098
Kailang Yang4e555fe2008-08-26 13:05:55 +020010099static hda_nid_t alc262_dmic_adc_nids[1] = {
10100 /* ADC0 */
10101 0x09
10102};
10103
10104static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10105
Kailang Yangdf694da2005-12-05 19:42:22 +010010106static struct snd_kcontrol_new alc262_base_mixer[] = {
10107 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10108 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10109 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10110 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10111 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10112 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10113 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10114 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010115 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010116 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10117 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010118 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010119 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10120 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10121 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10122 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010123 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010124};
10125
Takashi Iwaice875f02008-01-28 18:17:43 +010010126/* update HP, line and mono-out pins according to the master switch */
10127static void alc262_hp_master_update(struct hda_codec *codec)
10128{
10129 struct alc_spec *spec = codec->spec;
10130 int val = spec->master_sw;
10131
10132 /* HP & line-out */
10133 snd_hda_codec_write_cache(codec, 0x1b, 0,
10134 AC_VERB_SET_PIN_WIDGET_CONTROL,
10135 val ? PIN_HP : 0);
10136 snd_hda_codec_write_cache(codec, 0x15, 0,
10137 AC_VERB_SET_PIN_WIDGET_CONTROL,
10138 val ? PIN_HP : 0);
10139 /* mono (speaker) depending on the HP jack sense */
10140 val = val && !spec->jack_present;
10141 snd_hda_codec_write_cache(codec, 0x16, 0,
10142 AC_VERB_SET_PIN_WIDGET_CONTROL,
10143 val ? PIN_OUT : 0);
10144}
10145
10146static void alc262_hp_bpc_automute(struct hda_codec *codec)
10147{
10148 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010149
10150 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010151 alc262_hp_master_update(codec);
10152}
10153
10154static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10155{
10156 if ((res >> 26) != ALC880_HP_EVENT)
10157 return;
10158 alc262_hp_bpc_automute(codec);
10159}
10160
10161static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10162{
10163 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010164
10165 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010166 alc262_hp_master_update(codec);
10167}
10168
10169static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10170 unsigned int res)
10171{
10172 if ((res >> 26) != ALC880_HP_EVENT)
10173 return;
10174 alc262_hp_wildwest_automute(codec);
10175}
10176
Takashi Iwaib72519b2009-05-08 14:31:55 +020010177#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010178
10179static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10180 struct snd_ctl_elem_value *ucontrol)
10181{
10182 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10183 struct alc_spec *spec = codec->spec;
10184 int val = !!*ucontrol->value.integer.value;
10185
10186 if (val == spec->master_sw)
10187 return 0;
10188 spec->master_sw = val;
10189 alc262_hp_master_update(codec);
10190 return 1;
10191}
10192
Takashi Iwaib72519b2009-05-08 14:31:55 +020010193#define ALC262_HP_MASTER_SWITCH \
10194 { \
10195 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10196 .name = "Master Playback Switch", \
10197 .info = snd_ctl_boolean_mono_info, \
10198 .get = alc262_hp_master_sw_get, \
10199 .put = alc262_hp_master_sw_put, \
10200 }
10201
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010202static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010203 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010204 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10205 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10206 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010207 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10208 HDA_OUTPUT),
10209 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10210 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010211 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10212 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010213 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010214 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10215 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010216 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010217 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10218 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10219 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10220 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010221 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10222 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10223 { } /* end */
10224};
10225
Kailang Yangcd7509a2007-01-26 18:33:17 +010010226static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010227 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010228 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10229 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10230 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10231 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010232 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10233 HDA_OUTPUT),
10234 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10235 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010236 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10237 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010238 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010239 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10240 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10241 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10242 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010243 { } /* end */
10244};
10245
10246static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10247 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10248 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010249 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010250 { } /* end */
10251};
10252
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010253/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010254static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010255{
10256 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010257
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010258 spec->autocfg.hp_pins[0] = 0x15;
10259 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010260}
10261
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010262static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010263 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10264 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010265 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10266 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10267 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10268 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10269 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10270 { } /* end */
10271};
10272
10273static struct hda_verb alc262_hp_t5735_verbs[] = {
10274 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10275 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10276
10277 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10278 { }
10279};
10280
Kailang Yang8c427222008-01-10 13:03:59 +010010281static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010282 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10283 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010284 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10285 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010286 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10287 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10288 { } /* end */
10289};
10290
10291static struct hda_verb alc262_hp_rp5700_verbs[] = {
10292 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10293 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10294 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10295 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10296 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10297 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10298 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10299 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10300 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10301 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10302 {}
10303};
10304
10305static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10306 .num_items = 1,
10307 .items = {
10308 { "Line", 0x1 },
10309 },
10310};
10311
Takashi Iwai42171c12009-05-08 14:11:43 +020010312/* bind hp and internal speaker mute (with plug check) as master switch */
10313static void alc262_hippo_master_update(struct hda_codec *codec)
10314{
10315 struct alc_spec *spec = codec->spec;
10316 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10317 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10318 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10319 unsigned int mute;
10320
10321 /* HP */
10322 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10323 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10324 HDA_AMP_MUTE, mute);
10325 /* mute internal speaker per jack sense */
10326 if (spec->jack_present)
10327 mute = HDA_AMP_MUTE;
10328 if (line_nid)
10329 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10330 HDA_AMP_MUTE, mute);
10331 if (speaker_nid && speaker_nid != line_nid)
10332 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10333 HDA_AMP_MUTE, mute);
10334}
10335
10336#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10337
10338static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10339 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010340{
10341 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010342 struct alc_spec *spec = codec->spec;
10343 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010344
Takashi Iwai42171c12009-05-08 14:11:43 +020010345 if (val == spec->master_sw)
10346 return 0;
10347 spec->master_sw = val;
10348 alc262_hippo_master_update(codec);
10349 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010350}
Takashi Iwai5b319542007-07-26 11:49:22 +020010351
Takashi Iwai42171c12009-05-08 14:11:43 +020010352#define ALC262_HIPPO_MASTER_SWITCH \
10353 { \
10354 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10355 .name = "Master Playback Switch", \
10356 .info = snd_ctl_boolean_mono_info, \
10357 .get = alc262_hippo_master_sw_get, \
10358 .put = alc262_hippo_master_sw_put, \
10359 }
10360
10361static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10362 ALC262_HIPPO_MASTER_SWITCH,
10363 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10364 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10365 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10366 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10367 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10368 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10369 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10370 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10371 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10372 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10373 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10374 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10375 { } /* end */
10376};
10377
10378static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10379 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10380 ALC262_HIPPO_MASTER_SWITCH,
10381 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10382 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10383 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10384 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10385 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10386 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10387 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10388 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10389 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10390 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10391 { } /* end */
10392};
10393
10394/* mute/unmute internal speaker according to the hp jack and mute state */
10395static void alc262_hippo_automute(struct hda_codec *codec)
10396{
10397 struct alc_spec *spec = codec->spec;
10398 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020010399
Wu Fengguang864f92b2009-11-18 12:38:02 +080010400 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020010401 alc262_hippo_master_update(codec);
10402}
10403
10404static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10405{
10406 if ((res >> 26) != ALC880_HP_EVENT)
10407 return;
10408 alc262_hippo_automute(codec);
10409}
10410
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010411static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010412{
10413 struct alc_spec *spec = codec->spec;
10414
10415 spec->autocfg.hp_pins[0] = 0x15;
10416 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010417}
10418
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010419static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010420{
10421 struct alc_spec *spec = codec->spec;
10422
10423 spec->autocfg.hp_pins[0] = 0x1b;
10424 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010425}
10426
10427
Kailang Yang272a5272007-05-14 11:00:38 +020010428static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010429 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010430 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010431 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10432 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10433 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10434 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10435 { } /* end */
10436};
10437
Kailang Yang83c34212007-07-05 11:43:05 +020010438static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010439 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10440 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010441 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10442 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10443 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10444 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10445 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10446 { } /* end */
10447};
Kailang Yang272a5272007-05-14 11:00:38 +020010448
Tony Vroonba340e82009-02-02 19:01:30 +000010449static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10450 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10451 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10452 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10453 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10454 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10455 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10456 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10457 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10458 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10459 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10460 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10461 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10462 { } /* end */
10463};
10464
10465static struct hda_verb alc262_tyan_verbs[] = {
10466 /* Headphone automute */
10467 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10468 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10469 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10470
10471 /* P11 AUX_IN, white 4-pin connector */
10472 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10473 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10474 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10475 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10476
10477 {}
10478};
10479
10480/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010481static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010482{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010483 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010484
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010485 spec->autocfg.hp_pins[0] = 0x1b;
10486 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010487}
10488
Tony Vroonba340e82009-02-02 19:01:30 +000010489
Kailang Yangdf694da2005-12-05 19:42:22 +010010490#define alc262_capture_mixer alc882_capture_mixer
10491#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10492
10493/*
10494 * generic initialization of ADC, input mixers and output mixers
10495 */
10496static struct hda_verb alc262_init_verbs[] = {
10497 /*
10498 * Unmute ADC0-2 and set the default input to mic-in
10499 */
10500 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10501 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10502 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10503 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10504 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10505 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10506
Takashi Iwaicb53c622007-08-10 17:21:45 +020010507 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010508 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010509 * Note: PASD motherboards uses the Line In 2 as the input for
10510 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010511 */
10512 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010513 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10514 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10515 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10516 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10517 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010518
10519 /*
10520 * Set up output mixers (0x0c - 0x0e)
10521 */
10522 /* set vol=0 to output mixers */
10523 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10524 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10525 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10526 /* set up input amps for analog loopback */
10527 /* Amp Indices: DAC = 0, mixer = 1 */
10528 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10529 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10530 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10531 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10532 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10533 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10534
10535 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10536 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10537 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10538 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10539 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10540 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10541
10542 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10543 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10544 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10545 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10546 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010547
Kailang Yangdf694da2005-12-05 19:42:22 +010010548 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10549 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010550
Kailang Yangdf694da2005-12-05 19:42:22 +010010551 /* FIXME: use matrix-type input source selection */
10552 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10553 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10554 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10555 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10556 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10557 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10558 /* Input mixer2 */
10559 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10560 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10561 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10562 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10563 /* Input mixer3 */
10564 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10565 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10566 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010567 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010568
10569 { }
10570};
10571
Kailang Yang4e555fe2008-08-26 13:05:55 +020010572static struct hda_verb alc262_eapd_verbs[] = {
10573 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10574 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10575 { }
10576};
10577
Kailang Yangccc656c2006-10-17 12:32:26 +020010578static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10579 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10580 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10581 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10582
10583 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10584 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10585 {}
10586};
10587
Kailang Yang272a5272007-05-14 11:00:38 +020010588static struct hda_verb alc262_sony_unsol_verbs[] = {
10589 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10590 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10591 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10592
10593 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10594 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010595 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010596};
10597
Kailang Yang4e555fe2008-08-26 13:05:55 +020010598static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10599 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10600 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10601 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10602 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10603 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010604 { } /* end */
10605};
10606
10607static struct hda_verb alc262_toshiba_s06_verbs[] = {
10608 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10609 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10610 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10611 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10612 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10613 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10614 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10615 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10616 {}
10617};
10618
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010619static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020010620{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010621 struct alc_spec *spec = codec->spec;
10622
10623 spec->autocfg.hp_pins[0] = 0x15;
10624 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010625 spec->ext_mic.pin = 0x18;
10626 spec->ext_mic.mux_idx = 0;
10627 spec->int_mic.pin = 0x12;
10628 spec->int_mic.mux_idx = 9;
10629 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020010630}
10631
Takashi Iwai834be882006-03-01 14:16:17 +010010632/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010633 * nec model
10634 * 0x15 = headphone
10635 * 0x16 = internal speaker
10636 * 0x18 = external mic
10637 */
10638
10639static struct snd_kcontrol_new alc262_nec_mixer[] = {
10640 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10641 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10642
10643 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10644 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10645 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10646
10647 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10648 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10649 { } /* end */
10650};
10651
10652static struct hda_verb alc262_nec_verbs[] = {
10653 /* Unmute Speaker */
10654 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10655
10656 /* Headphone */
10657 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10658 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10659
10660 /* External mic to headphone */
10661 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10662 /* External mic to speaker */
10663 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10664 {}
10665};
10666
10667/*
Takashi Iwai834be882006-03-01 14:16:17 +010010668 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010669 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10670 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010671 */
10672
10673#define ALC_HP_EVENT 0x37
10674
10675static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10676 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10677 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010678 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10679 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010680 {}
10681};
10682
Jiang zhe0e31daf2008-03-20 12:12:39 +010010683static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10684 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10685 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10686 {}
10687};
10688
Takashi Iwai834be882006-03-01 14:16:17 +010010689static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010690 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010691 .items = {
10692 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010693 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010694 { "CD", 0x4 },
10695 },
10696};
10697
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010698static struct hda_input_mux alc262_HP_capture_source = {
10699 .num_items = 5,
10700 .items = {
10701 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010702 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010703 { "Line", 0x2 },
10704 { "CD", 0x4 },
10705 { "AUX IN", 0x6 },
10706 },
10707};
10708
zhejiangaccbe492007-08-31 12:36:05 +020010709static struct hda_input_mux alc262_HP_D7000_capture_source = {
10710 .num_items = 4,
10711 .items = {
10712 { "Mic", 0x0 },
10713 { "Front Mic", 0x2 },
10714 { "Line", 0x1 },
10715 { "CD", 0x4 },
10716 },
10717};
10718
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010719/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010720static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10721{
10722 struct alc_spec *spec = codec->spec;
10723 unsigned int mute;
10724
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010725 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080010726 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
10727 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010010728 spec->sense_updated = 1;
10729 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010730 /* unmute internal speaker only if both HPs are unplugged and
10731 * master switch is on
10732 */
10733 if (spec->jack_present)
10734 mute = HDA_AMP_MUTE;
10735 else
Takashi Iwai834be882006-03-01 14:16:17 +010010736 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010737 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10738 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010739}
10740
10741/* unsolicited event for HP jack sensing */
10742static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10743 unsigned int res)
10744{
10745 if ((res >> 26) != ALC_HP_EVENT)
10746 return;
10747 alc262_fujitsu_automute(codec, 1);
10748}
10749
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010750static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10751{
10752 alc262_fujitsu_automute(codec, 1);
10753}
10754
Takashi Iwai834be882006-03-01 14:16:17 +010010755/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010756static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10757 .ops = &snd_hda_bind_vol,
10758 .values = {
10759 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10760 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10761 0
10762 },
10763};
Takashi Iwai834be882006-03-01 14:16:17 +010010764
Jiang zhe0e31daf2008-03-20 12:12:39 +010010765/* mute/unmute internal speaker according to the hp jack and mute state */
10766static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10767{
10768 struct alc_spec *spec = codec->spec;
10769 unsigned int mute;
10770
10771 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080010772 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010773 spec->sense_updated = 1;
10774 }
10775 if (spec->jack_present) {
10776 /* mute internal speaker */
10777 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10778 HDA_AMP_MUTE, HDA_AMP_MUTE);
10779 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10780 HDA_AMP_MUTE, HDA_AMP_MUTE);
10781 } else {
10782 /* unmute internal speaker if necessary */
10783 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10784 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10785 HDA_AMP_MUTE, mute);
10786 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10787 HDA_AMP_MUTE, mute);
10788 }
10789}
10790
10791/* unsolicited event for HP jack sensing */
10792static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10793 unsigned int res)
10794{
10795 if ((res >> 26) != ALC_HP_EVENT)
10796 return;
10797 alc262_lenovo_3000_automute(codec, 1);
10798}
10799
Takashi Iwai8de56b72009-07-24 16:51:47 +020010800static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10801 int dir, int idx, long *valp)
10802{
10803 int i, change = 0;
10804
10805 for (i = 0; i < 2; i++, valp++)
10806 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10807 HDA_AMP_MUTE,
10808 *valp ? 0 : HDA_AMP_MUTE);
10809 return change;
10810}
10811
Takashi Iwai834be882006-03-01 14:16:17 +010010812/* bind hp and internal speaker mute (with plug check) */
10813static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10814 struct snd_ctl_elem_value *ucontrol)
10815{
10816 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10817 long *valp = ucontrol->value.integer.value;
10818 int change;
10819
Takashi Iwai8de56b72009-07-24 16:51:47 +020010820 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10821 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010822 if (change)
10823 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010824 return change;
10825}
10826
10827static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010828 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010829 {
10830 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10831 .name = "Master Playback Switch",
10832 .info = snd_hda_mixer_amp_switch_info,
10833 .get = snd_hda_mixer_amp_switch_get,
10834 .put = alc262_fujitsu_master_sw_put,
10835 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10836 },
10837 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10838 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10839 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10840 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10841 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010842 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10843 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10844 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010845 { } /* end */
10846};
10847
Jiang zhe0e31daf2008-03-20 12:12:39 +010010848/* bind hp and internal speaker mute (with plug check) */
10849static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10850 struct snd_ctl_elem_value *ucontrol)
10851{
10852 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10853 long *valp = ucontrol->value.integer.value;
10854 int change;
10855
Takashi Iwai8de56b72009-07-24 16:51:47 +020010856 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010857 if (change)
10858 alc262_lenovo_3000_automute(codec, 0);
10859 return change;
10860}
10861
10862static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10863 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10864 {
10865 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10866 .name = "Master Playback Switch",
10867 .info = snd_hda_mixer_amp_switch_info,
10868 .get = snd_hda_mixer_amp_switch_get,
10869 .put = alc262_lenovo_3000_master_sw_put,
10870 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10871 },
10872 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10873 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10874 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10875 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10876 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10877 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10878 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10879 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10880 { } /* end */
10881};
10882
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010883static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10884 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010885 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010886 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10887 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10888 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10889 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10890 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10891 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10892 { } /* end */
10893};
10894
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010895/* additional init verbs for Benq laptops */
10896static struct hda_verb alc262_EAPD_verbs[] = {
10897 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10898 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10899 {}
10900};
10901
Kailang Yang83c34212007-07-05 11:43:05 +020010902static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10903 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10904 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10905
10906 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10907 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10908 {}
10909};
10910
Tobin Davisf651b502007-10-26 12:40:47 +020010911/* Samsung Q1 Ultra Vista model setup */
10912static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010913 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10914 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010915 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10916 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10917 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010918 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010919 { } /* end */
10920};
10921
10922static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010923 /* output mixer */
10924 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10925 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10926 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10927 /* speaker */
10928 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10929 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10930 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10931 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10932 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010933 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010934 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10935 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10936 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10937 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10938 /* internal mic */
10939 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10940 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10941 /* ADC, choose mic */
10942 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10943 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10944 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10945 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10946 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10947 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10948 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10949 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10950 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10951 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010952 {}
10953};
10954
Tobin Davisf651b502007-10-26 12:40:47 +020010955/* mute/unmute internal speaker according to the hp jack and mute state */
10956static void alc262_ultra_automute(struct hda_codec *codec)
10957{
10958 struct alc_spec *spec = codec->spec;
10959 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010960
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010961 mute = 0;
10962 /* auto-mute only when HP is used as HP */
10963 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080010964 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010965 if (spec->jack_present)
10966 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010967 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010968 /* mute/unmute internal speaker */
10969 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10970 HDA_AMP_MUTE, mute);
10971 /* mute/unmute HP */
10972 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10973 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010974}
10975
10976/* unsolicited event for HP jack sensing */
10977static void alc262_ultra_unsol_event(struct hda_codec *codec,
10978 unsigned int res)
10979{
10980 if ((res >> 26) != ALC880_HP_EVENT)
10981 return;
10982 alc262_ultra_automute(codec);
10983}
10984
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010985static struct hda_input_mux alc262_ultra_capture_source = {
10986 .num_items = 2,
10987 .items = {
10988 { "Mic", 0x1 },
10989 { "Headphone", 0x7 },
10990 },
10991};
10992
10993static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10994 struct snd_ctl_elem_value *ucontrol)
10995{
10996 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10997 struct alc_spec *spec = codec->spec;
10998 int ret;
10999
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011000 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011001 if (!ret)
11002 return 0;
11003 /* reprogram the HP pin as mic or HP according to the input source */
11004 snd_hda_codec_write_cache(codec, 0x15, 0,
11005 AC_VERB_SET_PIN_WIDGET_CONTROL,
11006 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11007 alc262_ultra_automute(codec); /* mute/unmute HP */
11008 return ret;
11009}
11010
11011static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11012 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11013 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11014 {
11015 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11016 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011017 .info = alc_mux_enum_info,
11018 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011019 .put = alc262_ultra_mux_enum_put,
11020 },
11021 { } /* end */
11022};
11023
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011024/* We use two mixers depending on the output pin; 0x16 is a mono output
11025 * and thus it's bound with a different mixer.
11026 * This function returns which mixer amp should be used.
11027 */
11028static int alc262_check_volbit(hda_nid_t nid)
11029{
11030 if (!nid)
11031 return 0;
11032 else if (nid == 0x16)
11033 return 2;
11034 else
11035 return 1;
11036}
11037
11038static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
11039 const char *pfx, int *vbits)
11040{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011041 unsigned long val;
11042 int vbit;
11043
11044 vbit = alc262_check_volbit(nid);
11045 if (!vbit)
11046 return 0;
11047 if (*vbits & vbit) /* a volume control for this mixer already there */
11048 return 0;
11049 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011050 if (vbit == 2)
11051 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11052 else
11053 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011054 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011055}
11056
11057static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
11058 const char *pfx)
11059{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011060 unsigned long val;
11061
11062 if (!nid)
11063 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011064 if (nid == 0x16)
11065 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11066 else
11067 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011068 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011069}
11070
Kailang Yangdf694da2005-12-05 19:42:22 +010011071/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011072static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11073 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011074{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011075 const char *pfx;
11076 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010011077 int err;
11078
11079 spec->multiout.num_dacs = 1; /* only use one dac */
11080 spec->multiout.dac_nids = spec->private_dac_nids;
11081 spec->multiout.dac_nids[0] = 2;
11082
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011083 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11084 pfx = "Master";
11085 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11086 pfx = "Speaker";
11087 else
11088 pfx = "Front";
11089 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11090 if (err < 0)
11091 return err;
11092 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11093 if (err < 0)
11094 return err;
11095 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11096 if (err < 0)
11097 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011098
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011099 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11100 alc262_check_volbit(cfg->speaker_pins[0]) |
11101 alc262_check_volbit(cfg->hp_pins[0]);
11102 if (vbits == 1 || vbits == 2)
11103 pfx = "Master"; /* only one mixer is used */
11104 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11105 pfx = "Speaker";
11106 else
11107 pfx = "Front";
11108 vbits = 0;
11109 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11110 if (err < 0)
11111 return err;
11112 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11113 &vbits);
11114 if (err < 0)
11115 return err;
11116 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11117 &vbits);
11118 if (err < 0)
11119 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011120 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011121}
11122
Takashi Iwai05f5f472009-08-25 13:10:18 +020011123#define alc262_auto_create_input_ctls \
11124 alc880_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011125
11126/*
11127 * generic initialization of ADC, input mixers and output mixers
11128 */
11129static struct hda_verb alc262_volume_init_verbs[] = {
11130 /*
11131 * Unmute ADC0-2 and set the default input to mic-in
11132 */
11133 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11134 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11135 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11136 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11137 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11138 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11139
Takashi Iwaicb53c622007-08-10 17:21:45 +020011140 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011141 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011142 * Note: PASD motherboards uses the Line In 2 as the input for
11143 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011144 */
11145 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011146 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11147 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11148 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11149 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11150 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011151
11152 /*
11153 * Set up output mixers (0x0c - 0x0f)
11154 */
11155 /* set vol=0 to output mixers */
11156 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11157 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11158 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011159
Kailang Yangdf694da2005-12-05 19:42:22 +010011160 /* set up input amps for analog loopback */
11161 /* Amp Indices: DAC = 0, mixer = 1 */
11162 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11163 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11164 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11165 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11166 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11167 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11168
11169 /* FIXME: use matrix-type input source selection */
11170 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11171 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11172 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11173 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11174 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11175 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11176 /* Input mixer2 */
11177 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11178 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11179 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11180 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11181 /* Input mixer3 */
11182 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11183 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11184 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11185 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11186
11187 { }
11188};
11189
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011190static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11191 /*
11192 * Unmute ADC0-2 and set the default input to mic-in
11193 */
11194 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11195 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11196 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11197 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11198 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11199 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11200
Takashi Iwaicb53c622007-08-10 17:21:45 +020011201 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011202 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011203 * Note: PASD motherboards uses the Line In 2 as the input for
11204 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011205 */
11206 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011207 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11208 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11209 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11210 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11211 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11212 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11213 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011214
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011215 /*
11216 * Set up output mixers (0x0c - 0x0e)
11217 */
11218 /* set vol=0 to output mixers */
11219 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11220 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11221 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11222
11223 /* set up input amps for analog loopback */
11224 /* Amp Indices: DAC = 0, mixer = 1 */
11225 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11226 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11227 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11228 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11229 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11230 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11231
Takashi Iwaice875f02008-01-28 18:17:43 +010011232 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011233 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11234 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11235
11236 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11237 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11238
11239 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11240 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11241
11242 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11243 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11244 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11245 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11246 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11247
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011248 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011249 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11250 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011251 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011252 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11253 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11254
11255
11256 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011257 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11258 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011259 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011260 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11261 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11262 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11263 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11264 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11265 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11266 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11267 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011268 /* Input mixer2 */
11269 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011270 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11271 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11272 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11273 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11274 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11275 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11276 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11277 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011278 /* Input mixer3 */
11279 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011280 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11281 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11282 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11283 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11284 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11285 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011288
Takashi Iwaice875f02008-01-28 18:17:43 +010011289 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11290
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011291 { }
11292};
11293
Kailang Yangcd7509a2007-01-26 18:33:17 +010011294static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11295 /*
11296 * Unmute ADC0-2 and set the default input to mic-in
11297 */
11298 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11299 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11300 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11301 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11302 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11303 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11304
Takashi Iwaicb53c622007-08-10 17:21:45 +020011305 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011306 * mixer widget
11307 * Note: PASD motherboards uses the Line In 2 as the input for front
11308 * panel mic (mic 2)
11309 */
11310 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011311 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11312 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11313 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11314 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11315 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11316 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11317 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11318 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011319 /*
11320 * Set up output mixers (0x0c - 0x0e)
11321 */
11322 /* set vol=0 to output mixers */
11323 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11324 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11325 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11326
11327 /* set up input amps for analog loopback */
11328 /* Amp Indices: DAC = 0, mixer = 1 */
11329 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11330 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11331 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11332 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11333 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11335
11336
11337 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11338 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11339 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11340 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11341 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11342 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11343 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11344
11345 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11346 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11347
11348 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11349 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11350
11351 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11352 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11353 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11354 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11355 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11356 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11357
11358 /* FIXME: use matrix-type input source selection */
11359 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11360 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11361 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11362 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11363 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11364 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11365 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11366 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11367 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11368 /* Input mixer2 */
11369 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11370 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11371 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11372 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11373 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11374 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11375 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11376 /* Input mixer3 */
11377 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11378 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11379 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11380 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11381 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11382 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11383 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11384
Takashi Iwaice875f02008-01-28 18:17:43 +010011385 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11386
Kailang Yangcd7509a2007-01-26 18:33:17 +010011387 { }
11388};
11389
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011390static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11391
11392 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11393 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11394 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11395
11396 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11397 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11398 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11399 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11400
11401 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11402 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11403 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11404 {}
11405};
11406
11407
Takashi Iwaicb53c622007-08-10 17:21:45 +020011408#ifdef CONFIG_SND_HDA_POWER_SAVE
11409#define alc262_loopbacks alc880_loopbacks
11410#endif
11411
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011412/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011413#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11414#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11415#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11416#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11417
11418/*
11419 * BIOS auto configuration
11420 */
11421static int alc262_parse_auto_config(struct hda_codec *codec)
11422{
11423 struct alc_spec *spec = codec->spec;
11424 int err;
11425 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11426
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011427 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11428 alc262_ignore);
11429 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011430 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011431 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011432 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011433 spec->multiout.max_channels = 2;
11434 spec->no_analog = 1;
11435 goto dig_only;
11436 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011437 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011438 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011439 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11440 if (err < 0)
11441 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011442 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011443 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011444 return err;
11445
11446 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11447
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011448 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011449 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011450 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011451 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011452 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011453 if (spec->autocfg.dig_in_pin)
11454 spec->dig_in_nid = ALC262_DIGIN_NID;
11455
Takashi Iwai603c4012008-07-30 15:01:44 +020011456 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011457 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011458
Takashi Iwaid88897e2008-10-31 15:01:37 +010011459 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011460 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011461 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011462
Takashi Iwai776e1842007-08-29 15:07:11 +020011463 err = alc_auto_add_mic_boost(codec);
11464 if (err < 0)
11465 return err;
11466
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011467 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11468
Kailang Yangdf694da2005-12-05 19:42:22 +010011469 return 1;
11470}
11471
11472#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11473#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11474#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011475#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011476
11477
11478/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011479static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011480{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011481 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011482 alc262_auto_init_multi_out(codec);
11483 alc262_auto_init_hp_out(codec);
11484 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011485 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011486 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011487 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011488}
11489
11490/*
11491 * configuration and preset
11492 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011493static const char *alc262_models[ALC262_MODEL_LAST] = {
11494 [ALC262_BASIC] = "basic",
11495 [ALC262_HIPPO] = "hippo",
11496 [ALC262_HIPPO_1] = "hippo_1",
11497 [ALC262_FUJITSU] = "fujitsu",
11498 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011499 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011500 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011501 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011502 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011503 [ALC262_BENQ_T31] = "benq-t31",
11504 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011505 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011506 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011507 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011508 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011509 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011510 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011511 [ALC262_AUTO] = "auto",
11512};
11513
11514static struct snd_pci_quirk alc262_cfg_tbl[] = {
11515 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011516 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011517 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11518 ALC262_HP_BPC),
11519 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11520 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011521 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11522 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011523 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011524 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011525 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011526 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011527 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011528 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011529 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011530 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011531 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11532 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11533 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011534 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11535 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011536 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011537 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011538 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011539 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011540 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011541 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050011542 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010011543 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011544#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010011545 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11546 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011547#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090011548 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011549 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011550 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011551 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011552 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011553 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011554 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11555 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011556 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011557 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011558 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011559 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011560 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011561 {}
11562};
11563
11564static struct alc_config_preset alc262_presets[] = {
11565 [ALC262_BASIC] = {
11566 .mixers = { alc262_base_mixer },
11567 .init_verbs = { alc262_init_verbs },
11568 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11569 .dac_nids = alc262_dac_nids,
11570 .hp_nid = 0x03,
11571 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11572 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011573 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011574 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011575 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011576 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011577 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011578 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11579 .dac_nids = alc262_dac_nids,
11580 .hp_nid = 0x03,
11581 .dig_out_nid = ALC262_DIGOUT_NID,
11582 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11583 .channel_mode = alc262_modes,
11584 .input_mux = &alc262_capture_source,
11585 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011586 .setup = alc262_hippo_setup,
11587 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011588 },
11589 [ALC262_HIPPO_1] = {
11590 .mixers = { alc262_hippo1_mixer },
11591 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11592 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11593 .dac_nids = alc262_dac_nids,
11594 .hp_nid = 0x02,
11595 .dig_out_nid = ALC262_DIGOUT_NID,
11596 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11597 .channel_mode = alc262_modes,
11598 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011599 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011600 .setup = alc262_hippo1_setup,
11601 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011602 },
Takashi Iwai834be882006-03-01 14:16:17 +010011603 [ALC262_FUJITSU] = {
11604 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011605 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11606 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011607 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11608 .dac_nids = alc262_dac_nids,
11609 .hp_nid = 0x03,
11610 .dig_out_nid = ALC262_DIGOUT_NID,
11611 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11612 .channel_mode = alc262_modes,
11613 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011614 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011615 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011616 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011617 [ALC262_HP_BPC] = {
11618 .mixers = { alc262_HP_BPC_mixer },
11619 .init_verbs = { alc262_HP_BPC_init_verbs },
11620 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11621 .dac_nids = alc262_dac_nids,
11622 .hp_nid = 0x03,
11623 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11624 .channel_mode = alc262_modes,
11625 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011626 .unsol_event = alc262_hp_bpc_unsol_event,
11627 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011628 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011629 [ALC262_HP_BPC_D7000_WF] = {
11630 .mixers = { alc262_HP_BPC_WildWest_mixer },
11631 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11632 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11633 .dac_nids = alc262_dac_nids,
11634 .hp_nid = 0x03,
11635 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11636 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011637 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011638 .unsol_event = alc262_hp_wildwest_unsol_event,
11639 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011640 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011641 [ALC262_HP_BPC_D7000_WL] = {
11642 .mixers = { alc262_HP_BPC_WildWest_mixer,
11643 alc262_HP_BPC_WildWest_option_mixer },
11644 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11645 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11646 .dac_nids = alc262_dac_nids,
11647 .hp_nid = 0x03,
11648 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11649 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011650 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011651 .unsol_event = alc262_hp_wildwest_unsol_event,
11652 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011653 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011654 [ALC262_HP_TC_T5735] = {
11655 .mixers = { alc262_hp_t5735_mixer },
11656 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11657 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11658 .dac_nids = alc262_dac_nids,
11659 .hp_nid = 0x03,
11660 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11661 .channel_mode = alc262_modes,
11662 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011663 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011664 .setup = alc262_hp_t5735_setup,
11665 .init_hook = alc_automute_amp,
Kailang Yang8c427222008-01-10 13:03:59 +010011666 },
11667 [ALC262_HP_RP5700] = {
11668 .mixers = { alc262_hp_rp5700_mixer },
11669 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11670 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11671 .dac_nids = alc262_dac_nids,
11672 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11673 .channel_mode = alc262_modes,
11674 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011675 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011676 [ALC262_BENQ_ED8] = {
11677 .mixers = { alc262_base_mixer },
11678 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11679 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11680 .dac_nids = alc262_dac_nids,
11681 .hp_nid = 0x03,
11682 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11683 .channel_mode = alc262_modes,
11684 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011685 },
Kailang Yang272a5272007-05-14 11:00:38 +020011686 [ALC262_SONY_ASSAMD] = {
11687 .mixers = { alc262_sony_mixer },
11688 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11689 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11690 .dac_nids = alc262_dac_nids,
11691 .hp_nid = 0x02,
11692 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11693 .channel_mode = alc262_modes,
11694 .input_mux = &alc262_capture_source,
11695 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011696 .setup = alc262_hippo_setup,
11697 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020011698 },
11699 [ALC262_BENQ_T31] = {
11700 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011701 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
11702 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020011703 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11704 .dac_nids = alc262_dac_nids,
11705 .hp_nid = 0x03,
11706 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11707 .channel_mode = alc262_modes,
11708 .input_mux = &alc262_capture_source,
11709 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011710 .setup = alc262_hippo_setup,
11711 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020011712 },
Tobin Davisf651b502007-10-26 12:40:47 +020011713 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011714 .mixers = { alc262_ultra_mixer },
11715 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011716 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011717 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11718 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011719 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11720 .channel_mode = alc262_modes,
11721 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011722 .adc_nids = alc262_adc_nids, /* ADC0 */
11723 .capsrc_nids = alc262_capsrc_nids,
11724 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011725 .unsol_event = alc262_ultra_unsol_event,
11726 .init_hook = alc262_ultra_automute,
11727 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011728 [ALC262_LENOVO_3000] = {
11729 .mixers = { alc262_lenovo_3000_mixer },
11730 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11731 alc262_lenovo_3000_unsol_verbs },
11732 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11733 .dac_nids = alc262_dac_nids,
11734 .hp_nid = 0x03,
11735 .dig_out_nid = ALC262_DIGOUT_NID,
11736 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11737 .channel_mode = alc262_modes,
11738 .input_mux = &alc262_fujitsu_capture_source,
11739 .unsol_event = alc262_lenovo_3000_unsol_event,
11740 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011741 [ALC262_NEC] = {
11742 .mixers = { alc262_nec_mixer },
11743 .init_verbs = { alc262_nec_verbs },
11744 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11745 .dac_nids = alc262_dac_nids,
11746 .hp_nid = 0x03,
11747 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11748 .channel_mode = alc262_modes,
11749 .input_mux = &alc262_capture_source,
11750 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011751 [ALC262_TOSHIBA_S06] = {
11752 .mixers = { alc262_toshiba_s06_mixer },
11753 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11754 alc262_eapd_verbs },
11755 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11756 .capsrc_nids = alc262_dmic_capsrc_nids,
11757 .dac_nids = alc262_dac_nids,
11758 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011759 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011760 .dig_out_nid = ALC262_DIGOUT_NID,
11761 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11762 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011763 .unsol_event = alc_sku_unsol_event,
11764 .setup = alc262_toshiba_s06_setup,
11765 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020011766 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011767 [ALC262_TOSHIBA_RX1] = {
11768 .mixers = { alc262_toshiba_rx1_mixer },
11769 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11770 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11771 .dac_nids = alc262_dac_nids,
11772 .hp_nid = 0x03,
11773 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11774 .channel_mode = alc262_modes,
11775 .input_mux = &alc262_capture_source,
11776 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011777 .setup = alc262_hippo_setup,
11778 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011779 },
Tony Vroonba340e82009-02-02 19:01:30 +000011780 [ALC262_TYAN] = {
11781 .mixers = { alc262_tyan_mixer },
11782 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11783 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11784 .dac_nids = alc262_dac_nids,
11785 .hp_nid = 0x02,
11786 .dig_out_nid = ALC262_DIGOUT_NID,
11787 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11788 .channel_mode = alc262_modes,
11789 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011790 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011791 .setup = alc262_tyan_setup,
11792 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000011793 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011794};
11795
11796static int patch_alc262(struct hda_codec *codec)
11797{
11798 struct alc_spec *spec;
11799 int board_config;
11800 int err;
11801
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011802 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011803 if (spec == NULL)
11804 return -ENOMEM;
11805
11806 codec->spec = spec;
11807#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011808 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11809 * under-run
11810 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011811 {
11812 int tmp;
11813 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11814 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11815 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11816 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11817 }
11818#endif
11819
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011820 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11821
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011822 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11823 alc262_models,
11824 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011825
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011826 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011827 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11828 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011829 board_config = ALC262_AUTO;
11830 }
11831
11832 if (board_config == ALC262_AUTO) {
11833 /* automatic parse from the BIOS config */
11834 err = alc262_parse_auto_config(codec);
11835 if (err < 0) {
11836 alc_free(codec);
11837 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011838 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011839 printk(KERN_INFO
11840 "hda_codec: Cannot set up configuration "
11841 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011842 board_config = ALC262_BASIC;
11843 }
11844 }
11845
Takashi Iwai07eba612009-02-19 08:06:35 +010011846 if (!spec->no_analog) {
11847 err = snd_hda_attach_beep_device(codec, 0x1);
11848 if (err < 0) {
11849 alc_free(codec);
11850 return err;
11851 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011852 }
11853
Kailang Yangdf694da2005-12-05 19:42:22 +010011854 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011855 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011856
Kailang Yangdf694da2005-12-05 19:42:22 +010011857 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11858 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011859
Kailang Yangdf694da2005-12-05 19:42:22 +010011860 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11861 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11862
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011863 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011864 int i;
11865 /* check whether the digital-mic has to be supported */
11866 for (i = 0; i < spec->input_mux->num_items; i++) {
11867 if (spec->input_mux->items[i].index >= 9)
11868 break;
11869 }
11870 if (i < spec->input_mux->num_items) {
11871 /* use only ADC0 */
11872 spec->adc_nids = alc262_dmic_adc_nids;
11873 spec->num_adc_nids = 1;
11874 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011875 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011876 /* all analog inputs */
11877 /* check whether NID 0x07 is valid */
11878 unsigned int wcap = get_wcaps(codec, 0x07);
11879
11880 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011881 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020011882 if (wcap != AC_WID_AUD_IN) {
11883 spec->adc_nids = alc262_adc_nids_alt;
11884 spec->num_adc_nids =
11885 ARRAY_SIZE(alc262_adc_nids_alt);
11886 spec->capsrc_nids = alc262_capsrc_nids_alt;
11887 } else {
11888 spec->adc_nids = alc262_adc_nids;
11889 spec->num_adc_nids =
11890 ARRAY_SIZE(alc262_adc_nids);
11891 spec->capsrc_nids = alc262_capsrc_nids;
11892 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011893 }
11894 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011895 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011896 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011897 if (!spec->no_analog)
11898 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011899
Takashi Iwai2134ea42008-01-10 16:53:55 +010011900 spec->vmaster_nid = 0x0c;
11901
Kailang Yangdf694da2005-12-05 19:42:22 +010011902 codec->patch_ops = alc_patch_ops;
11903 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011904 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011905#ifdef CONFIG_SND_HDA_POWER_SAVE
11906 if (!spec->loopback.amplist)
11907 spec->loopback.amplist = alc262_loopbacks;
11908#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011909 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011910
Kailang Yangdf694da2005-12-05 19:42:22 +010011911 return 0;
11912}
11913
Kailang Yangdf694da2005-12-05 19:42:22 +010011914/*
Kailang Yanga361d842007-06-05 12:30:55 +020011915 * ALC268 channel source setting (2 channel)
11916 */
11917#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11918#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011919
Kailang Yanga361d842007-06-05 12:30:55 +020011920static hda_nid_t alc268_dac_nids[2] = {
11921 /* front, hp */
11922 0x02, 0x03
11923};
11924
11925static hda_nid_t alc268_adc_nids[2] = {
11926 /* ADC0-1 */
11927 0x08, 0x07
11928};
11929
11930static hda_nid_t alc268_adc_nids_alt[1] = {
11931 /* ADC0 */
11932 0x08
11933};
11934
Takashi Iwaie1406342008-02-11 18:32:32 +010011935static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11936
Kailang Yanga361d842007-06-05 12:30:55 +020011937static struct snd_kcontrol_new alc268_base_mixer[] = {
11938 /* output mixer control */
11939 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11940 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11941 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11942 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011943 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11944 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11945 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011946 { }
11947};
11948
Takashi Iwai42171c12009-05-08 14:11:43 +020011949static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11950 /* output mixer control */
11951 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11952 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11953 ALC262_HIPPO_MASTER_SWITCH,
11954 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11955 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11956 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11957 { }
11958};
11959
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011960/* bind Beep switches of both NID 0x0f and 0x10 */
11961static struct hda_bind_ctls alc268_bind_beep_sw = {
11962 .ops = &snd_hda_bind_sw,
11963 .values = {
11964 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11965 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11966 0
11967 },
11968};
11969
11970static struct snd_kcontrol_new alc268_beep_mixer[] = {
11971 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11972 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11973 { }
11974};
11975
Kailang Yangd1a991a2007-08-15 16:21:59 +020011976static struct hda_verb alc268_eapd_verbs[] = {
11977 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11978 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11979 { }
11980};
11981
Takashi Iwaid2738092007-08-16 14:59:45 +020011982/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011983static struct hda_verb alc268_toshiba_verbs[] = {
11984 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11985 { } /* end */
11986};
11987
11988/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011989/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011990static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11991 .ops = &snd_hda_bind_vol,
11992 .values = {
11993 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11994 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11995 0
11996 },
11997};
11998
Takashi Iwai889c4392007-08-23 18:56:52 +020011999/* mute/unmute internal speaker according to the hp jack and mute state */
12000static void alc268_acer_automute(struct hda_codec *codec, int force)
12001{
12002 struct alc_spec *spec = codec->spec;
12003 unsigned int mute;
12004
12005 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012006 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012007 spec->sense_updated = 1;
12008 }
12009 if (spec->jack_present)
12010 mute = HDA_AMP_MUTE; /* mute internal speaker */
12011 else /* unmute internal speaker if necessary */
12012 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12013 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12014 HDA_AMP_MUTE, mute);
12015}
12016
12017
12018/* bind hp and internal speaker mute (with plug check) */
12019static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12020 struct snd_ctl_elem_value *ucontrol)
12021{
12022 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12023 long *valp = ucontrol->value.integer.value;
12024 int change;
12025
Takashi Iwai8de56b72009-07-24 16:51:47 +020012026 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012027 if (change)
12028 alc268_acer_automute(codec, 0);
12029 return change;
12030}
Takashi Iwaid2738092007-08-16 14:59:45 +020012031
Kailang Yang8ef355d2008-08-26 13:10:22 +020012032static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12033 /* output mixer control */
12034 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12035 {
12036 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12037 .name = "Master Playback Switch",
12038 .info = snd_hda_mixer_amp_switch_info,
12039 .get = snd_hda_mixer_amp_switch_get,
12040 .put = alc268_acer_master_sw_put,
12041 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12042 },
12043 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12044 { }
12045};
12046
Takashi Iwaid2738092007-08-16 14:59:45 +020012047static struct snd_kcontrol_new alc268_acer_mixer[] = {
12048 /* output mixer control */
12049 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12050 {
12051 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12052 .name = "Master Playback Switch",
12053 .info = snd_hda_mixer_amp_switch_info,
12054 .get = snd_hda_mixer_amp_switch_get,
12055 .put = alc268_acer_master_sw_put,
12056 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12057 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012058 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12059 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12060 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012061 { }
12062};
12063
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012064static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12065 /* output mixer control */
12066 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12067 {
12068 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12069 .name = "Master Playback Switch",
12070 .info = snd_hda_mixer_amp_switch_info,
12071 .get = snd_hda_mixer_amp_switch_get,
12072 .put = alc268_acer_master_sw_put,
12073 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12074 },
12075 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12076 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12077 { }
12078};
12079
Kailang Yang8ef355d2008-08-26 13:10:22 +020012080static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12081 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12082 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12083 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12084 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12085 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12086 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12087 { }
12088};
12089
Takashi Iwaid2738092007-08-16 14:59:45 +020012090static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012091 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12092 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012093 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12094 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012095 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12096 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012097 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12098 { }
12099};
12100
12101/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012102#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012103#define alc268_toshiba_setup alc262_hippo_setup
12104#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012105
12106static void alc268_acer_unsol_event(struct hda_codec *codec,
12107 unsigned int res)
12108{
Takashi Iwai889c4392007-08-23 18:56:52 +020012109 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012110 return;
12111 alc268_acer_automute(codec, 1);
12112}
12113
Takashi Iwai889c4392007-08-23 18:56:52 +020012114static void alc268_acer_init_hook(struct hda_codec *codec)
12115{
12116 alc268_acer_automute(codec, 1);
12117}
12118
Kailang Yang8ef355d2008-08-26 13:10:22 +020012119/* toggle speaker-output according to the hp-jack state */
12120static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12121{
12122 unsigned int present;
12123 unsigned char bits;
12124
Wu Fengguang864f92b2009-11-18 12:38:02 +080012125 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012126 bits = present ? AMP_IN_MUTE(0) : 0;
12127 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
12128 AMP_IN_MUTE(0), bits);
12129 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
12130 AMP_IN_MUTE(0), bits);
12131}
12132
Kailang Yang8ef355d2008-08-26 13:10:22 +020012133static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12134 unsigned int res)
12135{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012136 switch (res >> 26) {
12137 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012138 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012139 break;
12140 case ALC880_MIC_EVENT:
12141 alc_mic_automute(codec);
12142 break;
12143 }
12144}
12145
12146static void alc268_acer_lc_setup(struct hda_codec *codec)
12147{
12148 struct alc_spec *spec = codec->spec;
12149 spec->ext_mic.pin = 0x18;
12150 spec->ext_mic.mux_idx = 0;
12151 spec->int_mic.pin = 0x12;
12152 spec->int_mic.mux_idx = 6;
12153 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012154}
12155
12156static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12157{
12158 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012159 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012160}
12161
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012162static struct snd_kcontrol_new alc268_dell_mixer[] = {
12163 /* output mixer control */
12164 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12165 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12166 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12167 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12168 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12169 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12170 { }
12171};
12172
12173static struct hda_verb alc268_dell_verbs[] = {
12174 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12175 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12176 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012177 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012178 { }
12179};
12180
12181/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012182static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012183{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012184 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012185
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012186 spec->autocfg.hp_pins[0] = 0x15;
12187 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012188 spec->ext_mic.pin = 0x18;
12189 spec->ext_mic.mux_idx = 0;
12190 spec->int_mic.pin = 0x19;
12191 spec->int_mic.mux_idx = 1;
12192 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012193}
12194
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012195static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12196 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12197 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12198 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12199 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12200 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12201 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12202 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12203 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12204 { }
12205};
12206
12207static struct hda_verb alc267_quanta_il1_verbs[] = {
12208 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12209 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12210 { }
12211};
12212
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012213static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012214{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012215 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012216 spec->autocfg.hp_pins[0] = 0x15;
12217 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012218 spec->ext_mic.pin = 0x18;
12219 spec->ext_mic.mux_idx = 0;
12220 spec->int_mic.pin = 0x19;
12221 spec->int_mic.mux_idx = 1;
12222 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012223}
12224
Kailang Yanga361d842007-06-05 12:30:55 +020012225/*
12226 * generic initialization of ADC, input mixers and output mixers
12227 */
12228static struct hda_verb alc268_base_init_verbs[] = {
12229 /* Unmute DAC0-1 and set vol = 0 */
12230 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012231 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012232
12233 /*
12234 * Set up output mixers (0x0c - 0x0e)
12235 */
12236 /* set vol=0 to output mixers */
12237 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012238 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12239
12240 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12241 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12242
12243 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12244 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12245 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12246 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12247 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12248 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12249 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12250 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12251
12252 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12253 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12254 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12255 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012256 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012257
12258 /* set PCBEEP vol = 0, mute connections */
12259 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12260 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12261 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012262
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012263 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012264
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012265 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12266 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12267 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12268 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012269
Kailang Yanga361d842007-06-05 12:30:55 +020012270 { }
12271};
12272
12273/*
12274 * generic initialization of ADC, input mixers and output mixers
12275 */
12276static struct hda_verb alc268_volume_init_verbs[] = {
12277 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012278 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12279 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012280
12281 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12282 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12283 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12284 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12285 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12286
Kailang Yanga361d842007-06-05 12:30:55 +020012287 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012288 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12289 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12290
12291 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012292 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012293
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012294 /* set PCBEEP vol = 0, mute connections */
12295 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12296 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12297 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012298
12299 { }
12300};
12301
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012302static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12303 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12304 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12305 { } /* end */
12306};
12307
Kailang Yanga361d842007-06-05 12:30:55 +020012308static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12309 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12310 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012311 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012312 { } /* end */
12313};
12314
12315static struct snd_kcontrol_new alc268_capture_mixer[] = {
12316 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12317 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12318 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12319 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012320 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012321 { } /* end */
12322};
12323
12324static struct hda_input_mux alc268_capture_source = {
12325 .num_items = 4,
12326 .items = {
12327 { "Mic", 0x0 },
12328 { "Front Mic", 0x1 },
12329 { "Line", 0x2 },
12330 { "CD", 0x3 },
12331 },
12332};
12333
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012334static struct hda_input_mux alc268_acer_capture_source = {
12335 .num_items = 3,
12336 .items = {
12337 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012338 { "Internal Mic", 0x1 },
12339 { "Line", 0x2 },
12340 },
12341};
12342
12343static struct hda_input_mux alc268_acer_dmic_capture_source = {
12344 .num_items = 3,
12345 .items = {
12346 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012347 { "Internal Mic", 0x6 },
12348 { "Line", 0x2 },
12349 },
12350};
12351
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012352#ifdef CONFIG_SND_DEBUG
12353static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012354 /* Volume widgets */
12355 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12356 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12357 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12358 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12359 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12360 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12361 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12362 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12363 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12364 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12365 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12366 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12367 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012368 /* The below appears problematic on some hardwares */
12369 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012370 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12371 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12372 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12373 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12374
12375 /* Modes for retasking pin widgets */
12376 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12377 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12378 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12379 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12380
12381 /* Controls for GPIO pins, assuming they are configured as outputs */
12382 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12383 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12384 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12385 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12386
12387 /* Switches to allow the digital SPDIF output pin to be enabled.
12388 * The ALC268 does not have an SPDIF input.
12389 */
12390 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12391
12392 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12393 * this output to turn on an external amplifier.
12394 */
12395 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12396 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12397
12398 { } /* end */
12399};
12400#endif
12401
Kailang Yanga361d842007-06-05 12:30:55 +020012402/* create input playback/capture controls for the given pin */
12403static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12404 const char *ctlname, int idx)
12405{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012406 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012407 int err;
12408
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012409 switch (nid) {
12410 case 0x14:
12411 case 0x16:
12412 dac = 0x02;
12413 break;
12414 case 0x15:
12415 dac = 0x03;
12416 break;
12417 default:
12418 return 0;
12419 }
12420 if (spec->multiout.dac_nids[0] != dac &&
12421 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012422 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012423 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012424 HDA_OUTPUT));
12425 if (err < 0)
12426 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012427 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12428 }
12429
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012430 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012431 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020012432 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012433 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012434 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012435 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012436 if (err < 0)
12437 return err;
12438 return 0;
12439}
12440
12441/* add playback controls from the parsed DAC table */
12442static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12443 const struct auto_pin_cfg *cfg)
12444{
12445 hda_nid_t nid;
12446 int err;
12447
Kailang Yanga361d842007-06-05 12:30:55 +020012448 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012449
12450 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012451 if (nid) {
12452 const char *name;
12453 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12454 name = "Speaker";
12455 else
12456 name = "Front";
12457 err = alc268_new_analog_output(spec, nid, name, 0);
12458 if (err < 0)
12459 return err;
12460 }
Kailang Yanga361d842007-06-05 12:30:55 +020012461
12462 nid = cfg->speaker_pins[0];
12463 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012464 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020012465 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12466 if (err < 0)
12467 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012468 } else {
12469 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12470 if (err < 0)
12471 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012472 }
12473 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012474 if (nid) {
12475 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12476 if (err < 0)
12477 return err;
12478 }
Kailang Yanga361d842007-06-05 12:30:55 +020012479
12480 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12481 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012482 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012483 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012484 if (err < 0)
12485 return err;
12486 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012487 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012488}
12489
12490/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020012491static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020012492 const struct auto_pin_cfg *cfg)
12493{
Takashi Iwai05f5f472009-08-25 13:10:18 +020012494 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020012495}
12496
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012497static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12498 hda_nid_t nid, int pin_type)
12499{
12500 int idx;
12501
12502 alc_set_pin_output(codec, nid, pin_type);
12503 if (nid == 0x14 || nid == 0x16)
12504 idx = 0;
12505 else
12506 idx = 1;
12507 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12508}
12509
12510static void alc268_auto_init_multi_out(struct hda_codec *codec)
12511{
12512 struct alc_spec *spec = codec->spec;
12513 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12514 if (nid) {
12515 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12516 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12517 }
12518}
12519
12520static void alc268_auto_init_hp_out(struct hda_codec *codec)
12521{
12522 struct alc_spec *spec = codec->spec;
12523 hda_nid_t pin;
12524
12525 pin = spec->autocfg.hp_pins[0];
12526 if (pin)
12527 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12528 pin = spec->autocfg.speaker_pins[0];
12529 if (pin)
12530 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12531}
12532
Kailang Yanga361d842007-06-05 12:30:55 +020012533static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12534{
12535 struct alc_spec *spec = codec->spec;
12536 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12537 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12538 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12539 unsigned int dac_vol1, dac_vol2;
12540
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012541 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020012542 snd_hda_codec_write(codec, speaker_nid, 0,
12543 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012544 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012545 snd_hda_codec_write(codec, 0x0f, 0,
12546 AC_VERB_SET_AMP_GAIN_MUTE,
12547 AMP_IN_UNMUTE(1));
12548 snd_hda_codec_write(codec, 0x10, 0,
12549 AC_VERB_SET_AMP_GAIN_MUTE,
12550 AMP_IN_UNMUTE(1));
12551 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012552 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012553 snd_hda_codec_write(codec, 0x0f, 0,
12554 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12555 snd_hda_codec_write(codec, 0x10, 0,
12556 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12557 }
12558
12559 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012560 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012561 dac_vol2 = AMP_OUT_ZERO;
12562 else if (line_nid == 0x15)
12563 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012564 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012565 dac_vol2 = AMP_OUT_ZERO;
12566 else if (hp_nid == 0x15)
12567 dac_vol1 = AMP_OUT_ZERO;
12568 if (line_nid != 0x16 || hp_nid != 0x16 ||
12569 spec->autocfg.line_out_pins[1] != 0x16 ||
12570 spec->autocfg.line_out_pins[2] != 0x16)
12571 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12572
12573 snd_hda_codec_write(codec, 0x02, 0,
12574 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12575 snd_hda_codec_write(codec, 0x03, 0,
12576 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12577}
12578
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012579/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012580#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12581#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012582#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012583#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12584
12585/*
12586 * BIOS auto configuration
12587 */
12588static int alc268_parse_auto_config(struct hda_codec *codec)
12589{
12590 struct alc_spec *spec = codec->spec;
12591 int err;
12592 static hda_nid_t alc268_ignore[] = { 0 };
12593
12594 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12595 alc268_ignore);
12596 if (err < 0)
12597 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012598 if (!spec->autocfg.line_outs) {
12599 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12600 spec->multiout.max_channels = 2;
12601 spec->no_analog = 1;
12602 goto dig_only;
12603 }
Kailang Yanga361d842007-06-05 12:30:55 +020012604 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012605 }
Kailang Yanga361d842007-06-05 12:30:55 +020012606 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12607 if (err < 0)
12608 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012609 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020012610 if (err < 0)
12611 return err;
12612
12613 spec->multiout.max_channels = 2;
12614
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012615 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012616 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012617 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012618 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012619 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12620 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012621 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012622 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012623
Takashi Iwai892981f2009-03-02 08:04:35 +010012624 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012625 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012626
Takashi Iwaid88897e2008-10-31 15:01:37 +010012627 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012628 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012629 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012630
Takashi Iwai776e1842007-08-29 15:07:11 +020012631 err = alc_auto_add_mic_boost(codec);
12632 if (err < 0)
12633 return err;
12634
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012635 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12636
Kailang Yanga361d842007-06-05 12:30:55 +020012637 return 1;
12638}
12639
Kailang Yanga361d842007-06-05 12:30:55 +020012640#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12641
12642/* init callback for auto-configuration model -- overriding the default init */
12643static void alc268_auto_init(struct hda_codec *codec)
12644{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012645 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012646 alc268_auto_init_multi_out(codec);
12647 alc268_auto_init_hp_out(codec);
12648 alc268_auto_init_mono_speaker_out(codec);
12649 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012650 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012651 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012652}
12653
12654/*
12655 * configuration and preset
12656 */
12657static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012658 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012659 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012660 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012661 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012662 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012663 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012664 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012665 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012666#ifdef CONFIG_SND_DEBUG
12667 [ALC268_TEST] = "test",
12668#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012669 [ALC268_AUTO] = "auto",
12670};
12671
12672static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012673 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012674 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012675 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012676 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012677 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012678 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12679 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012680 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050012681 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
12682 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020012683 /* almost compatible with toshiba but with optional digital outs;
12684 * auto-probing seems working fine
12685 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012686 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020012687 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020012688 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012689 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012690 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012691 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012692 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012693 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012694 {}
12695};
12696
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012697/* Toshiba laptops have no unique PCI SSID but only codec SSID */
12698static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
12699 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
12700 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
12701 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12702 ALC268_TOSHIBA),
12703 {}
12704};
12705
Kailang Yanga361d842007-06-05 12:30:55 +020012706static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012707 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012708 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
12709 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012710 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12711 alc267_quanta_il1_verbs },
12712 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12713 .dac_nids = alc268_dac_nids,
12714 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12715 .adc_nids = alc268_adc_nids_alt,
12716 .hp_nid = 0x03,
12717 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12718 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012719 .unsol_event = alc_sku_unsol_event,
12720 .setup = alc267_quanta_il1_setup,
12721 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012722 },
Kailang Yanga361d842007-06-05 12:30:55 +020012723 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012724 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12725 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012726 .init_verbs = { alc268_base_init_verbs },
12727 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12728 .dac_nids = alc268_dac_nids,
12729 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12730 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012731 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012732 .hp_nid = 0x03,
12733 .dig_out_nid = ALC268_DIGOUT_NID,
12734 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12735 .channel_mode = alc268_modes,
12736 .input_mux = &alc268_capture_source,
12737 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012738 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012739 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012740 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012741 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12742 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012743 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12744 .dac_nids = alc268_dac_nids,
12745 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12746 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012747 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012748 .hp_nid = 0x03,
12749 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12750 .channel_mode = alc268_modes,
12751 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012752 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012753 .setup = alc268_toshiba_setup,
12754 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020012755 },
12756 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020012757 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012758 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012759 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12760 alc268_acer_verbs },
12761 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12762 .dac_nids = alc268_dac_nids,
12763 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12764 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012765 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012766 .hp_nid = 0x02,
12767 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12768 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012769 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012770 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012771 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012772 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012773 [ALC268_ACER_DMIC] = {
12774 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12775 alc268_beep_mixer },
12776 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12777 alc268_acer_verbs },
12778 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12779 .dac_nids = alc268_dac_nids,
12780 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12781 .adc_nids = alc268_adc_nids_alt,
12782 .capsrc_nids = alc268_capsrc_nids,
12783 .hp_nid = 0x02,
12784 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12785 .channel_mode = alc268_modes,
12786 .input_mux = &alc268_acer_dmic_capture_source,
12787 .unsol_event = alc268_acer_unsol_event,
12788 .init_hook = alc268_acer_init_hook,
12789 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012790 [ALC268_ACER_ASPIRE_ONE] = {
12791 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012792 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012793 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012794 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12795 alc268_acer_aspire_one_verbs },
12796 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12797 .dac_nids = alc268_dac_nids,
12798 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12799 .adc_nids = alc268_adc_nids_alt,
12800 .capsrc_nids = alc268_capsrc_nids,
12801 .hp_nid = 0x03,
12802 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12803 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012804 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012805 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012806 .init_hook = alc268_acer_lc_init_hook,
12807 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012808 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012809 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
12810 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012811 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12812 alc268_dell_verbs },
12813 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12814 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012815 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12816 .adc_nids = alc268_adc_nids_alt,
12817 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012818 .hp_nid = 0x02,
12819 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12820 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012821 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012822 .setup = alc268_dell_setup,
12823 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012824 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012825 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012826 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12827 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012828 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12829 alc268_toshiba_verbs },
12830 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12831 .dac_nids = alc268_dac_nids,
12832 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12833 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012834 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012835 .hp_nid = 0x03,
12836 .dig_out_nid = ALC268_DIGOUT_NID,
12837 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12838 .channel_mode = alc268_modes,
12839 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012840 .setup = alc268_toshiba_setup,
12841 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012842 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012843#ifdef CONFIG_SND_DEBUG
12844 [ALC268_TEST] = {
12845 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12846 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12847 alc268_volume_init_verbs },
12848 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12849 .dac_nids = alc268_dac_nids,
12850 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12851 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012852 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012853 .hp_nid = 0x03,
12854 .dig_out_nid = ALC268_DIGOUT_NID,
12855 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12856 .channel_mode = alc268_modes,
12857 .input_mux = &alc268_capture_source,
12858 },
12859#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012860};
12861
12862static int patch_alc268(struct hda_codec *codec)
12863{
12864 struct alc_spec *spec;
12865 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012866 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012867
12868 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12869 if (spec == NULL)
12870 return -ENOMEM;
12871
12872 codec->spec = spec;
12873
12874 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12875 alc268_models,
12876 alc268_cfg_tbl);
12877
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012878 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
12879 board_config = snd_hda_check_board_codec_sid_config(codec,
12880 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
12881
Kailang Yanga361d842007-06-05 12:30:55 +020012882 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012883 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12884 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012885 board_config = ALC268_AUTO;
12886 }
12887
12888 if (board_config == ALC268_AUTO) {
12889 /* automatic parse from the BIOS config */
12890 err = alc268_parse_auto_config(codec);
12891 if (err < 0) {
12892 alc_free(codec);
12893 return err;
12894 } else if (!err) {
12895 printk(KERN_INFO
12896 "hda_codec: Cannot set up configuration "
12897 "from BIOS. Using base mode...\n");
12898 board_config = ALC268_3ST;
12899 }
12900 }
12901
12902 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012903 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020012904
Kailang Yanga361d842007-06-05 12:30:55 +020012905 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12906 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012907 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012908
Kailang Yanga361d842007-06-05 12:30:55 +020012909 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12910
Takashi Iwai22971e32009-02-10 11:56:44 +010012911 has_beep = 0;
12912 for (i = 0; i < spec->num_mixers; i++) {
12913 if (spec->mixers[i] == alc268_beep_mixer) {
12914 has_beep = 1;
12915 break;
12916 }
12917 }
12918
12919 if (has_beep) {
12920 err = snd_hda_attach_beep_device(codec, 0x1);
12921 if (err < 0) {
12922 alc_free(codec);
12923 return err;
12924 }
12925 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12926 /* override the amp caps for beep generator */
12927 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012928 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12929 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12930 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12931 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012932 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012933
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012934 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012935 /* check whether NID 0x07 is valid */
12936 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012937 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012938
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020012939 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012940 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012941 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012942 if (spec->auto_mic ||
12943 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012944 spec->adc_nids = alc268_adc_nids_alt;
12945 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020012946 if (spec->auto_mic)
12947 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012948 if (spec->auto_mic || spec->input_mux->num_items == 1)
12949 add_mixer(spec, alc268_capture_nosrc_mixer);
12950 else
12951 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012952 } else {
12953 spec->adc_nids = alc268_adc_nids;
12954 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012955 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012956 }
Takashi Iwai85860c02008-02-19 15:00:15 +010012957 /* set default input source */
12958 for (i = 0; i < spec->num_adc_nids; i++)
12959 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12960 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012961 i < spec->num_mux_defs ?
12962 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010012963 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012964 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012965
12966 spec->vmaster_nid = 0x02;
12967
Kailang Yanga361d842007-06-05 12:30:55 +020012968 codec->patch_ops = alc_patch_ops;
12969 if (board_config == ALC268_AUTO)
12970 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012971
Takashi Iwaidaead532008-11-28 12:55:36 +010012972 codec->proc_widget_hook = print_realtek_coef;
12973
Kailang Yanga361d842007-06-05 12:30:55 +020012974 return 0;
12975}
12976
12977/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012978 * ALC269 channel source setting (2 channel)
12979 */
12980#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12981
12982#define alc269_dac_nids alc260_dac_nids
12983
12984static hda_nid_t alc269_adc_nids[1] = {
12985 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012986 0x08,
12987};
12988
Takashi Iwaie01bf502008-08-21 16:25:07 +020012989static hda_nid_t alc269_capsrc_nids[1] = {
12990 0x23,
12991};
12992
12993/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12994 * not a mux!
12995 */
12996
Kailang Yangf6a92242007-12-13 16:52:54 +010012997#define alc269_modes alc260_modes
12998#define alc269_capture_source alc880_lg_lw_capture_source
12999
13000static struct snd_kcontrol_new alc269_base_mixer[] = {
13001 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13002 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13003 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13004 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13005 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13006 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13007 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13008 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13009 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13010 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13011 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13012 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13013 { } /* end */
13014};
13015
Kailang Yang60db6b52008-08-26 13:13:00 +020013016static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13017 /* output mixer control */
13018 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13019 {
13020 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13021 .name = "Master Playback Switch",
13022 .info = snd_hda_mixer_amp_switch_info,
13023 .get = snd_hda_mixer_amp_switch_get,
13024 .put = alc268_acer_master_sw_put,
13025 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13026 },
13027 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13028 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13029 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13030 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13031 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13032 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013033 { }
13034};
13035
Tony Vroon64154832008-11-06 15:08:49 +000013036static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13037 /* output mixer control */
13038 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13039 {
13040 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13041 .name = "Master Playback Switch",
13042 .info = snd_hda_mixer_amp_switch_info,
13043 .get = snd_hda_mixer_amp_switch_get,
13044 .put = alc268_acer_master_sw_put,
13045 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13046 },
13047 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13048 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13049 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13050 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13051 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13052 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13053 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13054 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13055 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013056 { }
13057};
13058
Kailang Yangf53281e2008-07-18 12:36:43 +020013059static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013060 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013061 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013062 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013063 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013064 { } /* end */
13065};
13066
Kailang Yangf6a92242007-12-13 16:52:54 +010013067/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020013068static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
13069 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13070 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013071 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13072 { } /* end */
13073};
13074
13075/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020013076#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013077
Kailang Yang60db6b52008-08-26 13:13:00 +020013078static struct hda_verb alc269_quanta_fl1_verbs[] = {
13079 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13080 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13081 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13082 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13083 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13084 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13085 { }
13086};
13087
Tony Vroon64154832008-11-06 15:08:49 +000013088static struct hda_verb alc269_lifebook_verbs[] = {
13089 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13090 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13091 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13092 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13093 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13094 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13095 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13096 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13097 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13098 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13099 { }
13100};
13101
Kailang Yang60db6b52008-08-26 13:13:00 +020013102/* toggle speaker-output according to the hp-jack state */
13103static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13104{
13105 unsigned int present;
13106 unsigned char bits;
13107
Wu Fengguang864f92b2009-11-18 12:38:02 +080013108 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang60db6b52008-08-26 13:13:00 +020013109 bits = present ? AMP_IN_MUTE(0) : 0;
13110 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13111 AMP_IN_MUTE(0), bits);
13112 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13113 AMP_IN_MUTE(0), bits);
13114
13115 snd_hda_codec_write(codec, 0x20, 0,
13116 AC_VERB_SET_COEF_INDEX, 0x0c);
13117 snd_hda_codec_write(codec, 0x20, 0,
13118 AC_VERB_SET_PROC_COEF, 0x680);
13119
13120 snd_hda_codec_write(codec, 0x20, 0,
13121 AC_VERB_SET_COEF_INDEX, 0x0c);
13122 snd_hda_codec_write(codec, 0x20, 0,
13123 AC_VERB_SET_PROC_COEF, 0x480);
13124}
13125
Tony Vroon64154832008-11-06 15:08:49 +000013126/* toggle speaker-output according to the hp-jacks state */
13127static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13128{
13129 unsigned int present;
13130 unsigned char bits;
13131
13132 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013133 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013134
13135 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013136 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013137
13138 bits = present ? AMP_IN_MUTE(0) : 0;
13139 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13140 AMP_IN_MUTE(0), bits);
13141 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13142 AMP_IN_MUTE(0), bits);
13143
13144 snd_hda_codec_write(codec, 0x20, 0,
13145 AC_VERB_SET_COEF_INDEX, 0x0c);
13146 snd_hda_codec_write(codec, 0x20, 0,
13147 AC_VERB_SET_PROC_COEF, 0x680);
13148
13149 snd_hda_codec_write(codec, 0x20, 0,
13150 AC_VERB_SET_COEF_INDEX, 0x0c);
13151 snd_hda_codec_write(codec, 0x20, 0,
13152 AC_VERB_SET_PROC_COEF, 0x480);
13153}
13154
Tony Vroon64154832008-11-06 15:08:49 +000013155static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13156{
13157 unsigned int present_laptop;
13158 unsigned int present_dock;
13159
Wu Fengguang864f92b2009-11-18 12:38:02 +080013160 present_laptop = snd_hda_jack_detect(codec, 0x18);
13161 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000013162
13163 /* Laptop mic port overrides dock mic port, design decision */
13164 if (present_dock)
13165 snd_hda_codec_write(codec, 0x23, 0,
13166 AC_VERB_SET_CONNECT_SEL, 0x3);
13167 if (present_laptop)
13168 snd_hda_codec_write(codec, 0x23, 0,
13169 AC_VERB_SET_CONNECT_SEL, 0x0);
13170 if (!present_dock && !present_laptop)
13171 snd_hda_codec_write(codec, 0x23, 0,
13172 AC_VERB_SET_CONNECT_SEL, 0x1);
13173}
13174
Kailang Yang60db6b52008-08-26 13:13:00 +020013175static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13176 unsigned int res)
13177{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013178 switch (res >> 26) {
13179 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013180 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013181 break;
13182 case ALC880_MIC_EVENT:
13183 alc_mic_automute(codec);
13184 break;
13185 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013186}
13187
Tony Vroon64154832008-11-06 15:08:49 +000013188static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13189 unsigned int res)
13190{
13191 if ((res >> 26) == ALC880_HP_EVENT)
13192 alc269_lifebook_speaker_automute(codec);
13193 if ((res >> 26) == ALC880_MIC_EVENT)
13194 alc269_lifebook_mic_autoswitch(codec);
13195}
13196
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013197static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13198{
13199 struct alc_spec *spec = codec->spec;
13200 spec->ext_mic.pin = 0x18;
13201 spec->ext_mic.mux_idx = 0;
13202 spec->int_mic.pin = 0x19;
13203 spec->int_mic.mux_idx = 1;
13204 spec->auto_mic = 1;
13205}
13206
Kailang Yang60db6b52008-08-26 13:13:00 +020013207static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13208{
13209 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013210 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013211}
13212
Tony Vroon64154832008-11-06 15:08:49 +000013213static void alc269_lifebook_init_hook(struct hda_codec *codec)
13214{
13215 alc269_lifebook_speaker_automute(codec);
13216 alc269_lifebook_mic_autoswitch(codec);
13217}
13218
Kailang Yang60db6b52008-08-26 13:13:00 +020013219static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
13220 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13221 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13222 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13223 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13224 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13225 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13226 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13227 {}
13228};
13229
13230static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
13231 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13232 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13233 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13234 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13235 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13236 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13237 {}
13238};
13239
13240/* toggle speaker-output according to the hp-jack state */
13241static void alc269_speaker_automute(struct hda_codec *codec)
13242{
Kailang Yangebb83ee2009-12-17 12:23:00 +010013243 struct alc_spec *spec = codec->spec;
13244 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020013245 unsigned int present;
13246 unsigned char bits;
13247
Kailang Yangebb83ee2009-12-17 12:23:00 +010013248 present = snd_hda_jack_detect(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020013249 bits = present ? AMP_IN_MUTE(0) : 0;
13250 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13251 AMP_IN_MUTE(0), bits);
13252 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13253 AMP_IN_MUTE(0), bits);
13254}
13255
Kailang Yang60db6b52008-08-26 13:13:00 +020013256/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013257static void alc269_eeepc_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013258 unsigned int res)
13259{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013260 switch (res >> 26) {
13261 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013262 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013263 break;
13264 case ALC880_MIC_EVENT:
13265 alc_mic_automute(codec);
13266 break;
13267 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013268}
13269
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013270static void alc269_eeepc_dmic_setup(struct hda_codec *codec)
13271{
13272 struct alc_spec *spec = codec->spec;
13273 spec->ext_mic.pin = 0x18;
13274 spec->ext_mic.mux_idx = 0;
13275 spec->int_mic.pin = 0x12;
13276 spec->int_mic.mux_idx = 5;
13277 spec->auto_mic = 1;
13278}
13279
13280static void alc269_eeepc_amic_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
13290static void alc269_eeepc_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013291{
13292 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013293 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013294}
13295
Kailang Yangf6a92242007-12-13 16:52:54 +010013296/*
13297 * generic initialization of ADC, input mixers and output mixers
13298 */
13299static struct hda_verb alc269_init_verbs[] = {
13300 /*
13301 * Unmute ADC0 and set the default input to mic-in
13302 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013303 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013304
13305 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13306 * analog-loopback mixer widget
13307 * Note: PASD motherboards uses the Line In 2 as the input for
13308 * front panel mic (mic 2)
13309 */
13310 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13311 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13312 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13313 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13314 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13315 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13316
13317 /*
13318 * Set up output mixers (0x0c - 0x0e)
13319 */
13320 /* set vol=0 to output mixers */
13321 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13322 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13323
13324 /* set up input amps for analog loopback */
13325 /* Amp Indices: DAC = 0, mixer = 1 */
13326 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13327 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13328 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13329 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13330 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13331 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13332
13333 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13334 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13335 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13336 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13337 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13338 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13339 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13340
13341 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13342 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13343 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13344 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13345 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13346 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13347 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13348
13349 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13350 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13351
13352 /* FIXME: use matrix-type input source selection */
13353 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13354 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013355 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13356 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013357 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13358 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13359
13360 /* set EAPD */
13361 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13362 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13363 { }
13364};
13365
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013366#define alc269_auto_create_multi_out_ctls \
13367 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020013368#define alc269_auto_create_input_ctls \
13369 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013370
13371#ifdef CONFIG_SND_HDA_POWER_SAVE
13372#define alc269_loopbacks alc880_loopbacks
13373#endif
13374
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013375/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013376#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13377#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13378#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13379#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13380
Takashi Iwaif03d3112009-03-05 14:18:16 +010013381static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13382 .substreams = 1,
13383 .channels_min = 2,
13384 .channels_max = 8,
13385 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13386 /* NID is set in alc_build_pcms */
13387 .ops = {
13388 .open = alc880_playback_pcm_open,
13389 .prepare = alc880_playback_pcm_prepare,
13390 .cleanup = alc880_playback_pcm_cleanup
13391 },
13392};
13393
13394static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13395 .substreams = 1,
13396 .channels_min = 2,
13397 .channels_max = 2,
13398 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13399 /* NID is set in alc_build_pcms */
13400};
13401
Kailang Yangf6a92242007-12-13 16:52:54 +010013402/*
13403 * BIOS auto configuration
13404 */
13405static int alc269_parse_auto_config(struct hda_codec *codec)
13406{
13407 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013408 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013409 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13410
13411 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13412 alc269_ignore);
13413 if (err < 0)
13414 return err;
13415
13416 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13417 if (err < 0)
13418 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013419 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010013420 if (err < 0)
13421 return err;
13422
13423 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13424
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013425 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013426 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13427
Takashi Iwai603c4012008-07-30 15:01:44 +020013428 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013429 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013430
Takashi Iwaid88897e2008-10-31 15:01:37 +010013431 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013432 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013433 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013434 /* set default input source */
13435 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13436 0, AC_VERB_SET_CONNECT_SEL,
13437 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013438
13439 err = alc_auto_add_mic_boost(codec);
13440 if (err < 0)
13441 return err;
13442
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013443 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013444 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013445
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013446 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13447
Kailang Yangf6a92242007-12-13 16:52:54 +010013448 return 1;
13449}
13450
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013451#define alc269_auto_init_multi_out alc268_auto_init_multi_out
13452#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010013453#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13454
13455
13456/* init callback for auto-configuration model -- overriding the default init */
13457static void alc269_auto_init(struct hda_codec *codec)
13458{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013459 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013460 alc269_auto_init_multi_out(codec);
13461 alc269_auto_init_hp_out(codec);
13462 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013463 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013464 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013465}
13466
13467/*
13468 * configuration and preset
13469 */
13470static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013471 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013472 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013473 [ALC269_ASUS_AMIC] = "asus-amic",
13474 [ALC269_ASUS_DMIC] = "asus-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000013475 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020013476 [ALC269_LIFEBOOK] = "lifebook",
13477 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010013478};
13479
13480static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013481 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013482 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013483 ALC269_ASUS_AMIC),
13484 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_ASUS_AMIC),
13485 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80JT", ALC269_ASUS_AMIC),
13486 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_ASUS_AMIC),
13487 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_ASUS_AMIC),
13488 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_ASUS_AMIC),
13489 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_ASUS_AMIC),
13490 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_ASUS_AMIC),
13491 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_ASUS_AMIC),
13492 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_ASUS_AMIC),
13493 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_ASUS_AMIC),
13494 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_ASUS_AMIC),
13495 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_ASUS_AMIC),
13496 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_ASUS_AMIC),
13497 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_ASUS_AMIC),
13498 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_ASUS_AMIC),
13499 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_ASUS_AMIC),
13500 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_ASUS_AMIC),
13501 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_ASUS_AMIC),
13502 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_ASUS_AMIC),
13503 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_ASUS_AMIC),
13504 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_AMIC),
13505 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_ASUS_AMIC),
13506 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_AMIC),
13507 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_DMIC),
13508 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_AMIC),
13509 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_AMIC),
13510 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_AMIC),
13511 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020013512 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013513 ALC269_ASUS_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020013514 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013515 ALC269_ASUS_DMIC),
13516 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_ASUS_DMIC),
13517 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_ASUS_DMIC),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013518 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013519 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013520 {}
13521};
13522
13523static struct alc_config_preset alc269_presets[] = {
13524 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013525 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013526 .init_verbs = { alc269_init_verbs },
13527 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13528 .dac_nids = alc269_dac_nids,
13529 .hp_nid = 0x03,
13530 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13531 .channel_mode = alc269_modes,
13532 .input_mux = &alc269_capture_source,
13533 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013534 [ALC269_QUANTA_FL1] = {
13535 .mixers = { alc269_quanta_fl1_mixer },
13536 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13537 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13538 .dac_nids = alc269_dac_nids,
13539 .hp_nid = 0x03,
13540 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13541 .channel_mode = alc269_modes,
13542 .input_mux = &alc269_capture_source,
13543 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013544 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020013545 .init_hook = alc269_quanta_fl1_init_hook,
13546 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010013547 [ALC269_ASUS_AMIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013548 .mixers = { alc269_eeepc_mixer },
13549 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013550 .init_verbs = { alc269_init_verbs,
13551 alc269_eeepc_amic_init_verbs },
13552 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13553 .dac_nids = alc269_dac_nids,
13554 .hp_nid = 0x03,
13555 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13556 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013557 .unsol_event = alc269_eeepc_unsol_event,
13558 .setup = alc269_eeepc_amic_setup,
13559 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013560 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010013561 [ALC269_ASUS_DMIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013562 .mixers = { alc269_eeepc_mixer },
13563 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013564 .init_verbs = { alc269_init_verbs,
13565 alc269_eeepc_dmic_init_verbs },
13566 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13567 .dac_nids = alc269_dac_nids,
13568 .hp_nid = 0x03,
13569 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13570 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013571 .unsol_event = alc269_eeepc_unsol_event,
13572 .setup = alc269_eeepc_dmic_setup,
13573 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013574 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013575 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013576 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013577 .cap_mixer = alc269_epc_capture_mixer,
13578 .init_verbs = { alc269_init_verbs,
13579 alc269_eeepc_dmic_init_verbs },
13580 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13581 .dac_nids = alc269_dac_nids,
13582 .hp_nid = 0x03,
13583 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13584 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013585 .unsol_event = alc269_eeepc_unsol_event,
13586 .setup = alc269_eeepc_dmic_setup,
13587 .init_hook = alc269_eeepc_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010013588 },
Tony Vroon64154832008-11-06 15:08:49 +000013589 [ALC269_LIFEBOOK] = {
13590 .mixers = { alc269_lifebook_mixer },
13591 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13592 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13593 .dac_nids = alc269_dac_nids,
13594 .hp_nid = 0x03,
13595 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13596 .channel_mode = alc269_modes,
13597 .input_mux = &alc269_capture_source,
13598 .unsol_event = alc269_lifebook_unsol_event,
13599 .init_hook = alc269_lifebook_init_hook,
13600 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013601};
13602
13603static int patch_alc269(struct hda_codec *codec)
13604{
13605 struct alc_spec *spec;
13606 int board_config;
13607 int err;
13608
13609 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13610 if (spec == NULL)
13611 return -ENOMEM;
13612
13613 codec->spec = spec;
13614
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013615 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13616
Kailang Yang274693f2009-12-03 10:07:50 +010013617 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
13618 kfree(codec->chip_name);
13619 codec->chip_name = kstrdup("ALC259", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010013620 if (!codec->chip_name) {
13621 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010013622 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010013623 }
Kailang Yang274693f2009-12-03 10:07:50 +010013624 }
13625
Kailang Yangf6a92242007-12-13 16:52:54 +010013626 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13627 alc269_models,
13628 alc269_cfg_tbl);
13629
13630 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013631 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13632 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013633 board_config = ALC269_AUTO;
13634 }
13635
13636 if (board_config == ALC269_AUTO) {
13637 /* automatic parse from the BIOS config */
13638 err = alc269_parse_auto_config(codec);
13639 if (err < 0) {
13640 alc_free(codec);
13641 return err;
13642 } else if (!err) {
13643 printk(KERN_INFO
13644 "hda_codec: Cannot set up configuration "
13645 "from BIOS. Using base mode...\n");
13646 board_config = ALC269_BASIC;
13647 }
13648 }
13649
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013650 err = snd_hda_attach_beep_device(codec, 0x1);
13651 if (err < 0) {
13652 alc_free(codec);
13653 return err;
13654 }
13655
Kailang Yangf6a92242007-12-13 16:52:54 +010013656 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013657 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010013658
Takashi Iwaif03d3112009-03-05 14:18:16 +010013659 if (codec->subsystem_id == 0x17aa3bf8) {
13660 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13661 * fix the sample rate of analog I/O to 44.1kHz
13662 */
13663 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13664 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13665 } else {
13666 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13667 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13668 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013669 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13670 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13671
13672 spec->adc_nids = alc269_adc_nids;
13673 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013674 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013675 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013676 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013677 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013678
Takashi Iwai100d5eb2009-08-10 11:55:51 +020013679 spec->vmaster_nid = 0x02;
13680
Kailang Yangf6a92242007-12-13 16:52:54 +010013681 codec->patch_ops = alc_patch_ops;
13682 if (board_config == ALC269_AUTO)
13683 spec->init_hook = alc269_auto_init;
13684#ifdef CONFIG_SND_HDA_POWER_SAVE
13685 if (!spec->loopback.amplist)
13686 spec->loopback.amplist = alc269_loopbacks;
13687#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013688 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013689
13690 return 0;
13691}
13692
13693/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013694 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13695 */
13696
13697/*
13698 * set the path ways for 2 channel output
13699 * need to set the codec line out and mic 1 pin widgets to inputs
13700 */
13701static struct hda_verb alc861_threestack_ch2_init[] = {
13702 /* set pin widget 1Ah (line in) for input */
13703 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013704 /* set pin widget 18h (mic1/2) for input, for mic also enable
13705 * the vref
13706 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013707 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13708
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013709 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13710#if 0
13711 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13712 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13713#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013714 { } /* end */
13715};
13716/*
13717 * 6ch mode
13718 * need to set the codec line out and mic 1 pin widgets to outputs
13719 */
13720static struct hda_verb alc861_threestack_ch6_init[] = {
13721 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13722 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13723 /* set pin widget 18h (mic1) for output (CLFE)*/
13724 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13725
13726 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013727 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013728
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013729 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13730#if 0
13731 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13732 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13733#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013734 { } /* end */
13735};
13736
13737static struct hda_channel_mode alc861_threestack_modes[2] = {
13738 { 2, alc861_threestack_ch2_init },
13739 { 6, alc861_threestack_ch6_init },
13740};
Takashi Iwai22309c32006-08-09 16:57:28 +020013741/* Set mic1 as input and unmute the mixer */
13742static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13743 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13744 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13745 { } /* end */
13746};
13747/* Set mic1 as output and mute mixer */
13748static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13749 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13750 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13751 { } /* end */
13752};
13753
13754static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13755 { 2, alc861_uniwill_m31_ch2_init },
13756 { 4, alc861_uniwill_m31_ch4_init },
13757};
Kailang Yangdf694da2005-12-05 19:42:22 +010013758
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013759/* Set mic1 and line-in as input and unmute the mixer */
13760static struct hda_verb alc861_asus_ch2_init[] = {
13761 /* set pin widget 1Ah (line in) for input */
13762 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013763 /* set pin widget 18h (mic1/2) for input, for mic also enable
13764 * the vref
13765 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013766 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13767
13768 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13769#if 0
13770 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13771 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13772#endif
13773 { } /* end */
13774};
13775/* Set mic1 nad line-in as output and mute mixer */
13776static struct hda_verb alc861_asus_ch6_init[] = {
13777 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13778 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13779 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13780 /* set pin widget 18h (mic1) for output (CLFE)*/
13781 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13782 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13783 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13784 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13785
13786 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13787#if 0
13788 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13789 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13790#endif
13791 { } /* end */
13792};
13793
13794static struct hda_channel_mode alc861_asus_modes[2] = {
13795 { 2, alc861_asus_ch2_init },
13796 { 6, alc861_asus_ch6_init },
13797};
13798
Kailang Yangdf694da2005-12-05 19:42:22 +010013799/* patch-ALC861 */
13800
13801static struct snd_kcontrol_new alc861_base_mixer[] = {
13802 /* output mixer control */
13803 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13804 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13805 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13806 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13807 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13808
13809 /*Input mixer control */
13810 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13811 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13812 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13813 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13814 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13815 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13816 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13817 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13818 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13819 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013820
Kailang Yangdf694da2005-12-05 19:42:22 +010013821 { } /* end */
13822};
13823
13824static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13825 /* output mixer control */
13826 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13827 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13828 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13829 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13830 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13831
13832 /* Input mixer control */
13833 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13834 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13835 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13836 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13837 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13838 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13839 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13840 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13841 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13842 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013843
Kailang Yangdf694da2005-12-05 19:42:22 +010013844 {
13845 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13846 .name = "Channel Mode",
13847 .info = alc_ch_mode_info,
13848 .get = alc_ch_mode_get,
13849 .put = alc_ch_mode_put,
13850 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13851 },
13852 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013853};
13854
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013855static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013856 /* output mixer control */
13857 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13858 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13859 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013860
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013861 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013862};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013863
Takashi Iwai22309c32006-08-09 16:57:28 +020013864static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13865 /* output mixer control */
13866 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13867 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13868 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13869 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13870 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13871
13872 /* Input mixer control */
13873 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13874 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13875 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13876 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13877 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13878 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13879 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13880 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13881 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13882 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013883
Takashi Iwai22309c32006-08-09 16:57:28 +020013884 {
13885 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13886 .name = "Channel Mode",
13887 .info = alc_ch_mode_info,
13888 .get = alc_ch_mode_get,
13889 .put = alc_ch_mode_put,
13890 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13891 },
13892 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013893};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013894
13895static struct snd_kcontrol_new alc861_asus_mixer[] = {
13896 /* output mixer control */
13897 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13898 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13899 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13900 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13901 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13902
13903 /* Input mixer control */
13904 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13905 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13906 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13907 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13908 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13909 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13910 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13911 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13912 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013913 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13914
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013915 {
13916 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13917 .name = "Channel Mode",
13918 .info = alc_ch_mode_info,
13919 .get = alc_ch_mode_get,
13920 .put = alc_ch_mode_put,
13921 .private_value = ARRAY_SIZE(alc861_asus_modes),
13922 },
13923 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013924};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013925
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013926/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013927static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013928 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13929 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013930 { }
13931};
13932
Kailang Yangdf694da2005-12-05 19:42:22 +010013933/*
13934 * generic initialization of ADC, input mixers and output mixers
13935 */
13936static struct hda_verb alc861_base_init_verbs[] = {
13937 /*
13938 * Unmute ADC0 and set the default input to mic-in
13939 */
13940 /* port-A for surround (rear panel) */
13941 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13942 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13943 /* port-B for mic-in (rear panel) with vref */
13944 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13945 /* port-C for line-in (rear panel) */
13946 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13947 /* port-D for Front */
13948 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13949 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13950 /* port-E for HP out (front panel) */
13951 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13952 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013953 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013954 /* port-F for mic-in (front panel) with vref */
13955 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13956 /* port-G for CLFE (rear panel) */
13957 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13958 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13959 /* port-H for side (rear panel) */
13960 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13961 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13962 /* CD-in */
13963 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13964 /* route front mic to ADC1*/
13965 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13966 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013967
Kailang Yangdf694da2005-12-05 19:42:22 +010013968 /* Unmute DAC0~3 & spdif out*/
13969 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13970 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13971 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13972 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13973 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013974
Kailang Yangdf694da2005-12-05 19:42:22 +010013975 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13976 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13977 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13978 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13979 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013980
Kailang Yangdf694da2005-12-05 19:42:22 +010013981 /* Unmute Stereo Mixer 15 */
13982 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13983 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13984 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013985 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013986
13987 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13988 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13989 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13990 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13991 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13992 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13993 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13994 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013995 /* hp used DAC 3 (Front) */
13996 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013997 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13998
13999 { }
14000};
14001
14002static struct hda_verb alc861_threestack_init_verbs[] = {
14003 /*
14004 * Unmute ADC0 and set the default input to mic-in
14005 */
14006 /* port-A for surround (rear panel) */
14007 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14008 /* port-B for mic-in (rear panel) with vref */
14009 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14010 /* port-C for line-in (rear panel) */
14011 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14012 /* port-D for Front */
14013 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14014 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14015 /* port-E for HP out (front panel) */
14016 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14017 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014018 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014019 /* port-F for mic-in (front panel) with vref */
14020 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14021 /* port-G for CLFE (rear panel) */
14022 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14023 /* port-H for side (rear panel) */
14024 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14025 /* CD-in */
14026 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14027 /* route front mic to ADC1*/
14028 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14029 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14030 /* Unmute DAC0~3 & spdif out*/
14031 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14032 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14033 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14034 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14035 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014036
Kailang Yangdf694da2005-12-05 19:42:22 +010014037 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14038 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14039 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14040 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14041 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014042
Kailang Yangdf694da2005-12-05 19:42:22 +010014043 /* Unmute Stereo Mixer 15 */
14044 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14045 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14046 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014047 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014048
14049 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14050 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14051 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14052 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14053 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14054 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14055 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14056 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014057 /* hp used DAC 3 (Front) */
14058 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014059 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14060 { }
14061};
Takashi Iwai22309c32006-08-09 16:57:28 +020014062
14063static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
14064 /*
14065 * Unmute ADC0 and set the default input to mic-in
14066 */
14067 /* port-A for surround (rear panel) */
14068 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14069 /* port-B for mic-in (rear panel) with vref */
14070 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14071 /* port-C for line-in (rear panel) */
14072 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14073 /* port-D for Front */
14074 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14075 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14076 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014077 /* this has to be set to VREF80 */
14078 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014079 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014080 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014081 /* port-F for mic-in (front panel) with vref */
14082 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14083 /* port-G for CLFE (rear panel) */
14084 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14085 /* port-H for side (rear panel) */
14086 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14087 /* CD-in */
14088 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14089 /* route front mic to ADC1*/
14090 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14091 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14092 /* Unmute DAC0~3 & spdif out*/
14093 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14094 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14095 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14096 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14097 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014098
Takashi Iwai22309c32006-08-09 16:57:28 +020014099 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14100 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14101 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14102 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14103 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014104
Takashi Iwai22309c32006-08-09 16:57:28 +020014105 /* Unmute Stereo Mixer 15 */
14106 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14107 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14108 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014109 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014110
14111 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14112 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14113 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14114 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14115 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14116 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14117 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14118 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014119 /* hp used DAC 3 (Front) */
14120 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014121 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14122 { }
14123};
14124
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014125static struct hda_verb alc861_asus_init_verbs[] = {
14126 /*
14127 * Unmute ADC0 and set the default input to mic-in
14128 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014129 /* port-A for surround (rear panel)
14130 * according to codec#0 this is the HP jack
14131 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014132 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14133 /* route front PCM to HP */
14134 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14135 /* port-B for mic-in (rear panel) with vref */
14136 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14137 /* port-C for line-in (rear panel) */
14138 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14139 /* port-D for Front */
14140 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14141 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14142 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014143 /* this has to be set to VREF80 */
14144 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014145 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014146 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014147 /* port-F for mic-in (front panel) with vref */
14148 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14149 /* port-G for CLFE (rear panel) */
14150 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14151 /* port-H for side (rear panel) */
14152 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14153 /* CD-in */
14154 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14155 /* route front mic to ADC1*/
14156 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14157 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14158 /* Unmute DAC0~3 & spdif out*/
14159 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14160 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14161 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14162 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14163 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14164 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14165 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14166 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14167 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14168 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014169
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014170 /* Unmute Stereo Mixer 15 */
14171 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14172 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14173 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014174 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014175
14176 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14177 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14178 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14179 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14180 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14181 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14182 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14183 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014184 /* hp used DAC 3 (Front) */
14185 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014186 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14187 { }
14188};
14189
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014190/* additional init verbs for ASUS laptops */
14191static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14192 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14193 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14194 { }
14195};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014196
Kailang Yangdf694da2005-12-05 19:42:22 +010014197/*
14198 * generic initialization of ADC, input mixers and output mixers
14199 */
14200static struct hda_verb alc861_auto_init_verbs[] = {
14201 /*
14202 * Unmute ADC0 and set the default input to mic-in
14203 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014204 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014205 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014206
Kailang Yangdf694da2005-12-05 19:42:22 +010014207 /* Unmute DAC0~3 & spdif out*/
14208 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14209 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14210 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14211 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14212 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014213
Kailang Yangdf694da2005-12-05 19:42:22 +010014214 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14215 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14216 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14217 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14218 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014219
Kailang Yangdf694da2005-12-05 19:42:22 +010014220 /* Unmute Stereo Mixer 15 */
14221 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14222 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14223 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14224 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14225
Takashi Iwai1c209302009-07-22 15:17:45 +020014226 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14227 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14228 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14229 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14230 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14231 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14232 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14233 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014234
14235 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14236 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014237 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14238 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014239 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14240 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014241 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14242 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014243
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014244 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014245
14246 { }
14247};
14248
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014249static struct hda_verb alc861_toshiba_init_verbs[] = {
14250 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014251
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014252 { }
14253};
14254
14255/* toggle speaker-output according to the hp-jack state */
14256static void alc861_toshiba_automute(struct hda_codec *codec)
14257{
Wu Fengguang864f92b2009-11-18 12:38:02 +080014258 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014259
Takashi Iwai47fd8302007-08-10 17:11:07 +020014260 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14261 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14262 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14263 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014264}
14265
14266static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14267 unsigned int res)
14268{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014269 if ((res >> 26) == ALC880_HP_EVENT)
14270 alc861_toshiba_automute(codec);
14271}
14272
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014273/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014274#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14275#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14276#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14277#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14278
14279
14280#define ALC861_DIGOUT_NID 0x07
14281
14282static struct hda_channel_mode alc861_8ch_modes[1] = {
14283 { 8, NULL }
14284};
14285
14286static hda_nid_t alc861_dac_nids[4] = {
14287 /* front, surround, clfe, side */
14288 0x03, 0x06, 0x05, 0x04
14289};
14290
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014291static hda_nid_t alc660_dac_nids[3] = {
14292 /* front, clfe, surround */
14293 0x03, 0x05, 0x06
14294};
14295
Kailang Yangdf694da2005-12-05 19:42:22 +010014296static hda_nid_t alc861_adc_nids[1] = {
14297 /* ADC0-2 */
14298 0x08,
14299};
14300
14301static struct hda_input_mux alc861_capture_source = {
14302 .num_items = 5,
14303 .items = {
14304 { "Mic", 0x0 },
14305 { "Front Mic", 0x3 },
14306 { "Line", 0x1 },
14307 { "CD", 0x4 },
14308 { "Mixer", 0x5 },
14309 },
14310};
14311
Takashi Iwai1c209302009-07-22 15:17:45 +020014312static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14313{
14314 struct alc_spec *spec = codec->spec;
14315 hda_nid_t mix, srcs[5];
14316 int i, j, num;
14317
14318 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14319 return 0;
14320 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14321 if (num < 0)
14322 return 0;
14323 for (i = 0; i < num; i++) {
14324 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014325 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014326 if (type != AC_WID_AUD_OUT)
14327 continue;
14328 for (j = 0; j < spec->multiout.num_dacs; j++)
14329 if (spec->multiout.dac_nids[j] == srcs[i])
14330 break;
14331 if (j >= spec->multiout.num_dacs)
14332 return srcs[i];
14333 }
14334 return 0;
14335}
14336
Kailang Yangdf694da2005-12-05 19:42:22 +010014337/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014338static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014339 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014340{
Takashi Iwai1c209302009-07-22 15:17:45 +020014341 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014342 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014343 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014344
14345 spec->multiout.dac_nids = spec->private_dac_nids;
14346 for (i = 0; i < cfg->line_outs; i++) {
14347 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014348 dac = alc861_look_for_dac(codec, nid);
14349 if (!dac)
14350 continue;
14351 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014352 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014353 return 0;
14354}
14355
Takashi Iwai1c209302009-07-22 15:17:45 +020014356static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14357 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014358{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020014359 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020014360 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14361}
14362
14363/* add playback controls from the parsed DAC table */
14364static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14365 const struct auto_pin_cfg *cfg)
14366{
14367 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014368 static const char *chname[4] = {
14369 "Front", "Surround", NULL /*CLFE*/, "Side"
14370 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014371 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014372 int i, err;
14373
14374 if (cfg->line_outs == 1) {
14375 const char *pfx = NULL;
14376 if (!cfg->hp_outs)
14377 pfx = "Master";
14378 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14379 pfx = "Speaker";
14380 if (pfx) {
14381 nid = spec->multiout.dac_nids[0];
14382 return alc861_create_out_sw(codec, pfx, nid, 3);
14383 }
14384 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014385
14386 for (i = 0; i < cfg->line_outs; i++) {
14387 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014388 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014389 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014390 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014391 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014392 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014393 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014394 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014395 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014396 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014397 return err;
14398 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014399 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014400 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014401 return err;
14402 }
14403 }
14404 return 0;
14405}
14406
Takashi Iwai1c209302009-07-22 15:17:45 +020014407static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014408{
Takashi Iwai1c209302009-07-22 15:17:45 +020014409 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014410 int err;
14411 hda_nid_t nid;
14412
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014413 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014414 return 0;
14415
14416 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014417 nid = alc861_look_for_dac(codec, pin);
14418 if (nid) {
14419 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14420 if (err < 0)
14421 return err;
14422 spec->multiout.hp_nid = nid;
14423 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014424 }
14425 return 0;
14426}
14427
14428/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020014429static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014430 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014431{
Takashi Iwai05f5f472009-08-25 13:10:18 +020014432 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014433}
14434
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014435static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14436 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014437 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014438{
Takashi Iwai1c209302009-07-22 15:17:45 +020014439 hda_nid_t mix, srcs[5];
14440 int i, num;
14441
Jacek Luczak564c5be2008-05-03 18:41:23 +020014442 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14443 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014444 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014445 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014446 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14447 return;
14448 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14449 if (num < 0)
14450 return;
14451 for (i = 0; i < num; i++) {
14452 unsigned int mute;
14453 if (srcs[i] == dac || srcs[i] == 0x15)
14454 mute = AMP_IN_UNMUTE(i);
14455 else
14456 mute = AMP_IN_MUTE(i);
14457 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14458 mute);
14459 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014460}
14461
14462static void alc861_auto_init_multi_out(struct hda_codec *codec)
14463{
14464 struct alc_spec *spec = codec->spec;
14465 int i;
14466
14467 for (i = 0; i < spec->autocfg.line_outs; i++) {
14468 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014469 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014470 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014471 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014472 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014473 }
14474}
14475
14476static void alc861_auto_init_hp_out(struct hda_codec *codec)
14477{
14478 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014479
Takashi Iwai15870f02009-10-05 08:25:13 +020014480 if (spec->autocfg.hp_outs)
14481 alc861_auto_set_output_and_unmute(codec,
14482 spec->autocfg.hp_pins[0],
14483 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014484 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020014485 if (spec->autocfg.speaker_outs)
14486 alc861_auto_set_output_and_unmute(codec,
14487 spec->autocfg.speaker_pins[0],
14488 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020014489 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014490}
14491
14492static void alc861_auto_init_analog_input(struct hda_codec *codec)
14493{
14494 struct alc_spec *spec = codec->spec;
14495 int i;
14496
14497 for (i = 0; i < AUTO_PIN_LAST; i++) {
14498 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014499 if (nid >= 0x0c && nid <= 0x11)
14500 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014501 }
14502}
14503
14504/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014505/* return 1 if successful, 0 if the proper config is not found,
14506 * or a negative error code
14507 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014508static int alc861_parse_auto_config(struct hda_codec *codec)
14509{
14510 struct alc_spec *spec = codec->spec;
14511 int err;
14512 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14513
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014514 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14515 alc861_ignore);
14516 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014517 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014518 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014519 return 0; /* can't find valid BIOS pin config */
14520
Takashi Iwai1c209302009-07-22 15:17:45 +020014521 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014522 if (err < 0)
14523 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014524 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014525 if (err < 0)
14526 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014527 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014528 if (err < 0)
14529 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014530 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014531 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014532 return err;
14533
14534 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14535
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014536 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014537 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14538
Takashi Iwai603c4012008-07-30 15:01:44 +020014539 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014540 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014541
Takashi Iwaid88897e2008-10-31 15:01:37 +010014542 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014543
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014544 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014545 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014546
14547 spec->adc_nids = alc861_adc_nids;
14548 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014549 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014550
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014551 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14552
Kailang Yangdf694da2005-12-05 19:42:22 +010014553 return 1;
14554}
14555
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014556/* additional initialization for auto-configuration model */
14557static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014558{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014559 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014560 alc861_auto_init_multi_out(codec);
14561 alc861_auto_init_hp_out(codec);
14562 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014563 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014564 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014565}
14566
Takashi Iwaicb53c622007-08-10 17:21:45 +020014567#ifdef CONFIG_SND_HDA_POWER_SAVE
14568static struct hda_amp_list alc861_loopbacks[] = {
14569 { 0x15, HDA_INPUT, 0 },
14570 { 0x15, HDA_INPUT, 1 },
14571 { 0x15, HDA_INPUT, 2 },
14572 { 0x15, HDA_INPUT, 3 },
14573 { } /* end */
14574};
14575#endif
14576
Kailang Yangdf694da2005-12-05 19:42:22 +010014577
14578/*
14579 * configuration and preset
14580 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014581static const char *alc861_models[ALC861_MODEL_LAST] = {
14582 [ALC861_3ST] = "3stack",
14583 [ALC660_3ST] = "3stack-660",
14584 [ALC861_3ST_DIG] = "3stack-dig",
14585 [ALC861_6ST_DIG] = "6stack-dig",
14586 [ALC861_UNIWILL_M31] = "uniwill-m31",
14587 [ALC861_TOSHIBA] = "toshiba",
14588 [ALC861_ASUS] = "asus",
14589 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14590 [ALC861_AUTO] = "auto",
14591};
14592
14593static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014594 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014595 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14596 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14597 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014598 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014599 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014600 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014601 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14602 * Any other models that need this preset?
14603 */
14604 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014605 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14606 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014607 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14608 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14609 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14610 /* FIXME: the below seems conflict */
14611 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14612 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14613 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014614 {}
14615};
14616
14617static struct alc_config_preset alc861_presets[] = {
14618 [ALC861_3ST] = {
14619 .mixers = { alc861_3ST_mixer },
14620 .init_verbs = { alc861_threestack_init_verbs },
14621 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14622 .dac_nids = alc861_dac_nids,
14623 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14624 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014625 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014626 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14627 .adc_nids = alc861_adc_nids,
14628 .input_mux = &alc861_capture_source,
14629 },
14630 [ALC861_3ST_DIG] = {
14631 .mixers = { alc861_base_mixer },
14632 .init_verbs = { alc861_threestack_init_verbs },
14633 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14634 .dac_nids = alc861_dac_nids,
14635 .dig_out_nid = ALC861_DIGOUT_NID,
14636 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14637 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014638 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014639 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14640 .adc_nids = alc861_adc_nids,
14641 .input_mux = &alc861_capture_source,
14642 },
14643 [ALC861_6ST_DIG] = {
14644 .mixers = { alc861_base_mixer },
14645 .init_verbs = { alc861_base_init_verbs },
14646 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14647 .dac_nids = alc861_dac_nids,
14648 .dig_out_nid = ALC861_DIGOUT_NID,
14649 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14650 .channel_mode = alc861_8ch_modes,
14651 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14652 .adc_nids = alc861_adc_nids,
14653 .input_mux = &alc861_capture_source,
14654 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014655 [ALC660_3ST] = {
14656 .mixers = { alc861_3ST_mixer },
14657 .init_verbs = { alc861_threestack_init_verbs },
14658 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14659 .dac_nids = alc660_dac_nids,
14660 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14661 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014662 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014663 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14664 .adc_nids = alc861_adc_nids,
14665 .input_mux = &alc861_capture_source,
14666 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014667 [ALC861_UNIWILL_M31] = {
14668 .mixers = { alc861_uniwill_m31_mixer },
14669 .init_verbs = { alc861_uniwill_m31_init_verbs },
14670 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14671 .dac_nids = alc861_dac_nids,
14672 .dig_out_nid = ALC861_DIGOUT_NID,
14673 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14674 .channel_mode = alc861_uniwill_m31_modes,
14675 .need_dac_fix = 1,
14676 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14677 .adc_nids = alc861_adc_nids,
14678 .input_mux = &alc861_capture_source,
14679 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014680 [ALC861_TOSHIBA] = {
14681 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014682 .init_verbs = { alc861_base_init_verbs,
14683 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014684 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14685 .dac_nids = alc861_dac_nids,
14686 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14687 .channel_mode = alc883_3ST_2ch_modes,
14688 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14689 .adc_nids = alc861_adc_nids,
14690 .input_mux = &alc861_capture_source,
14691 .unsol_event = alc861_toshiba_unsol_event,
14692 .init_hook = alc861_toshiba_automute,
14693 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014694 [ALC861_ASUS] = {
14695 .mixers = { alc861_asus_mixer },
14696 .init_verbs = { alc861_asus_init_verbs },
14697 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14698 .dac_nids = alc861_dac_nids,
14699 .dig_out_nid = ALC861_DIGOUT_NID,
14700 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14701 .channel_mode = alc861_asus_modes,
14702 .need_dac_fix = 1,
14703 .hp_nid = 0x06,
14704 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14705 .adc_nids = alc861_adc_nids,
14706 .input_mux = &alc861_capture_source,
14707 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014708 [ALC861_ASUS_LAPTOP] = {
14709 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14710 .init_verbs = { alc861_asus_init_verbs,
14711 alc861_asus_laptop_init_verbs },
14712 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14713 .dac_nids = alc861_dac_nids,
14714 .dig_out_nid = ALC861_DIGOUT_NID,
14715 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14716 .channel_mode = alc883_3ST_2ch_modes,
14717 .need_dac_fix = 1,
14718 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14719 .adc_nids = alc861_adc_nids,
14720 .input_mux = &alc861_capture_source,
14721 },
14722};
Kailang Yangdf694da2005-12-05 19:42:22 +010014723
Takashi Iwaicfc9b062009-12-01 12:19:37 +010014724/* Pin config fixes */
14725enum {
14726 PINFIX_FSC_AMILO_PI1505,
14727};
14728
14729static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = {
14730 { 0x0b, 0x0221101f }, /* HP */
14731 { 0x0f, 0x90170310 }, /* speaker */
14732 { }
14733};
14734
14735static const struct alc_fixup alc861_fixups[] = {
14736 [PINFIX_FSC_AMILO_PI1505] = {
14737 .pins = alc861_fsc_amilo_pi1505_pinfix
14738 },
14739};
14740
14741static struct snd_pci_quirk alc861_fixup_tbl[] = {
14742 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
14743 {}
14744};
Kailang Yangdf694da2005-12-05 19:42:22 +010014745
14746static int patch_alc861(struct hda_codec *codec)
14747{
14748 struct alc_spec *spec;
14749 int board_config;
14750 int err;
14751
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014752 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014753 if (spec == NULL)
14754 return -ENOMEM;
14755
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014756 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014757
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014758 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14759 alc861_models,
14760 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014761
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014762 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014763 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14764 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014765 board_config = ALC861_AUTO;
14766 }
14767
Takashi Iwaicfc9b062009-12-01 12:19:37 +010014768 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups);
14769
Kailang Yangdf694da2005-12-05 19:42:22 +010014770 if (board_config == ALC861_AUTO) {
14771 /* automatic parse from the BIOS config */
14772 err = alc861_parse_auto_config(codec);
14773 if (err < 0) {
14774 alc_free(codec);
14775 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014776 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014777 printk(KERN_INFO
14778 "hda_codec: Cannot set up configuration "
14779 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014780 board_config = ALC861_3ST_DIG;
14781 }
14782 }
14783
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014784 err = snd_hda_attach_beep_device(codec, 0x23);
14785 if (err < 0) {
14786 alc_free(codec);
14787 return err;
14788 }
14789
Kailang Yangdf694da2005-12-05 19:42:22 +010014790 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014791 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014792
Kailang Yangdf694da2005-12-05 19:42:22 +010014793 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14794 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14795
Kailang Yangdf694da2005-12-05 19:42:22 +010014796 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14797 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14798
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014799 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14800
Takashi Iwai2134ea42008-01-10 16:53:55 +010014801 spec->vmaster_nid = 0x03;
14802
Kailang Yangdf694da2005-12-05 19:42:22 +010014803 codec->patch_ops = alc_patch_ops;
14804 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014805 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014806#ifdef CONFIG_SND_HDA_POWER_SAVE
14807 if (!spec->loopback.amplist)
14808 spec->loopback.amplist = alc861_loopbacks;
14809#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014810 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014811
Kailang Yangdf694da2005-12-05 19:42:22 +010014812 return 0;
14813}
14814
14815/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014816 * ALC861-VD support
14817 *
14818 * Based on ALC882
14819 *
14820 * In addition, an independent DAC
14821 */
14822#define ALC861VD_DIGOUT_NID 0x06
14823
14824static hda_nid_t alc861vd_dac_nids[4] = {
14825 /* front, surr, clfe, side surr */
14826 0x02, 0x03, 0x04, 0x05
14827};
14828
14829/* dac_nids for ALC660vd are in a different order - according to
14830 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014831 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014832 * of ALC660vd codecs, but for now there is only 3stack mixer
14833 * - and it is the same as in 861vd.
14834 * adc_nids in ALC660vd are (is) the same as in 861vd
14835 */
14836static hda_nid_t alc660vd_dac_nids[3] = {
14837 /* front, rear, clfe, rear_surr */
14838 0x02, 0x04, 0x03
14839};
14840
14841static hda_nid_t alc861vd_adc_nids[1] = {
14842 /* ADC0 */
14843 0x09,
14844};
14845
Takashi Iwaie1406342008-02-11 18:32:32 +010014846static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14847
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014848/* input MUX */
14849/* FIXME: should be a matrix-type input source selection */
14850static struct hda_input_mux alc861vd_capture_source = {
14851 .num_items = 4,
14852 .items = {
14853 { "Mic", 0x0 },
14854 { "Front Mic", 0x1 },
14855 { "Line", 0x2 },
14856 { "CD", 0x4 },
14857 },
14858};
14859
Kailang Yang272a5272007-05-14 11:00:38 +020014860static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014861 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014862 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014863 { "Ext Mic", 0x0 },
14864 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014865 },
14866};
14867
Kailang Yangd1a991a2007-08-15 16:21:59 +020014868static struct hda_input_mux alc861vd_hp_capture_source = {
14869 .num_items = 2,
14870 .items = {
14871 { "Front Mic", 0x0 },
14872 { "ATAPI Mic", 0x1 },
14873 },
14874};
14875
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014876/*
14877 * 2ch mode
14878 */
14879static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14880 { 2, NULL }
14881};
14882
14883/*
14884 * 6ch mode
14885 */
14886static struct hda_verb alc861vd_6stack_ch6_init[] = {
14887 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14888 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14889 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14890 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14891 { } /* end */
14892};
14893
14894/*
14895 * 8ch mode
14896 */
14897static struct hda_verb alc861vd_6stack_ch8_init[] = {
14898 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14899 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14900 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14901 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14902 { } /* end */
14903};
14904
14905static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14906 { 6, alc861vd_6stack_ch6_init },
14907 { 8, alc861vd_6stack_ch8_init },
14908};
14909
14910static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14911 {
14912 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14913 .name = "Channel Mode",
14914 .info = alc_ch_mode_info,
14915 .get = alc_ch_mode_get,
14916 .put = alc_ch_mode_put,
14917 },
14918 { } /* end */
14919};
14920
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014921/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14922 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14923 */
14924static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14925 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14926 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14927
14928 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14929 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14930
14931 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14932 HDA_OUTPUT),
14933 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14934 HDA_OUTPUT),
14935 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14936 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14937
14938 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14939 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14940
14941 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14942
14943 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14944 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14945 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14946
14947 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14948 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14949 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14950
14951 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14952 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14953
14954 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14955 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14956
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014957 { } /* end */
14958};
14959
14960static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14961 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14962 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14963
14964 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14965
14966 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14967 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14968 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14969
14970 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14971 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14972 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14973
14974 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14975 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14976
14977 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14978 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14979
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014980 { } /* end */
14981};
14982
Kailang Yangbdd148a2007-05-08 15:19:08 +020014983static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14984 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14985 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14986 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14987
14988 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14989
14990 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14991 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14992 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14993
14994 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14995 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14996 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14997
14998 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14999 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15000
15001 { } /* end */
15002};
15003
Tobin Davisb419f342008-03-07 11:57:51 +010015004/* Pin assignment: Speaker=0x14, HP = 0x15,
15005 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020015006 */
15007static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010015008 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15009 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015010 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15011 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010015012 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
15013 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15014 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15015 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
15016 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15017 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015018 { } /* end */
15019};
15020
Kailang Yangd1a991a2007-08-15 16:21:59 +020015021/* Pin assignment: Speaker=0x14, Line-out = 0x15,
15022 * Front Mic=0x18, ATAPI Mic = 0x19,
15023 */
15024static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
15025 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15026 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15027 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15028 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
15029 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15030 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15031 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15032 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015033
Kailang Yangd1a991a2007-08-15 16:21:59 +020015034 { } /* end */
15035};
15036
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015037/*
15038 * generic initialization of ADC, input mixers and output mixers
15039 */
15040static struct hda_verb alc861vd_volume_init_verbs[] = {
15041 /*
15042 * Unmute ADC0 and set the default input to mic-in
15043 */
15044 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15045 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15046
15047 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
15048 * the analog-loopback mixer widget
15049 */
15050 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015051 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15052 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15053 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15054 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15055 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015056
15057 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020015058 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15059 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15060 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015061 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015062
15063 /*
15064 * Set up output mixers (0x02 - 0x05)
15065 */
15066 /* set vol=0 to output mixers */
15067 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15068 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15069 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15070 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15071
15072 /* set up input amps for analog loopback */
15073 /* Amp Indices: DAC = 0, mixer = 1 */
15074 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15075 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15076 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15077 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15078 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15079 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15080 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15081 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15082
15083 { }
15084};
15085
15086/*
15087 * 3-stack pin configuration:
15088 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
15089 */
15090static struct hda_verb alc861vd_3stack_init_verbs[] = {
15091 /*
15092 * Set pin mode and muting
15093 */
15094 /* set front pin widgets 0x14 for output */
15095 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15096 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15097 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15098
15099 /* Mic (rear) pin: input vref at 80% */
15100 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15101 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15102 /* Front Mic pin: input vref at 80% */
15103 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15104 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15105 /* Line In pin: input */
15106 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15107 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15108 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15109 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15110 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15111 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15112 /* CD pin widget for input */
15113 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15114
15115 { }
15116};
15117
15118/*
15119 * 6-stack pin configuration:
15120 */
15121static struct hda_verb alc861vd_6stack_init_verbs[] = {
15122 /*
15123 * Set pin mode and muting
15124 */
15125 /* set front pin widgets 0x14 for output */
15126 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15127 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15128 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15129
15130 /* Rear Pin: output 1 (0x0d) */
15131 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15132 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15133 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15134 /* CLFE Pin: output 2 (0x0e) */
15135 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15136 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15137 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15138 /* Side Pin: output 3 (0x0f) */
15139 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15140 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15141 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15142
15143 /* Mic (rear) pin: input vref at 80% */
15144 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15145 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15146 /* Front Mic pin: input vref at 80% */
15147 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15148 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15149 /* Line In pin: input */
15150 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15151 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15152 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15153 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15154 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15155 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15156 /* CD pin widget for input */
15157 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15158
15159 { }
15160};
15161
Kailang Yangbdd148a2007-05-08 15:19:08 +020015162static struct hda_verb alc861vd_eapd_verbs[] = {
15163 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15164 { }
15165};
15166
Kailang Yangf9423e72008-05-27 12:32:25 +020015167static struct hda_verb alc660vd_eapd_verbs[] = {
15168 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15169 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15170 { }
15171};
15172
Kailang Yangbdd148a2007-05-08 15:19:08 +020015173static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15174 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15175 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15176 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15177 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015178 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015179 {}
15180};
15181
Kailang Yangbdd148a2007-05-08 15:19:08 +020015182static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15183{
15184 unsigned int present;
15185 unsigned char bits;
15186
Wu Fengguang864f92b2009-11-18 12:38:02 +080015187 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020015188 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080015189
Takashi Iwai47fd8302007-08-10 17:11:07 +020015190 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15191 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015192}
15193
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015194static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015195{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015196 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015197 spec->autocfg.hp_pins[0] = 0x1b;
15198 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015199}
15200
15201static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15202{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015203 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015204 alc861vd_lenovo_mic_automute(codec);
15205}
15206
15207static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15208 unsigned int res)
15209{
15210 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015211 case ALC880_MIC_EVENT:
15212 alc861vd_lenovo_mic_automute(codec);
15213 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015214 default:
15215 alc_automute_amp_unsol_event(codec, res);
15216 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015217 }
15218}
15219
Kailang Yang272a5272007-05-14 11:00:38 +020015220static struct hda_verb alc861vd_dallas_verbs[] = {
15221 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15222 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15223 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15224 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15225
15226 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15227 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15228 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15229 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15230 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15231 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15232 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15233 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015234
Kailang Yang272a5272007-05-14 11:00:38 +020015235 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15236 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15237 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15238 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15239 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15240 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15241 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15242 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15243
15244 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15245 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15246 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15247 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15248 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15249 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15250 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15251 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15252
15253 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15254 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15255 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15256 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15257
15258 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015259 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015260 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15261
15262 { } /* end */
15263};
15264
15265/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015266static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015267{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015268 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015269
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015270 spec->autocfg.hp_pins[0] = 0x15;
15271 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020015272}
15273
Takashi Iwaicb53c622007-08-10 17:21:45 +020015274#ifdef CONFIG_SND_HDA_POWER_SAVE
15275#define alc861vd_loopbacks alc880_loopbacks
15276#endif
15277
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015278/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015279#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15280#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15281#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15282#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15283
15284/*
15285 * configuration and preset
15286 */
15287static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15288 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015289 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015290 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015291 [ALC861VD_3ST] = "3stack",
15292 [ALC861VD_3ST_DIG] = "3stack-digout",
15293 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015294 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015295 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015296 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015297 [ALC861VD_AUTO] = "auto",
15298};
15299
15300static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015301 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15302 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015303 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015304 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010015305 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015306 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015307 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015308 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015309 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015310 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015311 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015312 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015313 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015314 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015315 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015316 {}
15317};
15318
15319static struct alc_config_preset alc861vd_presets[] = {
15320 [ALC660VD_3ST] = {
15321 .mixers = { alc861vd_3st_mixer },
15322 .init_verbs = { alc861vd_volume_init_verbs,
15323 alc861vd_3stack_init_verbs },
15324 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15325 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015326 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15327 .channel_mode = alc861vd_3stack_2ch_modes,
15328 .input_mux = &alc861vd_capture_source,
15329 },
Mike Crash6963f842007-06-25 12:12:51 +020015330 [ALC660VD_3ST_DIG] = {
15331 .mixers = { alc861vd_3st_mixer },
15332 .init_verbs = { alc861vd_volume_init_verbs,
15333 alc861vd_3stack_init_verbs },
15334 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15335 .dac_nids = alc660vd_dac_nids,
15336 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015337 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15338 .channel_mode = alc861vd_3stack_2ch_modes,
15339 .input_mux = &alc861vd_capture_source,
15340 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015341 [ALC861VD_3ST] = {
15342 .mixers = { alc861vd_3st_mixer },
15343 .init_verbs = { alc861vd_volume_init_verbs,
15344 alc861vd_3stack_init_verbs },
15345 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15346 .dac_nids = alc861vd_dac_nids,
15347 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15348 .channel_mode = alc861vd_3stack_2ch_modes,
15349 .input_mux = &alc861vd_capture_source,
15350 },
15351 [ALC861VD_3ST_DIG] = {
15352 .mixers = { alc861vd_3st_mixer },
15353 .init_verbs = { alc861vd_volume_init_verbs,
15354 alc861vd_3stack_init_verbs },
15355 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15356 .dac_nids = alc861vd_dac_nids,
15357 .dig_out_nid = ALC861VD_DIGOUT_NID,
15358 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15359 .channel_mode = alc861vd_3stack_2ch_modes,
15360 .input_mux = &alc861vd_capture_source,
15361 },
15362 [ALC861VD_6ST_DIG] = {
15363 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15364 .init_verbs = { alc861vd_volume_init_verbs,
15365 alc861vd_6stack_init_verbs },
15366 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15367 .dac_nids = alc861vd_dac_nids,
15368 .dig_out_nid = ALC861VD_DIGOUT_NID,
15369 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15370 .channel_mode = alc861vd_6stack_modes,
15371 .input_mux = &alc861vd_capture_source,
15372 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015373 [ALC861VD_LENOVO] = {
15374 .mixers = { alc861vd_lenovo_mixer },
15375 .init_verbs = { alc861vd_volume_init_verbs,
15376 alc861vd_3stack_init_verbs,
15377 alc861vd_eapd_verbs,
15378 alc861vd_lenovo_unsol_verbs },
15379 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15380 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015381 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15382 .channel_mode = alc861vd_3stack_2ch_modes,
15383 .input_mux = &alc861vd_capture_source,
15384 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015385 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015386 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015387 },
Kailang Yang272a5272007-05-14 11:00:38 +020015388 [ALC861VD_DALLAS] = {
15389 .mixers = { alc861vd_dallas_mixer },
15390 .init_verbs = { alc861vd_dallas_verbs },
15391 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15392 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015393 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15394 .channel_mode = alc861vd_3stack_2ch_modes,
15395 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015396 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015397 .setup = alc861vd_dallas_setup,
15398 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015399 },
15400 [ALC861VD_HP] = {
15401 .mixers = { alc861vd_hp_mixer },
15402 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15403 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15404 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015405 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015406 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15407 .channel_mode = alc861vd_3stack_2ch_modes,
15408 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015409 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015410 .setup = alc861vd_dallas_setup,
15411 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020015412 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015413 [ALC660VD_ASUS_V1S] = {
15414 .mixers = { alc861vd_lenovo_mixer },
15415 .init_verbs = { alc861vd_volume_init_verbs,
15416 alc861vd_3stack_init_verbs,
15417 alc861vd_eapd_verbs,
15418 alc861vd_lenovo_unsol_verbs },
15419 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15420 .dac_nids = alc660vd_dac_nids,
15421 .dig_out_nid = ALC861VD_DIGOUT_NID,
15422 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15423 .channel_mode = alc861vd_3stack_2ch_modes,
15424 .input_mux = &alc861vd_capture_source,
15425 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015426 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015427 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015428 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015429};
15430
15431/*
15432 * BIOS auto configuration
15433 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015434static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15435 const struct auto_pin_cfg *cfg)
15436{
15437 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
15438}
15439
15440
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015441static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15442 hda_nid_t nid, int pin_type, int dac_idx)
15443{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015444 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015445}
15446
15447static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15448{
15449 struct alc_spec *spec = codec->spec;
15450 int i;
15451
15452 for (i = 0; i <= HDA_SIDE; i++) {
15453 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015454 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015455 if (nid)
15456 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015457 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015458 }
15459}
15460
15461
15462static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15463{
15464 struct alc_spec *spec = codec->spec;
15465 hda_nid_t pin;
15466
15467 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015468 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015469 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015470 pin = spec->autocfg.speaker_pins[0];
15471 if (pin)
15472 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015473}
15474
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015475#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15476
15477static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15478{
15479 struct alc_spec *spec = codec->spec;
15480 int i;
15481
15482 for (i = 0; i < AUTO_PIN_LAST; i++) {
15483 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020015484 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015485 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015486 if (nid != ALC861VD_PIN_CD_NID &&
15487 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015488 snd_hda_codec_write(codec, nid, 0,
15489 AC_VERB_SET_AMP_GAIN_MUTE,
15490 AMP_OUT_MUTE);
15491 }
15492 }
15493}
15494
Takashi Iwaif511b012008-08-15 16:46:42 +020015495#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15496
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015497#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15498#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15499
15500/* add playback controls from the parsed DAC table */
15501/* Based on ALC880 version. But ALC861VD has separate,
15502 * different NIDs for mute/unmute switch and volume control */
15503static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15504 const struct auto_pin_cfg *cfg)
15505{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015506 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15507 hda_nid_t nid_v, nid_s;
15508 int i, err;
15509
15510 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015511 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015512 continue;
15513 nid_v = alc861vd_idx_to_mixer_vol(
15514 alc880_dac_to_idx(
15515 spec->multiout.dac_nids[i]));
15516 nid_s = alc861vd_idx_to_mixer_switch(
15517 alc880_dac_to_idx(
15518 spec->multiout.dac_nids[i]));
15519
15520 if (i == 2) {
15521 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015522 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
15523 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015524 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15525 HDA_OUTPUT));
15526 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015527 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015528 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
15529 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015530 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15531 HDA_OUTPUT));
15532 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015533 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015534 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
15535 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015536 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15537 HDA_INPUT));
15538 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015539 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015540 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
15541 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015542 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15543 HDA_INPUT));
15544 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015545 return err;
15546 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015547 const char *pfx;
15548 if (cfg->line_outs == 1 &&
15549 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
15550 if (!cfg->hp_pins)
15551 pfx = "Speaker";
15552 else
15553 pfx = "PCM";
15554 } else
15555 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015556 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015557 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15558 HDA_OUTPUT));
15559 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015560 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015561 if (cfg->line_outs == 1 &&
15562 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15563 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015564 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015565 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015566 HDA_INPUT));
15567 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015568 return err;
15569 }
15570 }
15571 return 0;
15572}
15573
15574/* add playback controls for speaker and HP outputs */
15575/* Based on ALC880 version. But ALC861VD has separate,
15576 * different NIDs for mute/unmute switch and volume control */
15577static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15578 hda_nid_t pin, const char *pfx)
15579{
15580 hda_nid_t nid_v, nid_s;
15581 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015582
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015583 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015584 return 0;
15585
15586 if (alc880_is_fixed_pin(pin)) {
15587 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15588 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015589 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015590 spec->multiout.hp_nid = nid_v;
15591 else
15592 spec->multiout.extra_out_nid[0] = nid_v;
15593 /* control HP volume/switch on the output mixer amp */
15594 nid_v = alc861vd_idx_to_mixer_vol(
15595 alc880_fixed_pin_idx(pin));
15596 nid_s = alc861vd_idx_to_mixer_switch(
15597 alc880_fixed_pin_idx(pin));
15598
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015599 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015600 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15601 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015602 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015603 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015604 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15605 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015606 return err;
15607 } else if (alc880_is_multi_pin(pin)) {
15608 /* set manual connection */
15609 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015610 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015611 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15612 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015613 return err;
15614 }
15615 return 0;
15616}
15617
15618/* parse the BIOS configuration and set up the alc_spec
15619 * return 1 if successful, 0 if the proper config is not found,
15620 * or a negative error code
15621 * Based on ALC880 version - had to change it to override
15622 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15623static int alc861vd_parse_auto_config(struct hda_codec *codec)
15624{
15625 struct alc_spec *spec = codec->spec;
15626 int err;
15627 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15628
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015629 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15630 alc861vd_ignore);
15631 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015632 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015633 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015634 return 0; /* can't find valid BIOS pin config */
15635
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015636 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15637 if (err < 0)
15638 return err;
15639 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15640 if (err < 0)
15641 return err;
15642 err = alc861vd_auto_create_extra_out(spec,
15643 spec->autocfg.speaker_pins[0],
15644 "Speaker");
15645 if (err < 0)
15646 return err;
15647 err = alc861vd_auto_create_extra_out(spec,
15648 spec->autocfg.hp_pins[0],
15649 "Headphone");
15650 if (err < 0)
15651 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015652 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015653 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015654 return err;
15655
15656 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15657
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015658 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015659 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15660
Takashi Iwai603c4012008-07-30 15:01:44 +020015661 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015662 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015663
Takashi Iwaid88897e2008-10-31 15:01:37 +010015664 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015665
15666 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015667 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015668
Takashi Iwai776e1842007-08-29 15:07:11 +020015669 err = alc_auto_add_mic_boost(codec);
15670 if (err < 0)
15671 return err;
15672
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015673 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15674
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015675 return 1;
15676}
15677
15678/* additional initialization for auto-configuration model */
15679static void alc861vd_auto_init(struct hda_codec *codec)
15680{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015681 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015682 alc861vd_auto_init_multi_out(codec);
15683 alc861vd_auto_init_hp_out(codec);
15684 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015685 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015686 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015687 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015688}
15689
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015690enum {
15691 ALC660VD_FIX_ASUS_GPIO1
15692};
15693
15694/* reset GPIO1 */
15695static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
15696 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
15697 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
15698 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
15699 { }
15700};
15701
15702static const struct alc_fixup alc861vd_fixups[] = {
15703 [ALC660VD_FIX_ASUS_GPIO1] = {
15704 .verbs = alc660vd_fix_asus_gpio1_verbs,
15705 },
15706};
15707
15708static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
15709 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
15710 {}
15711};
15712
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015713static int patch_alc861vd(struct hda_codec *codec)
15714{
15715 struct alc_spec *spec;
15716 int err, board_config;
15717
15718 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15719 if (spec == NULL)
15720 return -ENOMEM;
15721
15722 codec->spec = spec;
15723
15724 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15725 alc861vd_models,
15726 alc861vd_cfg_tbl);
15727
15728 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015729 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15730 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015731 board_config = ALC861VD_AUTO;
15732 }
15733
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015734 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups);
15735
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015736 if (board_config == ALC861VD_AUTO) {
15737 /* automatic parse from the BIOS config */
15738 err = alc861vd_parse_auto_config(codec);
15739 if (err < 0) {
15740 alc_free(codec);
15741 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015742 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015743 printk(KERN_INFO
15744 "hda_codec: Cannot set up configuration "
15745 "from BIOS. Using base mode...\n");
15746 board_config = ALC861VD_3ST;
15747 }
15748 }
15749
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015750 err = snd_hda_attach_beep_device(codec, 0x23);
15751 if (err < 0) {
15752 alc_free(codec);
15753 return err;
15754 }
15755
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015756 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015757 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015758
Kailang Yang2f893282008-05-27 12:14:47 +020015759 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015760 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015761 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015762 }
15763
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015764 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15765 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15766
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015767 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15768 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15769
Takashi Iwaidd704692009-08-11 08:45:11 +020015770 if (!spec->adc_nids) {
15771 spec->adc_nids = alc861vd_adc_nids;
15772 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15773 }
15774 if (!spec->capsrc_nids)
15775 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015776
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015777 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015778 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015779
Takashi Iwai2134ea42008-01-10 16:53:55 +010015780 spec->vmaster_nid = 0x02;
15781
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015782 codec->patch_ops = alc_patch_ops;
15783
15784 if (board_config == ALC861VD_AUTO)
15785 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015786#ifdef CONFIG_SND_HDA_POWER_SAVE
15787 if (!spec->loopback.amplist)
15788 spec->loopback.amplist = alc861vd_loopbacks;
15789#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015790 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015791
15792 return 0;
15793}
15794
15795/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015796 * ALC662 support
15797 *
15798 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15799 * configuration. Each pin widget can choose any input DACs and a mixer.
15800 * Each ADC is connected from a mixer of all inputs. This makes possible
15801 * 6-channel independent captures.
15802 *
15803 * In addition, an independent DAC for the multi-playback (not used in this
15804 * driver yet).
15805 */
15806#define ALC662_DIGOUT_NID 0x06
15807#define ALC662_DIGIN_NID 0x0a
15808
15809static hda_nid_t alc662_dac_nids[4] = {
15810 /* front, rear, clfe, rear_surr */
15811 0x02, 0x03, 0x04
15812};
15813
Kailang Yang622e84c2009-04-21 07:39:04 +020015814static hda_nid_t alc272_dac_nids[2] = {
15815 0x02, 0x03
15816};
15817
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015818static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015819 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015820 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015821};
Takashi Iwaie1406342008-02-11 18:32:32 +010015822
Kailang Yang622e84c2009-04-21 07:39:04 +020015823static hda_nid_t alc272_adc_nids[1] = {
15824 /* ADC1-2 */
15825 0x08,
15826};
15827
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015828static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015829static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15830
Takashi Iwaie1406342008-02-11 18:32:32 +010015831
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015832/* input MUX */
15833/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015834static struct hda_input_mux alc662_capture_source = {
15835 .num_items = 4,
15836 .items = {
15837 { "Mic", 0x0 },
15838 { "Front Mic", 0x1 },
15839 { "Line", 0x2 },
15840 { "CD", 0x4 },
15841 },
15842};
15843
15844static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15845 .num_items = 2,
15846 .items = {
15847 { "Mic", 0x1 },
15848 { "Line", 0x2 },
15849 },
15850};
Kailang Yang291702f2007-10-16 14:28:03 +020015851
Kailang Yang6dda9f42008-05-27 12:05:31 +020015852static struct hda_input_mux alc663_capture_source = {
15853 .num_items = 3,
15854 .items = {
15855 { "Mic", 0x0 },
15856 { "Front Mic", 0x1 },
15857 { "Line", 0x2 },
15858 },
15859};
15860
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015861#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020015862static struct hda_input_mux alc272_nc10_capture_source = {
15863 .num_items = 16,
15864 .items = {
15865 { "Autoselect Mic", 0x0 },
15866 { "Internal Mic", 0x1 },
15867 { "In-0x02", 0x2 },
15868 { "In-0x03", 0x3 },
15869 { "In-0x04", 0x4 },
15870 { "In-0x05", 0x5 },
15871 { "In-0x06", 0x6 },
15872 { "In-0x07", 0x7 },
15873 { "In-0x08", 0x8 },
15874 { "In-0x09", 0x9 },
15875 { "In-0x0a", 0x0a },
15876 { "In-0x0b", 0x0b },
15877 { "In-0x0c", 0x0c },
15878 { "In-0x0d", 0x0d },
15879 { "In-0x0e", 0x0e },
15880 { "In-0x0f", 0x0f },
15881 },
15882};
15883#endif
15884
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015885/*
15886 * 2ch mode
15887 */
15888static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15889 { 2, NULL }
15890};
15891
15892/*
15893 * 2ch mode
15894 */
15895static struct hda_verb alc662_3ST_ch2_init[] = {
15896 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15897 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15898 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15899 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15900 { } /* end */
15901};
15902
15903/*
15904 * 6ch mode
15905 */
15906static struct hda_verb alc662_3ST_ch6_init[] = {
15907 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15908 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15909 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15910 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15911 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15912 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15913 { } /* end */
15914};
15915
15916static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15917 { 2, alc662_3ST_ch2_init },
15918 { 6, alc662_3ST_ch6_init },
15919};
15920
15921/*
15922 * 2ch mode
15923 */
15924static struct hda_verb alc662_sixstack_ch6_init[] = {
15925 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15926 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15927 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15928 { } /* end */
15929};
15930
15931/*
15932 * 6ch mode
15933 */
15934static struct hda_verb alc662_sixstack_ch8_init[] = {
15935 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15936 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15937 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15938 { } /* end */
15939};
15940
15941static struct hda_channel_mode alc662_5stack_modes[2] = {
15942 { 2, alc662_sixstack_ch6_init },
15943 { 6, alc662_sixstack_ch8_init },
15944};
15945
15946/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15947 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15948 */
15949
15950static struct snd_kcontrol_new alc662_base_mixer[] = {
15951 /* output mixer control */
15952 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015953 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015954 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015955 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015956 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15957 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015958 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15959 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015960 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15961
15962 /*Input mixer control */
15963 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15964 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15965 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15966 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15967 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15968 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15969 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15970 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015971 { } /* end */
15972};
15973
15974static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15975 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015976 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015977 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15978 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15979 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15980 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15981 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15982 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15983 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15984 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15985 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015986 { } /* end */
15987};
15988
15989static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15990 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015991 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015992 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015993 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015994 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15995 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015996 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15997 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015998 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15999 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16000 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16001 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16002 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16003 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16004 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16005 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16006 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016007 { } /* end */
16008};
16009
16010static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
16011 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16012 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010016013 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16014 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016015 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16016 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16017 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16018 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16019 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016020 { } /* end */
16021};
16022
Kailang Yang291702f2007-10-16 14:28:03 +020016023static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016024 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16025 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020016026
16027 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
16028 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16029 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16030
16031 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16032 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16033 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16034 { } /* end */
16035};
16036
Kailang Yang8c427222008-01-10 13:03:59 +010016037static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016038 ALC262_HIPPO_MASTER_SWITCH,
16039 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016040 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016041 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16042 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016043 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
16044 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16045 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16046 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16047 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16048 { } /* end */
16049};
16050
Kailang Yangf1d4e282008-08-26 14:03:29 +020016051static struct hda_bind_ctls alc663_asus_bind_master_vol = {
16052 .ops = &snd_hda_bind_vol,
16053 .values = {
16054 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16055 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
16056 0
16057 },
16058};
16059
16060static struct hda_bind_ctls alc663_asus_one_bind_switch = {
16061 .ops = &snd_hda_bind_sw,
16062 .values = {
16063 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16064 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16065 0
16066 },
16067};
16068
Kailang Yang6dda9f42008-05-27 12:05:31 +020016069static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016070 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16071 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
16072 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16073 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16074 { } /* end */
16075};
16076
16077static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
16078 .ops = &snd_hda_bind_sw,
16079 .values = {
16080 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16081 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16082 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16083 0
16084 },
16085};
16086
16087static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
16088 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16089 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
16090 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16091 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16092 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16093 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16094
16095 { } /* end */
16096};
16097
16098static struct hda_bind_ctls alc663_asus_four_bind_switch = {
16099 .ops = &snd_hda_bind_sw,
16100 .values = {
16101 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16102 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16103 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16104 0
16105 },
16106};
16107
16108static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
16109 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16110 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
16111 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16112 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16113 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16114 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16115 { } /* end */
16116};
16117
16118static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016119 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16120 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016121 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16122 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16123 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16124 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16125 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16126 { } /* end */
16127};
16128
16129static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
16130 .ops = &snd_hda_bind_vol,
16131 .values = {
16132 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16133 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16134 0
16135 },
16136};
16137
16138static struct hda_bind_ctls alc663_asus_two_bind_switch = {
16139 .ops = &snd_hda_bind_sw,
16140 .values = {
16141 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16142 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
16143 0
16144 },
16145};
16146
16147static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16148 HDA_BIND_VOL("Master Playback Volume",
16149 &alc663_asus_two_bind_master_vol),
16150 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16151 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016152 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16153 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16154 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016155 { } /* end */
16156};
16157
16158static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16159 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16160 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16161 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16162 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16163 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16164 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016165 { } /* end */
16166};
16167
16168static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16169 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16170 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16171 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16172 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16173 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16174
16175 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16176 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16177 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16178 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16179 { } /* end */
16180};
16181
16182static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16183 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16184 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16185 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16186
16187 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16188 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16189 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16190 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16191 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16192 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16193 { } /* end */
16194};
16195
Kailang Yangebb83ee2009-12-17 12:23:00 +010016196static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
16197 .ops = &snd_hda_bind_sw,
16198 .values = {
16199 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16200 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16201 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16202 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16203 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16204 0
16205 },
16206};
16207
16208static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
16209 .ops = &snd_hda_bind_sw,
16210 .values = {
16211 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16212 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16213 0
16214 },
16215};
16216
16217static struct snd_kcontrol_new alc663_mode7_mixer[] = {
16218 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16219 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16220 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16221 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16222 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16223 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16224 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16225 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16226 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16227 { } /* end */
16228};
16229
16230static struct snd_kcontrol_new alc663_mode8_mixer[] = {
16231 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16232 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16233 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16234 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16235 HDA_CODEC_MUTE("Headphone2 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),
16238 { } /* end */
16239};
16240
16241
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016242static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16243 {
16244 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16245 .name = "Channel Mode",
16246 .info = alc_ch_mode_info,
16247 .get = alc_ch_mode_get,
16248 .put = alc_ch_mode_put,
16249 },
16250 { } /* end */
16251};
16252
16253static struct hda_verb alc662_init_verbs[] = {
16254 /* ADC: mute amp left and right */
16255 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16256 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16257 /* Front mixer: unmute input/output amp left and right (volume = 0) */
16258
Takashi Iwaicb53c622007-08-10 17:21:45 +020016259 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16260 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16261 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16262 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16263 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016264
Kailang Yangb60dd392007-09-20 12:50:29 +020016265 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16266 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16267 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16268 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16269 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16270 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016271
16272 /* Front Pin: output 0 (0x0c) */
16273 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16274 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16275
16276 /* Rear Pin: output 1 (0x0d) */
16277 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16278 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16279
16280 /* CLFE Pin: output 2 (0x0e) */
16281 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16282 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16283
16284 /* Mic (rear) pin: input vref at 80% */
16285 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16286 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16287 /* Front Mic pin: input vref at 80% */
16288 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16289 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16290 /* Line In pin: input */
16291 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16292 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16293 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16294 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16295 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16296 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16297 /* CD pin widget for input */
16298 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16299
16300 /* FIXME: use matrix-type input source selection */
16301 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16302 /* Input mixer */
16303 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016304 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016305
16306 /* always trun on EAPD */
16307 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16308 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16309
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016310 { }
16311};
16312
16313static struct hda_verb alc662_sue_init_verbs[] = {
16314 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16315 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016316 {}
16317};
16318
16319static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16320 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16321 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16322 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016323};
16324
Kailang Yang8c427222008-01-10 13:03:59 +010016325/* Set Unsolicited Event*/
16326static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16327 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16328 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16329 {}
16330};
16331
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016332/*
16333 * generic initialization of ADC, input mixers and output mixers
16334 */
16335static struct hda_verb alc662_auto_init_verbs[] = {
16336 /*
16337 * Unmute ADC and set the default input to mic-in
16338 */
16339 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16340 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16341
16342 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16343 * mixer widget
16344 * Note: PASD motherboards uses the Line In 2 as the input for front
16345 * panel mic (mic 2)
16346 */
16347 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016348 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16349 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16350 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16351 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16352 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016353
16354 /*
16355 * Set up output mixers (0x0c - 0x0f)
16356 */
16357 /* set vol=0 to output mixers */
16358 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16359 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16360 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16361
16362 /* set up input amps for analog loopback */
16363 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020016364 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16365 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16366 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16367 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16368 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16369 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016370
16371
16372 /* FIXME: use matrix-type input source selection */
16373 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16374 /* Input mixer */
16375 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016376 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016377 { }
16378};
16379
Takashi Iwai24fb9172008-09-02 14:48:20 +020016380/* additional verbs for ALC663 */
16381static struct hda_verb alc663_auto_init_verbs[] = {
16382 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16383 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16384 { }
16385};
16386
Kailang Yang6dda9f42008-05-27 12:05:31 +020016387static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016388 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16389 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016390 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16391 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016392 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16393 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16394 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016395 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16396 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16397 {}
16398};
16399
Kailang Yangf1d4e282008-08-26 14:03:29 +020016400static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16401 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16402 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16403 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16404 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16405 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16406 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16407 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16408 {}
16409};
16410
16411static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16412 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16413 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16414 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16415 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16416 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16417 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16418 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16419 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16420 {}
16421};
16422
16423static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16424 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16425 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16426 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16427 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16428 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16429 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16430 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16431 {}
16432};
16433
16434static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16435 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16436 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16437 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16438 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16439 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16440 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16441 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16442 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16443 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16444 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16445 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16446 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16447 {}
16448};
16449
16450static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16451 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16452 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16453 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16454 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16455 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16456 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16457 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16459 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16460 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16461 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16462 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16463 {}
16464};
16465
Kailang Yang6dda9f42008-05-27 12:05:31 +020016466static struct hda_verb alc663_g71v_init_verbs[] = {
16467 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16468 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16469 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16470
16471 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16472 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16473 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16474
16475 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16476 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16477 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16478 {}
16479};
16480
16481static struct hda_verb alc663_g50v_init_verbs[] = {
16482 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16483 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16484 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16485
16486 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16487 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16488 {}
16489};
16490
Kailang Yangf1d4e282008-08-26 14:03:29 +020016491static struct hda_verb alc662_ecs_init_verbs[] = {
16492 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16493 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16494 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16495 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16496 {}
16497};
16498
Kailang Yang622e84c2009-04-21 07:39:04 +020016499static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16500 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16501 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16502 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16503 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16504 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16505 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16506 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16507 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16508 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16509 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16510 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16511 {}
16512};
16513
16514static struct hda_verb alc272_dell_init_verbs[] = {
16515 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16516 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16517 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
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, 0x01}, /* Headphone */
16522 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16523 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16524 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16525 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16526 {}
16527};
16528
Kailang Yangebb83ee2009-12-17 12:23:00 +010016529static struct hda_verb alc663_mode7_init_verbs[] = {
16530 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16531 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16532 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16533 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16534 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16535 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16536 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
16537 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16538 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16539 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16540 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16541 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16542 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16543 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16544 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16545 {}
16546};
16547
16548static struct hda_verb alc663_mode8_init_verbs[] = {
16549 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
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},
16553 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16554 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16555 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16556 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16557 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16558 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16559 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16560 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16561 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16562 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16563 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16564 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16565 {}
16566};
16567
Kailang Yangf1d4e282008-08-26 14:03:29 +020016568static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16569 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16570 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16571 { } /* end */
16572};
16573
Kailang Yang622e84c2009-04-21 07:39:04 +020016574static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16575 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16576 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16577 { } /* end */
16578};
16579
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016580static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16581{
16582 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016583 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016584
Wu Fengguang864f92b2009-11-18 12:38:02 +080016585 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016586 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016587
Takashi Iwai47fd8302007-08-10 17:11:07 +020016588 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16589 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016590}
16591
16592static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16593{
16594 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016595 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016596
Wu Fengguang864f92b2009-11-18 12:38:02 +080016597 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016598 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016599
Takashi Iwai47fd8302007-08-10 17:11:07 +020016600 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16601 HDA_AMP_MUTE, bits);
16602 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16603 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016604}
16605
16606static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16607 unsigned int res)
16608{
16609 if ((res >> 26) == ALC880_HP_EVENT)
16610 alc662_lenovo_101e_all_automute(codec);
16611 if ((res >> 26) == ALC880_FRONT_EVENT)
16612 alc662_lenovo_101e_ispeaker_automute(codec);
16613}
16614
Kailang Yang291702f2007-10-16 14:28:03 +020016615/* unsolicited event for HP jack sensing */
16616static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16617 unsigned int res)
16618{
Kailang Yang291702f2007-10-16 14:28:03 +020016619 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016620 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016621 else
16622 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016623}
16624
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016625static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020016626{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016627 struct alc_spec *spec = codec->spec;
16628
16629 alc262_hippo1_setup(codec);
16630 spec->ext_mic.pin = 0x18;
16631 spec->ext_mic.mux_idx = 0;
16632 spec->int_mic.pin = 0x19;
16633 spec->int_mic.mux_idx = 1;
16634 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020016635}
16636
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016637static void alc662_eeepc_inithook(struct hda_codec *codec)
16638{
16639 alc262_hippo_automute(codec);
16640 alc_mic_automute(codec);
16641}
16642
16643static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010016644{
Takashi Iwai42171c12009-05-08 14:11:43 +020016645 struct alc_spec *spec = codec->spec;
16646
16647 spec->autocfg.hp_pins[0] = 0x14;
16648 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010016649}
16650
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016651#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
16652
Kailang Yang6dda9f42008-05-27 12:05:31 +020016653static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16654{
16655 unsigned int present;
16656 unsigned char bits;
16657
Wu Fengguang864f92b2009-11-18 12:38:02 +080016658 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016659 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016660 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16661 AMP_IN_MUTE(0), bits);
16662 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16663 AMP_IN_MUTE(0), bits);
16664}
16665
16666static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16667{
16668 unsigned int present;
16669 unsigned char bits;
16670
Wu Fengguang864f92b2009-11-18 12:38:02 +080016671 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016672 bits = present ? HDA_AMP_MUTE : 0;
16673 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16674 AMP_IN_MUTE(0), bits);
16675 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16676 AMP_IN_MUTE(0), bits);
16677 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16678 AMP_IN_MUTE(0), bits);
16679 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16680 AMP_IN_MUTE(0), bits);
16681}
16682
16683static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16684{
16685 unsigned int present;
16686 unsigned char bits;
16687
Wu Fengguang864f92b2009-11-18 12:38:02 +080016688 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016689 bits = present ? HDA_AMP_MUTE : 0;
16690 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16691 AMP_IN_MUTE(0), bits);
16692 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16693 AMP_IN_MUTE(0), bits);
16694 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16695 AMP_IN_MUTE(0), bits);
16696 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16697 AMP_IN_MUTE(0), bits);
16698}
16699
16700static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16701{
16702 unsigned int present;
16703 unsigned char bits;
16704
Wu Fengguang864f92b2009-11-18 12:38:02 +080016705 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016706 bits = present ? 0 : PIN_OUT;
16707 snd_hda_codec_write(codec, 0x14, 0,
16708 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16709}
16710
16711static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16712{
16713 unsigned int present1, present2;
16714
Wu Fengguang864f92b2009-11-18 12:38:02 +080016715 present1 = snd_hda_jack_detect(codec, 0x21);
16716 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016717
16718 if (present1 || present2) {
16719 snd_hda_codec_write_cache(codec, 0x14, 0,
16720 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16721 } else {
16722 snd_hda_codec_write_cache(codec, 0x14, 0,
16723 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16724 }
16725}
16726
16727static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16728{
16729 unsigned int present1, present2;
16730
Wu Fengguang864f92b2009-11-18 12:38:02 +080016731 present1 = snd_hda_jack_detect(codec, 0x1b);
16732 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016733
16734 if (present1 || present2) {
16735 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16736 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16737 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16738 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16739 } else {
16740 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16741 AMP_IN_MUTE(0), 0);
16742 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16743 AMP_IN_MUTE(0), 0);
16744 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016745}
16746
Kailang Yangebb83ee2009-12-17 12:23:00 +010016747static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
16748{
16749 unsigned int present1, present2;
16750
16751 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16752 AC_VERB_GET_PIN_SENSE, 0)
16753 & AC_PINSENSE_PRESENCE;
16754 present2 = snd_hda_codec_read(codec, 0x21, 0,
16755 AC_VERB_GET_PIN_SENSE, 0)
16756 & AC_PINSENSE_PRESENCE;
16757
16758 if (present1 || present2) {
16759 snd_hda_codec_write_cache(codec, 0x14, 0,
16760 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16761 snd_hda_codec_write_cache(codec, 0x17, 0,
16762 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16763 } else {
16764 snd_hda_codec_write_cache(codec, 0x14, 0,
16765 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16766 snd_hda_codec_write_cache(codec, 0x17, 0,
16767 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16768 }
16769}
16770
16771static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
16772{
16773 unsigned int present1, present2;
16774
16775 present1 = snd_hda_codec_read(codec, 0x21, 0,
16776 AC_VERB_GET_PIN_SENSE, 0)
16777 & AC_PINSENSE_PRESENCE;
16778 present2 = snd_hda_codec_read(codec, 0x15, 0,
16779 AC_VERB_GET_PIN_SENSE, 0)
16780 & AC_PINSENSE_PRESENCE;
16781
16782 if (present1 || present2) {
16783 snd_hda_codec_write_cache(codec, 0x14, 0,
16784 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16785 snd_hda_codec_write_cache(codec, 0x17, 0,
16786 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16787 } else {
16788 snd_hda_codec_write_cache(codec, 0x14, 0,
16789 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16790 snd_hda_codec_write_cache(codec, 0x17, 0,
16791 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16792 }
16793}
16794
Kailang Yang6dda9f42008-05-27 12:05:31 +020016795static void alc663_m51va_unsol_event(struct hda_codec *codec,
16796 unsigned int res)
16797{
16798 switch (res >> 26) {
16799 case ALC880_HP_EVENT:
16800 alc663_m51va_speaker_automute(codec);
16801 break;
16802 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016803 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016804 break;
16805 }
16806}
16807
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016808static void alc663_m51va_setup(struct hda_codec *codec)
16809{
16810 struct alc_spec *spec = codec->spec;
16811 spec->ext_mic.pin = 0x18;
16812 spec->ext_mic.mux_idx = 0;
16813 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010016814 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016815 spec->auto_mic = 1;
16816}
16817
Kailang Yang6dda9f42008-05-27 12:05:31 +020016818static void alc663_m51va_inithook(struct hda_codec *codec)
16819{
16820 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016821 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016822}
16823
Kailang Yangf1d4e282008-08-26 14:03:29 +020016824/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016825#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010016826
16827static void alc663_mode1_setup(struct hda_codec *codec)
16828{
16829 struct alc_spec *spec = codec->spec;
16830 spec->ext_mic.pin = 0x18;
16831 spec->ext_mic.mux_idx = 0;
16832 spec->int_mic.pin = 0x19;
16833 spec->int_mic.mux_idx = 1;
16834 spec->auto_mic = 1;
16835}
16836
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016837#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020016838
Kailang Yangf1d4e282008-08-26 14:03:29 +020016839/* ***************** Mode2 ******************************/
16840static void alc662_mode2_unsol_event(struct hda_codec *codec,
16841 unsigned int res)
16842{
16843 switch (res >> 26) {
16844 case ALC880_HP_EVENT:
16845 alc662_f5z_speaker_automute(codec);
16846 break;
16847 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016848 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016849 break;
16850 }
16851}
16852
Kailang Yangebb83ee2009-12-17 12:23:00 +010016853#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016854
Kailang Yangf1d4e282008-08-26 14:03:29 +020016855static void alc662_mode2_inithook(struct hda_codec *codec)
16856{
16857 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016858 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016859}
16860/* ***************** Mode3 ******************************/
16861static void alc663_mode3_unsol_event(struct hda_codec *codec,
16862 unsigned int res)
16863{
16864 switch (res >> 26) {
16865 case ALC880_HP_EVENT:
16866 alc663_two_hp_m1_speaker_automute(codec);
16867 break;
16868 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016869 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016870 break;
16871 }
16872}
16873
Kailang Yangebb83ee2009-12-17 12:23:00 +010016874#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016875
Kailang Yangf1d4e282008-08-26 14:03:29 +020016876static void alc663_mode3_inithook(struct hda_codec *codec)
16877{
16878 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016879 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016880}
16881/* ***************** Mode4 ******************************/
16882static void alc663_mode4_unsol_event(struct hda_codec *codec,
16883 unsigned int res)
16884{
16885 switch (res >> 26) {
16886 case ALC880_HP_EVENT:
16887 alc663_21jd_two_speaker_automute(codec);
16888 break;
16889 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016890 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016891 break;
16892 }
16893}
16894
Kailang Yangebb83ee2009-12-17 12:23:00 +010016895#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016896
Kailang Yangf1d4e282008-08-26 14:03:29 +020016897static void alc663_mode4_inithook(struct hda_codec *codec)
16898{
16899 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016900 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016901}
16902/* ***************** Mode5 ******************************/
16903static void alc663_mode5_unsol_event(struct hda_codec *codec,
16904 unsigned int res)
16905{
16906 switch (res >> 26) {
16907 case ALC880_HP_EVENT:
16908 alc663_15jd_two_speaker_automute(codec);
16909 break;
16910 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016911 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016912 break;
16913 }
16914}
16915
Kailang Yangebb83ee2009-12-17 12:23:00 +010016916#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016917
Kailang Yangf1d4e282008-08-26 14:03:29 +020016918static void alc663_mode5_inithook(struct hda_codec *codec)
16919{
16920 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016921 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016922}
16923/* ***************** Mode6 ******************************/
16924static void alc663_mode6_unsol_event(struct hda_codec *codec,
16925 unsigned int res)
16926{
16927 switch (res >> 26) {
16928 case ALC880_HP_EVENT:
16929 alc663_two_hp_m2_speaker_automute(codec);
16930 break;
16931 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016932 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016933 break;
16934 }
16935}
16936
Kailang Yangebb83ee2009-12-17 12:23:00 +010016937#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016938
Kailang Yangf1d4e282008-08-26 14:03:29 +020016939static void alc663_mode6_inithook(struct hda_codec *codec)
16940{
16941 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016942 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016943}
16944
Kailang Yangebb83ee2009-12-17 12:23:00 +010016945/* ***************** Mode7 ******************************/
16946static void alc663_mode7_unsol_event(struct hda_codec *codec,
16947 unsigned int res)
16948{
16949 switch (res >> 26) {
16950 case ALC880_HP_EVENT:
16951 alc663_two_hp_m7_speaker_automute(codec);
16952 break;
16953 case ALC880_MIC_EVENT:
16954 alc_mic_automute(codec);
16955 break;
16956 }
16957}
16958
16959#define alc663_mode7_setup alc663_mode1_setup
16960
16961static void alc663_mode7_inithook(struct hda_codec *codec)
16962{
16963 alc663_two_hp_m7_speaker_automute(codec);
16964 alc_mic_automute(codec);
16965}
16966
16967/* ***************** Mode8 ******************************/
16968static void alc663_mode8_unsol_event(struct hda_codec *codec,
16969 unsigned int res)
16970{
16971 switch (res >> 26) {
16972 case ALC880_HP_EVENT:
16973 alc663_two_hp_m8_speaker_automute(codec);
16974 break;
16975 case ALC880_MIC_EVENT:
16976 alc_mic_automute(codec);
16977 break;
16978 }
16979}
16980
16981#define alc663_mode8_setup alc663_m51va_setup
16982
16983static void alc663_mode8_inithook(struct hda_codec *codec)
16984{
16985 alc663_two_hp_m8_speaker_automute(codec);
16986 alc_mic_automute(codec);
16987}
16988
Kailang Yang6dda9f42008-05-27 12:05:31 +020016989static void alc663_g71v_hp_automute(struct hda_codec *codec)
16990{
16991 unsigned int present;
16992 unsigned char bits;
16993
Wu Fengguang864f92b2009-11-18 12:38:02 +080016994 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016995 bits = present ? HDA_AMP_MUTE : 0;
16996 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16997 HDA_AMP_MUTE, bits);
16998 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16999 HDA_AMP_MUTE, bits);
17000}
17001
17002static void alc663_g71v_front_automute(struct hda_codec *codec)
17003{
17004 unsigned int present;
17005 unsigned char bits;
17006
Wu Fengguang864f92b2009-11-18 12:38:02 +080017007 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017008 bits = present ? HDA_AMP_MUTE : 0;
17009 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17010 HDA_AMP_MUTE, bits);
17011}
17012
17013static void alc663_g71v_unsol_event(struct hda_codec *codec,
17014 unsigned int res)
17015{
17016 switch (res >> 26) {
17017 case ALC880_HP_EVENT:
17018 alc663_g71v_hp_automute(codec);
17019 break;
17020 case ALC880_FRONT_EVENT:
17021 alc663_g71v_front_automute(codec);
17022 break;
17023 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017024 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017025 break;
17026 }
17027}
17028
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017029#define alc663_g71v_setup alc663_m51va_setup
17030
Kailang Yang6dda9f42008-05-27 12:05:31 +020017031static void alc663_g71v_inithook(struct hda_codec *codec)
17032{
17033 alc663_g71v_front_automute(codec);
17034 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017035 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017036}
17037
17038static void alc663_g50v_unsol_event(struct hda_codec *codec,
17039 unsigned int res)
17040{
17041 switch (res >> 26) {
17042 case ALC880_HP_EVENT:
17043 alc663_m51va_speaker_automute(codec);
17044 break;
17045 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017046 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017047 break;
17048 }
17049}
17050
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017051#define alc663_g50v_setup alc663_m51va_setup
17052
Kailang Yang6dda9f42008-05-27 12:05:31 +020017053static void alc663_g50v_inithook(struct hda_codec *codec)
17054{
17055 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017056 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017057}
17058
Kailang Yangf1d4e282008-08-26 14:03:29 +020017059static struct snd_kcontrol_new alc662_ecs_mixer[] = {
17060 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020017061 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017062
17063 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
17064 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
17065 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
17066
17067 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17068 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17069 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17070 { } /* end */
17071};
17072
Chris Pockelé9541ba12009-05-12 08:08:53 +020017073static struct snd_kcontrol_new alc272_nc10_mixer[] = {
17074 /* Master Playback automatically created from Speaker and Headphone */
17075 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17076 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17077 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17078 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17079
17080 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17081 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17082 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
17083
17084 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17085 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17086 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
17087 { } /* end */
17088};
17089
Takashi Iwaicb53c622007-08-10 17:21:45 +020017090#ifdef CONFIG_SND_HDA_POWER_SAVE
17091#define alc662_loopbacks alc880_loopbacks
17092#endif
17093
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017094
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017095/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017096#define alc662_pcm_analog_playback alc880_pcm_analog_playback
17097#define alc662_pcm_analog_capture alc880_pcm_analog_capture
17098#define alc662_pcm_digital_playback alc880_pcm_digital_playback
17099#define alc662_pcm_digital_capture alc880_pcm_digital_capture
17100
17101/*
17102 * configuration and preset
17103 */
17104static const char *alc662_models[ALC662_MODEL_LAST] = {
17105 [ALC662_3ST_2ch_DIG] = "3stack-dig",
17106 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
17107 [ALC662_3ST_6ch] = "3stack-6ch",
17108 [ALC662_5ST_DIG] = "6stack-dig",
17109 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020017110 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010017111 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017112 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020017113 [ALC663_ASUS_M51VA] = "m51va",
17114 [ALC663_ASUS_G71V] = "g71v",
17115 [ALC663_ASUS_H13] = "h13",
17116 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017117 [ALC663_ASUS_MODE1] = "asus-mode1",
17118 [ALC662_ASUS_MODE2] = "asus-mode2",
17119 [ALC663_ASUS_MODE3] = "asus-mode3",
17120 [ALC663_ASUS_MODE4] = "asus-mode4",
17121 [ALC663_ASUS_MODE5] = "asus-mode5",
17122 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010017123 [ALC663_ASUS_MODE7] = "asus-mode7",
17124 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020017125 [ALC272_DELL] = "dell",
17126 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020017127 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017128 [ALC662_AUTO] = "auto",
17129};
17130
17131static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010017132 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020017133 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
17134 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017135 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
17136 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
17137 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
17138 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
17139 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
17140 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017141 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
17142 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017143 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017144 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
17145 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
17146 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
17147 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
17148 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017149 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017150 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
17151 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017152 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
17153 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
17154 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
17155 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017156 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017157 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
17158 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
17159 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017160 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
17161 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
17162 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
17163 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017164 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017165 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
17166 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017167 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017168 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
17169 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
17170 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017171 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
17172 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
17173 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017174 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
17175 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
17176 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017177 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017178 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
17179 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017180 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017181 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020017182 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017183 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
17184 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
17185 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017186 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017187 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
17188 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010017189 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020017190 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010017191 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017192 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030017193 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
17194 ALC662_3ST_6ch_DIG),
Manoj Iyer3db6c032009-09-22 18:33:29 -050017195 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB200", ALC663_ASUS_MODE4),
Chris Pockelé9541ba12009-05-12 08:08:53 +020017196 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030017197 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
17198 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020017199 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020017200 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017201 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020017202 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020017203 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017204 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
17205 ALC663_ASUS_H13),
David Santinoli7aee6742009-12-09 12:34:26 +010017206 SND_PCI_QUIRK(0x8086, 0xd604, "Intel mobo", ALC662_3ST_2ch_DIG),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017207 {}
17208};
17209
17210static struct alc_config_preset alc662_presets[] = {
17211 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017212 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017213 .init_verbs = { alc662_init_verbs },
17214 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17215 .dac_nids = alc662_dac_nids,
17216 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017217 .dig_in_nid = ALC662_DIGIN_NID,
17218 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17219 .channel_mode = alc662_3ST_2ch_modes,
17220 .input_mux = &alc662_capture_source,
17221 },
17222 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017223 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017224 .init_verbs = { alc662_init_verbs },
17225 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17226 .dac_nids = alc662_dac_nids,
17227 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017228 .dig_in_nid = ALC662_DIGIN_NID,
17229 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17230 .channel_mode = alc662_3ST_6ch_modes,
17231 .need_dac_fix = 1,
17232 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017233 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017234 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017235 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017236 .init_verbs = { alc662_init_verbs },
17237 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17238 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017239 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17240 .channel_mode = alc662_3ST_6ch_modes,
17241 .need_dac_fix = 1,
17242 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017243 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017244 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017245 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017246 .init_verbs = { alc662_init_verbs },
17247 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17248 .dac_nids = alc662_dac_nids,
17249 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017250 .dig_in_nid = ALC662_DIGIN_NID,
17251 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
17252 .channel_mode = alc662_5stack_modes,
17253 .input_mux = &alc662_capture_source,
17254 },
17255 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017256 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017257 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
17258 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17259 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017260 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17261 .channel_mode = alc662_3ST_2ch_modes,
17262 .input_mux = &alc662_lenovo_101e_capture_source,
17263 .unsol_event = alc662_lenovo_101e_unsol_event,
17264 .init_hook = alc662_lenovo_101e_all_automute,
17265 },
Kailang Yang291702f2007-10-16 14:28:03 +020017266 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017267 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020017268 .init_verbs = { alc662_init_verbs,
17269 alc662_eeepc_sue_init_verbs },
17270 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17271 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020017272 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17273 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020017274 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017275 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020017276 .init_hook = alc662_eeepc_inithook,
17277 },
Kailang Yang8c427222008-01-10 13:03:59 +010017278 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017279 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010017280 alc662_chmode_mixer },
17281 .init_verbs = { alc662_init_verbs,
17282 alc662_eeepc_ep20_sue_init_verbs },
17283 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17284 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010017285 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17286 .channel_mode = alc662_3ST_6ch_modes,
17287 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020017288 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017289 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010017290 .init_hook = alc662_eeepc_ep20_inithook,
17291 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017292 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017293 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017294 .init_verbs = { alc662_init_verbs,
17295 alc662_ecs_init_verbs },
17296 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17297 .dac_nids = alc662_dac_nids,
17298 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17299 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017300 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017301 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017302 .init_hook = alc662_eeepc_inithook,
17303 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017304 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017305 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017306 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17307 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17308 .dac_nids = alc662_dac_nids,
17309 .dig_out_nid = ALC662_DIGOUT_NID,
17310 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17311 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017312 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017313 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017314 .init_hook = alc663_m51va_inithook,
17315 },
17316 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017317 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017318 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
17319 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17320 .dac_nids = alc662_dac_nids,
17321 .dig_out_nid = ALC662_DIGOUT_NID,
17322 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17323 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017324 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017325 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017326 .init_hook = alc663_g71v_inithook,
17327 },
17328 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017329 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017330 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17331 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17332 .dac_nids = alc662_dac_nids,
17333 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17334 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017335 .unsol_event = alc663_m51va_unsol_event,
17336 .init_hook = alc663_m51va_inithook,
17337 },
17338 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017339 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017340 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17341 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17342 .dac_nids = alc662_dac_nids,
17343 .dig_out_nid = ALC662_DIGOUT_NID,
17344 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17345 .channel_mode = alc662_3ST_6ch_modes,
17346 .input_mux = &alc663_capture_source,
17347 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017348 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017349 .init_hook = alc663_g50v_inithook,
17350 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017351 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017352 .mixers = { alc663_m51va_mixer },
17353 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017354 .init_verbs = { alc662_init_verbs,
17355 alc663_21jd_amic_init_verbs },
17356 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17357 .hp_nid = 0x03,
17358 .dac_nids = alc662_dac_nids,
17359 .dig_out_nid = ALC662_DIGOUT_NID,
17360 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17361 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017362 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017363 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017364 .init_hook = alc663_mode1_inithook,
17365 },
17366 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017367 .mixers = { alc662_1bjd_mixer },
17368 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017369 .init_verbs = { alc662_init_verbs,
17370 alc662_1bjd_amic_init_verbs },
17371 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17372 .dac_nids = alc662_dac_nids,
17373 .dig_out_nid = ALC662_DIGOUT_NID,
17374 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17375 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017376 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017377 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017378 .init_hook = alc662_mode2_inithook,
17379 },
17380 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017381 .mixers = { alc663_two_hp_m1_mixer },
17382 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017383 .init_verbs = { alc662_init_verbs,
17384 alc663_two_hp_amic_m1_init_verbs },
17385 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17386 .hp_nid = 0x03,
17387 .dac_nids = alc662_dac_nids,
17388 .dig_out_nid = ALC662_DIGOUT_NID,
17389 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17390 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017391 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017392 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017393 .init_hook = alc663_mode3_inithook,
17394 },
17395 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017396 .mixers = { alc663_asus_21jd_clfe_mixer },
17397 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017398 .init_verbs = { alc662_init_verbs,
17399 alc663_21jd_amic_init_verbs},
17400 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17401 .hp_nid = 0x03,
17402 .dac_nids = alc662_dac_nids,
17403 .dig_out_nid = ALC662_DIGOUT_NID,
17404 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17405 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017406 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017407 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017408 .init_hook = alc663_mode4_inithook,
17409 },
17410 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017411 .mixers = { alc663_asus_15jd_clfe_mixer },
17412 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017413 .init_verbs = { alc662_init_verbs,
17414 alc663_15jd_amic_init_verbs },
17415 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17416 .hp_nid = 0x03,
17417 .dac_nids = alc662_dac_nids,
17418 .dig_out_nid = ALC662_DIGOUT_NID,
17419 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17420 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017421 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017422 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017423 .init_hook = alc663_mode5_inithook,
17424 },
17425 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017426 .mixers = { alc663_two_hp_m2_mixer },
17427 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017428 .init_verbs = { alc662_init_verbs,
17429 alc663_two_hp_amic_m2_init_verbs },
17430 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17431 .hp_nid = 0x03,
17432 .dac_nids = alc662_dac_nids,
17433 .dig_out_nid = ALC662_DIGOUT_NID,
17434 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17435 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017436 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017437 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017438 .init_hook = alc663_mode6_inithook,
17439 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010017440 [ALC663_ASUS_MODE7] = {
17441 .mixers = { alc663_mode7_mixer },
17442 .cap_mixer = alc662_auto_capture_mixer,
17443 .init_verbs = { alc662_init_verbs,
17444 alc663_mode7_init_verbs },
17445 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17446 .hp_nid = 0x03,
17447 .dac_nids = alc662_dac_nids,
17448 .dig_out_nid = ALC662_DIGOUT_NID,
17449 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17450 .channel_mode = alc662_3ST_2ch_modes,
17451 .unsol_event = alc663_mode7_unsol_event,
17452 .setup = alc663_mode7_setup,
17453 .init_hook = alc663_mode7_inithook,
17454 },
17455 [ALC663_ASUS_MODE8] = {
17456 .mixers = { alc663_mode8_mixer },
17457 .cap_mixer = alc662_auto_capture_mixer,
17458 .init_verbs = { alc662_init_verbs,
17459 alc663_mode8_init_verbs },
17460 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17461 .hp_nid = 0x03,
17462 .dac_nids = alc662_dac_nids,
17463 .dig_out_nid = ALC662_DIGOUT_NID,
17464 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17465 .channel_mode = alc662_3ST_2ch_modes,
17466 .unsol_event = alc663_mode8_unsol_event,
17467 .setup = alc663_mode8_setup,
17468 .init_hook = alc663_mode8_inithook,
17469 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017470 [ALC272_DELL] = {
17471 .mixers = { alc663_m51va_mixer },
17472 .cap_mixer = alc272_auto_capture_mixer,
17473 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17474 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17475 .dac_nids = alc662_dac_nids,
17476 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17477 .adc_nids = alc272_adc_nids,
17478 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17479 .capsrc_nids = alc272_capsrc_nids,
17480 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017481 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017482 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017483 .init_hook = alc663_m51va_inithook,
17484 },
17485 [ALC272_DELL_ZM1] = {
17486 .mixers = { alc663_m51va_mixer },
17487 .cap_mixer = alc662_auto_capture_mixer,
17488 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17489 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17490 .dac_nids = alc662_dac_nids,
17491 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17492 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017493 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020017494 .capsrc_nids = alc662_capsrc_nids,
17495 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017496 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017497 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017498 .init_hook = alc663_m51va_inithook,
17499 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017500 [ALC272_SAMSUNG_NC10] = {
17501 .mixers = { alc272_nc10_mixer },
17502 .init_verbs = { alc662_init_verbs,
17503 alc663_21jd_amic_init_verbs },
17504 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17505 .dac_nids = alc272_dac_nids,
17506 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17507 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017508 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020017509 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017510 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020017511 .init_hook = alc663_mode4_inithook,
17512 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017513};
17514
17515
17516/*
17517 * BIOS auto configuration
17518 */
17519
Takashi Iwai7085ec12009-10-02 09:03:58 +020017520/* convert from MIX nid to DAC */
17521static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
17522{
17523 if (nid == 0x0f)
17524 return 0x02;
17525 else if (nid >= 0x0c && nid <= 0x0e)
17526 return nid - 0x0c + 0x02;
17527 else
17528 return 0;
17529}
17530
17531/* get MIX nid connected to the given pin targeted to DAC */
17532static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
17533 hda_nid_t dac)
17534{
17535 hda_nid_t mix[4];
17536 int i, num;
17537
17538 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
17539 for (i = 0; i < num; i++) {
17540 if (alc662_mix_to_dac(mix[i]) == dac)
17541 return mix[i];
17542 }
17543 return 0;
17544}
17545
17546/* look for an empty DAC slot */
17547static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
17548{
17549 struct alc_spec *spec = codec->spec;
17550 hda_nid_t srcs[5];
17551 int i, j, num;
17552
17553 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
17554 if (num < 0)
17555 return 0;
17556 for (i = 0; i < num; i++) {
17557 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
17558 if (!nid)
17559 continue;
17560 for (j = 0; j < spec->multiout.num_dacs; j++)
17561 if (spec->multiout.dac_nids[j] == nid)
17562 break;
17563 if (j >= spec->multiout.num_dacs)
17564 return nid;
17565 }
17566 return 0;
17567}
17568
17569/* fill in the dac_nids table from the parsed pin configuration */
17570static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
17571 const struct auto_pin_cfg *cfg)
17572{
17573 struct alc_spec *spec = codec->spec;
17574 int i;
17575 hda_nid_t dac;
17576
17577 spec->multiout.dac_nids = spec->private_dac_nids;
17578 for (i = 0; i < cfg->line_outs; i++) {
17579 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
17580 if (!dac)
17581 continue;
17582 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
17583 }
17584 return 0;
17585}
17586
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017587static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017588 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017589{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017590 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017591 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
17592}
17593
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017594static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017595 hda_nid_t nid, unsigned int chs)
17596{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017597 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017598 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
17599}
17600
17601#define alc662_add_stereo_vol(spec, pfx, nid) \
17602 alc662_add_vol_ctl(spec, pfx, nid, 3)
17603#define alc662_add_stereo_sw(spec, pfx, nid) \
17604 alc662_add_sw_ctl(spec, pfx, nid, 3)
17605
17606/* add playback controls from the parsed DAC table */
17607static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
17608 const struct auto_pin_cfg *cfg)
17609{
17610 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017611 static const char *chname[4] = {
17612 "Front", "Surround", NULL /*CLFE*/, "Side"
17613 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020017614 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017615 int i, err;
17616
17617 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017618 nid = spec->multiout.dac_nids[i];
17619 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017620 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017621 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
17622 if (!mix)
17623 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017624 if (i == 2) {
17625 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017626 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017627 if (err < 0)
17628 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017629 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017630 if (err < 0)
17631 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017632 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017633 if (err < 0)
17634 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017635 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017636 if (err < 0)
17637 return err;
17638 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017639 const char *pfx;
17640 if (cfg->line_outs == 1 &&
17641 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017642 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017643 pfx = "Speaker";
17644 else
17645 pfx = "PCM";
17646 } else
17647 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017648 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017649 if (err < 0)
17650 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017651 if (cfg->line_outs == 1 &&
17652 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
17653 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020017654 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017655 if (err < 0)
17656 return err;
17657 }
17658 }
17659 return 0;
17660}
17661
17662/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017663/* return DAC nid if any new DAC is assigned */
17664static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017665 const char *pfx)
17666{
Takashi Iwai7085ec12009-10-02 09:03:58 +020017667 struct alc_spec *spec = codec->spec;
17668 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017669 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017670
17671 if (!pin)
17672 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017673 nid = alc662_look_for_dac(codec, pin);
17674 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017675 /* the corresponding DAC is already occupied */
17676 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
17677 return 0; /* no way */
17678 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017679 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017680 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17681 }
17682
17683 mix = alc662_dac_to_mix(codec, pin, nid);
17684 if (!mix)
17685 return 0;
17686 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
17687 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020017688 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017689 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
17690 if (err < 0)
17691 return err;
17692 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017693}
17694
17695/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017696#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020017697 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017698
17699static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17700 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017701 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017702{
Takashi Iwai7085ec12009-10-02 09:03:58 +020017703 int i, num;
17704 hda_nid_t srcs[4];
17705
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017706 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017707 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017708 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
17709 if (num <= 1)
17710 return;
17711 for (i = 0; i < num; i++) {
17712 if (alc662_mix_to_dac(srcs[i]) != dac)
17713 continue;
17714 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
17715 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017716 }
17717}
17718
17719static void alc662_auto_init_multi_out(struct hda_codec *codec)
17720{
17721 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017722 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017723 int i;
17724
17725 for (i = 0; i <= HDA_SIDE; i++) {
17726 hda_nid_t nid = spec->autocfg.line_out_pins[i];
17727 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017728 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017729 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017730 }
17731}
17732
17733static void alc662_auto_init_hp_out(struct hda_codec *codec)
17734{
17735 struct alc_spec *spec = codec->spec;
17736 hda_nid_t pin;
17737
17738 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017739 if (pin)
17740 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
17741 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017742 pin = spec->autocfg.speaker_pins[0];
17743 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020017744 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
17745 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017746}
17747
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017748#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17749
17750static void alc662_auto_init_analog_input(struct hda_codec *codec)
17751{
17752 struct alc_spec *spec = codec->spec;
17753 int i;
17754
17755 for (i = 0; i < AUTO_PIN_LAST; i++) {
17756 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020017757 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017758 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017759 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017760 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017761 snd_hda_codec_write(codec, nid, 0,
17762 AC_VERB_SET_AMP_GAIN_MUTE,
17763 AMP_OUT_MUTE);
17764 }
17765 }
17766}
17767
Takashi Iwaif511b012008-08-15 16:46:42 +020017768#define alc662_auto_init_input_src alc882_auto_init_input_src
17769
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017770static int alc662_parse_auto_config(struct hda_codec *codec)
17771{
17772 struct alc_spec *spec = codec->spec;
17773 int err;
17774 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17775
17776 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17777 alc662_ignore);
17778 if (err < 0)
17779 return err;
17780 if (!spec->autocfg.line_outs)
17781 return 0; /* can't find valid BIOS pin config */
17782
Takashi Iwai7085ec12009-10-02 09:03:58 +020017783 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017784 if (err < 0)
17785 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017786 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017787 if (err < 0)
17788 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017789 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017790 spec->autocfg.speaker_pins[0],
17791 "Speaker");
17792 if (err < 0)
17793 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017794 if (err)
17795 spec->multiout.extra_out_nid[0] = err;
17796 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017797 "Headphone");
17798 if (err < 0)
17799 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017800 if (err)
17801 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017802 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017803 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017804 return err;
17805
17806 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17807
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017808 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017809 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17810
Takashi Iwai603c4012008-07-30 15:01:44 +020017811 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017812 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017813
17814 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017815 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017816
Takashi Iwaid88897e2008-10-31 15:01:37 +010017817 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017818 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017819 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017820
17821 err = alc_auto_add_mic_boost(codec);
17822 if (err < 0)
17823 return err;
17824
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017825 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17826
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017827 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017828}
17829
17830/* additional initialization for auto-configuration model */
17831static void alc662_auto_init(struct hda_codec *codec)
17832{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017833 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017834 alc662_auto_init_multi_out(codec);
17835 alc662_auto_init_hp_out(codec);
17836 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017837 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017838 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017839 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017840}
17841
17842static int patch_alc662(struct hda_codec *codec)
17843{
17844 struct alc_spec *spec;
17845 int err, board_config;
17846
17847 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17848 if (!spec)
17849 return -ENOMEM;
17850
17851 codec->spec = spec;
17852
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017853 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17854
Kailang Yang274693f2009-12-03 10:07:50 +010017855 if (alc_read_coef_idx(codec, 0)==0x8020){
17856 kfree(codec->chip_name);
17857 codec->chip_name = kstrdup("ALC661", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017858 if (!codec->chip_name) {
17859 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010017860 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017861 }
Kailang Yang274693f2009-12-03 10:07:50 +010017862 }
17863
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017864 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17865 alc662_models,
17866 alc662_cfg_tbl);
17867 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017868 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17869 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017870 board_config = ALC662_AUTO;
17871 }
17872
17873 if (board_config == ALC662_AUTO) {
17874 /* automatic parse from the BIOS config */
17875 err = alc662_parse_auto_config(codec);
17876 if (err < 0) {
17877 alc_free(codec);
17878 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017879 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017880 printk(KERN_INFO
17881 "hda_codec: Cannot set up configuration "
17882 "from BIOS. Using base mode...\n");
17883 board_config = ALC662_3ST_2ch_DIG;
17884 }
17885 }
17886
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017887 err = snd_hda_attach_beep_device(codec, 0x1);
17888 if (err < 0) {
17889 alc_free(codec);
17890 return err;
17891 }
17892
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017893 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017894 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017895
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017896 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17897 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17898
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017899 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17900 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17901
Takashi Iwaidd704692009-08-11 08:45:11 +020017902 if (!spec->adc_nids) {
17903 spec->adc_nids = alc662_adc_nids;
17904 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17905 }
17906 if (!spec->capsrc_nids)
17907 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017908
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017909 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017910 set_capture_mixer(codec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017911 if (codec->vendor_id == 0x10ec0662)
17912 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17913 else
17914 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017915
Takashi Iwai2134ea42008-01-10 16:53:55 +010017916 spec->vmaster_nid = 0x02;
17917
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017918 codec->patch_ops = alc_patch_ops;
17919 if (board_config == ALC662_AUTO)
17920 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017921#ifdef CONFIG_SND_HDA_POWER_SAVE
17922 if (!spec->loopback.amplist)
17923 spec->loopback.amplist = alc662_loopbacks;
17924#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017925 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017926
17927 return 0;
17928}
17929
Kailang Yang274693f2009-12-03 10:07:50 +010017930static int patch_alc888(struct hda_codec *codec)
17931{
17932 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
17933 kfree(codec->chip_name);
17934 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017935 if (!codec->chip_name) {
17936 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010017937 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017938 }
17939 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010017940 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017941 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010017942}
17943
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017944/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017945 * patch entries
17946 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017947static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017948 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017949 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017950 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017951 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017952 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010017953 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017954 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010017955 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017956 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017957 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017958 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17959 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17960 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017961 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017962 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017963 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17964 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017965 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017966 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017967 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017968 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020017969 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017970 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020017971 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017972 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017973 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017974 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020017975 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017976 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010017977 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017978 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010017979 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017980 {} /* terminator */
17981};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017982
17983MODULE_ALIAS("snd-hda-codec-id:10ec*");
17984
17985MODULE_LICENSE("GPL");
17986MODULE_DESCRIPTION("Realtek HD-audio codec");
17987
17988static struct hda_codec_preset_list realtek_list = {
17989 .preset = snd_hda_preset_realtek,
17990 .owner = THIS_MODULE,
17991};
17992
17993static int __init patch_realtek_init(void)
17994{
17995 return snd_hda_add_codec_preset(&realtek_list);
17996}
17997
17998static void __exit patch_realtek_exit(void)
17999{
18000 snd_hda_delete_codec_preset(&realtek_list);
18001}
18002
18003module_init(patch_realtek_init)
18004module_exit(patch_realtek_exit)