blob: cb97323acc17b65e97ff78be85649c73431f566c [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},
Hector Martin018df412009-06-04 00:13:40 +02001668/* DMIC fix
1669 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1670 * which makes the stereo useless. However, either the mic or the ALC889
1671 * makes the signal become a difference/sum signal instead of standard
1672 * stereo, which is annoying. So instead we flip this bit which makes the
1673 * codec replicate the sum signal to both channels, turning it into a
1674 * normal mono mic.
1675 */
1676/* DMIC_CONTROL? Init value = 0x0001 */
1677 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1678 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001679 { }
1680};
1681
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001682static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001683 /* Front mic only available on one ADC */
1684 {
1685 .num_items = 4,
1686 .items = {
1687 { "Mic", 0x0 },
1688 { "Line", 0x2 },
1689 { "CD", 0x4 },
1690 { "Front Mic", 0xb },
1691 },
1692 },
1693 {
1694 .num_items = 3,
1695 .items = {
1696 { "Mic", 0x0 },
1697 { "Line", 0x2 },
1698 { "CD", 0x4 },
1699 },
1700 }
1701};
1702
Tony Vroond2fd4b02009-06-21 00:40:10 +01001703static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1704 /* Interal mic only available on one ADC */
1705 {
Tony Vroon684a8842009-06-26 09:27:50 +01001706 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001707 .items = {
1708 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001709 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001710 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001711 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001712 { "Int Mic", 0xb },
1713 },
1714 },
1715 {
Tony Vroon684a8842009-06-26 09:27:50 +01001716 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001717 .items = {
1718 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001719 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001720 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001721 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001722 },
1723 }
1724};
1725
Hector Martin018df412009-06-04 00:13:40 +02001726static struct hda_input_mux alc889_capture_sources[3] = {
1727 /* Digital mic only available on first "ADC" */
1728 {
1729 .num_items = 5,
1730 .items = {
1731 { "Mic", 0x0 },
1732 { "Line", 0x2 },
1733 { "CD", 0x4 },
1734 { "Front Mic", 0xb },
1735 { "Input Mix", 0xa },
1736 },
1737 },
1738 {
1739 .num_items = 4,
1740 .items = {
1741 { "Mic", 0x0 },
1742 { "Line", 0x2 },
1743 { "CD", 0x4 },
1744 { "Input Mix", 0xa },
1745 },
1746 },
1747 {
1748 .num_items = 4,
1749 .items = {
1750 { "Mic", 0x0 },
1751 { "Line", 0x2 },
1752 { "CD", 0x4 },
1753 { "Input Mix", 0xa },
1754 },
1755 }
1756};
1757
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001758static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001759 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1760 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1761 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1762 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1763 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1764 HDA_OUTPUT),
1765 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1766 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1767 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1768 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1769 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1770 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1771 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1772 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1773 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1774 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1775 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1776 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001777 { } /* end */
1778};
1779
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001780static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001781{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001782 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001783
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001784 spec->autocfg.hp_pins[0] = 0x15;
1785 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01001786 spec->autocfg.speaker_pins[1] = 0x16;
1787 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001788}
1789
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001790static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001791{
1792 struct alc_spec *spec = codec->spec;
1793
1794 spec->autocfg.hp_pins[0] = 0x15;
1795 spec->autocfg.speaker_pins[0] = 0x14;
1796 spec->autocfg.speaker_pins[1] = 0x16;
1797 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001798}
1799
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001800static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001801{
1802 struct alc_spec *spec = codec->spec;
1803
1804 spec->autocfg.hp_pins[0] = 0x15;
1805 spec->autocfg.speaker_pins[0] = 0x14;
1806 spec->autocfg.speaker_pins[1] = 0x16;
1807 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001808}
1809
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001810/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001811 * ALC880 3-stack model
1812 *
1813 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001814 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1815 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001816 */
1817
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001818static hda_nid_t alc880_dac_nids[4] = {
1819 /* front, rear, clfe, rear_surr */
1820 0x02, 0x05, 0x04, 0x03
1821};
1822
1823static hda_nid_t alc880_adc_nids[3] = {
1824 /* ADC0-2 */
1825 0x07, 0x08, 0x09,
1826};
1827
1828/* The datasheet says the node 0x07 is connected from inputs,
1829 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001830 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001831 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001832static hda_nid_t alc880_adc_nids_alt[2] = {
1833 /* ADC1-2 */
1834 0x08, 0x09,
1835};
1836
1837#define ALC880_DIGOUT_NID 0x06
1838#define ALC880_DIGIN_NID 0x0a
1839
1840static struct hda_input_mux alc880_capture_source = {
1841 .num_items = 4,
1842 .items = {
1843 { "Mic", 0x0 },
1844 { "Front Mic", 0x3 },
1845 { "Line", 0x2 },
1846 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001847 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001848};
1849
1850/* channel source setting (2/6 channel selection for 3-stack) */
1851/* 2ch mode */
1852static struct hda_verb alc880_threestack_ch2_init[] = {
1853 /* set line-in to input, mute it */
1854 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1855 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1856 /* set mic-in to input vref 80%, mute it */
1857 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1858 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001859 { } /* end */
1860};
1861
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001862/* 6ch mode */
1863static struct hda_verb alc880_threestack_ch6_init[] = {
1864 /* set line-in to output, unmute it */
1865 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1866 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1867 /* set mic-in to output, unmute it */
1868 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1869 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1870 { } /* end */
1871};
1872
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001873static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001874 { 2, alc880_threestack_ch2_init },
1875 { 6, alc880_threestack_ch6_init },
1876};
1877
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001878static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001879 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001880 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001881 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001882 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001883 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1884 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001885 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1886 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001887 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1888 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1889 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1890 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1891 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1892 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1893 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1894 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001895 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001896 {
1897 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1898 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001899 .info = alc_ch_mode_info,
1900 .get = alc_ch_mode_get,
1901 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001902 },
1903 { } /* end */
1904};
1905
1906/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001907static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1908 struct snd_ctl_elem_info *uinfo)
1909{
1910 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1911 struct alc_spec *spec = codec->spec;
1912 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001913
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001914 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001915 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1916 HDA_INPUT);
1917 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001918 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001919 return err;
1920}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001921
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001922static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1923 unsigned int size, unsigned int __user *tlv)
1924{
1925 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1926 struct alc_spec *spec = codec->spec;
1927 int err;
1928
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001929 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001930 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1931 HDA_INPUT);
1932 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001933 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001934 return err;
1935}
1936
1937typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1938 struct snd_ctl_elem_value *ucontrol);
1939
1940static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1941 struct snd_ctl_elem_value *ucontrol,
1942 getput_call_t func)
1943{
1944 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1945 struct alc_spec *spec = codec->spec;
1946 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1947 int err;
1948
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001949 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001950 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1951 3, 0, HDA_INPUT);
1952 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001953 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001954 return err;
1955}
1956
1957static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1958 struct snd_ctl_elem_value *ucontrol)
1959{
1960 return alc_cap_getput_caller(kcontrol, ucontrol,
1961 snd_hda_mixer_amp_volume_get);
1962}
1963
1964static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1965 struct snd_ctl_elem_value *ucontrol)
1966{
1967 return alc_cap_getput_caller(kcontrol, ucontrol,
1968 snd_hda_mixer_amp_volume_put);
1969}
1970
1971/* capture mixer elements */
1972#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1973
1974static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1975 struct snd_ctl_elem_value *ucontrol)
1976{
1977 return alc_cap_getput_caller(kcontrol, ucontrol,
1978 snd_hda_mixer_amp_switch_get);
1979}
1980
1981static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1982 struct snd_ctl_elem_value *ucontrol)
1983{
1984 return alc_cap_getput_caller(kcontrol, ucontrol,
1985 snd_hda_mixer_amp_switch_put);
1986}
1987
Takashi Iwaia23b6882009-03-23 15:21:36 +01001988#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001989 { \
1990 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1991 .name = "Capture Switch", \
1992 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1993 .count = num, \
1994 .info = alc_cap_sw_info, \
1995 .get = alc_cap_sw_get, \
1996 .put = alc_cap_sw_put, \
1997 }, \
1998 { \
1999 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2000 .name = "Capture Volume", \
2001 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2002 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2003 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2004 .count = num, \
2005 .info = alc_cap_vol_info, \
2006 .get = alc_cap_vol_get, \
2007 .put = alc_cap_vol_put, \
2008 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002009 }
2010
2011#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002012 { \
2013 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2014 /* .name = "Capture Source", */ \
2015 .name = "Input Source", \
2016 .count = num, \
2017 .info = alc_mux_enum_info, \
2018 .get = alc_mux_enum_get, \
2019 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002020 }
2021
2022#define DEFINE_CAPMIX(num) \
2023static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2024 _DEFINE_CAPMIX(num), \
2025 _DEFINE_CAPSRC(num), \
2026 { } /* end */ \
2027}
2028
2029#define DEFINE_CAPMIX_NOSRC(num) \
2030static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2031 _DEFINE_CAPMIX(num), \
2032 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002033}
2034
2035/* up to three ADCs */
2036DEFINE_CAPMIX(1);
2037DEFINE_CAPMIX(2);
2038DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002039DEFINE_CAPMIX_NOSRC(1);
2040DEFINE_CAPMIX_NOSRC(2);
2041DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002042
2043/*
2044 * ALC880 5-stack model
2045 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002046 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2047 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002048 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2049 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2050 */
2051
2052/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002053static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002054 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002055 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002056 { } /* end */
2057};
2058
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002059/* channel source setting (6/8 channel selection for 5-stack) */
2060/* 6ch mode */
2061static struct hda_verb alc880_fivestack_ch6_init[] = {
2062 /* set line-in to input, mute it */
2063 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2064 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002065 { } /* end */
2066};
2067
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002068/* 8ch mode */
2069static struct hda_verb alc880_fivestack_ch8_init[] = {
2070 /* set line-in to output, unmute it */
2071 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2072 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2073 { } /* end */
2074};
2075
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002076static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002077 { 6, alc880_fivestack_ch6_init },
2078 { 8, alc880_fivestack_ch8_init },
2079};
2080
2081
2082/*
2083 * ALC880 6-stack model
2084 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002085 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2086 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002087 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2088 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2089 */
2090
2091static hda_nid_t alc880_6st_dac_nids[4] = {
2092 /* front, rear, clfe, rear_surr */
2093 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002094};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002095
2096static struct hda_input_mux alc880_6stack_capture_source = {
2097 .num_items = 4,
2098 .items = {
2099 { "Mic", 0x0 },
2100 { "Front Mic", 0x1 },
2101 { "Line", 0x2 },
2102 { "CD", 0x4 },
2103 },
2104};
2105
2106/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002107static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002108 { 8, NULL },
2109};
2110
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002111static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002112 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002113 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002114 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002115 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002116 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2117 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002118 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2119 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002120 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002121 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002122 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2123 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2124 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2125 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2126 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2127 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2128 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2129 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002130 {
2131 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2132 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002133 .info = alc_ch_mode_info,
2134 .get = alc_ch_mode_get,
2135 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002136 },
2137 { } /* end */
2138};
2139
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002140
2141/*
2142 * ALC880 W810 model
2143 *
2144 * W810 has rear IO for:
2145 * Front (DAC 02)
2146 * Surround (DAC 03)
2147 * Center/LFE (DAC 04)
2148 * Digital out (06)
2149 *
2150 * The system also has a pair of internal speakers, and a headphone jack.
2151 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002152 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002153 * There is a variable resistor to control the speaker or headphone
2154 * volume. This is a hardware-only device without a software API.
2155 *
2156 * Plugging headphones in will disable the internal speakers. This is
2157 * implemented in hardware, not via the driver using jack sense. In
2158 * a similar fashion, plugging into the rear socket marked "front" will
2159 * disable both the speakers and headphones.
2160 *
2161 * For input, there's a microphone jack, and an "audio in" jack.
2162 * These may not do anything useful with this driver yet, because I
2163 * haven't setup any initialization verbs for these yet...
2164 */
2165
2166static hda_nid_t alc880_w810_dac_nids[3] = {
2167 /* front, rear/surround, clfe */
2168 0x02, 0x03, 0x04
2169};
2170
2171/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002172static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002173 { 6, NULL }
2174};
2175
2176/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002177static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002178 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002179 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002180 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002181 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002182 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2183 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002184 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2185 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002186 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2187 { } /* end */
2188};
2189
2190
2191/*
2192 * Z710V model
2193 *
2194 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002195 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2196 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002197 */
2198
2199static hda_nid_t alc880_z71v_dac_nids[1] = {
2200 0x02
2201};
2202#define ALC880_Z71V_HP_DAC 0x03
2203
2204/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002205static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002206 { 2, NULL }
2207};
2208
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002209static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002210 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002211 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002212 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002213 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002214 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2215 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2216 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2217 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2218 { } /* end */
2219};
2220
2221
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002222/*
2223 * ALC880 F1734 model
2224 *
2225 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2226 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2227 */
2228
2229static hda_nid_t alc880_f1734_dac_nids[1] = {
2230 0x03
2231};
2232#define ALC880_F1734_HP_DAC 0x02
2233
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002234static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002235 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002236 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002237 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2238 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002239 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2240 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002241 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2242 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002243 { } /* end */
2244};
2245
Takashi Iwai937b4162008-02-11 14:52:36 +01002246static struct hda_input_mux alc880_f1734_capture_source = {
2247 .num_items = 2,
2248 .items = {
2249 { "Mic", 0x1 },
2250 { "CD", 0x4 },
2251 },
2252};
2253
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002254
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002255/*
2256 * ALC880 ASUS model
2257 *
2258 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2259 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2260 * Mic = 0x18, Line = 0x1a
2261 */
2262
2263#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2264#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2265
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002266static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002267 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002268 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002269 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002270 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002271 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2272 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002273 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2274 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002275 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2276 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2277 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2278 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2279 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2280 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002281 {
2282 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2283 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002284 .info = alc_ch_mode_info,
2285 .get = alc_ch_mode_get,
2286 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002287 },
2288 { } /* end */
2289};
2290
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002291/*
2292 * ALC880 ASUS W1V model
2293 *
2294 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2295 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2296 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2297 */
2298
2299/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002300static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002301 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2302 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002303 { } /* end */
2304};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002305
Kailang Yangdf694da2005-12-05 19:42:22 +01002306/* TCL S700 */
2307static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2308 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2309 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2310 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2311 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2312 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2313 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2314 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2315 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2316 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002317 { } /* end */
2318};
2319
Kailang Yangccc656c2006-10-17 12:32:26 +02002320/* Uniwill */
2321static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002322 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2323 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2324 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2325 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002326 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2327 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2328 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2329 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2330 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2331 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2332 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2333 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2334 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2335 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2336 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2337 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002338 {
2339 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2340 .name = "Channel Mode",
2341 .info = alc_ch_mode_info,
2342 .get = alc_ch_mode_get,
2343 .put = alc_ch_mode_put,
2344 },
2345 { } /* end */
2346};
2347
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002348static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2349 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2350 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2351 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2352 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2353 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2354 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2355 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2356 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2357 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2358 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2359 { } /* end */
2360};
2361
Kailang Yangccc656c2006-10-17 12:32:26 +02002362static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002363 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2364 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2365 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2366 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002367 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2368 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2369 { } /* end */
2370};
2371
Linus Torvalds1da177e2005-04-16 15:20:36 -07002372/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002373 * virtual master controls
2374 */
2375
2376/*
2377 * slave controls for virtual master
2378 */
2379static const char *alc_slave_vols[] = {
2380 "Front Playback Volume",
2381 "Surround Playback Volume",
2382 "Center Playback Volume",
2383 "LFE Playback Volume",
2384 "Side Playback Volume",
2385 "Headphone Playback Volume",
2386 "Speaker Playback Volume",
2387 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002388 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002389 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002390 NULL,
2391};
2392
2393static const char *alc_slave_sws[] = {
2394 "Front Playback Switch",
2395 "Surround Playback Switch",
2396 "Center Playback Switch",
2397 "LFE Playback Switch",
2398 "Side Playback Switch",
2399 "Headphone Playback Switch",
2400 "Speaker Playback Switch",
2401 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002402 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002403 "Line-Out Playback Switch",
2404 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002405 NULL,
2406};
2407
2408/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002409 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002410 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002411
2412static void alc_free_kctls(struct hda_codec *codec);
2413
Takashi Iwai67d634c2009-11-16 15:35:59 +01002414#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002415/* additional beep mixers; the actual parameters are overwritten at build */
2416static struct snd_kcontrol_new alc_beep_mixer[] = {
2417 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002418 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002419 { } /* end */
2420};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002421#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002422
Linus Torvalds1da177e2005-04-16 15:20:36 -07002423static int alc_build_controls(struct hda_codec *codec)
2424{
2425 struct alc_spec *spec = codec->spec;
2426 int err;
2427 int i;
2428
2429 for (i = 0; i < spec->num_mixers; i++) {
2430 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2431 if (err < 0)
2432 return err;
2433 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002434 if (spec->cap_mixer) {
2435 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2436 if (err < 0)
2437 return err;
2438 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002439 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002440 err = snd_hda_create_spdif_out_ctls(codec,
2441 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002442 if (err < 0)
2443 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002444 if (!spec->no_analog) {
2445 err = snd_hda_create_spdif_share_sw(codec,
2446 &spec->multiout);
2447 if (err < 0)
2448 return err;
2449 spec->multiout.share_spdif = 1;
2450 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002451 }
2452 if (spec->dig_in_nid) {
2453 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2454 if (err < 0)
2455 return err;
2456 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002457
Takashi Iwai67d634c2009-11-16 15:35:59 +01002458#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002459 /* create beep controls if needed */
2460 if (spec->beep_amp) {
2461 struct snd_kcontrol_new *knew;
2462 for (knew = alc_beep_mixer; knew->name; knew++) {
2463 struct snd_kcontrol *kctl;
2464 kctl = snd_ctl_new1(knew, codec);
2465 if (!kctl)
2466 return -ENOMEM;
2467 kctl->private_value = spec->beep_amp;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01002468 err = snd_hda_ctl_add(codec,
2469 get_amp_nid_(spec->beep_amp), kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002470 if (err < 0)
2471 return err;
2472 }
2473 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002474#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002475
Takashi Iwai2134ea42008-01-10 16:53:55 +01002476 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002477 if (!spec->no_analog &&
2478 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002479 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002480 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002481 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002482 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002483 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002484 if (err < 0)
2485 return err;
2486 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002487 if (!spec->no_analog &&
2488 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002489 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2490 NULL, alc_slave_sws);
2491 if (err < 0)
2492 return err;
2493 }
2494
Takashi Iwai603c4012008-07-30 15:01:44 +02002495 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002496 return 0;
2497}
2498
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002499
Linus Torvalds1da177e2005-04-16 15:20:36 -07002500/*
2501 * initialize the codec volumes, etc
2502 */
2503
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002504/*
2505 * generic initialization of ADC, input mixers and output mixers
2506 */
2507static struct hda_verb alc880_volume_init_verbs[] = {
2508 /*
2509 * Unmute ADC0-2 and set the default input to mic-in
2510 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002511 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002512 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002513 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002514 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002515 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002516 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002517
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002518 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2519 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002520 * Note: PASD motherboards uses the Line In 2 as the input for front
2521 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002522 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002523 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002524 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2525 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2526 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2527 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2528 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2529 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2530 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002531
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002532 /*
2533 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002534 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002535 /* set vol=0 to output mixers */
2536 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2537 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2538 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2539 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2540 /* set up input amps for analog loopback */
2541 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002542 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2543 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002544 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2545 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002546 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2547 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002548 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2549 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002550
2551 { }
2552};
2553
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002554/*
2555 * 3-stack pin configuration:
2556 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2557 */
2558static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2559 /*
2560 * preset connection lists of input pins
2561 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2562 */
2563 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2564 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2565 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2566
2567 /*
2568 * Set pin mode and muting
2569 */
2570 /* set front pin widgets 0x14 for output */
2571 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2572 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2573 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2574 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2575 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2576 /* Mic2 (as headphone out) for HP output */
2577 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2578 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2579 /* Line In pin widget for input */
2580 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2581 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2582 /* Line2 (as front mic) pin widget for input and vref at 80% */
2583 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2584 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2585 /* CD pin widget for input */
2586 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2587
2588 { }
2589};
2590
2591/*
2592 * 5-stack pin configuration:
2593 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2594 * line-in/side = 0x1a, f-mic = 0x1b
2595 */
2596static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2597 /*
2598 * preset connection lists of input pins
2599 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2600 */
2601 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2602 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2603
2604 /*
2605 * Set pin mode and muting
2606 */
2607 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002608 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2609 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2610 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2611 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002612 /* unmute pins for output (no gain on this amp) */
2613 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2614 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2615 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2616 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2617
Linus Torvalds1da177e2005-04-16 15:20:36 -07002618 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002619 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002620 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2621 /* Mic2 (as headphone out) for HP output */
2622 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002623 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002624 /* Line In pin widget for input */
2625 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2626 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2627 /* Line2 (as front mic) pin widget for input and vref at 80% */
2628 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2629 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2630 /* CD pin widget for input */
2631 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002632
2633 { }
2634};
2635
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002636/*
2637 * W810 pin configuration:
2638 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2639 */
2640static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002641 /* hphone/speaker input selector: front DAC */
2642 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2643
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002644 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2645 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2646 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2647 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2648 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2649 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2650
2651 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002652 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002653
Linus Torvalds1da177e2005-04-16 15:20:36 -07002654 { }
2655};
2656
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002657/*
2658 * Z71V pin configuration:
2659 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2660 */
2661static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002662 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002663 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002664 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002665 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002666
Takashi Iwai16ded522005-06-10 19:58:24 +02002667 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002668 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002669 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002670 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002671
2672 { }
2673};
2674
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002675/*
2676 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002677 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2678 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002679 */
2680static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2681 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2682
Takashi Iwai16ded522005-06-10 19:58:24 +02002683 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002684 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002685 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002686 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002687 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002688 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002689 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002690 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2691
Takashi Iwai16ded522005-06-10 19:58:24 +02002692 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002693 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002694 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002695 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002696 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002697 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002698 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002699 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002700 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002701
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002702 { }
2703};
Takashi Iwai16ded522005-06-10 19:58:24 +02002704
Kailang Yangccc656c2006-10-17 12:32:26 +02002705/*
2706 * Uniwill pin configuration:
2707 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2708 * line = 0x1a
2709 */
2710static struct hda_verb alc880_uniwill_init_verbs[] = {
2711 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2712
2713 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2714 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2715 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2716 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2717 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2718 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2719 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2720 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2721 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2722 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2723 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2724 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2725 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2726 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2727
2728 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2729 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2730 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2731 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2732 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2733 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2734 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2735 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2736 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2737
2738 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2739 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2740
2741 { }
2742};
2743
2744/*
2745* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002746* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002747 */
2748static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2749 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2750
2751 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2752 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2753 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2754 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2755 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2756 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2757 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2758 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2759 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2760 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2761 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2762 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2763
2764 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2765 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2766 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2767 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2768 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2769 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2770
2771 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2772 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2773
2774 { }
2775};
2776
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002777static struct hda_verb alc880_beep_init_verbs[] = {
2778 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2779 { }
2780};
2781
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002782/* auto-toggle front mic */
2783static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2784{
2785 unsigned int present;
2786 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002787
Wu Fengguang864f92b2009-11-18 12:38:02 +08002788 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002789 bits = present ? HDA_AMP_MUTE : 0;
2790 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002791}
2792
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002793static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002794{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002795 struct alc_spec *spec = codec->spec;
2796
2797 spec->autocfg.hp_pins[0] = 0x14;
2798 spec->autocfg.speaker_pins[0] = 0x15;
2799 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002800}
2801
2802static void alc880_uniwill_init_hook(struct hda_codec *codec)
2803{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002804 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002805 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002806}
2807
2808static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2809 unsigned int res)
2810{
2811 /* Looks like the unsol event is incompatible with the standard
2812 * definition. 4bit tag is placed at 28 bit!
2813 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002814 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002815 case ALC880_MIC_EVENT:
2816 alc880_uniwill_mic_automute(codec);
2817 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002818 default:
2819 alc_automute_amp_unsol_event(codec, res);
2820 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002821 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002822}
2823
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002824static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002825{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002826 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002827
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002828 spec->autocfg.hp_pins[0] = 0x14;
2829 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02002830}
2831
2832static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2833{
2834 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002835
Kailang Yangccc656c2006-10-17 12:32:26 +02002836 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002837 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2838 present &= HDA_AMP_VOLMASK;
2839 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2840 HDA_AMP_VOLMASK, present);
2841 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2842 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002843}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002844
Kailang Yangccc656c2006-10-17 12:32:26 +02002845static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2846 unsigned int res)
2847{
2848 /* Looks like the unsol event is incompatible with the standard
2849 * definition. 4bit tag is placed at 28 bit!
2850 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002851 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002852 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002853 else
2854 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002855}
2856
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002857/*
2858 * F1734 pin configuration:
2859 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2860 */
2861static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002862 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002863 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2864 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2865 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2866 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2867
2868 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2869 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2870 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2871 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2872
2873 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2874 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002875 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002876 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2877 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2878 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2879 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2880 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2881 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002882
Takashi Iwai937b4162008-02-11 14:52:36 +01002883 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2884 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2885
Takashi Iwai16ded522005-06-10 19:58:24 +02002886 { }
2887};
2888
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002889/*
2890 * ASUS pin configuration:
2891 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2892 */
2893static struct hda_verb alc880_pin_asus_init_verbs[] = {
2894 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2895 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2896 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2897 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2898
2899 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2900 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2901 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2902 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2903 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2904 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2905 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2906 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2907
2908 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2909 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2910 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2911 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2912 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2913 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2914 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2915 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2916 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002917
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002918 { }
2919};
2920
2921/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002922#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2923#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02002924#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002925
Kailang Yangdf694da2005-12-05 19:42:22 +01002926/* Clevo m520g init */
2927static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2928 /* headphone output */
2929 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2930 /* line-out */
2931 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2932 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2933 /* Line-in */
2934 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2935 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2936 /* CD */
2937 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2938 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2939 /* Mic1 (rear panel) */
2940 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2941 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2942 /* Mic2 (front panel) */
2943 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2944 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2945 /* headphone */
2946 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2947 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2948 /* change to EAPD mode */
2949 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2950 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2951
2952 { }
2953};
2954
2955static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002956 /* change to EAPD mode */
2957 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2958 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2959
Kailang Yangdf694da2005-12-05 19:42:22 +01002960 /* Headphone output */
2961 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2962 /* Front output*/
2963 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2964 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2965
2966 /* Line In pin widget for input */
2967 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2968 /* CD pin widget for input */
2969 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2970 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2971 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2972
2973 /* change to EAPD mode */
2974 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2975 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2976
2977 { }
2978};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002979
2980/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002981 * LG m1 express dual
2982 *
2983 * Pin assignment:
2984 * Rear Line-In/Out (blue): 0x14
2985 * Build-in Mic-In: 0x15
2986 * Speaker-out: 0x17
2987 * HP-Out (green): 0x1b
2988 * Mic-In/Out (red): 0x19
2989 * SPDIF-Out: 0x1e
2990 */
2991
2992/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2993static hda_nid_t alc880_lg_dac_nids[3] = {
2994 0x05, 0x02, 0x03
2995};
2996
2997/* seems analog CD is not working */
2998static struct hda_input_mux alc880_lg_capture_source = {
2999 .num_items = 3,
3000 .items = {
3001 { "Mic", 0x1 },
3002 { "Line", 0x5 },
3003 { "Internal Mic", 0x6 },
3004 },
3005};
3006
3007/* 2,4,6 channel modes */
3008static struct hda_verb alc880_lg_ch2_init[] = {
3009 /* set line-in and mic-in to input */
3010 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3011 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3012 { }
3013};
3014
3015static struct hda_verb alc880_lg_ch4_init[] = {
3016 /* set line-in to out and mic-in to input */
3017 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3018 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3019 { }
3020};
3021
3022static struct hda_verb alc880_lg_ch6_init[] = {
3023 /* set line-in and mic-in to output */
3024 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3025 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3026 { }
3027};
3028
3029static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3030 { 2, alc880_lg_ch2_init },
3031 { 4, alc880_lg_ch4_init },
3032 { 6, alc880_lg_ch6_init },
3033};
3034
3035static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003036 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3037 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003038 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3039 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3040 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3041 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3042 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3043 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3044 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3045 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3046 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3047 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3048 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3049 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3050 {
3051 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3052 .name = "Channel Mode",
3053 .info = alc_ch_mode_info,
3054 .get = alc_ch_mode_get,
3055 .put = alc_ch_mode_put,
3056 },
3057 { } /* end */
3058};
3059
3060static struct hda_verb alc880_lg_init_verbs[] = {
3061 /* set capture source to mic-in */
3062 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3063 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3064 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3065 /* mute all amp mixer inputs */
3066 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003067 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3068 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003069 /* line-in to input */
3070 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3071 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3072 /* built-in mic */
3073 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3074 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3075 /* speaker-out */
3076 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3077 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3078 /* mic-in to input */
3079 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3080 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3081 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3082 /* HP-out */
3083 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3084 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3085 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3086 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003087 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003088 { }
3089};
3090
3091/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003092static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003093{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003094 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003095
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003096 spec->autocfg.hp_pins[0] = 0x1b;
3097 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003098}
3099
3100/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003101 * LG LW20
3102 *
3103 * Pin assignment:
3104 * Speaker-out: 0x14
3105 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003106 * Built-in Mic-In: 0x19
3107 * Line-In: 0x1b
3108 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003109 * SPDIF-Out: 0x1e
3110 */
3111
Takashi Iwaid6815182006-03-23 16:06:23 +01003112static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003113 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003114 .items = {
3115 { "Mic", 0x0 },
3116 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003117 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003118 },
3119};
3120
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003121#define alc880_lg_lw_modes alc880_threestack_modes
3122
Takashi Iwaid6815182006-03-23 16:06:23 +01003123static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003124 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3125 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3126 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3127 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3128 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3129 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3130 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3131 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3132 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3133 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003134 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3135 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3136 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3137 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003138 {
3139 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3140 .name = "Channel Mode",
3141 .info = alc_ch_mode_info,
3142 .get = alc_ch_mode_get,
3143 .put = alc_ch_mode_put,
3144 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003145 { } /* end */
3146};
3147
3148static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003149 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3150 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3151 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3152
Takashi Iwaid6815182006-03-23 16:06:23 +01003153 /* set capture source to mic-in */
3154 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3155 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3156 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003157 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003158 /* speaker-out */
3159 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3160 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3161 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003162 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3163 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3164 /* mic-in to input */
3165 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3166 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3167 /* built-in mic */
3168 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3169 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3170 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003171 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003172 { }
3173};
3174
3175/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003176static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003177{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003178 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003179
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003180 spec->autocfg.hp_pins[0] = 0x1b;
3181 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003182}
3183
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003184static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3185 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3186 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3187 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3188 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3189 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3190 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3191 { } /* end */
3192};
3193
3194static struct hda_input_mux alc880_medion_rim_capture_source = {
3195 .num_items = 2,
3196 .items = {
3197 { "Mic", 0x0 },
3198 { "Internal Mic", 0x1 },
3199 },
3200};
3201
3202static struct hda_verb alc880_medion_rim_init_verbs[] = {
3203 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3204
3205 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3206 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3207
3208 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3209 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3210 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3211 /* Mic2 (as headphone out) for HP output */
3212 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3213 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3214 /* Internal Speaker */
3215 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3216 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3217
3218 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3219 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3220
3221 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3222 { }
3223};
3224
3225/* toggle speaker-output according to the hp-jack state */
3226static void alc880_medion_rim_automute(struct hda_codec *codec)
3227{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003228 struct alc_spec *spec = codec->spec;
3229 alc_automute_amp(codec);
3230 /* toggle EAPD */
3231 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003232 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3233 else
3234 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3235}
3236
3237static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3238 unsigned int res)
3239{
3240 /* Looks like the unsol event is incompatible with the standard
3241 * definition. 4bit tag is placed at 28 bit!
3242 */
3243 if ((res >> 28) == ALC880_HP_EVENT)
3244 alc880_medion_rim_automute(codec);
3245}
3246
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003247static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003248{
3249 struct alc_spec *spec = codec->spec;
3250
3251 spec->autocfg.hp_pins[0] = 0x14;
3252 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003253}
3254
Takashi Iwaicb53c622007-08-10 17:21:45 +02003255#ifdef CONFIG_SND_HDA_POWER_SAVE
3256static struct hda_amp_list alc880_loopbacks[] = {
3257 { 0x0b, HDA_INPUT, 0 },
3258 { 0x0b, HDA_INPUT, 1 },
3259 { 0x0b, HDA_INPUT, 2 },
3260 { 0x0b, HDA_INPUT, 3 },
3261 { 0x0b, HDA_INPUT, 4 },
3262 { } /* end */
3263};
3264
3265static struct hda_amp_list alc880_lg_loopbacks[] = {
3266 { 0x0b, HDA_INPUT, 1 },
3267 { 0x0b, HDA_INPUT, 6 },
3268 { 0x0b, HDA_INPUT, 7 },
3269 { } /* end */
3270};
3271#endif
3272
Takashi Iwaid6815182006-03-23 16:06:23 +01003273/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003274 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003275 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003276
Linus Torvalds1da177e2005-04-16 15:20:36 -07003277static int alc_init(struct hda_codec *codec)
3278{
3279 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003280 unsigned int i;
3281
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003282 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003283 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003284
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003285 for (i = 0; i < spec->num_init_verbs; i++)
3286 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003287
3288 if (spec->init_hook)
3289 spec->init_hook(codec);
3290
Linus Torvalds1da177e2005-04-16 15:20:36 -07003291 return 0;
3292}
3293
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003294static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3295{
3296 struct alc_spec *spec = codec->spec;
3297
3298 if (spec->unsol_event)
3299 spec->unsol_event(codec, res);
3300}
3301
Takashi Iwaicb53c622007-08-10 17:21:45 +02003302#ifdef CONFIG_SND_HDA_POWER_SAVE
3303static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3304{
3305 struct alc_spec *spec = codec->spec;
3306 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3307}
3308#endif
3309
Linus Torvalds1da177e2005-04-16 15:20:36 -07003310/*
3311 * Analog playback callbacks
3312 */
3313static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3314 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003315 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003316{
3317 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003318 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3319 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003320}
3321
3322static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3323 struct hda_codec *codec,
3324 unsigned int stream_tag,
3325 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003326 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003327{
3328 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003329 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3330 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003331}
3332
3333static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3334 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003335 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003336{
3337 struct alc_spec *spec = codec->spec;
3338 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3339}
3340
3341/*
3342 * Digital out
3343 */
3344static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3345 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003346 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003347{
3348 struct alc_spec *spec = codec->spec;
3349 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3350}
3351
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003352static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3353 struct hda_codec *codec,
3354 unsigned int stream_tag,
3355 unsigned int format,
3356 struct snd_pcm_substream *substream)
3357{
3358 struct alc_spec *spec = codec->spec;
3359 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3360 stream_tag, format, substream);
3361}
3362
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003363static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3364 struct hda_codec *codec,
3365 struct snd_pcm_substream *substream)
3366{
3367 struct alc_spec *spec = codec->spec;
3368 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3369}
3370
Linus Torvalds1da177e2005-04-16 15:20:36 -07003371static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3372 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003373 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003374{
3375 struct alc_spec *spec = codec->spec;
3376 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3377}
3378
3379/*
3380 * Analog capture
3381 */
Takashi Iwai63300792008-01-24 15:31:36 +01003382static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003383 struct hda_codec *codec,
3384 unsigned int stream_tag,
3385 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003386 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003387{
3388 struct alc_spec *spec = codec->spec;
3389
Takashi Iwai63300792008-01-24 15:31:36 +01003390 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003391 stream_tag, 0, format);
3392 return 0;
3393}
3394
Takashi Iwai63300792008-01-24 15:31:36 +01003395static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003396 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003397 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003398{
3399 struct alc_spec *spec = codec->spec;
3400
Takashi Iwai888afa12008-03-18 09:57:50 +01003401 snd_hda_codec_cleanup_stream(codec,
3402 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003403 return 0;
3404}
3405
3406
3407/*
3408 */
3409static struct hda_pcm_stream alc880_pcm_analog_playback = {
3410 .substreams = 1,
3411 .channels_min = 2,
3412 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003413 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003414 .ops = {
3415 .open = alc880_playback_pcm_open,
3416 .prepare = alc880_playback_pcm_prepare,
3417 .cleanup = alc880_playback_pcm_cleanup
3418 },
3419};
3420
3421static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003422 .substreams = 1,
3423 .channels_min = 2,
3424 .channels_max = 2,
3425 /* NID is set in alc_build_pcms */
3426};
3427
3428static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3429 .substreams = 1,
3430 .channels_min = 2,
3431 .channels_max = 2,
3432 /* NID is set in alc_build_pcms */
3433};
3434
3435static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3436 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003437 .channels_min = 2,
3438 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003439 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003440 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003441 .prepare = alc880_alt_capture_pcm_prepare,
3442 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003443 },
3444};
3445
3446static struct hda_pcm_stream alc880_pcm_digital_playback = {
3447 .substreams = 1,
3448 .channels_min = 2,
3449 .channels_max = 2,
3450 /* NID is set in alc_build_pcms */
3451 .ops = {
3452 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003453 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003454 .prepare = alc880_dig_playback_pcm_prepare,
3455 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003456 },
3457};
3458
3459static struct hda_pcm_stream alc880_pcm_digital_capture = {
3460 .substreams = 1,
3461 .channels_min = 2,
3462 .channels_max = 2,
3463 /* NID is set in alc_build_pcms */
3464};
3465
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003466/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003467static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003468 .substreams = 0,
3469 .channels_min = 0,
3470 .channels_max = 0,
3471};
3472
Linus Torvalds1da177e2005-04-16 15:20:36 -07003473static int alc_build_pcms(struct hda_codec *codec)
3474{
3475 struct alc_spec *spec = codec->spec;
3476 struct hda_pcm *info = spec->pcm_rec;
3477 int i;
3478
3479 codec->num_pcms = 1;
3480 codec->pcm_info = info;
3481
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003482 if (spec->no_analog)
3483 goto skip_analog;
3484
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003485 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3486 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003487 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003488
Takashi Iwai4a471b72005-12-07 13:56:29 +01003489 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003490 if (snd_BUG_ON(!spec->multiout.dac_nids))
3491 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003492 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3493 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3494 }
3495 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003496 if (snd_BUG_ON(!spec->adc_nids))
3497 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003498 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3499 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3500 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003501
Takashi Iwai4a471b72005-12-07 13:56:29 +01003502 if (spec->channel_mode) {
3503 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3504 for (i = 0; i < spec->num_channel_mode; i++) {
3505 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3506 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3507 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003508 }
3509 }
3510
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003511 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003512 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003513 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003514 snprintf(spec->stream_name_digital,
3515 sizeof(spec->stream_name_digital),
3516 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003517 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003518 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003519 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003520 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003521 if (spec->dig_out_type)
3522 info->pcm_type = spec->dig_out_type;
3523 else
3524 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003525 if (spec->multiout.dig_out_nid &&
3526 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003527 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3528 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3529 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003530 if (spec->dig_in_nid &&
3531 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003532 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3533 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3534 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003535 /* FIXME: do we need this for all Realtek codec models? */
3536 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003537 }
3538
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003539 if (spec->no_analog)
3540 return 0;
3541
Takashi Iwaie08a0072006-09-07 17:52:14 +02003542 /* If the use of more than one ADC is requested for the current
3543 * model, configure a second analog capture-only PCM.
3544 */
3545 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003546 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3547 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003548 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003549 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003550 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003551 if (spec->alt_dac_nid) {
3552 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3553 *spec->stream_analog_alt_playback;
3554 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3555 spec->alt_dac_nid;
3556 } else {
3557 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3558 alc_pcm_null_stream;
3559 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3560 }
3561 if (spec->num_adc_nids > 1) {
3562 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3563 *spec->stream_analog_alt_capture;
3564 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3565 spec->adc_nids[1];
3566 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3567 spec->num_adc_nids - 1;
3568 } else {
3569 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3570 alc_pcm_null_stream;
3571 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003572 }
3573 }
3574
Linus Torvalds1da177e2005-04-16 15:20:36 -07003575 return 0;
3576}
3577
Takashi Iwai603c4012008-07-30 15:01:44 +02003578static void alc_free_kctls(struct hda_codec *codec)
3579{
3580 struct alc_spec *spec = codec->spec;
3581
3582 if (spec->kctls.list) {
3583 struct snd_kcontrol_new *kctl = spec->kctls.list;
3584 int i;
3585 for (i = 0; i < spec->kctls.used; i++)
3586 kfree(kctl[i].name);
3587 }
3588 snd_array_free(&spec->kctls);
3589}
3590
Linus Torvalds1da177e2005-04-16 15:20:36 -07003591static void alc_free(struct hda_codec *codec)
3592{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003593 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003594
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003595 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003596 return;
3597
Takashi Iwai603c4012008-07-30 15:01:44 +02003598 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003599 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003600 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003601}
3602
Takashi Iwaie044c392008-10-27 16:56:24 +01003603#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003604static int alc_resume(struct hda_codec *codec)
3605{
Takashi Iwaie044c392008-10-27 16:56:24 +01003606 codec->patch_ops.init(codec);
3607 snd_hda_codec_resume_amp(codec);
3608 snd_hda_codec_resume_cache(codec);
3609 return 0;
3610}
Takashi Iwaie044c392008-10-27 16:56:24 +01003611#endif
3612
Linus Torvalds1da177e2005-04-16 15:20:36 -07003613/*
3614 */
3615static struct hda_codec_ops alc_patch_ops = {
3616 .build_controls = alc_build_controls,
3617 .build_pcms = alc_build_pcms,
3618 .init = alc_init,
3619 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003620 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003621#ifdef SND_HDA_NEEDS_RESUME
3622 .resume = alc_resume,
3623#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003624#ifdef CONFIG_SND_HDA_POWER_SAVE
3625 .check_power_status = alc_check_power_status,
3626#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003627};
3628
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003629
3630/*
3631 * Test configuration for debugging
3632 *
3633 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3634 * enum controls.
3635 */
3636#ifdef CONFIG_SND_DEBUG
3637static hda_nid_t alc880_test_dac_nids[4] = {
3638 0x02, 0x03, 0x04, 0x05
3639};
3640
3641static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003642 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003643 .items = {
3644 { "In-1", 0x0 },
3645 { "In-2", 0x1 },
3646 { "In-3", 0x2 },
3647 { "In-4", 0x3 },
3648 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003649 { "Front", 0x5 },
3650 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003651 },
3652};
3653
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003654static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003655 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003656 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003657 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003658 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003659};
3660
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003661static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3662 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003663{
3664 static char *texts[] = {
3665 "N/A", "Line Out", "HP Out",
3666 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3667 };
3668 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3669 uinfo->count = 1;
3670 uinfo->value.enumerated.items = 8;
3671 if (uinfo->value.enumerated.item >= 8)
3672 uinfo->value.enumerated.item = 7;
3673 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3674 return 0;
3675}
3676
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003677static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3678 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003679{
3680 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3681 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3682 unsigned int pin_ctl, item = 0;
3683
3684 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3685 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3686 if (pin_ctl & AC_PINCTL_OUT_EN) {
3687 if (pin_ctl & AC_PINCTL_HP_EN)
3688 item = 2;
3689 else
3690 item = 1;
3691 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3692 switch (pin_ctl & AC_PINCTL_VREFEN) {
3693 case AC_PINCTL_VREF_HIZ: item = 3; break;
3694 case AC_PINCTL_VREF_50: item = 4; break;
3695 case AC_PINCTL_VREF_GRD: item = 5; break;
3696 case AC_PINCTL_VREF_80: item = 6; break;
3697 case AC_PINCTL_VREF_100: item = 7; break;
3698 }
3699 }
3700 ucontrol->value.enumerated.item[0] = item;
3701 return 0;
3702}
3703
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003704static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3705 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003706{
3707 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3708 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3709 static unsigned int ctls[] = {
3710 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3711 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3712 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3713 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3714 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3715 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3716 };
3717 unsigned int old_ctl, new_ctl;
3718
3719 old_ctl = snd_hda_codec_read(codec, nid, 0,
3720 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3721 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3722 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003723 int val;
3724 snd_hda_codec_write_cache(codec, nid, 0,
3725 AC_VERB_SET_PIN_WIDGET_CONTROL,
3726 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003727 val = ucontrol->value.enumerated.item[0] >= 3 ?
3728 HDA_AMP_MUTE : 0;
3729 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3730 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003731 return 1;
3732 }
3733 return 0;
3734}
3735
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003736static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3737 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003738{
3739 static char *texts[] = {
3740 "Front", "Surround", "CLFE", "Side"
3741 };
3742 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3743 uinfo->count = 1;
3744 uinfo->value.enumerated.items = 4;
3745 if (uinfo->value.enumerated.item >= 4)
3746 uinfo->value.enumerated.item = 3;
3747 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3748 return 0;
3749}
3750
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003751static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3752 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003753{
3754 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3755 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3756 unsigned int sel;
3757
3758 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3759 ucontrol->value.enumerated.item[0] = sel & 3;
3760 return 0;
3761}
3762
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003763static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3764 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003765{
3766 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3767 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3768 unsigned int sel;
3769
3770 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3771 if (ucontrol->value.enumerated.item[0] != sel) {
3772 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003773 snd_hda_codec_write_cache(codec, nid, 0,
3774 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003775 return 1;
3776 }
3777 return 0;
3778}
3779
3780#define PIN_CTL_TEST(xname,nid) { \
3781 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3782 .name = xname, \
3783 .info = alc_test_pin_ctl_info, \
3784 .get = alc_test_pin_ctl_get, \
3785 .put = alc_test_pin_ctl_put, \
3786 .private_value = nid \
3787 }
3788
3789#define PIN_SRC_TEST(xname,nid) { \
3790 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3791 .name = xname, \
3792 .info = alc_test_pin_src_info, \
3793 .get = alc_test_pin_src_get, \
3794 .put = alc_test_pin_src_put, \
3795 .private_value = nid \
3796 }
3797
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003798static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003799 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3800 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3801 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3802 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003803 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3804 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3805 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3806 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003807 PIN_CTL_TEST("Front Pin Mode", 0x14),
3808 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3809 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3810 PIN_CTL_TEST("Side Pin Mode", 0x17),
3811 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3812 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3813 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3814 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3815 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3816 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3817 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3818 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3819 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3820 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3821 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3822 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3823 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3824 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3825 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3826 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3827 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3828 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003829 {
3830 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3831 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003832 .info = alc_ch_mode_info,
3833 .get = alc_ch_mode_get,
3834 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003835 },
3836 { } /* end */
3837};
3838
3839static struct hda_verb alc880_test_init_verbs[] = {
3840 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003841 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3842 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3843 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3844 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3845 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3846 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3847 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3848 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003849 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003850 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3851 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3852 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3853 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003854 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003855 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3856 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3857 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3858 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003859 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003860 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3861 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3862 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3863 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003864 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003865 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3866 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003867 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3868 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3869 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003870 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003871 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3872 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3873 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3874 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003875 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003876 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003877 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003878 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003879 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003880 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003881 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003882 /* Analog input/passthru */
3883 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3884 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3885 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3886 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3887 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003888 { }
3889};
3890#endif
3891
Linus Torvalds1da177e2005-04-16 15:20:36 -07003892/*
3893 */
3894
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003895static const char *alc880_models[ALC880_MODEL_LAST] = {
3896 [ALC880_3ST] = "3stack",
3897 [ALC880_TCL_S700] = "tcl",
3898 [ALC880_3ST_DIG] = "3stack-digout",
3899 [ALC880_CLEVO] = "clevo",
3900 [ALC880_5ST] = "5stack",
3901 [ALC880_5ST_DIG] = "5stack-digout",
3902 [ALC880_W810] = "w810",
3903 [ALC880_Z71V] = "z71v",
3904 [ALC880_6ST] = "6stack",
3905 [ALC880_6ST_DIG] = "6stack-digout",
3906 [ALC880_ASUS] = "asus",
3907 [ALC880_ASUS_W1V] = "asus-w1v",
3908 [ALC880_ASUS_DIG] = "asus-dig",
3909 [ALC880_ASUS_DIG2] = "asus-dig2",
3910 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003911 [ALC880_UNIWILL_P53] = "uniwill-p53",
3912 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003913 [ALC880_F1734] = "F1734",
3914 [ALC880_LG] = "lg",
3915 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003916 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003917#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003918 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003919#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003920 [ALC880_AUTO] = "auto",
3921};
3922
3923static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003924 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003925 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3926 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3927 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3928 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3929 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3930 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3931 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3932 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003933 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3934 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003935 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3936 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3937 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3938 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3939 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3940 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3941 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3942 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3943 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3944 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003945 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003946 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3947 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3948 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003949 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003950 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003951 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3952 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003953 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3954 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003955 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3956 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3957 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3958 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003959 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3960 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003961 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003962 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003963 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003964 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003965 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3966 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003967 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003968 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003969 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003970 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003971 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003972 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003973 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003974 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003975 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003976 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3977 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003978 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003979 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3980 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3981 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3982 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003983 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3984 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003985 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003986 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003987 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3988 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003989 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3990 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3991 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003992 /* default Intel */
3993 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003994 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3995 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003996 {}
3997};
3998
Takashi Iwai16ded522005-06-10 19:58:24 +02003999/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004000 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004001 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004002static struct alc_config_preset alc880_presets[] = {
4003 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004004 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004005 .init_verbs = { alc880_volume_init_verbs,
4006 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004007 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004008 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004009 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4010 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004011 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004012 .input_mux = &alc880_capture_source,
4013 },
4014 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004015 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004016 .init_verbs = { alc880_volume_init_verbs,
4017 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004018 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004019 .dac_nids = alc880_dac_nids,
4020 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004021 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4022 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004023 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004024 .input_mux = &alc880_capture_source,
4025 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004026 [ALC880_TCL_S700] = {
4027 .mixers = { alc880_tcl_s700_mixer },
4028 .init_verbs = { alc880_volume_init_verbs,
4029 alc880_pin_tcl_S700_init_verbs,
4030 alc880_gpio2_init_verbs },
4031 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4032 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004033 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4034 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004035 .hp_nid = 0x03,
4036 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4037 .channel_mode = alc880_2_jack_modes,
4038 .input_mux = &alc880_capture_source,
4039 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004040 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004041 .mixers = { alc880_three_stack_mixer,
4042 alc880_five_stack_mixer},
4043 .init_verbs = { alc880_volume_init_verbs,
4044 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004045 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4046 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004047 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4048 .channel_mode = alc880_fivestack_modes,
4049 .input_mux = &alc880_capture_source,
4050 },
4051 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004052 .mixers = { alc880_three_stack_mixer,
4053 alc880_five_stack_mixer },
4054 .init_verbs = { alc880_volume_init_verbs,
4055 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004056 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4057 .dac_nids = alc880_dac_nids,
4058 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004059 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4060 .channel_mode = alc880_fivestack_modes,
4061 .input_mux = &alc880_capture_source,
4062 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004063 [ALC880_6ST] = {
4064 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004065 .init_verbs = { alc880_volume_init_verbs,
4066 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004067 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4068 .dac_nids = alc880_6st_dac_nids,
4069 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4070 .channel_mode = alc880_sixstack_modes,
4071 .input_mux = &alc880_6stack_capture_source,
4072 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004073 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004074 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004075 .init_verbs = { alc880_volume_init_verbs,
4076 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004077 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4078 .dac_nids = alc880_6st_dac_nids,
4079 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004080 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4081 .channel_mode = alc880_sixstack_modes,
4082 .input_mux = &alc880_6stack_capture_source,
4083 },
4084 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004085 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004086 .init_verbs = { alc880_volume_init_verbs,
4087 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004088 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004089 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4090 .dac_nids = alc880_w810_dac_nids,
4091 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004092 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4093 .channel_mode = alc880_w810_modes,
4094 .input_mux = &alc880_capture_source,
4095 },
4096 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004097 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004098 .init_verbs = { alc880_volume_init_verbs,
4099 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004100 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4101 .dac_nids = alc880_z71v_dac_nids,
4102 .dig_out_nid = ALC880_DIGOUT_NID,
4103 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004104 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4105 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004106 .input_mux = &alc880_capture_source,
4107 },
4108 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004109 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004110 .init_verbs = { alc880_volume_init_verbs,
4111 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004112 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4113 .dac_nids = alc880_f1734_dac_nids,
4114 .hp_nid = 0x02,
4115 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4116 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004117 .input_mux = &alc880_f1734_capture_source,
4118 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004119 .setup = alc880_uniwill_p53_setup,
4120 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004121 },
4122 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004123 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004124 .init_verbs = { alc880_volume_init_verbs,
4125 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004126 alc880_gpio1_init_verbs },
4127 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4128 .dac_nids = alc880_asus_dac_nids,
4129 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4130 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004131 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004132 .input_mux = &alc880_capture_source,
4133 },
4134 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004135 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004136 .init_verbs = { alc880_volume_init_verbs,
4137 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004138 alc880_gpio1_init_verbs },
4139 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4140 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004141 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004142 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4143 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004144 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004145 .input_mux = &alc880_capture_source,
4146 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004147 [ALC880_ASUS_DIG2] = {
4148 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004149 .init_verbs = { alc880_volume_init_verbs,
4150 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004151 alc880_gpio2_init_verbs }, /* use GPIO2 */
4152 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4153 .dac_nids = alc880_asus_dac_nids,
4154 .dig_out_nid = ALC880_DIGOUT_NID,
4155 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4156 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004157 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004158 .input_mux = &alc880_capture_source,
4159 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004160 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004161 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004162 .init_verbs = { alc880_volume_init_verbs,
4163 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004164 alc880_gpio1_init_verbs },
4165 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4166 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004167 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004168 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4169 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004170 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004171 .input_mux = &alc880_capture_source,
4172 },
4173 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004174 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004175 .init_verbs = { alc880_volume_init_verbs,
4176 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004177 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4178 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004179 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004180 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4181 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004182 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004183 .input_mux = &alc880_capture_source,
4184 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004185 [ALC880_UNIWILL] = {
4186 .mixers = { alc880_uniwill_mixer },
4187 .init_verbs = { alc880_volume_init_verbs,
4188 alc880_uniwill_init_verbs },
4189 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4190 .dac_nids = alc880_asus_dac_nids,
4191 .dig_out_nid = ALC880_DIGOUT_NID,
4192 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4193 .channel_mode = alc880_threestack_modes,
4194 .need_dac_fix = 1,
4195 .input_mux = &alc880_capture_source,
4196 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004197 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004198 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004199 },
4200 [ALC880_UNIWILL_P53] = {
4201 .mixers = { alc880_uniwill_p53_mixer },
4202 .init_verbs = { alc880_volume_init_verbs,
4203 alc880_uniwill_p53_init_verbs },
4204 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4205 .dac_nids = alc880_asus_dac_nids,
4206 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004207 .channel_mode = alc880_threestack_modes,
4208 .input_mux = &alc880_capture_source,
4209 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004210 .setup = alc880_uniwill_p53_setup,
4211 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004212 },
4213 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004214 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004215 .init_verbs = { alc880_volume_init_verbs,
4216 alc880_uniwill_p53_init_verbs,
4217 alc880_beep_init_verbs },
4218 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4219 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004220 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004221 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4222 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004223 .input_mux = &alc880_capture_source,
4224 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004225 .setup = alc880_uniwill_p53_setup,
4226 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004227 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004228 [ALC880_CLEVO] = {
4229 .mixers = { alc880_three_stack_mixer },
4230 .init_verbs = { alc880_volume_init_verbs,
4231 alc880_pin_clevo_init_verbs },
4232 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4233 .dac_nids = alc880_dac_nids,
4234 .hp_nid = 0x03,
4235 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4236 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004237 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004238 .input_mux = &alc880_capture_source,
4239 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004240 [ALC880_LG] = {
4241 .mixers = { alc880_lg_mixer },
4242 .init_verbs = { alc880_volume_init_verbs,
4243 alc880_lg_init_verbs },
4244 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4245 .dac_nids = alc880_lg_dac_nids,
4246 .dig_out_nid = ALC880_DIGOUT_NID,
4247 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4248 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004249 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004250 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004251 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004252 .setup = alc880_lg_setup,
4253 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004254#ifdef CONFIG_SND_HDA_POWER_SAVE
4255 .loopbacks = alc880_lg_loopbacks,
4256#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004257 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004258 [ALC880_LG_LW] = {
4259 .mixers = { alc880_lg_lw_mixer },
4260 .init_verbs = { alc880_volume_init_verbs,
4261 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004262 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004263 .dac_nids = alc880_dac_nids,
4264 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004265 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4266 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004267 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004268 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004269 .setup = alc880_lg_lw_setup,
4270 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004271 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004272 [ALC880_MEDION_RIM] = {
4273 .mixers = { alc880_medion_rim_mixer },
4274 .init_verbs = { alc880_volume_init_verbs,
4275 alc880_medion_rim_init_verbs,
4276 alc_gpio2_init_verbs },
4277 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4278 .dac_nids = alc880_dac_nids,
4279 .dig_out_nid = ALC880_DIGOUT_NID,
4280 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4281 .channel_mode = alc880_2_jack_modes,
4282 .input_mux = &alc880_medion_rim_capture_source,
4283 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004284 .setup = alc880_medion_rim_setup,
4285 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004286 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004287#ifdef CONFIG_SND_DEBUG
4288 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004289 .mixers = { alc880_test_mixer },
4290 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004291 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4292 .dac_nids = alc880_test_dac_nids,
4293 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004294 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4295 .channel_mode = alc880_test_modes,
4296 .input_mux = &alc880_test_capture_source,
4297 },
4298#endif
4299};
4300
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004301/*
4302 * Automatic parse of I/O pins from the BIOS configuration
4303 */
4304
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004305enum {
4306 ALC_CTL_WIDGET_VOL,
4307 ALC_CTL_WIDGET_MUTE,
4308 ALC_CTL_BIND_MUTE,
4309};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004310static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004311 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4312 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004313 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004314};
4315
4316/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004317static int add_control(struct alc_spec *spec, int type, const char *name,
4318 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004319{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004320 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004321
Takashi Iwai603c4012008-07-30 15:01:44 +02004322 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4323 knew = snd_array_new(&spec->kctls);
4324 if (!knew)
4325 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004326 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004327 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004328 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004329 return -ENOMEM;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004330 if (get_amp_nid_(val))
Takashi Iwai9c96fa52009-11-16 11:25:33 +01004331 knew->subdevice = HDA_SUBDEV_NID_FLAG | get_amp_nid_(val);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004332 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004333 return 0;
4334}
4335
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004336static int add_control_with_pfx(struct alc_spec *spec, int type,
4337 const char *pfx, const char *dir,
4338 const char *sfx, unsigned long val)
4339{
4340 char name[32];
4341 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
4342 return add_control(spec, type, name, val);
4343}
4344
4345#define add_pb_vol_ctrl(spec, type, pfx, val) \
4346 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val)
4347#define add_pb_sw_ctrl(spec, type, pfx, val) \
4348 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val)
4349
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004350#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4351#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4352#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4353#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004354#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4355#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4356#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4357#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4358#define ALC880_PIN_CD_NID 0x1c
4359
4360/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004361static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4362 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004363{
4364 hda_nid_t nid;
4365 int assigned[4];
4366 int i, j;
4367
4368 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004369 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004370
4371 /* check the pins hardwired to audio widget */
4372 for (i = 0; i < cfg->line_outs; i++) {
4373 nid = cfg->line_out_pins[i];
4374 if (alc880_is_fixed_pin(nid)) {
4375 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004376 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004377 assigned[idx] = 1;
4378 }
4379 }
4380 /* left pins can be connect to any audio widget */
4381 for (i = 0; i < cfg->line_outs; i++) {
4382 nid = cfg->line_out_pins[i];
4383 if (alc880_is_fixed_pin(nid))
4384 continue;
4385 /* search for an empty channel */
4386 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004387 if (!assigned[j]) {
4388 spec->multiout.dac_nids[i] =
4389 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004390 assigned[j] = 1;
4391 break;
4392 }
4393 }
4394 }
4395 spec->multiout.num_dacs = cfg->line_outs;
4396 return 0;
4397}
4398
4399/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004400static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4401 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004402{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004403 static const char *chname[4] = {
4404 "Front", "Surround", NULL /*CLFE*/, "Side"
4405 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004406 hda_nid_t nid;
4407 int i, err;
4408
4409 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004410 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004411 continue;
4412 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4413 if (i == 2) {
4414 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004415 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4416 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004417 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4418 HDA_OUTPUT));
4419 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004420 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004421 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4422 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004423 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4424 HDA_OUTPUT));
4425 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004426 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004427 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4428 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004429 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4430 HDA_INPUT));
4431 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004432 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004433 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4434 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004435 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4436 HDA_INPUT));
4437 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004438 return err;
4439 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004440 const char *pfx;
4441 if (cfg->line_outs == 1 &&
4442 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4443 pfx = "Speaker";
4444 else
4445 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004446 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004447 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4448 HDA_OUTPUT));
4449 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004450 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004451 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004452 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4453 HDA_INPUT));
4454 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004455 return err;
4456 }
4457 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004458 return 0;
4459}
4460
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004461/* add playback controls for speaker and HP outputs */
4462static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4463 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004464{
4465 hda_nid_t nid;
4466 int err;
4467
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004468 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004469 return 0;
4470
4471 if (alc880_is_fixed_pin(pin)) {
4472 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004473 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004474 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004475 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004476 else
4477 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004478 /* control HP volume/switch on the output mixer amp */
4479 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004480 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004481 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4482 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004483 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004484 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004485 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4486 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004487 return err;
4488 } else if (alc880_is_multi_pin(pin)) {
4489 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004490 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004491 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004492 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4493 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004494 return err;
4495 }
4496 return 0;
4497}
4498
4499/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004500static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4501 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004502 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004503{
Kailang Yangdf694da2005-12-05 19:42:22 +01004504 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004505
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004506 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004507 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4508 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004509 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004510 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004511 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4512 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004513 return err;
4514 return 0;
4515}
4516
Takashi Iwai05f5f472009-08-25 13:10:18 +02004517static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004518{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004519 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4520 return (pincap & AC_PINCAP_IN) != 0;
4521}
4522
4523/* create playback/capture controls for input pins */
4524static int alc_auto_create_input_ctls(struct hda_codec *codec,
4525 const struct auto_pin_cfg *cfg,
4526 hda_nid_t mixer,
4527 hda_nid_t cap1, hda_nid_t cap2)
4528{
4529 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004530 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004531 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004532
4533 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004534 hda_nid_t pin;
4535
4536 pin = cfg->input_pins[i];
4537 if (!alc_is_input_pin(codec, pin))
4538 continue;
4539
4540 if (mixer) {
4541 idx = get_connection_index(codec, mixer, pin);
4542 if (idx >= 0) {
4543 err = new_analog_input(spec, pin,
4544 auto_pin_cfg_labels[i],
4545 idx, mixer);
4546 if (err < 0)
4547 return err;
4548 }
4549 }
4550
4551 if (!cap1)
4552 continue;
4553 idx = get_connection_index(codec, cap1, pin);
4554 if (idx < 0 && cap2)
4555 idx = get_connection_index(codec, cap2, pin);
4556 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004557 imux->items[imux->num_items].label =
4558 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004559 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004560 imux->num_items++;
4561 }
4562 }
4563 return 0;
4564}
4565
Takashi Iwai05f5f472009-08-25 13:10:18 +02004566static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4567 const struct auto_pin_cfg *cfg)
4568{
4569 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4570}
4571
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004572static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4573 unsigned int pin_type)
4574{
4575 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4576 pin_type);
4577 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004578 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4579 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004580}
4581
Kailang Yangdf694da2005-12-05 19:42:22 +01004582static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4583 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004584 int dac_idx)
4585{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004586 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004587 /* need the manual connection? */
4588 if (alc880_is_multi_pin(nid)) {
4589 struct alc_spec *spec = codec->spec;
4590 int idx = alc880_multi_pin_idx(nid);
4591 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4592 AC_VERB_SET_CONNECT_SEL,
4593 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4594 }
4595}
4596
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004597static int get_pin_type(int line_out_type)
4598{
4599 if (line_out_type == AUTO_PIN_HP_OUT)
4600 return PIN_HP;
4601 else
4602 return PIN_OUT;
4603}
4604
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004605static void alc880_auto_init_multi_out(struct hda_codec *codec)
4606{
4607 struct alc_spec *spec = codec->spec;
4608 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004609
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004610 for (i = 0; i < spec->autocfg.line_outs; i++) {
4611 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004612 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4613 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004614 }
4615}
4616
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004617static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004618{
4619 struct alc_spec *spec = codec->spec;
4620 hda_nid_t pin;
4621
Takashi Iwai82bc9552006-03-21 11:24:42 +01004622 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004623 if (pin) /* connect to front */
4624 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004625 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004626 if (pin) /* connect to front */
4627 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4628}
4629
4630static void alc880_auto_init_analog_input(struct hda_codec *codec)
4631{
4632 struct alc_spec *spec = codec->spec;
4633 int i;
4634
4635 for (i = 0; i < AUTO_PIN_LAST; i++) {
4636 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004637 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004638 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004639 if (nid != ALC880_PIN_CD_NID &&
4640 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004641 snd_hda_codec_write(codec, nid, 0,
4642 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004643 AMP_OUT_MUTE);
4644 }
4645 }
4646}
4647
4648/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004649/* return 1 if successful, 0 if the proper config is not found,
4650 * or a negative error code
4651 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004652static int alc880_parse_auto_config(struct hda_codec *codec)
4653{
4654 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004655 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004656 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004657
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004658 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4659 alc880_ignore);
4660 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004661 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004662 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004663 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004664
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004665 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4666 if (err < 0)
4667 return err;
4668 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4669 if (err < 0)
4670 return err;
4671 err = alc880_auto_create_extra_out(spec,
4672 spec->autocfg.speaker_pins[0],
4673 "Speaker");
4674 if (err < 0)
4675 return err;
4676 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4677 "Headphone");
4678 if (err < 0)
4679 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004680 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004681 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004682 return err;
4683
4684 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4685
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004686 /* check multiple SPDIF-out (for recent codecs) */
4687 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4688 hda_nid_t dig_nid;
4689 err = snd_hda_get_connections(codec,
4690 spec->autocfg.dig_out_pins[i],
4691 &dig_nid, 1);
4692 if (err < 0)
4693 continue;
4694 if (!i)
4695 spec->multiout.dig_out_nid = dig_nid;
4696 else {
4697 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004698 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004699 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004700 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004701 }
4702 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004703 if (spec->autocfg.dig_in_pin)
4704 spec->dig_in_nid = ALC880_DIGIN_NID;
4705
Takashi Iwai603c4012008-07-30 15:01:44 +02004706 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004707 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004708
Takashi Iwaid88897e2008-10-31 15:01:37 +01004709 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004710
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004711 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004712 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004713
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004714 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4715
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004716 return 1;
4717}
4718
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004719/* additional initialization for auto-configuration model */
4720static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004721{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004722 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004723 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004724 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004725 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004726 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004727 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004728}
4729
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004730/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4731 * one of two digital mic pins, e.g. on ALC272
4732 */
4733static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004734{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004735 struct alc_spec *spec = codec->spec;
4736 int i;
4737
4738 for (i = 0; i < spec->num_adc_nids; i++) {
4739 hda_nid_t cap = spec->capsrc_nids ?
4740 spec->capsrc_nids[i] : spec->adc_nids[i];
4741 int iidx, eidx;
4742
4743 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4744 if (iidx < 0)
4745 continue;
4746 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4747 if (eidx < 0)
4748 continue;
4749 spec->int_mic.mux_idx = iidx;
4750 spec->ext_mic.mux_idx = eidx;
4751 if (spec->capsrc_nids)
4752 spec->capsrc_nids += i;
4753 spec->adc_nids += i;
4754 spec->num_adc_nids = 1;
4755 return;
4756 }
4757 snd_printd(KERN_INFO "hda_codec: %s: "
4758 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4759 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4760 spec->auto_mic = 0; /* disable auto-mic to be sure */
4761}
4762
4763static void set_capture_mixer(struct hda_codec *codec)
4764{
4765 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01004766 static struct snd_kcontrol_new *caps[2][3] = {
4767 { alc_capture_mixer_nosrc1,
4768 alc_capture_mixer_nosrc2,
4769 alc_capture_mixer_nosrc3 },
4770 { alc_capture_mixer1,
4771 alc_capture_mixer2,
4772 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004773 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004774 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4775 int mux;
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004776 if (spec->auto_mic) {
4777 mux = 0;
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004778 fixup_automic_adc(codec);
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004779 } else if (spec->input_mux && spec->input_mux->num_items > 1)
Takashi Iwaia23b6882009-03-23 15:21:36 +01004780 mux = 1;
4781 else
4782 mux = 0;
4783 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4784 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004785}
4786
Takashi Iwai67d634c2009-11-16 15:35:59 +01004787#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004788#define set_beep_amp(spec, nid, idx, dir) \
4789 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwai67d634c2009-11-16 15:35:59 +01004790#else
4791#define set_beep_amp(spec, nid, idx, dir) /* NOP */
4792#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004793
4794/*
4795 * OK, here we have finally the patch for ALC880
4796 */
4797
Linus Torvalds1da177e2005-04-16 15:20:36 -07004798static int patch_alc880(struct hda_codec *codec)
4799{
4800 struct alc_spec *spec;
4801 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004802 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004803
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004804 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004805 if (spec == NULL)
4806 return -ENOMEM;
4807
4808 codec->spec = spec;
4809
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004810 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4811 alc880_models,
4812 alc880_cfg_tbl);
4813 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004814 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4815 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004816 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004817 }
4818
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004819 if (board_config == ALC880_AUTO) {
4820 /* automatic parse from the BIOS config */
4821 err = alc880_parse_auto_config(codec);
4822 if (err < 0) {
4823 alc_free(codec);
4824 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004825 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004826 printk(KERN_INFO
4827 "hda_codec: Cannot set up configuration "
4828 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004829 board_config = ALC880_3ST;
4830 }
4831 }
4832
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004833 err = snd_hda_attach_beep_device(codec, 0x1);
4834 if (err < 0) {
4835 alc_free(codec);
4836 return err;
4837 }
4838
Kailang Yangdf694da2005-12-05 19:42:22 +01004839 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02004840 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004841
Linus Torvalds1da177e2005-04-16 15:20:36 -07004842 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4843 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004844 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004845
Linus Torvalds1da177e2005-04-16 15:20:36 -07004846 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4847 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4848
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004849 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004850 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004851 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004852 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02004853 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004854 if (wcap != AC_WID_AUD_IN) {
4855 spec->adc_nids = alc880_adc_nids_alt;
4856 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004857 } else {
4858 spec->adc_nids = alc880_adc_nids;
4859 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004860 }
4861 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004862 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004863 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004864
Takashi Iwai2134ea42008-01-10 16:53:55 +01004865 spec->vmaster_nid = 0x0c;
4866
Linus Torvalds1da177e2005-04-16 15:20:36 -07004867 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004868 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004869 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004870#ifdef CONFIG_SND_HDA_POWER_SAVE
4871 if (!spec->loopback.amplist)
4872 spec->loopback.amplist = alc880_loopbacks;
4873#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004874 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004875
4876 return 0;
4877}
4878
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004879
Linus Torvalds1da177e2005-04-16 15:20:36 -07004880/*
4881 * ALC260 support
4882 */
4883
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004884static hda_nid_t alc260_dac_nids[1] = {
4885 /* front */
4886 0x02,
4887};
4888
4889static hda_nid_t alc260_adc_nids[1] = {
4890 /* ADC0 */
4891 0x04,
4892};
4893
Kailang Yangdf694da2005-12-05 19:42:22 +01004894static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004895 /* ADC1 */
4896 0x05,
4897};
4898
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004899/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4900 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4901 */
4902static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004903 /* ADC0, ADC1 */
4904 0x04, 0x05
4905};
4906
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004907#define ALC260_DIGOUT_NID 0x03
4908#define ALC260_DIGIN_NID 0x06
4909
4910static struct hda_input_mux alc260_capture_source = {
4911 .num_items = 4,
4912 .items = {
4913 { "Mic", 0x0 },
4914 { "Front Mic", 0x1 },
4915 { "Line", 0x2 },
4916 { "CD", 0x4 },
4917 },
4918};
4919
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004920/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004921 * headphone jack and the internal CD lines since these are the only pins at
4922 * which audio can appear. For flexibility, also allow the option of
4923 * recording the mixer output on the second ADC (ADC0 doesn't have a
4924 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004925 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004926static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4927 {
4928 .num_items = 3,
4929 .items = {
4930 { "Mic/Line", 0x0 },
4931 { "CD", 0x4 },
4932 { "Headphone", 0x2 },
4933 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004934 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004935 {
4936 .num_items = 4,
4937 .items = {
4938 { "Mic/Line", 0x0 },
4939 { "CD", 0x4 },
4940 { "Headphone", 0x2 },
4941 { "Mixer", 0x5 },
4942 },
4943 },
4944
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004945};
4946
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004947/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4948 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004949 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004950static struct hda_input_mux alc260_acer_capture_sources[2] = {
4951 {
4952 .num_items = 4,
4953 .items = {
4954 { "Mic", 0x0 },
4955 { "Line", 0x2 },
4956 { "CD", 0x4 },
4957 { "Headphone", 0x5 },
4958 },
4959 },
4960 {
4961 .num_items = 5,
4962 .items = {
4963 { "Mic", 0x0 },
4964 { "Line", 0x2 },
4965 { "CD", 0x4 },
4966 { "Headphone", 0x6 },
4967 { "Mixer", 0x5 },
4968 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004969 },
4970};
Michael Schwingencc959482009-02-22 18:58:45 +01004971
4972/* Maxdata Favorit 100XS */
4973static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4974 {
4975 .num_items = 2,
4976 .items = {
4977 { "Line/Mic", 0x0 },
4978 { "CD", 0x4 },
4979 },
4980 },
4981 {
4982 .num_items = 3,
4983 .items = {
4984 { "Line/Mic", 0x0 },
4985 { "CD", 0x4 },
4986 { "Mixer", 0x5 },
4987 },
4988 },
4989};
4990
Linus Torvalds1da177e2005-04-16 15:20:36 -07004991/*
4992 * This is just place-holder, so there's something for alc_build_pcms to look
4993 * at when it calculates the maximum number of channels. ALC260 has no mixer
4994 * element which allows changing the channel mode, so the verb list is
4995 * never used.
4996 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004997static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004998 { 2, NULL },
4999};
5000
Kailang Yangdf694da2005-12-05 19:42:22 +01005001
5002/* Mixer combinations
5003 *
5004 * basic: base_output + input + pc_beep + capture
5005 * HP: base_output + input + capture_alt
5006 * HP_3013: hp_3013 + input + capture
5007 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005008 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005009 */
5010
5011static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005012 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005013 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005014 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5015 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5016 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5017 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5018 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005019};
Kailang Yangdf694da2005-12-05 19:42:22 +01005020
5021static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005022 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5023 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5024 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5025 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5026 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5027 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5028 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5029 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005030 { } /* end */
5031};
5032
Takashi Iwaibec15c32008-01-28 18:16:30 +01005033/* update HP, line and mono out pins according to the master switch */
5034static void alc260_hp_master_update(struct hda_codec *codec,
5035 hda_nid_t hp, hda_nid_t line,
5036 hda_nid_t mono)
5037{
5038 struct alc_spec *spec = codec->spec;
5039 unsigned int val = spec->master_sw ? PIN_HP : 0;
5040 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005041 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005042 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005043 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005044 val);
5045 /* mono (speaker) depending on the HP jack sense */
5046 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005047 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005048 val);
5049}
5050
5051static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5052 struct snd_ctl_elem_value *ucontrol)
5053{
5054 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5055 struct alc_spec *spec = codec->spec;
5056 *ucontrol->value.integer.value = spec->master_sw;
5057 return 0;
5058}
5059
5060static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5061 struct snd_ctl_elem_value *ucontrol)
5062{
5063 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5064 struct alc_spec *spec = codec->spec;
5065 int val = !!*ucontrol->value.integer.value;
5066 hda_nid_t hp, line, mono;
5067
5068 if (val == spec->master_sw)
5069 return 0;
5070 spec->master_sw = val;
5071 hp = (kcontrol->private_value >> 16) & 0xff;
5072 line = (kcontrol->private_value >> 8) & 0xff;
5073 mono = kcontrol->private_value & 0xff;
5074 alc260_hp_master_update(codec, hp, line, mono);
5075 return 1;
5076}
5077
5078static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5079 {
5080 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5081 .name = "Master Playback Switch",
5082 .info = snd_ctl_boolean_mono_info,
5083 .get = alc260_hp_master_sw_get,
5084 .put = alc260_hp_master_sw_put,
5085 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5086 },
5087 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5088 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5089 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5090 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5091 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5092 HDA_OUTPUT),
5093 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5094 { } /* end */
5095};
5096
5097static struct hda_verb alc260_hp_unsol_verbs[] = {
5098 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5099 {},
5100};
5101
5102static void alc260_hp_automute(struct hda_codec *codec)
5103{
5104 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005105
Wu Fengguang864f92b2009-11-18 12:38:02 +08005106 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005107 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5108}
5109
5110static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5111{
5112 if ((res >> 26) == ALC880_HP_EVENT)
5113 alc260_hp_automute(codec);
5114}
5115
Kailang Yangdf694da2005-12-05 19:42:22 +01005116static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005117 {
5118 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5119 .name = "Master Playback Switch",
5120 .info = snd_ctl_boolean_mono_info,
5121 .get = alc260_hp_master_sw_get,
5122 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005123 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005124 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005125 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5126 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5127 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5128 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5129 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5130 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005131 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5132 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005133 { } /* end */
5134};
5135
Kailang Yang3f878302008-08-26 13:02:23 +02005136static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5137 .ops = &snd_hda_bind_vol,
5138 .values = {
5139 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5140 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5141 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5142 0
5143 },
5144};
5145
5146static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5147 .ops = &snd_hda_bind_sw,
5148 .values = {
5149 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5150 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5151 0
5152 },
5153};
5154
5155static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5156 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5157 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5158 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5159 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5160 { } /* end */
5161};
5162
Takashi Iwaibec15c32008-01-28 18:16:30 +01005163static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5164 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5165 {},
5166};
5167
5168static void alc260_hp_3013_automute(struct hda_codec *codec)
5169{
5170 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005171
Wu Fengguang864f92b2009-11-18 12:38:02 +08005172 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005173 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005174}
5175
5176static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5177 unsigned int res)
5178{
5179 if ((res >> 26) == ALC880_HP_EVENT)
5180 alc260_hp_3013_automute(codec);
5181}
5182
Kailang Yang3f878302008-08-26 13:02:23 +02005183static void alc260_hp_3012_automute(struct hda_codec *codec)
5184{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005185 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005186
Kailang Yang3f878302008-08-26 13:02:23 +02005187 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5188 bits);
5189 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5190 bits);
5191 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5192 bits);
5193}
5194
5195static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5196 unsigned int res)
5197{
5198 if ((res >> 26) == ALC880_HP_EVENT)
5199 alc260_hp_3012_automute(codec);
5200}
5201
5202/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005203 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5204 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005205static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005206 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005207 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005208 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005209 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5210 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5211 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5212 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005213 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005214 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5215 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005216 { } /* end */
5217};
5218
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005219/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5220 * versions of the ALC260 don't act on requests to enable mic bias from NID
5221 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5222 * datasheet doesn't mention this restriction. At this stage it's not clear
5223 * whether this behaviour is intentional or is a hardware bug in chip
5224 * revisions available in early 2006. Therefore for now allow the
5225 * "Headphone Jack Mode" control to span all choices, but if it turns out
5226 * that the lack of mic bias for this NID is intentional we could change the
5227 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5228 *
5229 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5230 * don't appear to make the mic bias available from the "line" jack, even
5231 * though the NID used for this jack (0x14) can supply it. The theory is
5232 * that perhaps Acer have included blocking capacitors between the ALC260
5233 * and the output jack. If this turns out to be the case for all such
5234 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5235 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005236 *
5237 * The C20x Tablet series have a mono internal speaker which is controlled
5238 * via the chip's Mono sum widget and pin complex, so include the necessary
5239 * controls for such models. On models without a "mono speaker" the control
5240 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005241 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005242static struct snd_kcontrol_new alc260_acer_mixer[] = {
5243 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5244 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005245 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005246 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005247 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005248 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005249 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005250 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5251 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5252 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5253 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5254 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5255 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5256 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5257 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005258 { } /* end */
5259};
5260
Michael Schwingencc959482009-02-22 18:58:45 +01005261/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5262 */
5263static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5264 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5265 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5266 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5267 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5268 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5269 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5270 { } /* end */
5271};
5272
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005273/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5274 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5275 */
5276static struct snd_kcontrol_new alc260_will_mixer[] = {
5277 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5278 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5279 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5280 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5281 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5282 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5283 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5284 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5285 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5286 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005287 { } /* end */
5288};
5289
5290/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5291 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5292 */
5293static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5294 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5295 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5296 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5297 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5298 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5299 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5300 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5301 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5302 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5303 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5304 { } /* end */
5305};
5306
Kailang Yangdf694da2005-12-05 19:42:22 +01005307/*
5308 * initialization verbs
5309 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005310static struct hda_verb alc260_init_verbs[] = {
5311 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005312 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005313 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005314 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005315 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005316 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005317 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005318 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005319 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005320 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005321 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005322 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005323 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005324 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005325 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005326 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005327 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005328 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5329 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005330 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005331 /* set connection select to line in (default select for this ADC) */
5332 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005333 /* mute capture amp left and right */
5334 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5335 /* set connection select to line in (default select for this ADC) */
5336 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005337 /* set vol=0 Line-Out mixer amp left and right */
5338 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5339 /* unmute pin widget amp left and right (no gain on this amp) */
5340 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5341 /* set vol=0 HP mixer amp left and right */
5342 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5343 /* unmute pin widget amp left and right (no gain on this amp) */
5344 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5345 /* set vol=0 Mono mixer amp left and right */
5346 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5347 /* unmute pin widget amp left and right (no gain on this amp) */
5348 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5349 /* unmute LINE-2 out pin */
5350 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005351 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5352 * Line In 2 = 0x03
5353 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005354 /* mute analog inputs */
5355 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5356 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5357 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5358 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5359 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005360 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005361 /* mute Front out path */
5362 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5363 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5364 /* mute Headphone out path */
5365 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5366 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5367 /* mute Mono out path */
5368 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5369 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005370 { }
5371};
5372
Takashi Iwai474167d2006-05-17 17:17:43 +02005373#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005374static struct hda_verb alc260_hp_init_verbs[] = {
5375 /* Headphone and output */
5376 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5377 /* mono output */
5378 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5379 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5380 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5381 /* Mic2 (front panel) pin widget for input and vref at 80% */
5382 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5383 /* Line In pin widget for input */
5384 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5385 /* Line-2 pin widget for output */
5386 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5387 /* CD pin widget for input */
5388 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5389 /* unmute amp left and right */
5390 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5391 /* set connection select to line in (default select for this ADC) */
5392 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5393 /* unmute Line-Out mixer amp left and right (volume = 0) */
5394 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5395 /* mute pin widget amp left and right (no gain on this amp) */
5396 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5397 /* unmute HP mixer amp left and right (volume = 0) */
5398 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5399 /* mute pin widget amp left and right (no gain on this amp) */
5400 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005401 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5402 * Line In 2 = 0x03
5403 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005404 /* mute analog inputs */
5405 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5406 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5407 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5408 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5409 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005410 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5411 /* Unmute Front out path */
5412 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5413 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5414 /* Unmute Headphone out path */
5415 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5416 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5417 /* Unmute Mono out path */
5418 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5419 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5420 { }
5421};
Takashi Iwai474167d2006-05-17 17:17:43 +02005422#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005423
5424static struct hda_verb alc260_hp_3013_init_verbs[] = {
5425 /* Line out and output */
5426 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5427 /* mono output */
5428 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5429 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5430 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5431 /* Mic2 (front panel) pin widget for input and vref at 80% */
5432 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5433 /* Line In pin widget for input */
5434 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5435 /* Headphone pin widget for output */
5436 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5437 /* CD pin widget for input */
5438 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5439 /* unmute amp left and right */
5440 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5441 /* set connection select to line in (default select for this ADC) */
5442 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5443 /* unmute Line-Out mixer amp left and right (volume = 0) */
5444 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5445 /* mute pin widget amp left and right (no gain on this amp) */
5446 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5447 /* unmute HP mixer amp left and right (volume = 0) */
5448 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5449 /* mute pin widget amp left and right (no gain on this amp) */
5450 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005451 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5452 * Line In 2 = 0x03
5453 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005454 /* mute analog inputs */
5455 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5456 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5457 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5458 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5459 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005460 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5461 /* Unmute Front out path */
5462 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5463 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5464 /* Unmute Headphone out path */
5465 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5466 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5467 /* Unmute Mono out path */
5468 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5469 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5470 { }
5471};
5472
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005473/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005474 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5475 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005476 */
5477static struct hda_verb alc260_fujitsu_init_verbs[] = {
5478 /* Disable all GPIOs */
5479 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5480 /* Internal speaker is connected to headphone pin */
5481 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5482 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5483 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005484 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5485 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5486 /* Ensure all other unused pins are disabled and muted. */
5487 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5488 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005489 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005490 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005491 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005492 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5493 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5494 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005495
Jonathan Woithef7ace402006-02-28 11:46:14 +01005496 /* Disable digital (SPDIF) pins */
5497 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5498 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005499
Kailang Yangea1fb292008-08-26 12:58:38 +02005500 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005501 * when acting as an output.
5502 */
5503 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5504
5505 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005506 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5507 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5508 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5509 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5510 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5511 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5512 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5513 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5514 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005515
Jonathan Woithef7ace402006-02-28 11:46:14 +01005516 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5517 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5518 /* Unmute Line1 pin widget output buffer since it starts as an output.
5519 * If the pin mode is changed by the user the pin mode control will
5520 * take care of enabling the pin's input/output buffers as needed.
5521 * Therefore there's no need to enable the input buffer at this
5522 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005523 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005524 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005525 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005526 * mixer ctrl)
5527 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005528 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005529
Jonathan Woithef7ace402006-02-28 11:46:14 +01005530 /* Mute capture amp left and right */
5531 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005532 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005533 * in (on mic1 pin)
5534 */
5535 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005536
Jonathan Woithef7ace402006-02-28 11:46:14 +01005537 /* Do the same for the second ADC: mute capture input amp and
5538 * set ADC connection to line in (on mic1 pin)
5539 */
5540 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5541 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005542
Jonathan Woithef7ace402006-02-28 11:46:14 +01005543 /* Mute all inputs to mixer widget (even unconnected ones) */
5544 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5545 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5546 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5547 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5548 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5549 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5550 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5551 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005552
5553 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005554};
5555
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005556/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5557 * similar laptops (adapted from Fujitsu init verbs).
5558 */
5559static struct hda_verb alc260_acer_init_verbs[] = {
5560 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5561 * the headphone jack. Turn this on and rely on the standard mute
5562 * methods whenever the user wants to turn these outputs off.
5563 */
5564 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5565 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5566 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5567 /* Internal speaker/Headphone jack is connected to Line-out pin */
5568 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5569 /* Internal microphone/Mic jack is connected to Mic1 pin */
5570 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5571 /* Line In jack is connected to Line1 pin */
5572 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005573 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5574 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005575 /* Ensure all other unused pins are disabled and muted. */
5576 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5577 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005578 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5579 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5580 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5581 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5582 /* Disable digital (SPDIF) pins */
5583 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5584 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5585
Kailang Yangea1fb292008-08-26 12:58:38 +02005586 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005587 * bus when acting as outputs.
5588 */
5589 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5590 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5591
5592 /* Start with output sum widgets muted and their output gains at min */
5593 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5594 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5595 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5596 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5597 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5598 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5599 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5600 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5601 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5602
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005603 /* Unmute Line-out pin widget amp left and right
5604 * (no equiv mixer ctrl)
5605 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005606 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005607 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5608 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005609 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5610 * inputs. If the pin mode is changed by the user the pin mode control
5611 * will take care of enabling the pin's input/output buffers as needed.
5612 * Therefore there's no need to enable the input buffer at this
5613 * stage.
5614 */
5615 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5616 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5617
5618 /* Mute capture amp left and right */
5619 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5620 /* Set ADC connection select to match default mixer setting - mic
5621 * (on mic1 pin)
5622 */
5623 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5624
5625 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005626 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005627 */
5628 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005629 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005630
5631 /* Mute all inputs to mixer widget (even unconnected ones) */
5632 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5633 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5634 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5635 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5636 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5637 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5638 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5639 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5640
5641 { }
5642};
5643
Michael Schwingencc959482009-02-22 18:58:45 +01005644/* Initialisation sequence for Maxdata Favorit 100XS
5645 * (adapted from Acer init verbs).
5646 */
5647static struct hda_verb alc260_favorit100_init_verbs[] = {
5648 /* GPIO 0 enables the output jack.
5649 * Turn this on and rely on the standard mute
5650 * methods whenever the user wants to turn these outputs off.
5651 */
5652 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5653 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5654 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5655 /* Line/Mic input jack is connected to Mic1 pin */
5656 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5657 /* Ensure all other unused pins are disabled and muted. */
5658 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5659 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5660 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5661 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5662 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5663 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5664 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5665 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5666 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5667 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5668 /* Disable digital (SPDIF) pins */
5669 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5670 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5671
5672 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5673 * bus when acting as outputs.
5674 */
5675 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5676 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5677
5678 /* Start with output sum widgets muted and their output gains at min */
5679 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5680 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5681 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5682 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5683 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5684 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5685 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5686 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5687 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5688
5689 /* Unmute Line-out pin widget amp left and right
5690 * (no equiv mixer ctrl)
5691 */
5692 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5693 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5694 * inputs. If the pin mode is changed by the user the pin mode control
5695 * will take care of enabling the pin's input/output buffers as needed.
5696 * Therefore there's no need to enable the input buffer at this
5697 * stage.
5698 */
5699 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5700
5701 /* Mute capture amp left and right */
5702 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5703 /* Set ADC connection select to match default mixer setting - mic
5704 * (on mic1 pin)
5705 */
5706 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5707
5708 /* Do similar with the second ADC: mute capture input amp and
5709 * set ADC connection to mic to match ALSA's default state.
5710 */
5711 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5712 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5713
5714 /* Mute all inputs to mixer widget (even unconnected ones) */
5715 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5716 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5717 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5718 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5719 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5720 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5721 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5722 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5723
5724 { }
5725};
5726
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005727static struct hda_verb alc260_will_verbs[] = {
5728 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5729 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5730 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5731 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5732 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5733 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5734 {}
5735};
5736
5737static struct hda_verb alc260_replacer_672v_verbs[] = {
5738 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5739 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5740 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5741
5742 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5743 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5744 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5745
5746 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5747 {}
5748};
5749
5750/* toggle speaker-output according to the hp-jack state */
5751static void alc260_replacer_672v_automute(struct hda_codec *codec)
5752{
5753 unsigned int present;
5754
5755 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08005756 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005757 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005758 snd_hda_codec_write_cache(codec, 0x01, 0,
5759 AC_VERB_SET_GPIO_DATA, 1);
5760 snd_hda_codec_write_cache(codec, 0x0f, 0,
5761 AC_VERB_SET_PIN_WIDGET_CONTROL,
5762 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005763 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005764 snd_hda_codec_write_cache(codec, 0x01, 0,
5765 AC_VERB_SET_GPIO_DATA, 0);
5766 snd_hda_codec_write_cache(codec, 0x0f, 0,
5767 AC_VERB_SET_PIN_WIDGET_CONTROL,
5768 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005769 }
5770}
5771
5772static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5773 unsigned int res)
5774{
5775 if ((res >> 26) == ALC880_HP_EVENT)
5776 alc260_replacer_672v_automute(codec);
5777}
5778
Kailang Yang3f878302008-08-26 13:02:23 +02005779static struct hda_verb alc260_hp_dc7600_verbs[] = {
5780 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5781 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5782 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5783 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5784 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5785 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5786 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5787 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5788 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5789 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5790 {}
5791};
5792
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005793/* Test configuration for debugging, modelled after the ALC880 test
5794 * configuration.
5795 */
5796#ifdef CONFIG_SND_DEBUG
5797static hda_nid_t alc260_test_dac_nids[1] = {
5798 0x02,
5799};
5800static hda_nid_t alc260_test_adc_nids[2] = {
5801 0x04, 0x05,
5802};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005803/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005804 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005805 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005806 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005807static struct hda_input_mux alc260_test_capture_sources[2] = {
5808 {
5809 .num_items = 7,
5810 .items = {
5811 { "MIC1 pin", 0x0 },
5812 { "MIC2 pin", 0x1 },
5813 { "LINE1 pin", 0x2 },
5814 { "LINE2 pin", 0x3 },
5815 { "CD pin", 0x4 },
5816 { "LINE-OUT pin", 0x5 },
5817 { "HP-OUT pin", 0x6 },
5818 },
5819 },
5820 {
5821 .num_items = 8,
5822 .items = {
5823 { "MIC1 pin", 0x0 },
5824 { "MIC2 pin", 0x1 },
5825 { "LINE1 pin", 0x2 },
5826 { "LINE2 pin", 0x3 },
5827 { "CD pin", 0x4 },
5828 { "Mixer", 0x5 },
5829 { "LINE-OUT pin", 0x6 },
5830 { "HP-OUT pin", 0x7 },
5831 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005832 },
5833};
5834static struct snd_kcontrol_new alc260_test_mixer[] = {
5835 /* Output driver widgets */
5836 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5837 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5838 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5839 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5840 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5841 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5842
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005843 /* Modes for retasking pin widgets
5844 * Note: the ALC260 doesn't seem to act on requests to enable mic
5845 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5846 * mention this restriction. At this stage it's not clear whether
5847 * this behaviour is intentional or is a hardware bug in chip
5848 * revisions available at least up until early 2006. Therefore for
5849 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5850 * choices, but if it turns out that the lack of mic bias for these
5851 * NIDs is intentional we could change their modes from
5852 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5853 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005854 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5855 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5856 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5857 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5858 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5859 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5860
5861 /* Loopback mixer controls */
5862 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5863 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5864 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5865 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5866 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5867 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5868 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5869 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5870 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5871 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005872 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5873 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5874 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5875 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005876
5877 /* Controls for GPIO pins, assuming they are configured as outputs */
5878 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5879 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5880 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5881 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5882
Jonathan Woithe92621f12006-02-28 11:47:47 +01005883 /* Switches to allow the digital IO pins to be enabled. The datasheet
5884 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005885 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005886 */
5887 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5888 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5889
Jonathan Woithef8225f62008-01-08 12:16:54 +01005890 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5891 * this output to turn on an external amplifier.
5892 */
5893 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5894 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5895
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005896 { } /* end */
5897};
5898static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005899 /* Enable all GPIOs as outputs with an initial value of 0 */
5900 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5901 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5902 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5903
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005904 /* Enable retasking pins as output, initially without power amp */
5905 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5906 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5907 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5908 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5909 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5910 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5911
Jonathan Woithe92621f12006-02-28 11:47:47 +01005912 /* Disable digital (SPDIF) pins initially, but users can enable
5913 * them via a mixer switch. In the case of SPDIF-out, this initverb
5914 * payload also sets the generation to 0, output to be in "consumer"
5915 * PCM format, copyright asserted, no pre-emphasis and no validity
5916 * control.
5917 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005918 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5919 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5920
Kailang Yangea1fb292008-08-26 12:58:38 +02005921 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005922 * OUT1 sum bus when acting as an output.
5923 */
5924 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5925 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5926 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5927 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5928
5929 /* Start with output sum widgets muted and their output gains at min */
5930 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5931 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5932 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5933 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5934 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5935 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5936 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5937 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5938 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5939
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005940 /* Unmute retasking pin widget output buffers since the default
5941 * state appears to be output. As the pin mode is changed by the
5942 * user the pin mode control will take care of enabling the pin's
5943 * input/output buffers as needed.
5944 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005945 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5946 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5947 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5948 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5949 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5950 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5951 /* Also unmute the mono-out pin widget */
5952 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5953
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005954 /* Mute capture amp left and right */
5955 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005956 /* Set ADC connection select to match default mixer setting (mic1
5957 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005958 */
5959 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5960
5961 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005962 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005963 */
5964 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5965 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5966
5967 /* Mute all inputs to mixer widget (even unconnected ones) */
5968 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5969 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5970 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5971 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5972 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5973 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5974 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5975 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5976
5977 { }
5978};
5979#endif
5980
Takashi Iwai63300792008-01-24 15:31:36 +01005981#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5982#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005983
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005984#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5985#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5986
Kailang Yangdf694da2005-12-05 19:42:22 +01005987/*
5988 * for BIOS auto-configuration
5989 */
5990
5991static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005992 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005993{
5994 hda_nid_t nid_vol;
5995 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01005996 int err;
5997
5998 if (nid >= 0x0f && nid < 0x11) {
5999 nid_vol = nid - 0x7;
6000 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6001 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6002 } else if (nid == 0x11) {
6003 nid_vol = nid - 0x7;
6004 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6005 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6006 } else if (nid >= 0x12 && nid <= 0x15) {
6007 nid_vol = 0x08;
6008 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6009 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6010 } else
6011 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006012
Takashi Iwai863b4512008-10-21 17:01:47 +02006013 if (!(*vol_bits & (1 << nid_vol))) {
6014 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006015 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006016 if (err < 0)
6017 return err;
6018 *vol_bits |= (1 << nid_vol);
6019 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006020 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006021 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006022 return err;
6023 return 1;
6024}
6025
6026/* add playback controls from the parsed DAC table */
6027static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6028 const struct auto_pin_cfg *cfg)
6029{
6030 hda_nid_t nid;
6031 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006032 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006033
6034 spec->multiout.num_dacs = 1;
6035 spec->multiout.dac_nids = spec->private_dac_nids;
6036 spec->multiout.dac_nids[0] = 0x02;
6037
6038 nid = cfg->line_out_pins[0];
6039 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006040 const char *pfx;
6041 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6042 pfx = "Master";
6043 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6044 pfx = "Speaker";
6045 else
6046 pfx = "Front";
6047 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006048 if (err < 0)
6049 return err;
6050 }
6051
Takashi Iwai82bc9552006-03-21 11:24:42 +01006052 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006053 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006054 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006055 if (err < 0)
6056 return err;
6057 }
6058
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006059 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006060 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006061 err = alc260_add_playback_controls(spec, nid, "Headphone",
6062 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006063 if (err < 0)
6064 return err;
6065 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006066 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006067}
6068
6069/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006070static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006071 const struct auto_pin_cfg *cfg)
6072{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006073 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006074}
6075
6076static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6077 hda_nid_t nid, int pin_type,
6078 int sel_idx)
6079{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006080 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006081 /* need the manual connection? */
6082 if (nid >= 0x12) {
6083 int idx = nid - 0x12;
6084 snd_hda_codec_write(codec, idx + 0x0b, 0,
6085 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006086 }
6087}
6088
6089static void alc260_auto_init_multi_out(struct hda_codec *codec)
6090{
6091 struct alc_spec *spec = codec->spec;
6092 hda_nid_t nid;
6093
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006094 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006095 if (nid) {
6096 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6097 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6098 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006099
Takashi Iwai82bc9552006-03-21 11:24:42 +01006100 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006101 if (nid)
6102 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6103
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006104 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006105 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006106 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006107}
Kailang Yangdf694da2005-12-05 19:42:22 +01006108
6109#define ALC260_PIN_CD_NID 0x16
6110static void alc260_auto_init_analog_input(struct hda_codec *codec)
6111{
6112 struct alc_spec *spec = codec->spec;
6113 int i;
6114
6115 for (i = 0; i < AUTO_PIN_LAST; i++) {
6116 hda_nid_t nid = spec->autocfg.input_pins[i];
6117 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006118 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006119 if (nid != ALC260_PIN_CD_NID &&
6120 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006121 snd_hda_codec_write(codec, nid, 0,
6122 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006123 AMP_OUT_MUTE);
6124 }
6125 }
6126}
6127
6128/*
6129 * generic initialization of ADC, input mixers and output mixers
6130 */
6131static struct hda_verb alc260_volume_init_verbs[] = {
6132 /*
6133 * Unmute ADC0-1 and set the default input to mic-in
6134 */
6135 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6136 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6137 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6138 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006139
Kailang Yangdf694da2005-12-05 19:42:22 +01006140 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6141 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006142 * Note: PASD motherboards uses the Line In 2 as the input for
6143 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006144 */
6145 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006146 /* mute analog inputs */
6147 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6148 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6149 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6150 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6151 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006152
6153 /*
6154 * Set up output mixers (0x08 - 0x0a)
6155 */
6156 /* set vol=0 to output mixers */
6157 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6158 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6159 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6160 /* set up input amps for analog loopback */
6161 /* Amp Indices: DAC = 0, mixer = 1 */
6162 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6163 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6164 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6165 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6166 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6167 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006168
Kailang Yangdf694da2005-12-05 19:42:22 +01006169 { }
6170};
6171
6172static int alc260_parse_auto_config(struct hda_codec *codec)
6173{
6174 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006175 int err;
6176 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6177
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006178 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6179 alc260_ignore);
6180 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006181 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006182 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6183 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006184 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006185 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006186 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006187 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006188 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006189 return err;
6190
6191 spec->multiout.max_channels = 2;
6192
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006193 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006194 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006195 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006196 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006197
Takashi Iwaid88897e2008-10-31 15:01:37 +01006198 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006199
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006200 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006201 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006202
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006203 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6204
Kailang Yangdf694da2005-12-05 19:42:22 +01006205 return 1;
6206}
6207
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006208/* additional initialization for auto-configuration model */
6209static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006210{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006211 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006212 alc260_auto_init_multi_out(codec);
6213 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006214 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006215 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006216}
6217
Takashi Iwaicb53c622007-08-10 17:21:45 +02006218#ifdef CONFIG_SND_HDA_POWER_SAVE
6219static struct hda_amp_list alc260_loopbacks[] = {
6220 { 0x07, HDA_INPUT, 0 },
6221 { 0x07, HDA_INPUT, 1 },
6222 { 0x07, HDA_INPUT, 2 },
6223 { 0x07, HDA_INPUT, 3 },
6224 { 0x07, HDA_INPUT, 4 },
6225 { } /* end */
6226};
6227#endif
6228
Kailang Yangdf694da2005-12-05 19:42:22 +01006229/*
6230 * ALC260 configurations
6231 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006232static const char *alc260_models[ALC260_MODEL_LAST] = {
6233 [ALC260_BASIC] = "basic",
6234 [ALC260_HP] = "hp",
6235 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006236 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006237 [ALC260_FUJITSU_S702X] = "fujitsu",
6238 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006239 [ALC260_WILL] = "will",
6240 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006241 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006242#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006243 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006244#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006245 [ALC260_AUTO] = "auto",
6246};
6247
6248static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006249 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006250 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006251 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006252 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006253 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006254 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006255 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006256 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006257 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006258 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6259 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6260 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6261 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6262 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6263 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6264 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6265 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6266 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006267 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006268 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006269 {}
6270};
6271
Kailang Yangdf694da2005-12-05 19:42:22 +01006272static struct alc_config_preset alc260_presets[] = {
6273 [ALC260_BASIC] = {
6274 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006275 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006276 .init_verbs = { alc260_init_verbs },
6277 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6278 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006279 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006280 .adc_nids = alc260_adc_nids,
6281 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6282 .channel_mode = alc260_modes,
6283 .input_mux = &alc260_capture_source,
6284 },
6285 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006286 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006287 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006288 .init_verbs = { alc260_init_verbs,
6289 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006290 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6291 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006292 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6293 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006294 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6295 .channel_mode = alc260_modes,
6296 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006297 .unsol_event = alc260_hp_unsol_event,
6298 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006299 },
Kailang Yang3f878302008-08-26 13:02:23 +02006300 [ALC260_HP_DC7600] = {
6301 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006302 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006303 .init_verbs = { alc260_init_verbs,
6304 alc260_hp_dc7600_verbs },
6305 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6306 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006307 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6308 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006309 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6310 .channel_mode = alc260_modes,
6311 .input_mux = &alc260_capture_source,
6312 .unsol_event = alc260_hp_3012_unsol_event,
6313 .init_hook = alc260_hp_3012_automute,
6314 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006315 [ALC260_HP_3013] = {
6316 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006317 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006318 .init_verbs = { alc260_hp_3013_init_verbs,
6319 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006320 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6321 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006322 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6323 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006324 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6325 .channel_mode = alc260_modes,
6326 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006327 .unsol_event = alc260_hp_3013_unsol_event,
6328 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006329 },
6330 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006331 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006332 .init_verbs = { alc260_fujitsu_init_verbs },
6333 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6334 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006335 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6336 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006337 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6338 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006339 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6340 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006341 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006342 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006343 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006344 .init_verbs = { alc260_acer_init_verbs },
6345 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6346 .dac_nids = alc260_dac_nids,
6347 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6348 .adc_nids = alc260_dual_adc_nids,
6349 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6350 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006351 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6352 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006353 },
Michael Schwingencc959482009-02-22 18:58:45 +01006354 [ALC260_FAVORIT100] = {
6355 .mixers = { alc260_favorit100_mixer },
6356 .init_verbs = { alc260_favorit100_init_verbs },
6357 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6358 .dac_nids = alc260_dac_nids,
6359 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6360 .adc_nids = alc260_dual_adc_nids,
6361 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6362 .channel_mode = alc260_modes,
6363 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6364 .input_mux = alc260_favorit100_capture_sources,
6365 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006366 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006367 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006368 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6369 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6370 .dac_nids = alc260_dac_nids,
6371 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6372 .adc_nids = alc260_adc_nids,
6373 .dig_out_nid = ALC260_DIGOUT_NID,
6374 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6375 .channel_mode = alc260_modes,
6376 .input_mux = &alc260_capture_source,
6377 },
6378 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006379 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006380 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6381 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6382 .dac_nids = alc260_dac_nids,
6383 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6384 .adc_nids = alc260_adc_nids,
6385 .dig_out_nid = ALC260_DIGOUT_NID,
6386 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6387 .channel_mode = alc260_modes,
6388 .input_mux = &alc260_capture_source,
6389 .unsol_event = alc260_replacer_672v_unsol_event,
6390 .init_hook = alc260_replacer_672v_automute,
6391 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006392#ifdef CONFIG_SND_DEBUG
6393 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006394 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006395 .init_verbs = { alc260_test_init_verbs },
6396 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6397 .dac_nids = alc260_test_dac_nids,
6398 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6399 .adc_nids = alc260_test_adc_nids,
6400 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6401 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006402 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6403 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006404 },
6405#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006406};
6407
Linus Torvalds1da177e2005-04-16 15:20:36 -07006408static int patch_alc260(struct hda_codec *codec)
6409{
6410 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006411 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006412
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006413 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006414 if (spec == NULL)
6415 return -ENOMEM;
6416
6417 codec->spec = spec;
6418
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006419 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6420 alc260_models,
6421 alc260_cfg_tbl);
6422 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006423 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006424 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006425 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006426 }
6427
Kailang Yangdf694da2005-12-05 19:42:22 +01006428 if (board_config == ALC260_AUTO) {
6429 /* automatic parse from the BIOS config */
6430 err = alc260_parse_auto_config(codec);
6431 if (err < 0) {
6432 alc_free(codec);
6433 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006434 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006435 printk(KERN_INFO
6436 "hda_codec: Cannot set up configuration "
6437 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006438 board_config = ALC260_BASIC;
6439 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006440 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006441
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006442 err = snd_hda_attach_beep_device(codec, 0x1);
6443 if (err < 0) {
6444 alc_free(codec);
6445 return err;
6446 }
6447
Kailang Yangdf694da2005-12-05 19:42:22 +01006448 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006449 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006450
Linus Torvalds1da177e2005-04-16 15:20:36 -07006451 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6452 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6453
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006454 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6455 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6456
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006457 if (!spec->adc_nids && spec->input_mux) {
6458 /* check whether NID 0x04 is valid */
6459 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006460 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006461 /* get type */
6462 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6463 spec->adc_nids = alc260_adc_nids_alt;
6464 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6465 } else {
6466 spec->adc_nids = alc260_adc_nids;
6467 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6468 }
6469 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006470 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006471 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006472
Takashi Iwai2134ea42008-01-10 16:53:55 +01006473 spec->vmaster_nid = 0x08;
6474
Linus Torvalds1da177e2005-04-16 15:20:36 -07006475 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006476 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006477 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006478#ifdef CONFIG_SND_HDA_POWER_SAVE
6479 if (!spec->loopback.amplist)
6480 spec->loopback.amplist = alc260_loopbacks;
6481#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006482 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006483
6484 return 0;
6485}
6486
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006487
Linus Torvalds1da177e2005-04-16 15:20:36 -07006488/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006489 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006490 *
6491 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6492 * configuration. Each pin widget can choose any input DACs and a mixer.
6493 * Each ADC is connected from a mixer of all inputs. This makes possible
6494 * 6-channel independent captures.
6495 *
6496 * In addition, an independent DAC for the multi-playback (not used in this
6497 * driver yet).
6498 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006499#define ALC882_DIGOUT_NID 0x06
6500#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006501#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6502#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6503#define ALC1200_DIGOUT_NID 0x10
6504
Linus Torvalds1da177e2005-04-16 15:20:36 -07006505
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006506static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006507 { 8, NULL }
6508};
6509
Takashi Iwai4953550a2009-06-30 15:28:30 +02006510/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006511static hda_nid_t alc882_dac_nids[4] = {
6512 /* front, rear, clfe, rear_surr */
6513 0x02, 0x03, 0x04, 0x05
6514};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006515#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006516
Takashi Iwai4953550a2009-06-30 15:28:30 +02006517/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006518#define alc882_adc_nids alc880_adc_nids
6519#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006520#define alc883_adc_nids alc882_adc_nids_alt
6521static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6522static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6523#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006524
Takashi Iwaie1406342008-02-11 18:32:32 +01006525static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6526static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006527#define alc883_capsrc_nids alc882_capsrc_nids_alt
6528static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6529#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006530
Linus Torvalds1da177e2005-04-16 15:20:36 -07006531/* input MUX */
6532/* FIXME: should be a matrix-type input source selection */
6533
6534static struct hda_input_mux alc882_capture_source = {
6535 .num_items = 4,
6536 .items = {
6537 { "Mic", 0x0 },
6538 { "Front Mic", 0x1 },
6539 { "Line", 0x2 },
6540 { "CD", 0x4 },
6541 },
6542};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006543
Takashi Iwai4953550a2009-06-30 15:28:30 +02006544#define alc883_capture_source alc882_capture_source
6545
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006546static struct hda_input_mux alc889_capture_source = {
6547 .num_items = 3,
6548 .items = {
6549 { "Front Mic", 0x0 },
6550 { "Mic", 0x3 },
6551 { "Line", 0x2 },
6552 },
6553};
6554
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006555static struct hda_input_mux mb5_capture_source = {
6556 .num_items = 3,
6557 .items = {
6558 { "Mic", 0x1 },
6559 { "Line", 0x2 },
6560 { "CD", 0x4 },
6561 },
6562};
6563
Takashi Iwai4953550a2009-06-30 15:28:30 +02006564static struct hda_input_mux alc883_3stack_6ch_intel = {
6565 .num_items = 4,
6566 .items = {
6567 { "Mic", 0x1 },
6568 { "Front Mic", 0x0 },
6569 { "Line", 0x2 },
6570 { "CD", 0x4 },
6571 },
6572};
6573
6574static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6575 .num_items = 2,
6576 .items = {
6577 { "Mic", 0x1 },
6578 { "Line", 0x2 },
6579 },
6580};
6581
6582static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6583 .num_items = 4,
6584 .items = {
6585 { "Mic", 0x0 },
6586 { "iMic", 0x1 },
6587 { "Line", 0x2 },
6588 { "CD", 0x4 },
6589 },
6590};
6591
6592static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6593 .num_items = 2,
6594 .items = {
6595 { "Mic", 0x0 },
6596 { "Int Mic", 0x1 },
6597 },
6598};
6599
6600static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6601 .num_items = 3,
6602 .items = {
6603 { "Mic", 0x0 },
6604 { "Front Mic", 0x1 },
6605 { "Line", 0x4 },
6606 },
6607};
6608
6609static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6610 .num_items = 2,
6611 .items = {
6612 { "Mic", 0x0 },
6613 { "Line", 0x2 },
6614 },
6615};
6616
6617static struct hda_input_mux alc889A_mb31_capture_source = {
6618 .num_items = 2,
6619 .items = {
6620 { "Mic", 0x0 },
6621 /* Front Mic (0x01) unused */
6622 { "Line", 0x2 },
6623 /* Line 2 (0x03) unused */
6624 /* CD (0x04) unsused? */
6625 },
6626};
6627
6628/*
6629 * 2ch mode
6630 */
6631static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6632 { 2, NULL }
6633};
6634
Kailang Yangdf694da2005-12-05 19:42:22 +01006635/*
Kailang Yang272a5272007-05-14 11:00:38 +02006636 * 2ch mode
6637 */
6638static struct hda_verb alc882_3ST_ch2_init[] = {
6639 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6640 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6641 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6642 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6643 { } /* end */
6644};
6645
6646/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006647 * 4ch mode
6648 */
6649static struct hda_verb alc882_3ST_ch4_init[] = {
6650 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6651 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6652 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6653 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6654 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6655 { } /* end */
6656};
6657
6658/*
Kailang Yang272a5272007-05-14 11:00:38 +02006659 * 6ch mode
6660 */
6661static struct hda_verb alc882_3ST_ch6_init[] = {
6662 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6663 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6664 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6665 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6666 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6667 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6668 { } /* end */
6669};
6670
Takashi Iwai4953550a2009-06-30 15:28:30 +02006671static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006672 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006673 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006674 { 6, alc882_3ST_ch6_init },
6675};
6676
Takashi Iwai4953550a2009-06-30 15:28:30 +02006677#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6678
Kailang Yang272a5272007-05-14 11:00:38 +02006679/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04306680 * 2ch mode
6681 */
6682static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6683 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6684 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6685 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6686 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6687 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6688 { } /* end */
6689};
6690
6691/*
6692 * 4ch mode
6693 */
6694static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
6695 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6696 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6697 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6698 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6699 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6700 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6701 { } /* end */
6702};
6703
6704/*
6705 * 6ch mode
6706 */
6707static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
6708 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6709 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6710 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6711 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6712 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6713 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6714 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6715 { } /* end */
6716};
6717
6718static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
6719 { 2, alc883_3ST_ch2_clevo_init },
6720 { 4, alc883_3ST_ch4_clevo_init },
6721 { 6, alc883_3ST_ch6_clevo_init },
6722};
6723
6724
6725/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006726 * 6ch mode
6727 */
6728static struct hda_verb alc882_sixstack_ch6_init[] = {
6729 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6730 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6731 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6732 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6733 { } /* end */
6734};
6735
6736/*
6737 * 8ch mode
6738 */
6739static struct hda_verb alc882_sixstack_ch8_init[] = {
6740 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6741 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6742 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6743 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6744 { } /* end */
6745};
6746
6747static struct hda_channel_mode alc882_sixstack_modes[2] = {
6748 { 6, alc882_sixstack_ch6_init },
6749 { 8, alc882_sixstack_ch8_init },
6750};
6751
Takashi Iwai87350ad2007-08-16 18:19:38 +02006752/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006753 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006754 */
6755
6756/*
6757 * 2ch mode
6758 */
6759static struct hda_verb alc885_mbp_ch2_init[] = {
6760 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6761 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6762 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6763 { } /* end */
6764};
6765
6766/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006767 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02006768 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006769static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006770 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6771 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6772 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6773 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6774 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6775 { } /* end */
6776};
6777
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006778static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006779 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006780 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006781};
6782
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006783/*
6784 * 2ch
6785 * Speakers/Woofer/HP = Front
6786 * LineIn = Input
6787 */
6788static struct hda_verb alc885_mb5_ch2_init[] = {
6789 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6790 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6791 { } /* end */
6792};
6793
6794/*
6795 * 6ch mode
6796 * Speakers/HP = Front
6797 * Woofer = LFE
6798 * LineIn = Surround
6799 */
6800static struct hda_verb alc885_mb5_ch6_init[] = {
6801 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6802 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6803 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6804 { } /* end */
6805};
6806
6807static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6808 { 2, alc885_mb5_ch2_init },
6809 { 6, alc885_mb5_ch6_init },
6810};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006811
Takashi Iwai4953550a2009-06-30 15:28:30 +02006812
6813/*
6814 * 2ch mode
6815 */
6816static struct hda_verb alc883_4ST_ch2_init[] = {
6817 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6818 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6819 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6820 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6821 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6822 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6823 { } /* end */
6824};
6825
6826/*
6827 * 4ch mode
6828 */
6829static struct hda_verb alc883_4ST_ch4_init[] = {
6830 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6831 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6832 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6833 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6834 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6835 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6836 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6837 { } /* end */
6838};
6839
6840/*
6841 * 6ch mode
6842 */
6843static struct hda_verb alc883_4ST_ch6_init[] = {
6844 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6845 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6846 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6847 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6848 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6849 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6850 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6851 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6852 { } /* end */
6853};
6854
6855/*
6856 * 8ch mode
6857 */
6858static struct hda_verb alc883_4ST_ch8_init[] = {
6859 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6860 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6861 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6862 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6863 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6864 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6865 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6866 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6867 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6868 { } /* end */
6869};
6870
6871static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6872 { 2, alc883_4ST_ch2_init },
6873 { 4, alc883_4ST_ch4_init },
6874 { 6, alc883_4ST_ch6_init },
6875 { 8, alc883_4ST_ch8_init },
6876};
6877
6878
6879/*
6880 * 2ch mode
6881 */
6882static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6883 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6884 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6885 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6886 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6887 { } /* end */
6888};
6889
6890/*
6891 * 4ch mode
6892 */
6893static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6894 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6895 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6896 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6897 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6898 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6899 { } /* end */
6900};
6901
6902/*
6903 * 6ch mode
6904 */
6905static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6906 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6907 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6908 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6909 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6910 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6911 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6912 { } /* end */
6913};
6914
6915static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6916 { 2, alc883_3ST_ch2_intel_init },
6917 { 4, alc883_3ST_ch4_intel_init },
6918 { 6, alc883_3ST_ch6_intel_init },
6919};
6920
6921/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006922 * 2ch mode
6923 */
6924static struct hda_verb alc889_ch2_intel_init[] = {
6925 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6926 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
6927 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
6928 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
6929 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6930 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6931 { } /* end */
6932};
6933
6934/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006935 * 6ch mode
6936 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006937static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006938 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6939 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6940 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6941 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6942 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006943 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6944 { } /* end */
6945};
6946
6947/*
6948 * 8ch mode
6949 */
6950static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006951 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6952 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6953 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6954 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6955 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006956 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6957 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006958 { } /* end */
6959};
6960
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006961static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
6962 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006963 { 6, alc889_ch6_intel_init },
6964 { 8, alc889_ch8_intel_init },
6965};
6966
6967/*
6968 * 6ch mode
6969 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006970static struct hda_verb alc883_sixstack_ch6_init[] = {
6971 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6972 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6973 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6974 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6975 { } /* end */
6976};
6977
6978/*
6979 * 8ch mode
6980 */
6981static struct hda_verb alc883_sixstack_ch8_init[] = {
6982 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6983 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6984 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6985 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6986 { } /* end */
6987};
6988
6989static struct hda_channel_mode alc883_sixstack_modes[2] = {
6990 { 6, alc883_sixstack_ch6_init },
6991 { 8, alc883_sixstack_ch8_init },
6992};
6993
6994
Linus Torvalds1da177e2005-04-16 15:20:36 -07006995/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6996 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6997 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006998static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006999 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007000 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007001 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007002 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007003 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7004 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007005 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7006 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007007 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007008 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007009 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7010 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7011 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7012 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7013 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7014 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007015 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007016 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7017 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007018 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007019 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007020 { } /* end */
7021};
7022
Takashi Iwai87350ad2007-08-16 18:19:38 +02007023static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007024 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7025 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7026 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7027 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7028 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007029 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7030 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007031 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7032 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007033 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007034 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7035 { } /* end */
7036};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007037
7038static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007039 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7040 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7041 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7042 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7043 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7044 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7045 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7046 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007047 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7048 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7049 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7050 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7051 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7052 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7053 { } /* end */
7054};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007055
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007056static struct snd_kcontrol_new alc885_imac91_mixer[] = {
7057 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7058 HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
7059 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
7060 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7061 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7062 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7063 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7064 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7065 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7066 { } /* end */
7067};
7068
7069
Kailang Yangbdd148a2007-05-08 15:19:08 +02007070static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7071 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7072 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7073 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7074 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7075 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7076 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7077 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7078 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7079 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007080 { } /* end */
7081};
7082
Kailang Yang272a5272007-05-14 11:00:38 +02007083static struct snd_kcontrol_new alc882_targa_mixer[] = {
7084 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7085 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7086 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7087 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7088 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7089 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7090 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7091 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7092 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007093 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007094 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7095 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007096 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007097 { } /* end */
7098};
7099
7100/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7101 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7102 */
7103static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7104 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7105 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7106 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7107 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7108 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7109 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7110 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7111 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7112 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7113 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7114 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7115 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007116 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007117 { } /* end */
7118};
7119
Takashi Iwai914759b2007-09-06 14:52:04 +02007120static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7121 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7122 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7123 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7124 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7125 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7126 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7127 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7128 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7129 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7130 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007131 { } /* end */
7132};
7133
Kailang Yangdf694da2005-12-05 19:42:22 +01007134static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7135 {
7136 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7137 .name = "Channel Mode",
7138 .info = alc_ch_mode_info,
7139 .get = alc_ch_mode_get,
7140 .put = alc_ch_mode_put,
7141 },
7142 { } /* end */
7143};
7144
Takashi Iwai4953550a2009-06-30 15:28:30 +02007145static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007146 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007147 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7148 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7149 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007150 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007151 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7152 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7153 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007154 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007155 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7156 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7157 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007158 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007159 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7160 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7161 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007162
Takashi Iwaicb638122009-07-03 10:56:10 +02007163 /* mute analog input loopbacks */
7164 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7165 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7166 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7167 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7168 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7169
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007170 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007171 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007172 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007173 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007174 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007175 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007176 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007177 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007178 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007179 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007180 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007181 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007182 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007183 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007184 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007185 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007186 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007187 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007188 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7189 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007190 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007191 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7192 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007193 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007194 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7195 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7196 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7197 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7198 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007199 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007200 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007201
7202 /* FIXME: use matrix-type input source selection */
7203 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007204 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007205 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7206 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7207 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7208 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007209 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007210 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7211 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7212 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7213 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007214 /* ADC2: mute amp left and right */
7215 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007216 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007217 /* ADC3: mute amp left and right */
7218 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007219 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007220
7221 { }
7222};
7223
Takashi Iwai4953550a2009-06-30 15:28:30 +02007224static struct hda_verb alc882_adc1_init_verbs[] = {
7225 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7226 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7227 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7228 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7229 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7230 /* ADC1: mute amp left and right */
7231 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7232 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7233 { }
7234};
7235
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007236static struct hda_verb alc882_eapd_verbs[] = {
7237 /* change to EAPD mode */
7238 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007239 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007240 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007241};
7242
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007243static struct hda_verb alc889_eapd_verbs[] = {
7244 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7245 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7246 { }
7247};
7248
Wu Fengguang6732bd02009-07-30 09:19:14 +02007249static struct hda_verb alc_hp15_unsol_verbs[] = {
7250 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7251 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7252 {}
7253};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007254
7255static struct hda_verb alc885_init_verbs[] = {
7256 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7257 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7258 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7259 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7260 /* Rear mixer */
7261 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7262 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7263 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7264 /* CLFE mixer */
7265 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7266 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7267 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7268 /* Side mixer */
7269 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7270 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7271 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7272
7273 /* mute analog input loopbacks */
7274 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7275 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7276 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7277
7278 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007279 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007280 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7281 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7282 /* Front Pin: output 0 (0x0c) */
7283 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7284 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7285 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7286 /* Rear Pin: output 1 (0x0d) */
7287 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7288 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7289 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7290 /* CLFE Pin: output 2 (0x0e) */
7291 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7292 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7293 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7294 /* Side Pin: output 3 (0x0f) */
7295 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7296 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7297 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7298 /* Mic (rear) pin: input vref at 80% */
7299 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7300 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7301 /* Front Mic pin: input vref at 80% */
7302 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7303 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7304 /* Line In pin: input */
7305 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7306 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7307
7308 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7309 /* Input mixer1 */
7310 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7311 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7312 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7313 /* Input mixer2 */
7314 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7315 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7316 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7317 /* Input mixer3 */
7318 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7319 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7320 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7321 /* ADC2: mute amp left and right */
7322 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7323 /* ADC3: mute amp left and right */
7324 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7325
7326 { }
7327};
7328
7329static struct hda_verb alc885_init_input_verbs[] = {
7330 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7331 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7332 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7333 { }
7334};
7335
7336
7337/* Unmute Selector 24h and set the default input to front mic */
7338static struct hda_verb alc889_init_input_verbs[] = {
7339 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7340 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7341 { }
7342};
7343
7344
Takashi Iwai4953550a2009-06-30 15:28:30 +02007345#define alc883_init_verbs alc882_base_init_verbs
7346
Tobin Davis9102cd12006-12-15 10:02:12 +01007347/* Mac Pro test */
7348static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7349 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7350 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7351 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7352 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7353 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007354 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007355 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7356 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007357 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007358 { } /* end */
7359};
7360
7361static struct hda_verb alc882_macpro_init_verbs[] = {
7362 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7363 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7364 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7365 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7366 /* Front Pin: output 0 (0x0c) */
7367 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7368 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7369 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7370 /* Front Mic pin: input vref at 80% */
7371 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7372 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7373 /* Speaker: output */
7374 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7375 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7376 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7377 /* Headphone output (output 0 - 0x0c) */
7378 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7379 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7380 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7381
7382 /* FIXME: use matrix-type input source selection */
7383 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7384 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7385 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7386 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7387 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7388 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7389 /* Input mixer2 */
7390 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7391 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7392 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7393 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7394 /* Input mixer3 */
7395 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7396 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7397 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7398 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7399 /* ADC1: mute amp left and right */
7400 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7401 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7402 /* ADC2: mute amp left and right */
7403 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7404 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7405 /* ADC3: mute amp left and right */
7406 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7407 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7408
7409 { }
7410};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007411
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007412/* Macbook 5,1 */
7413static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007414 /* DACs */
7415 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7416 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7417 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7418 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007419 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007420 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7421 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7422 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007423 /* Surround mixer */
7424 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7425 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7426 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7427 /* LFE mixer */
7428 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7429 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7430 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7431 /* HP mixer */
7432 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7433 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7434 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7435 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007436 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7437 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007438 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7439 /* LFE Pin (0x0e) */
7440 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7441 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7442 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7443 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007444 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7445 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007446 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007447 /* Front Mic pin: input vref at 80% */
7448 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7449 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7450 /* Line In pin */
7451 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7452 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7453
7454 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7455 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7456 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7457 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7458 { }
7459};
7460
Takashi Iwai87350ad2007-08-16 18:19:38 +02007461/* Macbook Pro rev3 */
7462static struct hda_verb alc885_mbp3_init_verbs[] = {
7463 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7464 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7465 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7466 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7467 /* Rear mixer */
7468 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7469 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7470 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007471 /* HP mixer */
7472 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7473 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7474 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007475 /* Front Pin: output 0 (0x0c) */
7476 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7477 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7478 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007479 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007480 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007481 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7482 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007483 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7484 /* Mic (rear) pin: input vref at 80% */
7485 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7486 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7487 /* Front Mic pin: input vref at 80% */
7488 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7489 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7490 /* Line In pin: use output 1 when in LineOut mode */
7491 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7492 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7493 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7494
7495 /* FIXME: use matrix-type input source selection */
7496 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7497 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7498 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7499 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7500 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7501 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7502 /* Input mixer2 */
7503 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7504 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7505 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7506 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7507 /* Input mixer3 */
7508 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7509 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7510 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7511 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7512 /* ADC1: mute amp left and right */
7513 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7514 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7515 /* ADC2: mute amp left and right */
7516 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7517 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7518 /* ADC3: mute amp left and right */
7519 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7520 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7521
7522 { }
7523};
7524
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007525/* iMac 9,1 */
7526static struct hda_verb alc885_imac91_init_verbs[] = {
7527 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
7528 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7529 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7530 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7531 /* Rear mixer */
7532 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7533 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7534 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7535 /* HP Pin: output 0 (0x0c) */
7536 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7537 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7538 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7539 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7540 /* Internal Speakers: output 0 (0x0d) */
7541 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7542 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7543 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7544 /* Mic (rear) pin: input vref at 80% */
7545 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7546 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7547 /* Front Mic pin: input vref at 80% */
7548 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7549 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7550 /* Line In pin: use output 1 when in LineOut mode */
7551 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7552 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7553 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7554
7555 /* FIXME: use matrix-type input source selection */
7556 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7557 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7558 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7559 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7560 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7561 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7562 /* Input mixer2 */
7563 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7564 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7565 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7566 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7567 /* Input mixer3 */
7568 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7569 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7570 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7571 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7572 /* ADC1: mute amp left and right */
7573 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7574 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7575 /* ADC2: mute amp left and right */
7576 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7577 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7578 /* ADC3: mute amp left and right */
7579 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7580 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7581
7582 { }
7583};
7584
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007585/* iMac 24 mixer. */
7586static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7587 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7588 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7589 { } /* end */
7590};
7591
7592/* iMac 24 init verbs. */
7593static struct hda_verb alc885_imac24_init_verbs[] = {
7594 /* Internal speakers: output 0 (0x0c) */
7595 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7596 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7597 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7598 /* Internal speakers: output 0 (0x0c) */
7599 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7600 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7601 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7602 /* Headphone: output 0 (0x0c) */
7603 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7604 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7605 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7606 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7607 /* Front Mic: input vref at 80% */
7608 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7609 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7610 { }
7611};
7612
7613/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007614static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007615{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007616 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007617
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007618 spec->autocfg.hp_pins[0] = 0x14;
7619 spec->autocfg.speaker_pins[0] = 0x18;
7620 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007621}
7622
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007623static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007624{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007625 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007626
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007627 spec->autocfg.hp_pins[0] = 0x15;
7628 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02007629}
7630
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007631static void alc885_imac91_automute(struct hda_codec *codec)
7632{
7633 unsigned int present;
7634
7635 present = snd_hda_codec_read(codec, 0x14, 0,
7636 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7637 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7638 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7639 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
7640 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7641
7642}
7643
7644static void alc885_imac91_unsol_event(struct hda_codec *codec,
7645 unsigned int res)
7646{
7647 /* Headphone insertion or removal. */
7648 if ((res >> 26) == ALC880_HP_EVENT)
7649 alc885_imac91_automute(codec);
7650}
Takashi Iwai87350ad2007-08-16 18:19:38 +02007651
Kailang Yang272a5272007-05-14 11:00:38 +02007652static struct hda_verb alc882_targa_verbs[] = {
7653 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7654 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7655
7656 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7657 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007658
Kailang Yang272a5272007-05-14 11:00:38 +02007659 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7660 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7661 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7662
7663 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007664 { } /* end */
7665};
7666
7667/* toggle speaker-output according to the hp-jack state */
7668static void alc882_targa_automute(struct hda_codec *codec)
7669{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007670 struct alc_spec *spec = codec->spec;
7671 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007672 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007673 spec->jack_present ? 1 : 3);
7674}
7675
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007676static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007677{
7678 struct alc_spec *spec = codec->spec;
7679
7680 spec->autocfg.hp_pins[0] = 0x14;
7681 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02007682}
7683
7684static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7685{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007686 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007687 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007688}
7689
7690static struct hda_verb alc882_asus_a7j_verbs[] = {
7691 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7692 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7693
7694 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7695 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7696 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007697
Kailang Yang272a5272007-05-14 11:00:38 +02007698 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7699 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7700 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7701
7702 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7703 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7704 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7705 { } /* end */
7706};
7707
Takashi Iwai914759b2007-09-06 14:52:04 +02007708static struct hda_verb alc882_asus_a7m_verbs[] = {
7709 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7710 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7711
7712 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7713 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7714 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007715
Takashi Iwai914759b2007-09-06 14:52:04 +02007716 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7717 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7718 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7719
7720 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7721 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7722 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7723 { } /* end */
7724};
7725
Tobin Davis9102cd12006-12-15 10:02:12 +01007726static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7727{
7728 unsigned int gpiostate, gpiomask, gpiodir;
7729
7730 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7731 AC_VERB_GET_GPIO_DATA, 0);
7732
7733 if (!muted)
7734 gpiostate |= (1 << pin);
7735 else
7736 gpiostate &= ~(1 << pin);
7737
7738 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7739 AC_VERB_GET_GPIO_MASK, 0);
7740 gpiomask |= (1 << pin);
7741
7742 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7743 AC_VERB_GET_GPIO_DIRECTION, 0);
7744 gpiodir |= (1 << pin);
7745
7746
7747 snd_hda_codec_write(codec, codec->afg, 0,
7748 AC_VERB_SET_GPIO_MASK, gpiomask);
7749 snd_hda_codec_write(codec, codec->afg, 0,
7750 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7751
7752 msleep(1);
7753
7754 snd_hda_codec_write(codec, codec->afg, 0,
7755 AC_VERB_SET_GPIO_DATA, gpiostate);
7756}
7757
Takashi Iwai7debbe52007-08-16 15:01:03 +02007758/* set up GPIO at initialization */
7759static void alc885_macpro_init_hook(struct hda_codec *codec)
7760{
7761 alc882_gpio_mute(codec, 0, 0);
7762 alc882_gpio_mute(codec, 1, 0);
7763}
7764
7765/* set up GPIO and update auto-muting at initialization */
7766static void alc885_imac24_init_hook(struct hda_codec *codec)
7767{
7768 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007769 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007770}
7771
Kailang Yangdf694da2005-12-05 19:42:22 +01007772/*
7773 * generic initialization of ADC, input mixers and output mixers
7774 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007775static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007776 /*
7777 * Unmute ADC0-2 and set the default input to mic-in
7778 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007779 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7780 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7781 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7782 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7783
Takashi Iwaicb53c622007-08-10 17:21:45 +02007784 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007785 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007786 * Note: PASD motherboards uses the Line In 2 as the input for
7787 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007788 */
7789 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007790 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7791 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7792 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7793 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7794 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007795
7796 /*
7797 * Set up output mixers (0x0c - 0x0f)
7798 */
7799 /* set vol=0 to output mixers */
7800 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7801 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7802 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7803 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7804 /* set up input amps for analog loopback */
7805 /* Amp Indices: DAC = 0, mixer = 1 */
7806 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7807 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7808 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7809 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7810 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7811 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7812 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7813 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7814 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7815 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7816
7817 /* FIXME: use matrix-type input source selection */
7818 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01007819 /* Input mixer2 */
7820 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7821 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7822 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7823 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7824 /* Input mixer3 */
7825 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7826 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7827 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7828 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7829
7830 { }
7831};
7832
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007833/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7834static struct hda_verb alc889A_mb31_ch2_init[] = {
7835 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7836 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7837 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7838 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7839 { } /* end */
7840};
7841
7842/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7843static struct hda_verb alc889A_mb31_ch4_init[] = {
7844 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7845 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7846 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7847 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7848 { } /* end */
7849};
7850
7851/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7852static struct hda_verb alc889A_mb31_ch5_init[] = {
7853 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7854 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7855 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7856 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7857 { } /* end */
7858};
7859
7860/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7861static struct hda_verb alc889A_mb31_ch6_init[] = {
7862 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7863 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7864 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7865 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7866 { } /* end */
7867};
7868
7869static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7870 { 2, alc889A_mb31_ch2_init },
7871 { 4, alc889A_mb31_ch4_init },
7872 { 5, alc889A_mb31_ch5_init },
7873 { 6, alc889A_mb31_ch6_init },
7874};
7875
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007876static struct hda_verb alc883_medion_eapd_verbs[] = {
7877 /* eanable EAPD on medion laptop */
7878 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7879 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7880 { }
7881};
7882
Takashi Iwai4953550a2009-06-30 15:28:30 +02007883#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007884
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007885static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7886 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7887 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7888 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7889 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7890 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7891 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7892 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7893 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7894 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7895 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7896 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7897 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7898 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007899 { } /* end */
7900};
7901
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007902static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007903 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7904 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7905 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7906 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7907 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7908 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7909 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7910 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7911 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7912 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007913 { } /* end */
7914};
7915
Jiang zhefb97dc62008-03-06 11:07:11 +01007916static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7917 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7918 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7919 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7920 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7921 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7922 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7923 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7924 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7925 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7926 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007927 { } /* end */
7928};
7929
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007930static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7931 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7932 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7933 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7934 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7935 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7936 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7937 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7938 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007939 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007940 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7941 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007942 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007943 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007944 { } /* end */
7945};
7946
7947static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7948 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7949 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7950 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7951 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7952 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7953 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7954 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7955 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7956 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7957 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7958 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7959 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7960 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7961 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007962 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007963 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7964 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007965 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007966 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007967 { } /* end */
7968};
7969
Jiang zhe17bba1b2008-06-04 12:11:07 +02007970static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7971 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7972 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7973 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7974 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7975 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7976 HDA_OUTPUT),
7977 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7978 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7979 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7980 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7981 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7982 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7983 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7984 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7985 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7986 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7987 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7988 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7989 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7990 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007991 { } /* end */
7992};
7993
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007994static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
7995 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7996 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7997 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7998 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7999 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8000 HDA_OUTPUT),
8001 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8002 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8003 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8004 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8005 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8006 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8007 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8008 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8009 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8010 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8011 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8012 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8013 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8014 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8015 { } /* end */
8016};
8017
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008018static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008019 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008020 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008021 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008022 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008023 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8024 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008025 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8026 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008027 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8028 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8029 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8030 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8031 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8032 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008033 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008034 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8035 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008036 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008037 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008038 { } /* end */
8039};
8040
Sasha Alexandrc2592492009-06-16 14:52:54 -04008041static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008042 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008043 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008044 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008045 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008046 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8047 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8048 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8049 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8050 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8051 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8052 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8053 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8054 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8055 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8056 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008057 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008058 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008059 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008060};
Kailang Yangccc656c2006-10-17 12:32:26 +02008061
Sasha Alexandrc2592492009-06-16 14:52:54 -04008062static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008063 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008064 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008065 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008066 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008067 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8068 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8069 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008070 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008071 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008072 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8073 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8074 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008075 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008076};
Kailang Yangccc656c2006-10-17 12:32:26 +02008077
Takashi Iwaib99dba32009-09-17 18:23:00 +02008078static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8079 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8080 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8081 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8082 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8083 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8084 { } /* end */
8085};
8086
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008087static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8088 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8089 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008090 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8091 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008092 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8093 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8094 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8095 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008096 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008097};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008098
Kailang Yang272a5272007-05-14 11:00:38 +02008099static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8100 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8101 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8102 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8103 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8104 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8105 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8106 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8107 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8108 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008109 { } /* end */
8110};
8111
8112static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8113 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8114 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8115 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8116 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8117 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8118 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8119 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8120 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8121 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008122 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008123};
Kailang Yang272a5272007-05-14 11:00:38 +02008124
Tobin Davis2880a862007-08-07 11:50:26 +02008125static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008126 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8127 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008128 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008129 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8130 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008131 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8132 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8133 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008134 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008135};
Tobin Davis2880a862007-08-07 11:50:26 +02008136
Tony Vroond2fd4b02009-06-21 00:40:10 +01008137static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8138 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8139 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8140 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8141 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008142 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8143 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008144 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8145 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8146 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8147 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8148 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8149 { } /* end */
8150};
8151
Kailang Yange2757d52008-08-26 13:17:46 +02008152static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8153 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8154 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8155 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8156 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8157 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8158 0x0d, 1, 0x0, HDA_OUTPUT),
8159 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8160 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8161 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8162 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8163 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008164 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8165 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8166 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8167 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8168 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8169 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8170 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8171 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8172 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8173 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008174 { } /* end */
8175};
8176
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008177static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8178 /* Output mixers */
8179 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8180 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8181 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8182 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8183 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8184 HDA_OUTPUT),
8185 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8186 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8187 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8188 /* Output switches */
8189 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8190 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8191 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8192 /* Boost mixers */
8193 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8194 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8195 /* Input mixers */
8196 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8197 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8198 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8199 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8200 { } /* end */
8201};
8202
Guido Günther3e1647c2009-06-05 00:47:26 +02008203static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8204 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8205 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8206 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8207 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8208 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8209 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8210 { } /* end */
8211};
8212
Kailang Yange2757d52008-08-26 13:17:46 +02008213static struct hda_bind_ctls alc883_bind_cap_vol = {
8214 .ops = &snd_hda_bind_vol,
8215 .values = {
8216 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8217 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8218 0
8219 },
8220};
8221
8222static struct hda_bind_ctls alc883_bind_cap_switch = {
8223 .ops = &snd_hda_bind_sw,
8224 .values = {
8225 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8226 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8227 0
8228 },
8229};
8230
8231static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8232 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8233 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8234 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8235 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8236 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8237 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8238 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8239 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008240 { } /* end */
8241};
8242
8243static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008244 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8245 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8246 {
8247 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8248 /* .name = "Capture Source", */
8249 .name = "Input Source",
8250 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008251 .info = alc_mux_enum_info,
8252 .get = alc_mux_enum_get,
8253 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008254 },
8255 { } /* end */
8256};
8257
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008258static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8259 {
8260 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8261 .name = "Channel Mode",
8262 .info = alc_ch_mode_info,
8263 .get = alc_ch_mode_get,
8264 .put = alc_ch_mode_put,
8265 },
8266 { } /* end */
8267};
8268
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008269/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008270static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008271{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008272 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008273
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008274 spec->autocfg.hp_pins[0] = 0x15;
8275 spec->autocfg.speaker_pins[0] = 0x14;
8276 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008277}
8278
8279/* auto-toggle front mic */
8280/*
8281static void alc883_mitac_mic_automute(struct hda_codec *codec)
8282{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008283 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008284
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008285 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8286}
8287*/
8288
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008289static struct hda_verb alc883_mitac_verbs[] = {
8290 /* HP */
8291 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8292 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8293 /* Subwoofer */
8294 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8295 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8296
8297 /* enable unsolicited event */
8298 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8299 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8300
8301 { } /* end */
8302};
8303
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308304static struct hda_verb alc883_clevo_m540r_verbs[] = {
8305 /* HP */
8306 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8307 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8308 /* Int speaker */
8309 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8310
8311 /* enable unsolicited event */
8312 /*
8313 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8314 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8315 */
8316
8317 { } /* end */
8318};
8319
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008320static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008321 /* HP */
8322 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8323 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8324 /* Int speaker */
8325 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8326 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8327
8328 /* enable unsolicited event */
8329 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008330 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008331
8332 { } /* end */
8333};
8334
Jiang zhefb97dc62008-03-06 11:07:11 +01008335static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8336 /* HP */
8337 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8338 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8339 /* Subwoofer */
8340 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8341 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8342
8343 /* enable unsolicited event */
8344 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8345
8346 { } /* end */
8347};
8348
Sasha Alexandrc2592492009-06-16 14:52:54 -04008349static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008350 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8351 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8352
8353 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8354 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008355
David Heidelberger64a8be72009-06-08 16:15:18 +02008356/* Connect Line-Out side jack (SPDIF) to Side */
8357 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8358 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8359 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8360/* Connect Mic jack to CLFE */
8361 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8362 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8363 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8364/* Connect Line-in jack to Surround */
8365 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8366 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8367 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8368/* Connect HP out jack to Front */
8369 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8370 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8371 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008372
8373 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008374
8375 { } /* end */
8376};
8377
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008378static struct hda_verb alc883_lenovo_101e_verbs[] = {
8379 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8380 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8381 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8382 { } /* end */
8383};
8384
Kailang Yang272a5272007-05-14 11:00:38 +02008385static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8386 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8387 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8388 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8389 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8390 { } /* end */
8391};
8392
8393static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8394 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8395 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8396 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8397 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8398 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8399 { } /* end */
8400};
8401
Kailang Yang189609a2007-08-20 11:31:23 +02008402static struct hda_verb alc883_haier_w66_verbs[] = {
8403 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8404 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8405
8406 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8407
8408 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8409 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8410 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8411 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8412 { } /* end */
8413};
8414
Kailang Yange2757d52008-08-26 13:17:46 +02008415static struct hda_verb alc888_lenovo_sky_verbs[] = {
8416 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8417 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8418 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8419 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8420 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8421 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8422 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8423 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8424 { } /* end */
8425};
8426
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008427static struct hda_verb alc888_6st_dell_verbs[] = {
8428 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8429 { }
8430};
8431
Guido Günther3e1647c2009-06-05 00:47:26 +02008432static struct hda_verb alc883_vaiott_verbs[] = {
8433 /* HP */
8434 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8435 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8436
8437 /* enable unsolicited event */
8438 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8439
8440 { } /* end */
8441};
8442
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008443static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008444{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008445 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008446
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008447 spec->autocfg.hp_pins[0] = 0x1b;
8448 spec->autocfg.speaker_pins[0] = 0x14;
8449 spec->autocfg.speaker_pins[1] = 0x16;
8450 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008451}
8452
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008453static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008454 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008455 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8456 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008457 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008458 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008459};
8460
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008461/*
8462 * 2ch mode
8463 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008464static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008465 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8466 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8467 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8468 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008469 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008470};
8471
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008472/*
8473 * 4ch mode
8474 */
8475static struct hda_verb alc888_3st_hp_4ch_init[] = {
8476 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8477 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8478 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8479 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8480 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8481 { } /* end */
8482};
8483
8484/*
8485 * 6ch mode
8486 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008487static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008488 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8489 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008490 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008491 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8492 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008493 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8494 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008495};
8496
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008497static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008498 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008499 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008500 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008501};
8502
Kailang Yang272a5272007-05-14 11:00:38 +02008503/* toggle front-jack and RCA according to the hp-jack state */
8504static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8505{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008506 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02008507
Takashi Iwai47fd8302007-08-10 17:11:07 +02008508 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8509 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8510 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8511 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008512}
8513
8514/* toggle RCA according to the front-jack state */
8515static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8516{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008517 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02008518
Takashi Iwai47fd8302007-08-10 17:11:07 +02008519 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8520 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008521}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008522
Kailang Yang272a5272007-05-14 11:00:38 +02008523static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8524 unsigned int res)
8525{
8526 if ((res >> 26) == ALC880_HP_EVENT)
8527 alc888_lenovo_ms7195_front_automute(codec);
8528 if ((res >> 26) == ALC880_FRONT_EVENT)
8529 alc888_lenovo_ms7195_rca_automute(codec);
8530}
8531
8532static struct hda_verb alc883_medion_md2_verbs[] = {
8533 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8534 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8535
8536 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8537
8538 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8539 { } /* end */
8540};
8541
8542/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008543static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008544{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008545 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008546
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008547 spec->autocfg.hp_pins[0] = 0x14;
8548 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008549}
8550
Kailang Yangccc656c2006-10-17 12:32:26 +02008551/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008552#define alc883_targa_init_hook alc882_targa_init_hook
8553#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008554
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008555static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8556{
8557 unsigned int present;
8558
Takashi Iwaid56757a2009-11-18 08:00:14 +01008559 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008560 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8561 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8562}
8563
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008564static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008565{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008566 struct alc_spec *spec = codec->spec;
8567
8568 spec->autocfg.hp_pins[0] = 0x15;
8569 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008570}
8571
8572static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8573{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008574 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008575 alc883_clevo_m720_mic_automute(codec);
8576}
8577
8578static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008579 unsigned int res)
8580{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008581 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008582 case ALC880_MIC_EVENT:
8583 alc883_clevo_m720_mic_automute(codec);
8584 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008585 default:
8586 alc_automute_amp_unsol_event(codec, res);
8587 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008588 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008589}
8590
Jiang zhefb97dc62008-03-06 11:07:11 +01008591/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008592static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008593{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008594 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008595
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008596 spec->autocfg.hp_pins[0] = 0x14;
8597 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01008598}
8599
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008600static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008601{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008602 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008603
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008604 spec->autocfg.hp_pins[0] = 0x1b;
8605 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02008606}
8607
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008608static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8609{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008610 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008611
Takashi Iwai47fd8302007-08-10 17:11:07 +02008612 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8613 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008614}
8615
8616static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8617{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008618 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008619
Takashi Iwai47fd8302007-08-10 17:11:07 +02008620 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8621 HDA_AMP_MUTE, bits);
8622 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8623 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008624}
8625
8626static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8627 unsigned int res)
8628{
8629 if ((res >> 26) == ALC880_HP_EVENT)
8630 alc883_lenovo_101e_all_automute(codec);
8631 if ((res >> 26) == ALC880_FRONT_EVENT)
8632 alc883_lenovo_101e_ispeaker_automute(codec);
8633}
8634
Takashi Iwai676a9b52007-08-16 15:23:35 +02008635/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008636static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008637{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008638 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008639
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008640 spec->autocfg.hp_pins[0] = 0x14;
8641 spec->autocfg.speaker_pins[0] = 0x15;
8642 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02008643}
8644
Kailang Yangd1a991a2007-08-15 16:21:59 +02008645static struct hda_verb alc883_acer_eapd_verbs[] = {
8646 /* HP Pin: output 0 (0x0c) */
8647 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8648 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8649 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8650 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008651 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8652 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008653 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008654 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8655 /* eanable EAPD on medion laptop */
8656 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8657 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008658 /* enable unsolicited event */
8659 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008660 { }
8661};
8662
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008663static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8664 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8665 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8666 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8667 { } /* end */
8668};
8669
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008670static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008671{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008672 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008673
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008674 spec->autocfg.hp_pins[0] = 0x1b;
8675 spec->autocfg.speaker_pins[0] = 0x14;
8676 spec->autocfg.speaker_pins[1] = 0x15;
8677 spec->autocfg.speaker_pins[2] = 0x16;
8678 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008679}
8680
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008681static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008682{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008683 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008684
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008685 spec->autocfg.hp_pins[0] = 0x1b;
8686 spec->autocfg.speaker_pins[0] = 0x14;
8687 spec->autocfg.speaker_pins[1] = 0x15;
8688 spec->autocfg.speaker_pins[2] = 0x16;
8689 spec->autocfg.speaker_pins[3] = 0x17;
8690 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02008691}
8692
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008693static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02008694{
8695 struct alc_spec *spec = codec->spec;
8696
8697 spec->autocfg.hp_pins[0] = 0x15;
8698 spec->autocfg.speaker_pins[0] = 0x14;
8699 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02008700}
8701
Kailang Yange2757d52008-08-26 13:17:46 +02008702static struct hda_verb alc888_asus_m90v_verbs[] = {
8703 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8704 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8705 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8706 /* enable unsolicited event */
8707 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8708 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8709 { } /* end */
8710};
8711
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008712static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008713{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008714 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008715
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008716 spec->autocfg.hp_pins[0] = 0x1b;
8717 spec->autocfg.speaker_pins[0] = 0x14;
8718 spec->autocfg.speaker_pins[1] = 0x15;
8719 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008720 spec->ext_mic.pin = 0x18;
8721 spec->int_mic.pin = 0x19;
8722 spec->ext_mic.mux_idx = 0;
8723 spec->int_mic.mux_idx = 1;
8724 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02008725}
8726
8727static struct hda_verb alc888_asus_eee1601_verbs[] = {
8728 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8729 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8730 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8731 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8732 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8733 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8734 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8735 /* enable unsolicited event */
8736 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8737 { } /* end */
8738};
8739
Kailang Yange2757d52008-08-26 13:17:46 +02008740static void alc883_eee1601_inithook(struct hda_codec *codec)
8741{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008742 struct alc_spec *spec = codec->spec;
8743
8744 spec->autocfg.hp_pins[0] = 0x14;
8745 spec->autocfg.speaker_pins[0] = 0x1b;
8746 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008747}
8748
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008749static struct hda_verb alc889A_mb31_verbs[] = {
8750 /* Init rear pin (used as headphone output) */
8751 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8752 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8753 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8754 /* Init line pin (used as output in 4ch and 6ch mode) */
8755 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8756 /* Init line 2 pin (used as headphone out by default) */
8757 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8758 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8759 { } /* end */
8760};
8761
8762/* Mute speakers according to the headphone jack state */
8763static void alc889A_mb31_automute(struct hda_codec *codec)
8764{
8765 unsigned int present;
8766
8767 /* Mute only in 2ch or 4ch mode */
8768 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8769 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08008770 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008771 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8772 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8773 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8774 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8775 }
8776}
8777
8778static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8779{
8780 if ((res >> 26) == ALC880_HP_EVENT)
8781 alc889A_mb31_automute(codec);
8782}
8783
Takashi Iwai4953550a2009-06-30 15:28:30 +02008784
Takashi Iwaicb53c622007-08-10 17:21:45 +02008785#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02008786#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02008787#endif
8788
Sasha Alexandrdef319f2009-06-16 16:00:15 -04008789/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008790#define alc882_pcm_analog_playback alc880_pcm_analog_playback
8791#define alc882_pcm_analog_capture alc880_pcm_analog_capture
8792#define alc882_pcm_digital_playback alc880_pcm_digital_playback
8793#define alc882_pcm_digital_capture alc880_pcm_digital_capture
8794
8795static hda_nid_t alc883_slave_dig_outs[] = {
8796 ALC1200_DIGOUT_NID, 0,
8797};
8798
8799static hda_nid_t alc1200_slave_dig_outs[] = {
8800 ALC883_DIGOUT_NID, 0,
8801};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008802
8803/*
8804 * configuration and preset
8805 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008806static const char *alc882_models[ALC882_MODEL_LAST] = {
8807 [ALC882_3ST_DIG] = "3stack-dig",
8808 [ALC882_6ST_DIG] = "6stack-dig",
8809 [ALC882_ARIMA] = "arima",
8810 [ALC882_W2JC] = "w2jc",
8811 [ALC882_TARGA] = "targa",
8812 [ALC882_ASUS_A7J] = "asus-a7j",
8813 [ALC882_ASUS_A7M] = "asus-a7m",
8814 [ALC885_MACPRO] = "macpro",
8815 [ALC885_MB5] = "mb5",
8816 [ALC885_MBP3] = "mbp3",
8817 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008818 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008819 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008820 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8821 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008822 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008823 [ALC883_TARGA_DIG] = "targa-dig",
8824 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02008825 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008826 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008827 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008828 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02008829 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02008830 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008831 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008832 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008833 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008834 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008835 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008836 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8837 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008838 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008839 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008840 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008841 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008842 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308843 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008844 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008845 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008846 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008847 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008848 [ALC889A_INTEL] = "intel-alc889a",
8849 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008850 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008851 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02008852 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008853 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008854};
8855
Takashi Iwai4953550a2009-06-30 15:28:30 +02008856static struct snd_pci_quirk alc882_cfg_tbl[] = {
8857 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8858
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008859 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008860 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008861 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008862 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8863 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008864 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008865 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8866 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008867 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01008868 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02008869 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8870 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02008871 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
8872 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008873 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
8874 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008875 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02008876 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008877 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01008878 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008879 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
8880 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02008881 /* default Acer -- disabled as it causes more problems.
8882 * model=auto should work fine now
8883 */
8884 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008885
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008886 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008887
Tobin Davisfebe3372007-06-12 11:27:46 +02008888 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008889 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8890 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008891 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008892 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008893 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008894
8895 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8896 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8897 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008898 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008899 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8900 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8901 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008902 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008903 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008904 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008905 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008906
8907 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02008908 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008909 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008910 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008911 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8912 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008913 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008914 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008915 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8916
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008917 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8918 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8919 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008920 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01008921 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008922 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008923 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008924 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008925 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8926 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8927 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8928 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8929 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8930 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008931 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008932 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8933 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8934 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02008935 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008936 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8937 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008938 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008939 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008940 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008941 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008942 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04008943 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008944 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008945 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008946
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008947 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008948 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8949 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308950 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008951 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008952 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008953 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008954 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008955 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008956 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008957 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008958 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008959 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008960 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008961 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8962 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008963 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008964 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008965 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008966 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008967 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008968
Jiang zhe17bba1b2008-06-04 12:11:07 +02008969 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8970 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008971 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008972 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
8973 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
8974 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008975 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008976
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008977 {}
8978};
8979
Takashi Iwai4953550a2009-06-30 15:28:30 +02008980/* codec SSID table for Intel Mac */
8981static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
8982 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
8983 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
8984 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
8985 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
8986 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
8987 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
8988 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
8989 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
8990 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
8991 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008992 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008993 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05008994 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
8995 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02008996 */
8997 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05008998 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008999 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009000};
9001
Takashi Iwai4953550a2009-06-30 15:28:30 +02009002static struct alc_config_preset alc882_presets[] = {
9003 [ALC882_3ST_DIG] = {
9004 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009005 .init_verbs = { alc882_base_init_verbs,
9006 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009007 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9008 .dac_nids = alc882_dac_nids,
9009 .dig_out_nid = ALC882_DIGOUT_NID,
9010 .dig_in_nid = ALC882_DIGIN_NID,
9011 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9012 .channel_mode = alc882_ch_modes,
9013 .need_dac_fix = 1,
9014 .input_mux = &alc882_capture_source,
9015 },
9016 [ALC882_6ST_DIG] = {
9017 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009018 .init_verbs = { alc882_base_init_verbs,
9019 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009020 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9021 .dac_nids = alc882_dac_nids,
9022 .dig_out_nid = ALC882_DIGOUT_NID,
9023 .dig_in_nid = ALC882_DIGIN_NID,
9024 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9025 .channel_mode = alc882_sixstack_modes,
9026 .input_mux = &alc882_capture_source,
9027 },
9028 [ALC882_ARIMA] = {
9029 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009030 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9031 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009032 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9033 .dac_nids = alc882_dac_nids,
9034 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9035 .channel_mode = alc882_sixstack_modes,
9036 .input_mux = &alc882_capture_source,
9037 },
9038 [ALC882_W2JC] = {
9039 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009040 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9041 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009042 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9043 .dac_nids = alc882_dac_nids,
9044 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9045 .channel_mode = alc880_threestack_modes,
9046 .need_dac_fix = 1,
9047 .input_mux = &alc882_capture_source,
9048 .dig_out_nid = ALC882_DIGOUT_NID,
9049 },
9050 [ALC885_MBP3] = {
9051 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9052 .init_verbs = { alc885_mbp3_init_verbs,
9053 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009054 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009055 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009056 .hp_nid = 0x04,
9057 .channel_mode = alc885_mbp_4ch_modes,
9058 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009059 .input_mux = &alc882_capture_source,
9060 .dig_out_nid = ALC882_DIGOUT_NID,
9061 .dig_in_nid = ALC882_DIGIN_NID,
9062 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009063 .setup = alc885_mbp3_setup,
9064 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009065 },
9066 [ALC885_MB5] = {
9067 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9068 .init_verbs = { alc885_mb5_init_verbs,
9069 alc880_gpio1_init_verbs },
9070 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9071 .dac_nids = alc882_dac_nids,
9072 .channel_mode = alc885_mb5_6ch_modes,
9073 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9074 .input_mux = &mb5_capture_source,
9075 .dig_out_nid = ALC882_DIGOUT_NID,
9076 .dig_in_nid = ALC882_DIGIN_NID,
9077 },
9078 [ALC885_MACPRO] = {
9079 .mixers = { alc882_macpro_mixer },
9080 .init_verbs = { alc882_macpro_init_verbs },
9081 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9082 .dac_nids = alc882_dac_nids,
9083 .dig_out_nid = ALC882_DIGOUT_NID,
9084 .dig_in_nid = ALC882_DIGIN_NID,
9085 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9086 .channel_mode = alc882_ch_modes,
9087 .input_mux = &alc882_capture_source,
9088 .init_hook = alc885_macpro_init_hook,
9089 },
9090 [ALC885_IMAC24] = {
9091 .mixers = { alc885_imac24_mixer },
9092 .init_verbs = { alc885_imac24_init_verbs },
9093 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9094 .dac_nids = alc882_dac_nids,
9095 .dig_out_nid = ALC882_DIGOUT_NID,
9096 .dig_in_nid = ALC882_DIGIN_NID,
9097 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9098 .channel_mode = alc882_ch_modes,
9099 .input_mux = &alc882_capture_source,
9100 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009101 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009102 .init_hook = alc885_imac24_init_hook,
9103 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009104 [ALC885_IMAC91] = {
9105 .mixers = { alc885_imac91_mixer, alc882_chmode_mixer },
9106 .init_verbs = { alc885_imac91_init_verbs,
9107 alc880_gpio1_init_verbs },
9108 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9109 .dac_nids = alc882_dac_nids,
9110 .channel_mode = alc885_mbp_4ch_modes,
9111 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
9112 .input_mux = &alc882_capture_source,
9113 .dig_out_nid = ALC882_DIGOUT_NID,
9114 .dig_in_nid = ALC882_DIGIN_NID,
9115 .unsol_event = alc885_imac91_unsol_event,
9116 .init_hook = alc885_imac91_automute,
9117 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009118 [ALC882_TARGA] = {
9119 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009120 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009121 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009122 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9123 .dac_nids = alc882_dac_nids,
9124 .dig_out_nid = ALC882_DIGOUT_NID,
9125 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9126 .adc_nids = alc882_adc_nids,
9127 .capsrc_nids = alc882_capsrc_nids,
9128 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9129 .channel_mode = alc882_3ST_6ch_modes,
9130 .need_dac_fix = 1,
9131 .input_mux = &alc882_capture_source,
9132 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009133 .setup = alc882_targa_setup,
9134 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009135 },
9136 [ALC882_ASUS_A7J] = {
9137 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009138 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9139 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009140 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9141 .dac_nids = alc882_dac_nids,
9142 .dig_out_nid = ALC882_DIGOUT_NID,
9143 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9144 .adc_nids = alc882_adc_nids,
9145 .capsrc_nids = alc882_capsrc_nids,
9146 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9147 .channel_mode = alc882_3ST_6ch_modes,
9148 .need_dac_fix = 1,
9149 .input_mux = &alc882_capture_source,
9150 },
9151 [ALC882_ASUS_A7M] = {
9152 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009153 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9154 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009155 alc882_asus_a7m_verbs },
9156 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9157 .dac_nids = alc882_dac_nids,
9158 .dig_out_nid = ALC882_DIGOUT_NID,
9159 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9160 .channel_mode = alc880_threestack_modes,
9161 .need_dac_fix = 1,
9162 .input_mux = &alc882_capture_source,
9163 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009164 [ALC883_3ST_2ch_DIG] = {
9165 .mixers = { alc883_3ST_2ch_mixer },
9166 .init_verbs = { alc883_init_verbs },
9167 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9168 .dac_nids = alc883_dac_nids,
9169 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009170 .dig_in_nid = ALC883_DIGIN_NID,
9171 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9172 .channel_mode = alc883_3ST_2ch_modes,
9173 .input_mux = &alc883_capture_source,
9174 },
9175 [ALC883_3ST_6ch_DIG] = {
9176 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9177 .init_verbs = { alc883_init_verbs },
9178 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9179 .dac_nids = alc883_dac_nids,
9180 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009181 .dig_in_nid = ALC883_DIGIN_NID,
9182 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9183 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009184 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009185 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009186 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009187 [ALC883_3ST_6ch] = {
9188 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9189 .init_verbs = { alc883_init_verbs },
9190 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9191 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009192 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9193 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009194 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009195 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009196 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009197 [ALC883_3ST_6ch_INTEL] = {
9198 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9199 .init_verbs = { alc883_init_verbs },
9200 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9201 .dac_nids = alc883_dac_nids,
9202 .dig_out_nid = ALC883_DIGOUT_NID,
9203 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009204 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009205 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9206 .channel_mode = alc883_3ST_6ch_intel_modes,
9207 .need_dac_fix = 1,
9208 .input_mux = &alc883_3stack_6ch_intel,
9209 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009210 [ALC889A_INTEL] = {
9211 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009212 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9213 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009214 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9215 .dac_nids = alc883_dac_nids,
9216 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9217 .adc_nids = alc889_adc_nids,
9218 .dig_out_nid = ALC883_DIGOUT_NID,
9219 .dig_in_nid = ALC883_DIGIN_NID,
9220 .slave_dig_outs = alc883_slave_dig_outs,
9221 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9222 .channel_mode = alc889_8ch_intel_modes,
9223 .capsrc_nids = alc889_capsrc_nids,
9224 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009225 .setup = alc889_automute_setup,
9226 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009227 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009228 .need_dac_fix = 1,
9229 },
9230 [ALC889_INTEL] = {
9231 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9232 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009233 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009234 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9235 .dac_nids = alc883_dac_nids,
9236 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9237 .adc_nids = alc889_adc_nids,
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009238 .capsrc_nids = alc889_capsrc_nids,
9239 .capsrc_nids = alc889_capsrc_nids,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009240 .dig_out_nid = ALC883_DIGOUT_NID,
9241 .dig_in_nid = ALC883_DIGIN_NID,
9242 .slave_dig_outs = alc883_slave_dig_outs,
9243 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9244 .channel_mode = alc889_8ch_intel_modes,
9245 .capsrc_nids = alc889_capsrc_nids,
9246 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009247 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009248 .init_hook = alc889_intel_init_hook,
9249 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009250 .need_dac_fix = 1,
9251 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009252 [ALC883_6ST_DIG] = {
9253 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9254 .init_verbs = { alc883_init_verbs },
9255 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9256 .dac_nids = alc883_dac_nids,
9257 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009258 .dig_in_nid = ALC883_DIGIN_NID,
9259 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9260 .channel_mode = alc883_sixstack_modes,
9261 .input_mux = &alc883_capture_source,
9262 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009263 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009264 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009265 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9266 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009267 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9268 .dac_nids = alc883_dac_nids,
9269 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009270 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9271 .channel_mode = alc883_3ST_6ch_modes,
9272 .need_dac_fix = 1,
9273 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009274 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009275 .setup = alc882_targa_setup,
9276 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009277 },
9278 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009279 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009280 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9281 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009282 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9283 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009284 .adc_nids = alc883_adc_nids_alt,
9285 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009286 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +02009287 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009288 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9289 .channel_mode = alc883_3ST_2ch_modes,
9290 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009291 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009292 .setup = alc882_targa_setup,
9293 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009294 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009295 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009296 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9297 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +02009298 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009299 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009300 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9301 .dac_nids = alc883_dac_nids,
9302 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9303 .adc_nids = alc883_adc_nids_rev,
9304 .capsrc_nids = alc883_capsrc_nids_rev,
9305 .dig_out_nid = ALC883_DIGOUT_NID,
9306 .dig_in_nid = ALC883_DIGIN_NID,
9307 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9308 .channel_mode = alc883_4ST_8ch_modes,
9309 .need_dac_fix = 1,
9310 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009311 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009312 .setup = alc882_targa_setup,
9313 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009314 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009315 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009316 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009317 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9318 * and the headphone jack. Turn this on and rely on the
9319 * standard mute methods whenever the user wants to turn
9320 * these outputs off.
9321 */
9322 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9323 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9324 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009325 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9326 .channel_mode = alc883_3ST_2ch_modes,
9327 .input_mux = &alc883_capture_source,
9328 },
Tobin Davis2880a862007-08-07 11:50:26 +02009329 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009330 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009331 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009332 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9333 .dac_nids = alc883_dac_nids,
9334 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009335 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9336 .channel_mode = alc883_3ST_2ch_modes,
9337 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009338 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009339 .setup = alc883_acer_aspire_setup,
9340 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009341 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009342 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009343 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009344 alc883_chmode_mixer },
9345 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9346 alc888_acer_aspire_4930g_verbs },
9347 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9348 .dac_nids = alc883_dac_nids,
9349 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9350 .adc_nids = alc883_adc_nids_rev,
9351 .capsrc_nids = alc883_capsrc_nids_rev,
9352 .dig_out_nid = ALC883_DIGOUT_NID,
9353 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9354 .channel_mode = alc883_3ST_6ch_modes,
9355 .need_dac_fix = 1,
9356 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009357 ARRAY_SIZE(alc888_2_capture_sources),
9358 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009359 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009360 .setup = alc888_acer_aspire_4930g_setup,
9361 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009362 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009363 [ALC888_ACER_ASPIRE_6530G] = {
9364 .mixers = { alc888_acer_aspire_6530_mixer },
9365 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9366 alc888_acer_aspire_6530g_verbs },
9367 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9368 .dac_nids = alc883_dac_nids,
9369 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9370 .adc_nids = alc883_adc_nids_rev,
9371 .capsrc_nids = alc883_capsrc_nids_rev,
9372 .dig_out_nid = ALC883_DIGOUT_NID,
9373 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9374 .channel_mode = alc883_3ST_2ch_modes,
9375 .num_mux_defs =
9376 ARRAY_SIZE(alc888_2_capture_sources),
9377 .input_mux = alc888_acer_aspire_6530_sources,
9378 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009379 .setup = alc888_acer_aspire_6530g_setup,
9380 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009381 },
Hector Martin3b315d72009-06-02 10:54:19 +02009382 [ALC888_ACER_ASPIRE_8930G] = {
9383 .mixers = { alc888_base_mixer,
9384 alc883_chmode_mixer },
9385 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +01009386 alc889_acer_aspire_8930g_verbs,
9387 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +02009388 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9389 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009390 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9391 .adc_nids = alc889_adc_nids,
9392 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009393 .dig_out_nid = ALC883_DIGOUT_NID,
9394 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9395 .channel_mode = alc883_3ST_6ch_modes,
9396 .need_dac_fix = 1,
9397 .const_channel_count = 6,
9398 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009399 ARRAY_SIZE(alc889_capture_sources),
9400 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009401 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009402 .setup = alc889_acer_aspire_8930g_setup,
9403 .init_hook = alc_automute_amp,
Hector Martin3b315d72009-06-02 10:54:19 +02009404 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009405 [ALC888_ACER_ASPIRE_7730G] = {
9406 .mixers = { alc883_3ST_6ch_mixer,
9407 alc883_chmode_mixer },
9408 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9409 alc888_acer_aspire_7730G_verbs },
9410 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9411 .dac_nids = alc883_dac_nids,
9412 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9413 .adc_nids = alc883_adc_nids_rev,
9414 .capsrc_nids = alc883_capsrc_nids_rev,
9415 .dig_out_nid = ALC883_DIGOUT_NID,
9416 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9417 .channel_mode = alc883_3ST_6ch_modes,
9418 .need_dac_fix = 1,
9419 .const_channel_count = 6,
9420 .input_mux = &alc883_capture_source,
9421 .unsol_event = alc_automute_amp_unsol_event,
9422 .setup = alc888_acer_aspire_6530g_setup,
9423 .init_hook = alc_automute_amp,
9424 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009425 [ALC883_MEDION] = {
9426 .mixers = { alc883_fivestack_mixer,
9427 alc883_chmode_mixer },
9428 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009429 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009430 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9431 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009432 .adc_nids = alc883_adc_nids_alt,
9433 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009434 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02009435 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9436 .channel_mode = alc883_sixstack_modes,
9437 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009438 },
Kailang Yang272a5272007-05-14 11:00:38 +02009439 [ALC883_MEDION_MD2] = {
9440 .mixers = { alc883_medion_md2_mixer},
9441 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9442 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9443 .dac_nids = alc883_dac_nids,
9444 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009445 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9446 .channel_mode = alc883_3ST_2ch_modes,
9447 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009448 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009449 .setup = alc883_medion_md2_setup,
9450 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009451 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009452 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009453 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009454 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9455 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9456 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009457 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9458 .channel_mode = alc883_3ST_2ch_modes,
9459 .input_mux = &alc883_capture_source,
9460 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309461 [ALC883_CLEVO_M540R] = {
9462 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9463 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9464 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9465 .dac_nids = alc883_dac_nids,
9466 .dig_out_nid = ALC883_DIGOUT_NID,
9467 .dig_in_nid = ALC883_DIGIN_NID,
9468 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9469 .channel_mode = alc883_3ST_6ch_clevo_modes,
9470 .need_dac_fix = 1,
9471 .input_mux = &alc883_capture_source,
9472 /* This machine has the hardware HP auto-muting, thus
9473 * we need no software mute via unsol event
9474 */
9475 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009476 [ALC883_CLEVO_M720] = {
9477 .mixers = { alc883_clevo_m720_mixer },
9478 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009479 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9480 .dac_nids = alc883_dac_nids,
9481 .dig_out_nid = ALC883_DIGOUT_NID,
9482 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9483 .channel_mode = alc883_3ST_2ch_modes,
9484 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009485 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009486 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009487 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009488 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009489 [ALC883_LENOVO_101E_2ch] = {
9490 .mixers = { alc883_lenovo_101e_2ch_mixer},
9491 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9492 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9493 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009494 .adc_nids = alc883_adc_nids_alt,
9495 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009496 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009497 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9498 .channel_mode = alc883_3ST_2ch_modes,
9499 .input_mux = &alc883_lenovo_101e_capture_source,
9500 .unsol_event = alc883_lenovo_101e_unsol_event,
9501 .init_hook = alc883_lenovo_101e_all_automute,
9502 },
Kailang Yang272a5272007-05-14 11:00:38 +02009503 [ALC883_LENOVO_NB0763] = {
9504 .mixers = { alc883_lenovo_nb0763_mixer },
9505 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9506 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9507 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009508 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9509 .channel_mode = alc883_3ST_2ch_modes,
9510 .need_dac_fix = 1,
9511 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009512 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009513 .setup = alc883_medion_md2_setup,
9514 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009515 },
9516 [ALC888_LENOVO_MS7195_DIG] = {
9517 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9518 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9519 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9520 .dac_nids = alc883_dac_nids,
9521 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009522 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9523 .channel_mode = alc883_3ST_6ch_modes,
9524 .need_dac_fix = 1,
9525 .input_mux = &alc883_capture_source,
9526 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9527 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009528 },
9529 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009530 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009531 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9532 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9533 .dac_nids = alc883_dac_nids,
9534 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009535 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9536 .channel_mode = alc883_3ST_2ch_modes,
9537 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009538 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009539 .setup = alc883_haier_w66_setup,
9540 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009541 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009542 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009543 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009544 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009545 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9546 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009547 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9548 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009549 .need_dac_fix = 1,
9550 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009551 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009552 .setup = alc888_3st_hp_setup,
9553 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009554 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009555 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009556 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009557 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9558 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9559 .dac_nids = alc883_dac_nids,
9560 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009561 .dig_in_nid = ALC883_DIGIN_NID,
9562 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9563 .channel_mode = alc883_sixstack_modes,
9564 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009565 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009566 .setup = alc888_6st_dell_setup,
9567 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009568 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009569 [ALC883_MITAC] = {
9570 .mixers = { alc883_mitac_mixer },
9571 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9572 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9573 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009574 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9575 .channel_mode = alc883_3ST_2ch_modes,
9576 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009577 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009578 .setup = alc883_mitac_setup,
9579 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009580 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009581 [ALC883_FUJITSU_PI2515] = {
9582 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9583 .init_verbs = { alc883_init_verbs,
9584 alc883_2ch_fujitsu_pi2515_verbs},
9585 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9586 .dac_nids = alc883_dac_nids,
9587 .dig_out_nid = ALC883_DIGOUT_NID,
9588 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9589 .channel_mode = alc883_3ST_2ch_modes,
9590 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009591 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009592 .setup = alc883_2ch_fujitsu_pi2515_setup,
9593 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +01009594 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009595 [ALC888_FUJITSU_XA3530] = {
9596 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9597 .init_verbs = { alc883_init_verbs,
9598 alc888_fujitsu_xa3530_verbs },
9599 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9600 .dac_nids = alc883_dac_nids,
9601 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9602 .adc_nids = alc883_adc_nids_rev,
9603 .capsrc_nids = alc883_capsrc_nids_rev,
9604 .dig_out_nid = ALC883_DIGOUT_NID,
9605 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9606 .channel_mode = alc888_4ST_8ch_intel_modes,
9607 .num_mux_defs =
9608 ARRAY_SIZE(alc888_2_capture_sources),
9609 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009610 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009611 .setup = alc888_fujitsu_xa3530_setup,
9612 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009613 },
Kailang Yange2757d52008-08-26 13:17:46 +02009614 [ALC888_LENOVO_SKY] = {
9615 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9616 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9617 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9618 .dac_nids = alc883_dac_nids,
9619 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009620 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9621 .channel_mode = alc883_sixstack_modes,
9622 .need_dac_fix = 1,
9623 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009624 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009625 .setup = alc888_lenovo_sky_setup,
9626 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +02009627 },
9628 [ALC888_ASUS_M90V] = {
9629 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9630 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9631 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9632 .dac_nids = alc883_dac_nids,
9633 .dig_out_nid = ALC883_DIGOUT_NID,
9634 .dig_in_nid = ALC883_DIGIN_NID,
9635 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9636 .channel_mode = alc883_3ST_6ch_modes,
9637 .need_dac_fix = 1,
9638 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009639 .unsol_event = alc_sku_unsol_event,
9640 .setup = alc883_mode2_setup,
9641 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +02009642 },
9643 [ALC888_ASUS_EEE1601] = {
9644 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009645 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009646 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9647 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9648 .dac_nids = alc883_dac_nids,
9649 .dig_out_nid = ALC883_DIGOUT_NID,
9650 .dig_in_nid = ALC883_DIGIN_NID,
9651 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9652 .channel_mode = alc883_3ST_2ch_modes,
9653 .need_dac_fix = 1,
9654 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009655 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009656 .init_hook = alc883_eee1601_inithook,
9657 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009658 [ALC1200_ASUS_P5Q] = {
9659 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9660 .init_verbs = { alc883_init_verbs },
9661 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9662 .dac_nids = alc883_dac_nids,
9663 .dig_out_nid = ALC1200_DIGOUT_NID,
9664 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009665 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009666 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9667 .channel_mode = alc883_sixstack_modes,
9668 .input_mux = &alc883_capture_source,
9669 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009670 [ALC889A_MB31] = {
9671 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9672 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9673 alc880_gpio1_init_verbs },
9674 .adc_nids = alc883_adc_nids,
9675 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009676 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009677 .dac_nids = alc883_dac_nids,
9678 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9679 .channel_mode = alc889A_mb31_6ch_modes,
9680 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9681 .input_mux = &alc889A_mb31_capture_source,
9682 .dig_out_nid = ALC883_DIGOUT_NID,
9683 .unsol_event = alc889A_mb31_unsol_event,
9684 .init_hook = alc889A_mb31_automute,
9685 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009686 [ALC883_SONY_VAIO_TT] = {
9687 .mixers = { alc883_vaiott_mixer },
9688 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9689 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9690 .dac_nids = alc883_dac_nids,
9691 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9692 .channel_mode = alc883_3ST_2ch_modes,
9693 .input_mux = &alc883_capture_source,
9694 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009695 .setup = alc883_vaiott_setup,
9696 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +02009697 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009698};
9699
9700
9701/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02009702 * Pin config fixes
9703 */
9704enum {
9705 PINFIX_ABIT_AW9D_MAX
9706};
9707
9708static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9709 { 0x15, 0x01080104 }, /* side */
9710 { 0x16, 0x01011012 }, /* rear */
9711 { 0x17, 0x01016011 }, /* clfe */
9712 { }
9713};
9714
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009715static const struct alc_fixup alc882_fixups[] = {
9716 [PINFIX_ABIT_AW9D_MAX] = {
9717 .pins = alc882_abit_aw9d_pinfix
9718 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009719};
9720
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009721static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009722 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9723 {}
9724};
9725
9726/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009727 * BIOS auto configuration
9728 */
Takashi Iwai05f5f472009-08-25 13:10:18 +02009729static int alc882_auto_create_input_ctls(struct hda_codec *codec,
9730 const struct auto_pin_cfg *cfg)
9731{
9732 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
9733}
9734
Takashi Iwai4953550a2009-06-30 15:28:30 +02009735static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009736 hda_nid_t nid, int pin_type,
9737 int dac_idx)
9738{
9739 /* set as output */
9740 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009741 int idx;
9742
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009743 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009744 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9745 idx = 4;
9746 else
9747 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009748 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9749
9750}
9751
Takashi Iwai4953550a2009-06-30 15:28:30 +02009752static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009753{
9754 struct alc_spec *spec = codec->spec;
9755 int i;
9756
9757 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009758 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009759 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009760 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009761 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009762 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009763 }
9764}
9765
Takashi Iwai4953550a2009-06-30 15:28:30 +02009766static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009767{
9768 struct alc_spec *spec = codec->spec;
9769 hda_nid_t pin;
9770
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009771 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009772 if (pin) /* connect to front */
9773 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009774 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009775 pin = spec->autocfg.speaker_pins[0];
9776 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009777 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009778}
9779
Takashi Iwai4953550a2009-06-30 15:28:30 +02009780static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009781{
9782 struct alc_spec *spec = codec->spec;
9783 int i;
9784
9785 for (i = 0; i < AUTO_PIN_LAST; i++) {
9786 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +02009787 if (!nid)
9788 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +02009789 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009790 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9791 snd_hda_codec_write(codec, nid, 0,
9792 AC_VERB_SET_AMP_GAIN_MUTE,
9793 AMP_OUT_MUTE);
9794 }
9795}
9796
9797static void alc882_auto_init_input_src(struct hda_codec *codec)
9798{
9799 struct alc_spec *spec = codec->spec;
9800 int c;
9801
9802 for (c = 0; c < spec->num_adc_nids; c++) {
9803 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9804 hda_nid_t nid = spec->capsrc_nids[c];
9805 unsigned int mux_idx;
9806 const struct hda_input_mux *imux;
9807 int conns, mute, idx, item;
9808
9809 conns = snd_hda_get_connections(codec, nid, conn_list,
9810 ARRAY_SIZE(conn_list));
9811 if (conns < 0)
9812 continue;
9813 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9814 imux = &spec->input_mux[mux_idx];
9815 for (idx = 0; idx < conns; idx++) {
9816 /* if the current connection is the selected one,
9817 * unmute it as default - otherwise mute it
9818 */
9819 mute = AMP_IN_MUTE(idx);
9820 for (item = 0; item < imux->num_items; item++) {
9821 if (imux->items[item].index == idx) {
9822 if (spec->cur_mux[c] == item)
9823 mute = AMP_IN_UNMUTE(idx);
9824 break;
9825 }
9826 }
9827 /* check if we have a selector or mixer
9828 * we could check for the widget type instead, but
9829 * just check for Amp-In presence (in case of mixer
9830 * without amp-in there is something wrong, this
9831 * function shouldn't be used or capsrc nid is wrong)
9832 */
9833 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009834 snd_hda_codec_write(codec, nid, 0,
9835 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009836 mute);
9837 else if (mute != AMP_IN_MUTE(idx))
9838 snd_hda_codec_write(codec, nid, 0,
9839 AC_VERB_SET_CONNECT_SEL,
9840 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009841 }
9842 }
9843}
9844
Takashi Iwai4953550a2009-06-30 15:28:30 +02009845/* add mic boosts if needed */
9846static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009847{
9848 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009849 int err;
9850 hda_nid_t nid;
9851
9852 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9853 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9854 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9855 "Mic Boost",
9856 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9857 if (err < 0)
9858 return err;
9859 }
9860 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9861 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9862 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9863 "Front Mic Boost",
9864 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9865 if (err < 0)
9866 return err;
9867 }
9868 return 0;
9869}
9870
9871/* almost identical with ALC880 parser... */
9872static int alc882_parse_auto_config(struct hda_codec *codec)
9873{
9874 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009875 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
9876 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009877
Takashi Iwai05f5f472009-08-25 13:10:18 +02009878 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9879 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009880 if (err < 0)
9881 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009882 if (!spec->autocfg.line_outs)
9883 return 0; /* can't find valid BIOS pin config */
9884
9885 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
9886 if (err < 0)
9887 return err;
9888 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
9889 if (err < 0)
9890 return err;
9891 err = alc880_auto_create_extra_out(spec,
9892 spec->autocfg.speaker_pins[0],
9893 "Speaker");
9894 if (err < 0)
9895 return err;
9896 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
9897 "Headphone");
9898 if (err < 0)
9899 return err;
9900 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
9901 if (err < 0)
9902 return err;
9903
9904 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9905
9906 /* check multiple SPDIF-out (for recent codecs) */
9907 for (i = 0; i < spec->autocfg.dig_outs; i++) {
9908 hda_nid_t dig_nid;
9909 err = snd_hda_get_connections(codec,
9910 spec->autocfg.dig_out_pins[i],
9911 &dig_nid, 1);
9912 if (err < 0)
9913 continue;
9914 if (!i)
9915 spec->multiout.dig_out_nid = dig_nid;
9916 else {
9917 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01009918 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai05f5f472009-08-25 13:10:18 +02009919 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01009920 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009921 }
9922 }
9923 if (spec->autocfg.dig_in_pin)
9924 spec->dig_in_nid = ALC880_DIGIN_NID;
9925
9926 if (spec->kctls.list)
9927 add_mixer(spec, spec->kctls.list);
9928
9929 add_verb(spec, alc883_auto_init_verbs);
9930 /* if ADC 0x07 is available, initialize it, too */
9931 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
9932 add_verb(spec, alc882_adc1_init_verbs);
9933
9934 spec->num_mux_defs = 1;
9935 spec->input_mux = &spec->private_imux[0];
9936
9937 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
Takashi Iwai776e1842007-08-29 15:07:11 +02009938
9939 err = alc_auto_add_mic_boost(codec);
9940 if (err < 0)
9941 return err;
9942
Takashi Iwai776e1842007-08-29 15:07:11 +02009943 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009944}
9945
9946/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009947static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009948{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009949 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009950 alc882_auto_init_multi_out(codec);
9951 alc882_auto_init_hp_out(codec);
9952 alc882_auto_init_analog_input(codec);
9953 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009954 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009955 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009956}
9957
Takashi Iwai4953550a2009-06-30 15:28:30 +02009958static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009959{
9960 struct alc_spec *spec;
9961 int err, board_config;
9962
9963 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9964 if (spec == NULL)
9965 return -ENOMEM;
9966
9967 codec->spec = spec;
9968
Takashi Iwai4953550a2009-06-30 15:28:30 +02009969 switch (codec->vendor_id) {
9970 case 0x10ec0882:
9971 case 0x10ec0885:
9972 break;
9973 default:
9974 /* ALC883 and variants */
9975 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9976 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009977 }
9978
Takashi Iwai4953550a2009-06-30 15:28:30 +02009979 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
9980 alc882_models,
9981 alc882_cfg_tbl);
9982
9983 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
9984 board_config = snd_hda_check_board_codec_sid_config(codec,
9985 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
9986
9987 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02009988 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009989 codec->chip_name);
9990 board_config = ALC882_AUTO;
9991 }
9992
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009993 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009994
9995 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009996 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009997 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009998 if (err < 0) {
9999 alc_free(codec);
10000 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010001 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010002 printk(KERN_INFO
10003 "hda_codec: Cannot set up configuration "
10004 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010005 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010006 }
10007 }
10008
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010009 err = snd_hda_attach_beep_device(codec, 0x1);
10010 if (err < 0) {
10011 alc_free(codec);
10012 return err;
10013 }
10014
Takashi Iwai4953550a2009-06-30 15:28:30 +020010015 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010016 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010017
Takashi Iwai4953550a2009-06-30 15:28:30 +020010018 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10019 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10020 /* FIXME: setup DAC5 */
10021 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10022 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10023
10024 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10025 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10026
10027 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010028 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010029
10030 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010031 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010032 spec->num_adc_nids = 0;
10033 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010034 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010035 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010036 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010037 hda_nid_t nid = alc882_adc_nids[i];
10038 unsigned int wcap = get_wcaps(codec, nid);
10039 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010040 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010041 if (wcap != AC_WID_AUD_IN)
10042 continue;
10043 spec->private_adc_nids[spec->num_adc_nids] = nid;
10044 err = snd_hda_get_connections(codec, nid, &cap, 1);
10045 if (err < 0)
10046 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010047 err = snd_hda_get_connections(codec, cap, items,
10048 ARRAY_SIZE(items));
10049 if (err < 0)
10050 continue;
10051 for (j = 0; j < imux->num_items; j++)
10052 if (imux->items[j].index >= err)
10053 break;
10054 if (j < imux->num_items)
10055 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010056 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10057 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010058 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010059 spec->adc_nids = spec->private_adc_nids;
10060 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010061 }
10062
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010063 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010010064 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010065
Takashi Iwai2134ea42008-01-10 16:53:55 +010010066 spec->vmaster_nid = 0x0c;
10067
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010068 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010069 if (board_config == ALC882_AUTO)
10070 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010071#ifdef CONFIG_SND_HDA_POWER_SAVE
10072 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010073 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010074#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010010075 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010076
10077 return 0;
10078}
10079
Takashi Iwai4953550a2009-06-30 15:28:30 +020010080
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010081/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010082 * ALC262 support
10083 */
10084
10085#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10086#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10087
10088#define alc262_dac_nids alc260_dac_nids
10089#define alc262_adc_nids alc882_adc_nids
10090#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010091#define alc262_capsrc_nids alc882_capsrc_nids
10092#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010093
10094#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010095#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010096
Kailang Yang4e555fe2008-08-26 13:05:55 +020010097static hda_nid_t alc262_dmic_adc_nids[1] = {
10098 /* ADC0 */
10099 0x09
10100};
10101
10102static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10103
Kailang Yangdf694da2005-12-05 19:42:22 +010010104static struct snd_kcontrol_new alc262_base_mixer[] = {
10105 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10106 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10107 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10108 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10109 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10110 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10111 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10112 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010113 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010114 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10115 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010116 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010117 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10118 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10119 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10120 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010121 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010122};
10123
Takashi Iwaice875f02008-01-28 18:17:43 +010010124/* update HP, line and mono-out pins according to the master switch */
10125static void alc262_hp_master_update(struct hda_codec *codec)
10126{
10127 struct alc_spec *spec = codec->spec;
10128 int val = spec->master_sw;
10129
10130 /* HP & line-out */
10131 snd_hda_codec_write_cache(codec, 0x1b, 0,
10132 AC_VERB_SET_PIN_WIDGET_CONTROL,
10133 val ? PIN_HP : 0);
10134 snd_hda_codec_write_cache(codec, 0x15, 0,
10135 AC_VERB_SET_PIN_WIDGET_CONTROL,
10136 val ? PIN_HP : 0);
10137 /* mono (speaker) depending on the HP jack sense */
10138 val = val && !spec->jack_present;
10139 snd_hda_codec_write_cache(codec, 0x16, 0,
10140 AC_VERB_SET_PIN_WIDGET_CONTROL,
10141 val ? PIN_OUT : 0);
10142}
10143
10144static void alc262_hp_bpc_automute(struct hda_codec *codec)
10145{
10146 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010147
10148 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010149 alc262_hp_master_update(codec);
10150}
10151
10152static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10153{
10154 if ((res >> 26) != ALC880_HP_EVENT)
10155 return;
10156 alc262_hp_bpc_automute(codec);
10157}
10158
10159static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10160{
10161 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010162
10163 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010164 alc262_hp_master_update(codec);
10165}
10166
10167static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10168 unsigned int res)
10169{
10170 if ((res >> 26) != ALC880_HP_EVENT)
10171 return;
10172 alc262_hp_wildwest_automute(codec);
10173}
10174
Takashi Iwaib72519b2009-05-08 14:31:55 +020010175#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010176
10177static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10178 struct snd_ctl_elem_value *ucontrol)
10179{
10180 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10181 struct alc_spec *spec = codec->spec;
10182 int val = !!*ucontrol->value.integer.value;
10183
10184 if (val == spec->master_sw)
10185 return 0;
10186 spec->master_sw = val;
10187 alc262_hp_master_update(codec);
10188 return 1;
10189}
10190
Takashi Iwaib72519b2009-05-08 14:31:55 +020010191#define ALC262_HP_MASTER_SWITCH \
10192 { \
10193 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10194 .name = "Master Playback Switch", \
10195 .info = snd_ctl_boolean_mono_info, \
10196 .get = alc262_hp_master_sw_get, \
10197 .put = alc262_hp_master_sw_put, \
10198 }
10199
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010200static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010201 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010202 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10203 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10204 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010205 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10206 HDA_OUTPUT),
10207 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10208 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010209 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10210 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010211 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010212 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10213 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010214 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010215 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10216 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10217 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10218 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010219 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10220 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10221 { } /* end */
10222};
10223
Kailang Yangcd7509a2007-01-26 18:33:17 +010010224static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010225 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010226 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10227 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10228 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10229 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010230 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10231 HDA_OUTPUT),
10232 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10233 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010234 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10235 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010236 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010237 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10238 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10239 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10240 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010241 { } /* end */
10242};
10243
10244static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10245 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10246 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010247 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010248 { } /* end */
10249};
10250
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010251/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010252static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010253{
10254 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010255
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010256 spec->autocfg.hp_pins[0] = 0x15;
10257 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010258}
10259
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010260static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010261 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10262 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010263 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10264 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10265 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10266 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10267 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10268 { } /* end */
10269};
10270
10271static struct hda_verb alc262_hp_t5735_verbs[] = {
10272 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10273 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10274
10275 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10276 { }
10277};
10278
Kailang Yang8c427222008-01-10 13:03:59 +010010279static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010280 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10281 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010282 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10283 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010284 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10285 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10286 { } /* end */
10287};
10288
10289static struct hda_verb alc262_hp_rp5700_verbs[] = {
10290 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10291 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10292 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10293 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10294 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10295 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10296 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10297 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10298 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10299 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10300 {}
10301};
10302
10303static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10304 .num_items = 1,
10305 .items = {
10306 { "Line", 0x1 },
10307 },
10308};
10309
Takashi Iwai42171c12009-05-08 14:11:43 +020010310/* bind hp and internal speaker mute (with plug check) as master switch */
10311static void alc262_hippo_master_update(struct hda_codec *codec)
10312{
10313 struct alc_spec *spec = codec->spec;
10314 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10315 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10316 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10317 unsigned int mute;
10318
10319 /* HP */
10320 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10321 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10322 HDA_AMP_MUTE, mute);
10323 /* mute internal speaker per jack sense */
10324 if (spec->jack_present)
10325 mute = HDA_AMP_MUTE;
10326 if (line_nid)
10327 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10328 HDA_AMP_MUTE, mute);
10329 if (speaker_nid && speaker_nid != line_nid)
10330 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10331 HDA_AMP_MUTE, mute);
10332}
10333
10334#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10335
10336static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10337 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010338{
10339 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010340 struct alc_spec *spec = codec->spec;
10341 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010342
Takashi Iwai42171c12009-05-08 14:11:43 +020010343 if (val == spec->master_sw)
10344 return 0;
10345 spec->master_sw = val;
10346 alc262_hippo_master_update(codec);
10347 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010348}
Takashi Iwai5b319542007-07-26 11:49:22 +020010349
Takashi Iwai42171c12009-05-08 14:11:43 +020010350#define ALC262_HIPPO_MASTER_SWITCH \
10351 { \
10352 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10353 .name = "Master Playback Switch", \
10354 .info = snd_ctl_boolean_mono_info, \
10355 .get = alc262_hippo_master_sw_get, \
10356 .put = alc262_hippo_master_sw_put, \
10357 }
10358
10359static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10360 ALC262_HIPPO_MASTER_SWITCH,
10361 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10362 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10363 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10364 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10365 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10366 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10367 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10368 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10369 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10370 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10371 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10372 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10373 { } /* end */
10374};
10375
10376static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10377 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10378 ALC262_HIPPO_MASTER_SWITCH,
10379 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10380 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10381 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10382 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10383 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10384 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10385 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10386 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10387 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10388 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10389 { } /* end */
10390};
10391
10392/* mute/unmute internal speaker according to the hp jack and mute state */
10393static void alc262_hippo_automute(struct hda_codec *codec)
10394{
10395 struct alc_spec *spec = codec->spec;
10396 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020010397
Wu Fengguang864f92b2009-11-18 12:38:02 +080010398 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020010399 alc262_hippo_master_update(codec);
10400}
10401
10402static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10403{
10404 if ((res >> 26) != ALC880_HP_EVENT)
10405 return;
10406 alc262_hippo_automute(codec);
10407}
10408
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010409static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010410{
10411 struct alc_spec *spec = codec->spec;
10412
10413 spec->autocfg.hp_pins[0] = 0x15;
10414 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010415}
10416
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010417static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010418{
10419 struct alc_spec *spec = codec->spec;
10420
10421 spec->autocfg.hp_pins[0] = 0x1b;
10422 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010423}
10424
10425
Kailang Yang272a5272007-05-14 11:00:38 +020010426static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010427 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010428 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010429 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10430 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10431 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10432 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10433 { } /* end */
10434};
10435
Kailang Yang83c34212007-07-05 11:43:05 +020010436static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010437 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10438 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010439 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10440 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10441 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10442 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10443 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10444 { } /* end */
10445};
Kailang Yang272a5272007-05-14 11:00:38 +020010446
Tony Vroonba340e82009-02-02 19:01:30 +000010447static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10448 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10449 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10450 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10451 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10452 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10453 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10454 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10455 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10456 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10457 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10458 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10459 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10460 { } /* end */
10461};
10462
10463static struct hda_verb alc262_tyan_verbs[] = {
10464 /* Headphone automute */
10465 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10466 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10467 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10468
10469 /* P11 AUX_IN, white 4-pin connector */
10470 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10471 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10472 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10473 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10474
10475 {}
10476};
10477
10478/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010479static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010480{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010481 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010482
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010483 spec->autocfg.hp_pins[0] = 0x1b;
10484 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010485}
10486
Tony Vroonba340e82009-02-02 19:01:30 +000010487
Kailang Yangdf694da2005-12-05 19:42:22 +010010488#define alc262_capture_mixer alc882_capture_mixer
10489#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10490
10491/*
10492 * generic initialization of ADC, input mixers and output mixers
10493 */
10494static struct hda_verb alc262_init_verbs[] = {
10495 /*
10496 * Unmute ADC0-2 and set the default input to mic-in
10497 */
10498 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10499 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10500 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10501 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10502 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10503 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10504
Takashi Iwaicb53c622007-08-10 17:21:45 +020010505 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010506 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010507 * Note: PASD motherboards uses the Line In 2 as the input for
10508 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010509 */
10510 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010511 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10512 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10513 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10514 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10515 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010516
10517 /*
10518 * Set up output mixers (0x0c - 0x0e)
10519 */
10520 /* set vol=0 to output mixers */
10521 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10522 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10523 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10524 /* set up input amps for analog loopback */
10525 /* Amp Indices: DAC = 0, mixer = 1 */
10526 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10527 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10528 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10529 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10530 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10531 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10532
10533 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10534 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10535 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10536 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10537 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10538 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10539
10540 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10541 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10542 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10543 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10544 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010545
Kailang Yangdf694da2005-12-05 19:42:22 +010010546 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10547 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010548
Kailang Yangdf694da2005-12-05 19:42:22 +010010549 /* FIXME: use matrix-type input source selection */
10550 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10551 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10552 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10553 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10554 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10555 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10556 /* Input mixer2 */
10557 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10558 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10559 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10560 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10561 /* Input mixer3 */
10562 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10563 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10564 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010565 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010566
10567 { }
10568};
10569
Kailang Yang4e555fe2008-08-26 13:05:55 +020010570static struct hda_verb alc262_eapd_verbs[] = {
10571 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10572 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10573 { }
10574};
10575
Kailang Yangccc656c2006-10-17 12:32:26 +020010576static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10577 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10578 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10579 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10580
10581 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10582 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10583 {}
10584};
10585
Kailang Yang272a5272007-05-14 11:00:38 +020010586static struct hda_verb alc262_sony_unsol_verbs[] = {
10587 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10588 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10589 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10590
10591 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10592 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010593 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010594};
10595
Kailang Yang4e555fe2008-08-26 13:05:55 +020010596static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10597 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10598 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10599 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10600 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10601 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010602 { } /* end */
10603};
10604
10605static struct hda_verb alc262_toshiba_s06_verbs[] = {
10606 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10607 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10608 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10609 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10610 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10611 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10612 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10613 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10614 {}
10615};
10616
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010617static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020010618{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010619 struct alc_spec *spec = codec->spec;
10620
10621 spec->autocfg.hp_pins[0] = 0x15;
10622 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010623 spec->ext_mic.pin = 0x18;
10624 spec->ext_mic.mux_idx = 0;
10625 spec->int_mic.pin = 0x12;
10626 spec->int_mic.mux_idx = 9;
10627 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020010628}
10629
Takashi Iwai834be882006-03-01 14:16:17 +010010630/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010631 * nec model
10632 * 0x15 = headphone
10633 * 0x16 = internal speaker
10634 * 0x18 = external mic
10635 */
10636
10637static struct snd_kcontrol_new alc262_nec_mixer[] = {
10638 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10639 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10640
10641 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10642 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10643 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10644
10645 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10646 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10647 { } /* end */
10648};
10649
10650static struct hda_verb alc262_nec_verbs[] = {
10651 /* Unmute Speaker */
10652 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10653
10654 /* Headphone */
10655 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10656 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10657
10658 /* External mic to headphone */
10659 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10660 /* External mic to speaker */
10661 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10662 {}
10663};
10664
10665/*
Takashi Iwai834be882006-03-01 14:16:17 +010010666 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010667 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10668 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010669 */
10670
10671#define ALC_HP_EVENT 0x37
10672
10673static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10674 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10675 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010676 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10677 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010678 {}
10679};
10680
Jiang zhe0e31daf2008-03-20 12:12:39 +010010681static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10682 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10683 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10684 {}
10685};
10686
Daniel T Chene2595322009-12-19 18:19:02 -050010687static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
10688 /* Front Mic pin: input vref at 50% */
10689 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10690 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10691 {}
10692};
10693
Takashi Iwai834be882006-03-01 14:16:17 +010010694static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010695 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010696 .items = {
10697 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010698 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010699 { "CD", 0x4 },
10700 },
10701};
10702
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010703static struct hda_input_mux alc262_HP_capture_source = {
10704 .num_items = 5,
10705 .items = {
10706 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010707 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010708 { "Line", 0x2 },
10709 { "CD", 0x4 },
10710 { "AUX IN", 0x6 },
10711 },
10712};
10713
zhejiangaccbe492007-08-31 12:36:05 +020010714static struct hda_input_mux alc262_HP_D7000_capture_source = {
10715 .num_items = 4,
10716 .items = {
10717 { "Mic", 0x0 },
10718 { "Front Mic", 0x2 },
10719 { "Line", 0x1 },
10720 { "CD", 0x4 },
10721 },
10722};
10723
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010724/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010725static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10726{
10727 struct alc_spec *spec = codec->spec;
10728 unsigned int mute;
10729
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010730 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080010731 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
10732 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010010733 spec->sense_updated = 1;
10734 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010735 /* unmute internal speaker only if both HPs are unplugged and
10736 * master switch is on
10737 */
10738 if (spec->jack_present)
10739 mute = HDA_AMP_MUTE;
10740 else
Takashi Iwai834be882006-03-01 14:16:17 +010010741 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010742 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10743 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010744}
10745
10746/* unsolicited event for HP jack sensing */
10747static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10748 unsigned int res)
10749{
10750 if ((res >> 26) != ALC_HP_EVENT)
10751 return;
10752 alc262_fujitsu_automute(codec, 1);
10753}
10754
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010755static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10756{
10757 alc262_fujitsu_automute(codec, 1);
10758}
10759
Takashi Iwai834be882006-03-01 14:16:17 +010010760/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010761static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10762 .ops = &snd_hda_bind_vol,
10763 .values = {
10764 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10765 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10766 0
10767 },
10768};
Takashi Iwai834be882006-03-01 14:16:17 +010010769
Jiang zhe0e31daf2008-03-20 12:12:39 +010010770/* mute/unmute internal speaker according to the hp jack and mute state */
10771static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10772{
10773 struct alc_spec *spec = codec->spec;
10774 unsigned int mute;
10775
10776 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080010777 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010778 spec->sense_updated = 1;
10779 }
10780 if (spec->jack_present) {
10781 /* mute internal speaker */
10782 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10783 HDA_AMP_MUTE, HDA_AMP_MUTE);
10784 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10785 HDA_AMP_MUTE, HDA_AMP_MUTE);
10786 } else {
10787 /* unmute internal speaker if necessary */
10788 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10789 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10790 HDA_AMP_MUTE, mute);
10791 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10792 HDA_AMP_MUTE, mute);
10793 }
10794}
10795
10796/* unsolicited event for HP jack sensing */
10797static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10798 unsigned int res)
10799{
10800 if ((res >> 26) != ALC_HP_EVENT)
10801 return;
10802 alc262_lenovo_3000_automute(codec, 1);
10803}
10804
Takashi Iwai8de56b72009-07-24 16:51:47 +020010805static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10806 int dir, int idx, long *valp)
10807{
10808 int i, change = 0;
10809
10810 for (i = 0; i < 2; i++, valp++)
10811 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10812 HDA_AMP_MUTE,
10813 *valp ? 0 : HDA_AMP_MUTE);
10814 return change;
10815}
10816
Takashi Iwai834be882006-03-01 14:16:17 +010010817/* bind hp and internal speaker mute (with plug check) */
10818static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10819 struct snd_ctl_elem_value *ucontrol)
10820{
10821 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10822 long *valp = ucontrol->value.integer.value;
10823 int change;
10824
Takashi Iwai8de56b72009-07-24 16:51:47 +020010825 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10826 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010827 if (change)
10828 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010829 return change;
10830}
10831
10832static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010833 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010834 {
10835 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10836 .name = "Master Playback Switch",
10837 .info = snd_hda_mixer_amp_switch_info,
10838 .get = snd_hda_mixer_amp_switch_get,
10839 .put = alc262_fujitsu_master_sw_put,
10840 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10841 },
10842 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10843 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10844 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10845 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10846 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010847 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10848 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10849 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010850 { } /* end */
10851};
10852
Jiang zhe0e31daf2008-03-20 12:12:39 +010010853/* bind hp and internal speaker mute (with plug check) */
10854static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10855 struct snd_ctl_elem_value *ucontrol)
10856{
10857 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10858 long *valp = ucontrol->value.integer.value;
10859 int change;
10860
Takashi Iwai8de56b72009-07-24 16:51:47 +020010861 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010862 if (change)
10863 alc262_lenovo_3000_automute(codec, 0);
10864 return change;
10865}
10866
10867static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10868 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10869 {
10870 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10871 .name = "Master Playback Switch",
10872 .info = snd_hda_mixer_amp_switch_info,
10873 .get = snd_hda_mixer_amp_switch_get,
10874 .put = alc262_lenovo_3000_master_sw_put,
10875 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10876 },
10877 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10878 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10879 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10880 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10881 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10882 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10883 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10884 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10885 { } /* end */
10886};
10887
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010888static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10889 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010890 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010891 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10892 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10893 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10894 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10895 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10896 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10897 { } /* end */
10898};
10899
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010900/* additional init verbs for Benq laptops */
10901static struct hda_verb alc262_EAPD_verbs[] = {
10902 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10903 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10904 {}
10905};
10906
Kailang Yang83c34212007-07-05 11:43:05 +020010907static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10908 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10909 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10910
10911 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10912 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10913 {}
10914};
10915
Tobin Davisf651b502007-10-26 12:40:47 +020010916/* Samsung Q1 Ultra Vista model setup */
10917static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010918 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10919 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010920 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10921 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10922 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010923 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010924 { } /* end */
10925};
10926
10927static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010928 /* output mixer */
10929 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10930 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10931 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10932 /* speaker */
10933 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10934 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10935 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10936 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10937 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010938 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010939 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10940 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10941 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10942 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10943 /* internal mic */
10944 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10945 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10946 /* ADC, choose mic */
10947 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10948 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10949 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10950 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10951 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10952 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10953 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10954 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10955 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10956 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010957 {}
10958};
10959
Tobin Davisf651b502007-10-26 12:40:47 +020010960/* mute/unmute internal speaker according to the hp jack and mute state */
10961static void alc262_ultra_automute(struct hda_codec *codec)
10962{
10963 struct alc_spec *spec = codec->spec;
10964 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010965
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010966 mute = 0;
10967 /* auto-mute only when HP is used as HP */
10968 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080010969 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010970 if (spec->jack_present)
10971 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010972 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010973 /* mute/unmute internal speaker */
10974 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10975 HDA_AMP_MUTE, mute);
10976 /* mute/unmute HP */
10977 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10978 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010979}
10980
10981/* unsolicited event for HP jack sensing */
10982static void alc262_ultra_unsol_event(struct hda_codec *codec,
10983 unsigned int res)
10984{
10985 if ((res >> 26) != ALC880_HP_EVENT)
10986 return;
10987 alc262_ultra_automute(codec);
10988}
10989
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010990static struct hda_input_mux alc262_ultra_capture_source = {
10991 .num_items = 2,
10992 .items = {
10993 { "Mic", 0x1 },
10994 { "Headphone", 0x7 },
10995 },
10996};
10997
10998static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10999 struct snd_ctl_elem_value *ucontrol)
11000{
11001 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11002 struct alc_spec *spec = codec->spec;
11003 int ret;
11004
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011005 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011006 if (!ret)
11007 return 0;
11008 /* reprogram the HP pin as mic or HP according to the input source */
11009 snd_hda_codec_write_cache(codec, 0x15, 0,
11010 AC_VERB_SET_PIN_WIDGET_CONTROL,
11011 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11012 alc262_ultra_automute(codec); /* mute/unmute HP */
11013 return ret;
11014}
11015
11016static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11017 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11018 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11019 {
11020 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11021 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011022 .info = alc_mux_enum_info,
11023 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011024 .put = alc262_ultra_mux_enum_put,
11025 },
11026 { } /* end */
11027};
11028
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011029/* We use two mixers depending on the output pin; 0x16 is a mono output
11030 * and thus it's bound with a different mixer.
11031 * This function returns which mixer amp should be used.
11032 */
11033static int alc262_check_volbit(hda_nid_t nid)
11034{
11035 if (!nid)
11036 return 0;
11037 else if (nid == 0x16)
11038 return 2;
11039 else
11040 return 1;
11041}
11042
11043static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
11044 const char *pfx, int *vbits)
11045{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011046 unsigned long val;
11047 int vbit;
11048
11049 vbit = alc262_check_volbit(nid);
11050 if (!vbit)
11051 return 0;
11052 if (*vbits & vbit) /* a volume control for this mixer already there */
11053 return 0;
11054 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011055 if (vbit == 2)
11056 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11057 else
11058 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011059 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011060}
11061
11062static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
11063 const char *pfx)
11064{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011065 unsigned long val;
11066
11067 if (!nid)
11068 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011069 if (nid == 0x16)
11070 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11071 else
11072 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011073 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011074}
11075
Kailang Yangdf694da2005-12-05 19:42:22 +010011076/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011077static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11078 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011079{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011080 const char *pfx;
11081 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010011082 int err;
11083
11084 spec->multiout.num_dacs = 1; /* only use one dac */
11085 spec->multiout.dac_nids = spec->private_dac_nids;
11086 spec->multiout.dac_nids[0] = 2;
11087
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011088 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11089 pfx = "Master";
11090 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11091 pfx = "Speaker";
11092 else
11093 pfx = "Front";
11094 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11095 if (err < 0)
11096 return err;
11097 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11098 if (err < 0)
11099 return err;
11100 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11101 if (err < 0)
11102 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011103
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011104 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11105 alc262_check_volbit(cfg->speaker_pins[0]) |
11106 alc262_check_volbit(cfg->hp_pins[0]);
11107 if (vbits == 1 || vbits == 2)
11108 pfx = "Master"; /* only one mixer is used */
11109 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11110 pfx = "Speaker";
11111 else
11112 pfx = "Front";
11113 vbits = 0;
11114 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11115 if (err < 0)
11116 return err;
11117 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11118 &vbits);
11119 if (err < 0)
11120 return err;
11121 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11122 &vbits);
11123 if (err < 0)
11124 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011125 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011126}
11127
Takashi Iwai05f5f472009-08-25 13:10:18 +020011128#define alc262_auto_create_input_ctls \
11129 alc880_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011130
11131/*
11132 * generic initialization of ADC, input mixers and output mixers
11133 */
11134static struct hda_verb alc262_volume_init_verbs[] = {
11135 /*
11136 * Unmute ADC0-2 and set the default input to mic-in
11137 */
11138 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11139 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11140 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11141 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11142 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11143 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11144
Takashi Iwaicb53c622007-08-10 17:21:45 +020011145 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011146 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011147 * Note: PASD motherboards uses the Line In 2 as the input for
11148 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011149 */
11150 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011151 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11152 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11153 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11154 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11155 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011156
11157 /*
11158 * Set up output mixers (0x0c - 0x0f)
11159 */
11160 /* set vol=0 to output mixers */
11161 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11162 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11163 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011164
Kailang Yangdf694da2005-12-05 19:42:22 +010011165 /* set up input amps for analog loopback */
11166 /* Amp Indices: DAC = 0, mixer = 1 */
11167 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11168 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11169 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11170 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11171 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11172 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11173
11174 /* FIXME: use matrix-type input source selection */
11175 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11176 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11177 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11178 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11179 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11180 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11181 /* Input mixer2 */
11182 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11183 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11184 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11185 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11186 /* Input mixer3 */
11187 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11188 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11189 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11190 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11191
11192 { }
11193};
11194
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011195static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11196 /*
11197 * Unmute ADC0-2 and set the default input to mic-in
11198 */
11199 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11200 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11201 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11202 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11203 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11204 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11205
Takashi Iwaicb53c622007-08-10 17:21:45 +020011206 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011207 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011208 * Note: PASD motherboards uses the Line In 2 as the input for
11209 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011210 */
11211 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011212 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11213 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11214 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11215 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11216 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11217 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11218 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011219
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011220 /*
11221 * Set up output mixers (0x0c - 0x0e)
11222 */
11223 /* set vol=0 to output mixers */
11224 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11225 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11226 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11227
11228 /* set up input amps for analog loopback */
11229 /* Amp Indices: DAC = 0, mixer = 1 */
11230 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11231 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11232 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11233 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11234 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11235 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11236
Takashi Iwaice875f02008-01-28 18:17:43 +010011237 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011238 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11239 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11240
11241 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11242 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11243
11244 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11245 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11246
11247 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11248 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11249 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11250 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11251 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11252
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011253 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011254 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11255 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011256 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011257 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11258 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11259
11260
11261 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011262 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11263 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011264 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011265 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11266 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11267 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11268 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11269 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11270 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11271 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11272 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011273 /* Input mixer2 */
11274 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011275 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11276 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11277 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11278 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11279 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11280 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11281 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11282 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011283 /* Input mixer3 */
11284 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011285 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11288 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11289 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11290 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11291 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11292 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011293
Takashi Iwaice875f02008-01-28 18:17:43 +010011294 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11295
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011296 { }
11297};
11298
Kailang Yangcd7509a2007-01-26 18:33:17 +010011299static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11300 /*
11301 * Unmute ADC0-2 and set the default input to mic-in
11302 */
11303 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11304 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11305 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11306 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11307 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11308 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11309
Takashi Iwaicb53c622007-08-10 17:21:45 +020011310 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011311 * mixer widget
11312 * Note: PASD motherboards uses the Line In 2 as the input for front
11313 * panel mic (mic 2)
11314 */
11315 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011316 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11317 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11318 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11319 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11320 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11321 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11322 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11323 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011324 /*
11325 * Set up output mixers (0x0c - 0x0e)
11326 */
11327 /* set vol=0 to output mixers */
11328 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11329 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11330 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11331
11332 /* set up input amps for analog loopback */
11333 /* Amp Indices: DAC = 0, mixer = 1 */
11334 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11335 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11336 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11337 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11338 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11339 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11340
11341
11342 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11343 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11344 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11345 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11346 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11347 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11348 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11349
11350 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11351 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11352
11353 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11354 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11355
11356 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11357 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11358 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11359 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11360 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11361 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11362
11363 /* FIXME: use matrix-type input source selection */
11364 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11365 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11366 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11367 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11368 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11369 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11370 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11371 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11372 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11373 /* Input mixer2 */
11374 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11375 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11376 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11377 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11378 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11379 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11380 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11381 /* Input mixer3 */
11382 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11383 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11384 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11385 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11386 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11387 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11388 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11389
Takashi Iwaice875f02008-01-28 18:17:43 +010011390 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11391
Kailang Yangcd7509a2007-01-26 18:33:17 +010011392 { }
11393};
11394
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011395static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11396
11397 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11398 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11399 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11400
11401 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11402 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11403 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11404 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11405
11406 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11407 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11408 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11409 {}
11410};
11411
11412
Takashi Iwaicb53c622007-08-10 17:21:45 +020011413#ifdef CONFIG_SND_HDA_POWER_SAVE
11414#define alc262_loopbacks alc880_loopbacks
11415#endif
11416
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011417/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011418#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11419#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11420#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11421#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11422
11423/*
11424 * BIOS auto configuration
11425 */
11426static int alc262_parse_auto_config(struct hda_codec *codec)
11427{
11428 struct alc_spec *spec = codec->spec;
11429 int err;
11430 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11431
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011432 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11433 alc262_ignore);
11434 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011435 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011436 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011437 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011438 spec->multiout.max_channels = 2;
11439 spec->no_analog = 1;
11440 goto dig_only;
11441 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011442 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011443 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011444 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11445 if (err < 0)
11446 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011447 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011448 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011449 return err;
11450
11451 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11452
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011453 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011454 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011455 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011456 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011457 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011458 if (spec->autocfg.dig_in_pin)
11459 spec->dig_in_nid = ALC262_DIGIN_NID;
11460
Takashi Iwai603c4012008-07-30 15:01:44 +020011461 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011462 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011463
Takashi Iwaid88897e2008-10-31 15:01:37 +010011464 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011465 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011466 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011467
Takashi Iwai776e1842007-08-29 15:07:11 +020011468 err = alc_auto_add_mic_boost(codec);
11469 if (err < 0)
11470 return err;
11471
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011472 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11473
Kailang Yangdf694da2005-12-05 19:42:22 +010011474 return 1;
11475}
11476
11477#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11478#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11479#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011480#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011481
11482
11483/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011484static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011485{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011486 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011487 alc262_auto_init_multi_out(codec);
11488 alc262_auto_init_hp_out(codec);
11489 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011490 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011491 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011492 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011493}
11494
11495/*
11496 * configuration and preset
11497 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011498static const char *alc262_models[ALC262_MODEL_LAST] = {
11499 [ALC262_BASIC] = "basic",
11500 [ALC262_HIPPO] = "hippo",
11501 [ALC262_HIPPO_1] = "hippo_1",
11502 [ALC262_FUJITSU] = "fujitsu",
11503 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011504 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011505 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011506 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011507 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011508 [ALC262_BENQ_T31] = "benq-t31",
11509 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011510 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011511 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011512 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011513 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011514 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011515 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011516 [ALC262_AUTO] = "auto",
11517};
11518
11519static struct snd_pci_quirk alc262_cfg_tbl[] = {
11520 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011521 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011522 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11523 ALC262_HP_BPC),
11524 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11525 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011526 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11527 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011528 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011529 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011530 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011531 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011532 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011533 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011534 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011535 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011536 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11537 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11538 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011539 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11540 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011541 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011542 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011543 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011544 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011545 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011546 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050011547 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010011548 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011549#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010011550 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11551 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011552#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090011553 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011554 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011555 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011556 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011557 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011558 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011559 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11560 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011561 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011562 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011563 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011564 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011565 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011566 {}
11567};
11568
11569static struct alc_config_preset alc262_presets[] = {
11570 [ALC262_BASIC] = {
11571 .mixers = { alc262_base_mixer },
11572 .init_verbs = { alc262_init_verbs },
11573 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11574 .dac_nids = alc262_dac_nids,
11575 .hp_nid = 0x03,
11576 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11577 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011578 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011579 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011580 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011581 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011582 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011583 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11584 .dac_nids = alc262_dac_nids,
11585 .hp_nid = 0x03,
11586 .dig_out_nid = ALC262_DIGOUT_NID,
11587 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11588 .channel_mode = alc262_modes,
11589 .input_mux = &alc262_capture_source,
11590 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011591 .setup = alc262_hippo_setup,
11592 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011593 },
11594 [ALC262_HIPPO_1] = {
11595 .mixers = { alc262_hippo1_mixer },
11596 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11597 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11598 .dac_nids = alc262_dac_nids,
11599 .hp_nid = 0x02,
11600 .dig_out_nid = ALC262_DIGOUT_NID,
11601 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11602 .channel_mode = alc262_modes,
11603 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011604 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011605 .setup = alc262_hippo1_setup,
11606 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011607 },
Takashi Iwai834be882006-03-01 14:16:17 +010011608 [ALC262_FUJITSU] = {
11609 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011610 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11611 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011612 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11613 .dac_nids = alc262_dac_nids,
11614 .hp_nid = 0x03,
11615 .dig_out_nid = ALC262_DIGOUT_NID,
11616 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11617 .channel_mode = alc262_modes,
11618 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011619 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011620 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011621 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011622 [ALC262_HP_BPC] = {
11623 .mixers = { alc262_HP_BPC_mixer },
11624 .init_verbs = { alc262_HP_BPC_init_verbs },
11625 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11626 .dac_nids = alc262_dac_nids,
11627 .hp_nid = 0x03,
11628 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11629 .channel_mode = alc262_modes,
11630 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011631 .unsol_event = alc262_hp_bpc_unsol_event,
11632 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011633 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011634 [ALC262_HP_BPC_D7000_WF] = {
11635 .mixers = { alc262_HP_BPC_WildWest_mixer },
11636 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11637 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11638 .dac_nids = alc262_dac_nids,
11639 .hp_nid = 0x03,
11640 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11641 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011642 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011643 .unsol_event = alc262_hp_wildwest_unsol_event,
11644 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011645 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011646 [ALC262_HP_BPC_D7000_WL] = {
11647 .mixers = { alc262_HP_BPC_WildWest_mixer,
11648 alc262_HP_BPC_WildWest_option_mixer },
11649 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11650 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11651 .dac_nids = alc262_dac_nids,
11652 .hp_nid = 0x03,
11653 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11654 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011655 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011656 .unsol_event = alc262_hp_wildwest_unsol_event,
11657 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011658 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011659 [ALC262_HP_TC_T5735] = {
11660 .mixers = { alc262_hp_t5735_mixer },
11661 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11662 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11663 .dac_nids = alc262_dac_nids,
11664 .hp_nid = 0x03,
11665 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11666 .channel_mode = alc262_modes,
11667 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011668 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011669 .setup = alc262_hp_t5735_setup,
11670 .init_hook = alc_automute_amp,
Kailang Yang8c427222008-01-10 13:03:59 +010011671 },
11672 [ALC262_HP_RP5700] = {
11673 .mixers = { alc262_hp_rp5700_mixer },
11674 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11675 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11676 .dac_nids = alc262_dac_nids,
11677 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11678 .channel_mode = alc262_modes,
11679 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011680 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011681 [ALC262_BENQ_ED8] = {
11682 .mixers = { alc262_base_mixer },
11683 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11684 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11685 .dac_nids = alc262_dac_nids,
11686 .hp_nid = 0x03,
11687 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11688 .channel_mode = alc262_modes,
11689 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011690 },
Kailang Yang272a5272007-05-14 11:00:38 +020011691 [ALC262_SONY_ASSAMD] = {
11692 .mixers = { alc262_sony_mixer },
11693 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11694 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11695 .dac_nids = alc262_dac_nids,
11696 .hp_nid = 0x02,
11697 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11698 .channel_mode = alc262_modes,
11699 .input_mux = &alc262_capture_source,
11700 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011701 .setup = alc262_hippo_setup,
11702 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020011703 },
11704 [ALC262_BENQ_T31] = {
11705 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011706 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
11707 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020011708 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11709 .dac_nids = alc262_dac_nids,
11710 .hp_nid = 0x03,
11711 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11712 .channel_mode = alc262_modes,
11713 .input_mux = &alc262_capture_source,
11714 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011715 .setup = alc262_hippo_setup,
11716 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020011717 },
Tobin Davisf651b502007-10-26 12:40:47 +020011718 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011719 .mixers = { alc262_ultra_mixer },
11720 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011721 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011722 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11723 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011724 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11725 .channel_mode = alc262_modes,
11726 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011727 .adc_nids = alc262_adc_nids, /* ADC0 */
11728 .capsrc_nids = alc262_capsrc_nids,
11729 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011730 .unsol_event = alc262_ultra_unsol_event,
11731 .init_hook = alc262_ultra_automute,
11732 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011733 [ALC262_LENOVO_3000] = {
11734 .mixers = { alc262_lenovo_3000_mixer },
11735 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050011736 alc262_lenovo_3000_unsol_verbs,
11737 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011738 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11739 .dac_nids = alc262_dac_nids,
11740 .hp_nid = 0x03,
11741 .dig_out_nid = ALC262_DIGOUT_NID,
11742 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11743 .channel_mode = alc262_modes,
11744 .input_mux = &alc262_fujitsu_capture_source,
11745 .unsol_event = alc262_lenovo_3000_unsol_event,
11746 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011747 [ALC262_NEC] = {
11748 .mixers = { alc262_nec_mixer },
11749 .init_verbs = { alc262_nec_verbs },
11750 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11751 .dac_nids = alc262_dac_nids,
11752 .hp_nid = 0x03,
11753 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11754 .channel_mode = alc262_modes,
11755 .input_mux = &alc262_capture_source,
11756 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011757 [ALC262_TOSHIBA_S06] = {
11758 .mixers = { alc262_toshiba_s06_mixer },
11759 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11760 alc262_eapd_verbs },
11761 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11762 .capsrc_nids = alc262_dmic_capsrc_nids,
11763 .dac_nids = alc262_dac_nids,
11764 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011765 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011766 .dig_out_nid = ALC262_DIGOUT_NID,
11767 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11768 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011769 .unsol_event = alc_sku_unsol_event,
11770 .setup = alc262_toshiba_s06_setup,
11771 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020011772 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011773 [ALC262_TOSHIBA_RX1] = {
11774 .mixers = { alc262_toshiba_rx1_mixer },
11775 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11776 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11777 .dac_nids = alc262_dac_nids,
11778 .hp_nid = 0x03,
11779 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11780 .channel_mode = alc262_modes,
11781 .input_mux = &alc262_capture_source,
11782 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011783 .setup = alc262_hippo_setup,
11784 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011785 },
Tony Vroonba340e82009-02-02 19:01:30 +000011786 [ALC262_TYAN] = {
11787 .mixers = { alc262_tyan_mixer },
11788 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11789 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11790 .dac_nids = alc262_dac_nids,
11791 .hp_nid = 0x02,
11792 .dig_out_nid = ALC262_DIGOUT_NID,
11793 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11794 .channel_mode = alc262_modes,
11795 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011796 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011797 .setup = alc262_tyan_setup,
11798 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000011799 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011800};
11801
11802static int patch_alc262(struct hda_codec *codec)
11803{
11804 struct alc_spec *spec;
11805 int board_config;
11806 int err;
11807
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011808 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011809 if (spec == NULL)
11810 return -ENOMEM;
11811
11812 codec->spec = spec;
11813#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011814 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11815 * under-run
11816 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011817 {
11818 int tmp;
11819 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11820 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11821 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11822 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11823 }
11824#endif
11825
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011826 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11827
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011828 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11829 alc262_models,
11830 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011831
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011832 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011833 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11834 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011835 board_config = ALC262_AUTO;
11836 }
11837
11838 if (board_config == ALC262_AUTO) {
11839 /* automatic parse from the BIOS config */
11840 err = alc262_parse_auto_config(codec);
11841 if (err < 0) {
11842 alc_free(codec);
11843 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011844 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011845 printk(KERN_INFO
11846 "hda_codec: Cannot set up configuration "
11847 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011848 board_config = ALC262_BASIC;
11849 }
11850 }
11851
Takashi Iwai07eba612009-02-19 08:06:35 +010011852 if (!spec->no_analog) {
11853 err = snd_hda_attach_beep_device(codec, 0x1);
11854 if (err < 0) {
11855 alc_free(codec);
11856 return err;
11857 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011858 }
11859
Kailang Yangdf694da2005-12-05 19:42:22 +010011860 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011861 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011862
Kailang Yangdf694da2005-12-05 19:42:22 +010011863 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11864 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011865
Kailang Yangdf694da2005-12-05 19:42:22 +010011866 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11867 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11868
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011869 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011870 int i;
11871 /* check whether the digital-mic has to be supported */
11872 for (i = 0; i < spec->input_mux->num_items; i++) {
11873 if (spec->input_mux->items[i].index >= 9)
11874 break;
11875 }
11876 if (i < spec->input_mux->num_items) {
11877 /* use only ADC0 */
11878 spec->adc_nids = alc262_dmic_adc_nids;
11879 spec->num_adc_nids = 1;
11880 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011881 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011882 /* all analog inputs */
11883 /* check whether NID 0x07 is valid */
11884 unsigned int wcap = get_wcaps(codec, 0x07);
11885
11886 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011887 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020011888 if (wcap != AC_WID_AUD_IN) {
11889 spec->adc_nids = alc262_adc_nids_alt;
11890 spec->num_adc_nids =
11891 ARRAY_SIZE(alc262_adc_nids_alt);
11892 spec->capsrc_nids = alc262_capsrc_nids_alt;
11893 } else {
11894 spec->adc_nids = alc262_adc_nids;
11895 spec->num_adc_nids =
11896 ARRAY_SIZE(alc262_adc_nids);
11897 spec->capsrc_nids = alc262_capsrc_nids;
11898 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011899 }
11900 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011901 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011902 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011903 if (!spec->no_analog)
11904 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011905
Takashi Iwai2134ea42008-01-10 16:53:55 +010011906 spec->vmaster_nid = 0x0c;
11907
Kailang Yangdf694da2005-12-05 19:42:22 +010011908 codec->patch_ops = alc_patch_ops;
11909 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011910 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011911#ifdef CONFIG_SND_HDA_POWER_SAVE
11912 if (!spec->loopback.amplist)
11913 spec->loopback.amplist = alc262_loopbacks;
11914#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011915 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011916
Kailang Yangdf694da2005-12-05 19:42:22 +010011917 return 0;
11918}
11919
Kailang Yangdf694da2005-12-05 19:42:22 +010011920/*
Kailang Yanga361d842007-06-05 12:30:55 +020011921 * ALC268 channel source setting (2 channel)
11922 */
11923#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11924#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011925
Kailang Yanga361d842007-06-05 12:30:55 +020011926static hda_nid_t alc268_dac_nids[2] = {
11927 /* front, hp */
11928 0x02, 0x03
11929};
11930
11931static hda_nid_t alc268_adc_nids[2] = {
11932 /* ADC0-1 */
11933 0x08, 0x07
11934};
11935
11936static hda_nid_t alc268_adc_nids_alt[1] = {
11937 /* ADC0 */
11938 0x08
11939};
11940
Takashi Iwaie1406342008-02-11 18:32:32 +010011941static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11942
Kailang Yanga361d842007-06-05 12:30:55 +020011943static struct snd_kcontrol_new alc268_base_mixer[] = {
11944 /* output mixer control */
11945 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11946 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11947 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11948 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011949 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11950 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11951 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011952 { }
11953};
11954
Takashi Iwai42171c12009-05-08 14:11:43 +020011955static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11956 /* output mixer control */
11957 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11958 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11959 ALC262_HIPPO_MASTER_SWITCH,
11960 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11961 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11962 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11963 { }
11964};
11965
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011966/* bind Beep switches of both NID 0x0f and 0x10 */
11967static struct hda_bind_ctls alc268_bind_beep_sw = {
11968 .ops = &snd_hda_bind_sw,
11969 .values = {
11970 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11971 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11972 0
11973 },
11974};
11975
11976static struct snd_kcontrol_new alc268_beep_mixer[] = {
11977 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11978 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11979 { }
11980};
11981
Kailang Yangd1a991a2007-08-15 16:21:59 +020011982static struct hda_verb alc268_eapd_verbs[] = {
11983 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11984 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11985 { }
11986};
11987
Takashi Iwaid2738092007-08-16 14:59:45 +020011988/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011989static struct hda_verb alc268_toshiba_verbs[] = {
11990 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11991 { } /* end */
11992};
11993
11994/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011995/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011996static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11997 .ops = &snd_hda_bind_vol,
11998 .values = {
11999 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12000 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12001 0
12002 },
12003};
12004
Takashi Iwai889c4392007-08-23 18:56:52 +020012005/* mute/unmute internal speaker according to the hp jack and mute state */
12006static void alc268_acer_automute(struct hda_codec *codec, int force)
12007{
12008 struct alc_spec *spec = codec->spec;
12009 unsigned int mute;
12010
12011 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012012 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012013 spec->sense_updated = 1;
12014 }
12015 if (spec->jack_present)
12016 mute = HDA_AMP_MUTE; /* mute internal speaker */
12017 else /* unmute internal speaker if necessary */
12018 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12019 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12020 HDA_AMP_MUTE, mute);
12021}
12022
12023
12024/* bind hp and internal speaker mute (with plug check) */
12025static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12026 struct snd_ctl_elem_value *ucontrol)
12027{
12028 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12029 long *valp = ucontrol->value.integer.value;
12030 int change;
12031
Takashi Iwai8de56b72009-07-24 16:51:47 +020012032 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012033 if (change)
12034 alc268_acer_automute(codec, 0);
12035 return change;
12036}
Takashi Iwaid2738092007-08-16 14:59:45 +020012037
Kailang Yang8ef355d2008-08-26 13:10:22 +020012038static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12039 /* output mixer control */
12040 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12041 {
12042 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12043 .name = "Master Playback Switch",
12044 .info = snd_hda_mixer_amp_switch_info,
12045 .get = snd_hda_mixer_amp_switch_get,
12046 .put = alc268_acer_master_sw_put,
12047 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12048 },
12049 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12050 { }
12051};
12052
Takashi Iwaid2738092007-08-16 14:59:45 +020012053static struct snd_kcontrol_new alc268_acer_mixer[] = {
12054 /* output mixer control */
12055 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12056 {
12057 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12058 .name = "Master Playback Switch",
12059 .info = snd_hda_mixer_amp_switch_info,
12060 .get = snd_hda_mixer_amp_switch_get,
12061 .put = alc268_acer_master_sw_put,
12062 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12063 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012064 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12065 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12066 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012067 { }
12068};
12069
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012070static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12071 /* output mixer control */
12072 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12073 {
12074 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12075 .name = "Master Playback Switch",
12076 .info = snd_hda_mixer_amp_switch_info,
12077 .get = snd_hda_mixer_amp_switch_get,
12078 .put = alc268_acer_master_sw_put,
12079 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12080 },
12081 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12082 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12083 { }
12084};
12085
Kailang Yang8ef355d2008-08-26 13:10:22 +020012086static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12087 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12088 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12089 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12090 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12091 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12092 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12093 { }
12094};
12095
Takashi Iwaid2738092007-08-16 14:59:45 +020012096static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012097 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12098 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012099 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12100 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012101 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12102 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012103 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12104 { }
12105};
12106
12107/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012108#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012109#define alc268_toshiba_setup alc262_hippo_setup
12110#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012111
12112static void alc268_acer_unsol_event(struct hda_codec *codec,
12113 unsigned int res)
12114{
Takashi Iwai889c4392007-08-23 18:56:52 +020012115 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012116 return;
12117 alc268_acer_automute(codec, 1);
12118}
12119
Takashi Iwai889c4392007-08-23 18:56:52 +020012120static void alc268_acer_init_hook(struct hda_codec *codec)
12121{
12122 alc268_acer_automute(codec, 1);
12123}
12124
Kailang Yang8ef355d2008-08-26 13:10:22 +020012125/* toggle speaker-output according to the hp-jack state */
12126static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12127{
12128 unsigned int present;
12129 unsigned char bits;
12130
Wu Fengguang864f92b2009-11-18 12:38:02 +080012131 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012132 bits = present ? AMP_IN_MUTE(0) : 0;
12133 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
12134 AMP_IN_MUTE(0), bits);
12135 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
12136 AMP_IN_MUTE(0), bits);
12137}
12138
Kailang Yang8ef355d2008-08-26 13:10:22 +020012139static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12140 unsigned int res)
12141{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012142 switch (res >> 26) {
12143 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012144 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012145 break;
12146 case ALC880_MIC_EVENT:
12147 alc_mic_automute(codec);
12148 break;
12149 }
12150}
12151
12152static void alc268_acer_lc_setup(struct hda_codec *codec)
12153{
12154 struct alc_spec *spec = codec->spec;
12155 spec->ext_mic.pin = 0x18;
12156 spec->ext_mic.mux_idx = 0;
12157 spec->int_mic.pin = 0x12;
12158 spec->int_mic.mux_idx = 6;
12159 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012160}
12161
12162static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12163{
12164 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012165 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012166}
12167
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012168static struct snd_kcontrol_new alc268_dell_mixer[] = {
12169 /* output mixer control */
12170 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12171 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12172 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12173 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12174 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12175 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12176 { }
12177};
12178
12179static struct hda_verb alc268_dell_verbs[] = {
12180 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12181 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12182 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012183 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012184 { }
12185};
12186
12187/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012188static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012189{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012190 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012191
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012192 spec->autocfg.hp_pins[0] = 0x15;
12193 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012194 spec->ext_mic.pin = 0x18;
12195 spec->ext_mic.mux_idx = 0;
12196 spec->int_mic.pin = 0x19;
12197 spec->int_mic.mux_idx = 1;
12198 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012199}
12200
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012201static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12202 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12203 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12204 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12205 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12206 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12207 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12208 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12209 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12210 { }
12211};
12212
12213static struct hda_verb alc267_quanta_il1_verbs[] = {
12214 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12215 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12216 { }
12217};
12218
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012219static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012220{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012221 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012222 spec->autocfg.hp_pins[0] = 0x15;
12223 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012224 spec->ext_mic.pin = 0x18;
12225 spec->ext_mic.mux_idx = 0;
12226 spec->int_mic.pin = 0x19;
12227 spec->int_mic.mux_idx = 1;
12228 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012229}
12230
Kailang Yanga361d842007-06-05 12:30:55 +020012231/*
12232 * generic initialization of ADC, input mixers and output mixers
12233 */
12234static struct hda_verb alc268_base_init_verbs[] = {
12235 /* Unmute DAC0-1 and set vol = 0 */
12236 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012237 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012238
12239 /*
12240 * Set up output mixers (0x0c - 0x0e)
12241 */
12242 /* set vol=0 to output mixers */
12243 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012244 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12245
12246 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12247 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12248
12249 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12250 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12251 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12252 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12253 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12254 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12255 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12256 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12257
12258 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12259 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12260 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12261 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012262 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012263
12264 /* set PCBEEP vol = 0, mute connections */
12265 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12266 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12267 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012268
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012269 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012270
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012271 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12272 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12273 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12274 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012275
Kailang Yanga361d842007-06-05 12:30:55 +020012276 { }
12277};
12278
12279/*
12280 * generic initialization of ADC, input mixers and output mixers
12281 */
12282static struct hda_verb alc268_volume_init_verbs[] = {
12283 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012284 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12285 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012286
12287 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12288 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12289 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12290 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12291 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12292
Kailang Yanga361d842007-06-05 12:30:55 +020012293 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012294 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12295 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12296
12297 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012298 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012299
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012300 /* set PCBEEP vol = 0, mute connections */
12301 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12302 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12303 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012304
12305 { }
12306};
12307
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012308static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12309 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12310 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12311 { } /* end */
12312};
12313
Kailang Yanga361d842007-06-05 12:30:55 +020012314static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12315 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12316 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012317 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012318 { } /* end */
12319};
12320
12321static struct snd_kcontrol_new alc268_capture_mixer[] = {
12322 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12323 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12324 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12325 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012326 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012327 { } /* end */
12328};
12329
12330static struct hda_input_mux alc268_capture_source = {
12331 .num_items = 4,
12332 .items = {
12333 { "Mic", 0x0 },
12334 { "Front Mic", 0x1 },
12335 { "Line", 0x2 },
12336 { "CD", 0x3 },
12337 },
12338};
12339
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012340static struct hda_input_mux alc268_acer_capture_source = {
12341 .num_items = 3,
12342 .items = {
12343 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012344 { "Internal Mic", 0x1 },
12345 { "Line", 0x2 },
12346 },
12347};
12348
12349static struct hda_input_mux alc268_acer_dmic_capture_source = {
12350 .num_items = 3,
12351 .items = {
12352 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012353 { "Internal Mic", 0x6 },
12354 { "Line", 0x2 },
12355 },
12356};
12357
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012358#ifdef CONFIG_SND_DEBUG
12359static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012360 /* Volume widgets */
12361 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12362 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12363 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12364 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12365 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12366 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12367 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12368 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12369 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12370 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12371 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12372 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12373 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012374 /* The below appears problematic on some hardwares */
12375 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012376 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12377 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12378 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12379 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12380
12381 /* Modes for retasking pin widgets */
12382 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12383 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12384 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12385 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12386
12387 /* Controls for GPIO pins, assuming they are configured as outputs */
12388 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12389 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12390 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12391 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12392
12393 /* Switches to allow the digital SPDIF output pin to be enabled.
12394 * The ALC268 does not have an SPDIF input.
12395 */
12396 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12397
12398 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12399 * this output to turn on an external amplifier.
12400 */
12401 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12402 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12403
12404 { } /* end */
12405};
12406#endif
12407
Kailang Yanga361d842007-06-05 12:30:55 +020012408/* create input playback/capture controls for the given pin */
12409static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12410 const char *ctlname, int idx)
12411{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012412 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012413 int err;
12414
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012415 switch (nid) {
12416 case 0x14:
12417 case 0x16:
12418 dac = 0x02;
12419 break;
12420 case 0x15:
12421 dac = 0x03;
12422 break;
12423 default:
12424 return 0;
12425 }
12426 if (spec->multiout.dac_nids[0] != dac &&
12427 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012428 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012429 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012430 HDA_OUTPUT));
12431 if (err < 0)
12432 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012433 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12434 }
12435
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012436 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012437 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020012438 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012439 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012440 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012441 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012442 if (err < 0)
12443 return err;
12444 return 0;
12445}
12446
12447/* add playback controls from the parsed DAC table */
12448static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12449 const struct auto_pin_cfg *cfg)
12450{
12451 hda_nid_t nid;
12452 int err;
12453
Kailang Yanga361d842007-06-05 12:30:55 +020012454 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012455
12456 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012457 if (nid) {
12458 const char *name;
12459 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12460 name = "Speaker";
12461 else
12462 name = "Front";
12463 err = alc268_new_analog_output(spec, nid, name, 0);
12464 if (err < 0)
12465 return err;
12466 }
Kailang Yanga361d842007-06-05 12:30:55 +020012467
12468 nid = cfg->speaker_pins[0];
12469 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012470 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020012471 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12472 if (err < 0)
12473 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012474 } else {
12475 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12476 if (err < 0)
12477 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012478 }
12479 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012480 if (nid) {
12481 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12482 if (err < 0)
12483 return err;
12484 }
Kailang Yanga361d842007-06-05 12:30:55 +020012485
12486 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12487 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012488 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012489 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012490 if (err < 0)
12491 return err;
12492 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012493 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012494}
12495
12496/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020012497static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020012498 const struct auto_pin_cfg *cfg)
12499{
Takashi Iwai05f5f472009-08-25 13:10:18 +020012500 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020012501}
12502
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012503static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12504 hda_nid_t nid, int pin_type)
12505{
12506 int idx;
12507
12508 alc_set_pin_output(codec, nid, pin_type);
12509 if (nid == 0x14 || nid == 0x16)
12510 idx = 0;
12511 else
12512 idx = 1;
12513 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12514}
12515
12516static void alc268_auto_init_multi_out(struct hda_codec *codec)
12517{
12518 struct alc_spec *spec = codec->spec;
12519 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12520 if (nid) {
12521 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12522 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12523 }
12524}
12525
12526static void alc268_auto_init_hp_out(struct hda_codec *codec)
12527{
12528 struct alc_spec *spec = codec->spec;
12529 hda_nid_t pin;
12530
12531 pin = spec->autocfg.hp_pins[0];
12532 if (pin)
12533 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12534 pin = spec->autocfg.speaker_pins[0];
12535 if (pin)
12536 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12537}
12538
Kailang Yanga361d842007-06-05 12:30:55 +020012539static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12540{
12541 struct alc_spec *spec = codec->spec;
12542 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12543 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12544 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12545 unsigned int dac_vol1, dac_vol2;
12546
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012547 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020012548 snd_hda_codec_write(codec, speaker_nid, 0,
12549 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012550 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012551 snd_hda_codec_write(codec, 0x0f, 0,
12552 AC_VERB_SET_AMP_GAIN_MUTE,
12553 AMP_IN_UNMUTE(1));
12554 snd_hda_codec_write(codec, 0x10, 0,
12555 AC_VERB_SET_AMP_GAIN_MUTE,
12556 AMP_IN_UNMUTE(1));
12557 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012558 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012559 snd_hda_codec_write(codec, 0x0f, 0,
12560 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12561 snd_hda_codec_write(codec, 0x10, 0,
12562 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12563 }
12564
12565 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012566 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012567 dac_vol2 = AMP_OUT_ZERO;
12568 else if (line_nid == 0x15)
12569 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012570 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012571 dac_vol2 = AMP_OUT_ZERO;
12572 else if (hp_nid == 0x15)
12573 dac_vol1 = AMP_OUT_ZERO;
12574 if (line_nid != 0x16 || hp_nid != 0x16 ||
12575 spec->autocfg.line_out_pins[1] != 0x16 ||
12576 spec->autocfg.line_out_pins[2] != 0x16)
12577 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12578
12579 snd_hda_codec_write(codec, 0x02, 0,
12580 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12581 snd_hda_codec_write(codec, 0x03, 0,
12582 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12583}
12584
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012585/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012586#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12587#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012588#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012589#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12590
12591/*
12592 * BIOS auto configuration
12593 */
12594static int alc268_parse_auto_config(struct hda_codec *codec)
12595{
12596 struct alc_spec *spec = codec->spec;
12597 int err;
12598 static hda_nid_t alc268_ignore[] = { 0 };
12599
12600 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12601 alc268_ignore);
12602 if (err < 0)
12603 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012604 if (!spec->autocfg.line_outs) {
12605 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12606 spec->multiout.max_channels = 2;
12607 spec->no_analog = 1;
12608 goto dig_only;
12609 }
Kailang Yanga361d842007-06-05 12:30:55 +020012610 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012611 }
Kailang Yanga361d842007-06-05 12:30:55 +020012612 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12613 if (err < 0)
12614 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012615 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020012616 if (err < 0)
12617 return err;
12618
12619 spec->multiout.max_channels = 2;
12620
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012621 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012622 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012623 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012624 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012625 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12626 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012627 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012628 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012629
Takashi Iwai892981f2009-03-02 08:04:35 +010012630 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012631 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012632
Takashi Iwaid88897e2008-10-31 15:01:37 +010012633 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012634 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012635 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012636
Takashi Iwai776e1842007-08-29 15:07:11 +020012637 err = alc_auto_add_mic_boost(codec);
12638 if (err < 0)
12639 return err;
12640
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012641 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12642
Kailang Yanga361d842007-06-05 12:30:55 +020012643 return 1;
12644}
12645
Kailang Yanga361d842007-06-05 12:30:55 +020012646#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12647
12648/* init callback for auto-configuration model -- overriding the default init */
12649static void alc268_auto_init(struct hda_codec *codec)
12650{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012651 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012652 alc268_auto_init_multi_out(codec);
12653 alc268_auto_init_hp_out(codec);
12654 alc268_auto_init_mono_speaker_out(codec);
12655 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012656 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012657 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012658}
12659
12660/*
12661 * configuration and preset
12662 */
12663static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012664 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012665 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012666 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012667 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012668 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012669 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012670 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012671 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012672#ifdef CONFIG_SND_DEBUG
12673 [ALC268_TEST] = "test",
12674#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012675 [ALC268_AUTO] = "auto",
12676};
12677
12678static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012679 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012680 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012681 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012682 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012683 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012684 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12685 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012686 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050012687 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
12688 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020012689 /* almost compatible with toshiba but with optional digital outs;
12690 * auto-probing seems working fine
12691 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012692 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020012693 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020012694 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012695 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012696 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012697 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012698 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012699 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012700 {}
12701};
12702
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012703/* Toshiba laptops have no unique PCI SSID but only codec SSID */
12704static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
12705 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
12706 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
12707 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12708 ALC268_TOSHIBA),
12709 {}
12710};
12711
Kailang Yanga361d842007-06-05 12:30:55 +020012712static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012713 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012714 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
12715 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012716 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12717 alc267_quanta_il1_verbs },
12718 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12719 .dac_nids = alc268_dac_nids,
12720 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12721 .adc_nids = alc268_adc_nids_alt,
12722 .hp_nid = 0x03,
12723 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12724 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012725 .unsol_event = alc_sku_unsol_event,
12726 .setup = alc267_quanta_il1_setup,
12727 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012728 },
Kailang Yanga361d842007-06-05 12:30:55 +020012729 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012730 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12731 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012732 .init_verbs = { alc268_base_init_verbs },
12733 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12734 .dac_nids = alc268_dac_nids,
12735 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12736 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012737 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012738 .hp_nid = 0x03,
12739 .dig_out_nid = ALC268_DIGOUT_NID,
12740 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12741 .channel_mode = alc268_modes,
12742 .input_mux = &alc268_capture_source,
12743 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012744 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012745 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012746 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012747 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12748 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012749 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12750 .dac_nids = alc268_dac_nids,
12751 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12752 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012753 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012754 .hp_nid = 0x03,
12755 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12756 .channel_mode = alc268_modes,
12757 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012758 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012759 .setup = alc268_toshiba_setup,
12760 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020012761 },
12762 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020012763 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012764 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012765 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12766 alc268_acer_verbs },
12767 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12768 .dac_nids = alc268_dac_nids,
12769 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12770 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012771 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012772 .hp_nid = 0x02,
12773 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12774 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012775 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012776 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012777 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012778 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012779 [ALC268_ACER_DMIC] = {
12780 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12781 alc268_beep_mixer },
12782 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12783 alc268_acer_verbs },
12784 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12785 .dac_nids = alc268_dac_nids,
12786 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12787 .adc_nids = alc268_adc_nids_alt,
12788 .capsrc_nids = alc268_capsrc_nids,
12789 .hp_nid = 0x02,
12790 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12791 .channel_mode = alc268_modes,
12792 .input_mux = &alc268_acer_dmic_capture_source,
12793 .unsol_event = alc268_acer_unsol_event,
12794 .init_hook = alc268_acer_init_hook,
12795 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012796 [ALC268_ACER_ASPIRE_ONE] = {
12797 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012798 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012799 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012800 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12801 alc268_acer_aspire_one_verbs },
12802 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12803 .dac_nids = alc268_dac_nids,
12804 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12805 .adc_nids = alc268_adc_nids_alt,
12806 .capsrc_nids = alc268_capsrc_nids,
12807 .hp_nid = 0x03,
12808 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12809 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012810 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012811 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012812 .init_hook = alc268_acer_lc_init_hook,
12813 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012814 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012815 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
12816 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012817 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12818 alc268_dell_verbs },
12819 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12820 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012821 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12822 .adc_nids = alc268_adc_nids_alt,
12823 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012824 .hp_nid = 0x02,
12825 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12826 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012827 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012828 .setup = alc268_dell_setup,
12829 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012830 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012831 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012832 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12833 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012834 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12835 alc268_toshiba_verbs },
12836 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12837 .dac_nids = alc268_dac_nids,
12838 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12839 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012840 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012841 .hp_nid = 0x03,
12842 .dig_out_nid = ALC268_DIGOUT_NID,
12843 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12844 .channel_mode = alc268_modes,
12845 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012846 .setup = alc268_toshiba_setup,
12847 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012848 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012849#ifdef CONFIG_SND_DEBUG
12850 [ALC268_TEST] = {
12851 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12852 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12853 alc268_volume_init_verbs },
12854 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12855 .dac_nids = alc268_dac_nids,
12856 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12857 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012858 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012859 .hp_nid = 0x03,
12860 .dig_out_nid = ALC268_DIGOUT_NID,
12861 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12862 .channel_mode = alc268_modes,
12863 .input_mux = &alc268_capture_source,
12864 },
12865#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012866};
12867
12868static int patch_alc268(struct hda_codec *codec)
12869{
12870 struct alc_spec *spec;
12871 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012872 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012873
12874 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12875 if (spec == NULL)
12876 return -ENOMEM;
12877
12878 codec->spec = spec;
12879
12880 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12881 alc268_models,
12882 alc268_cfg_tbl);
12883
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012884 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
12885 board_config = snd_hda_check_board_codec_sid_config(codec,
12886 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
12887
Kailang Yanga361d842007-06-05 12:30:55 +020012888 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012889 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12890 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012891 board_config = ALC268_AUTO;
12892 }
12893
12894 if (board_config == ALC268_AUTO) {
12895 /* automatic parse from the BIOS config */
12896 err = alc268_parse_auto_config(codec);
12897 if (err < 0) {
12898 alc_free(codec);
12899 return err;
12900 } else if (!err) {
12901 printk(KERN_INFO
12902 "hda_codec: Cannot set up configuration "
12903 "from BIOS. Using base mode...\n");
12904 board_config = ALC268_3ST;
12905 }
12906 }
12907
12908 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012909 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020012910
Kailang Yanga361d842007-06-05 12:30:55 +020012911 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12912 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012913 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012914
Kailang Yanga361d842007-06-05 12:30:55 +020012915 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12916
Takashi Iwai22971e32009-02-10 11:56:44 +010012917 has_beep = 0;
12918 for (i = 0; i < spec->num_mixers; i++) {
12919 if (spec->mixers[i] == alc268_beep_mixer) {
12920 has_beep = 1;
12921 break;
12922 }
12923 }
12924
12925 if (has_beep) {
12926 err = snd_hda_attach_beep_device(codec, 0x1);
12927 if (err < 0) {
12928 alc_free(codec);
12929 return err;
12930 }
12931 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12932 /* override the amp caps for beep generator */
12933 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012934 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12935 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12936 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12937 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012938 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012939
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012940 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012941 /* check whether NID 0x07 is valid */
12942 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012943 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012944
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020012945 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012946 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012947 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012948 if (spec->auto_mic ||
12949 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012950 spec->adc_nids = alc268_adc_nids_alt;
12951 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020012952 if (spec->auto_mic)
12953 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012954 if (spec->auto_mic || spec->input_mux->num_items == 1)
12955 add_mixer(spec, alc268_capture_nosrc_mixer);
12956 else
12957 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012958 } else {
12959 spec->adc_nids = alc268_adc_nids;
12960 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012961 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012962 }
Takashi Iwai85860c02008-02-19 15:00:15 +010012963 /* set default input source */
12964 for (i = 0; i < spec->num_adc_nids; i++)
12965 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12966 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012967 i < spec->num_mux_defs ?
12968 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010012969 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012970 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012971
12972 spec->vmaster_nid = 0x02;
12973
Kailang Yanga361d842007-06-05 12:30:55 +020012974 codec->patch_ops = alc_patch_ops;
12975 if (board_config == ALC268_AUTO)
12976 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012977
Takashi Iwaidaead532008-11-28 12:55:36 +010012978 codec->proc_widget_hook = print_realtek_coef;
12979
Kailang Yanga361d842007-06-05 12:30:55 +020012980 return 0;
12981}
12982
12983/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012984 * ALC269 channel source setting (2 channel)
12985 */
12986#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12987
12988#define alc269_dac_nids alc260_dac_nids
12989
12990static hda_nid_t alc269_adc_nids[1] = {
12991 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012992 0x08,
12993};
12994
Takashi Iwaie01bf502008-08-21 16:25:07 +020012995static hda_nid_t alc269_capsrc_nids[1] = {
12996 0x23,
12997};
12998
12999/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
13000 * not a mux!
13001 */
13002
Kailang Yangf6a92242007-12-13 16:52:54 +010013003#define alc269_modes alc260_modes
13004#define alc269_capture_source alc880_lg_lw_capture_source
13005
13006static struct snd_kcontrol_new alc269_base_mixer[] = {
13007 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13008 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13009 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13010 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13011 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13012 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13013 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13014 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13015 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13016 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13017 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13018 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13019 { } /* end */
13020};
13021
Kailang Yang60db6b52008-08-26 13:13:00 +020013022static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13023 /* output mixer control */
13024 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13025 {
13026 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13027 .name = "Master Playback Switch",
13028 .info = snd_hda_mixer_amp_switch_info,
13029 .get = snd_hda_mixer_amp_switch_get,
13030 .put = alc268_acer_master_sw_put,
13031 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13032 },
13033 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13034 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13035 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13036 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13037 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13038 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013039 { }
13040};
13041
Tony Vroon64154832008-11-06 15:08:49 +000013042static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13043 /* output mixer control */
13044 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13045 {
13046 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13047 .name = "Master Playback Switch",
13048 .info = snd_hda_mixer_amp_switch_info,
13049 .get = snd_hda_mixer_amp_switch_get,
13050 .put = alc268_acer_master_sw_put,
13051 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13052 },
13053 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13054 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13055 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13056 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13057 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13058 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13059 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13060 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13061 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013062 { }
13063};
13064
Kailang Yangf53281e2008-07-18 12:36:43 +020013065static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013066 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013067 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013068 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013069 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013070 { } /* end */
13071};
13072
Kailang Yangf6a92242007-12-13 16:52:54 +010013073/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020013074static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
13075 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13076 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013077 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13078 { } /* end */
13079};
13080
13081/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020013082#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013083
Kailang Yang60db6b52008-08-26 13:13:00 +020013084static struct hda_verb alc269_quanta_fl1_verbs[] = {
13085 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13086 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13087 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13088 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13089 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13090 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13091 { }
13092};
13093
Tony Vroon64154832008-11-06 15:08:49 +000013094static struct hda_verb alc269_lifebook_verbs[] = {
13095 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13096 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13097 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13098 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13099 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13100 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13101 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13102 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13103 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13104 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13105 { }
13106};
13107
Kailang Yang60db6b52008-08-26 13:13:00 +020013108/* toggle speaker-output according to the hp-jack state */
13109static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13110{
13111 unsigned int present;
13112 unsigned char bits;
13113
Wu Fengguang864f92b2009-11-18 12:38:02 +080013114 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang60db6b52008-08-26 13:13:00 +020013115 bits = present ? AMP_IN_MUTE(0) : 0;
13116 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13117 AMP_IN_MUTE(0), bits);
13118 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13119 AMP_IN_MUTE(0), bits);
13120
13121 snd_hda_codec_write(codec, 0x20, 0,
13122 AC_VERB_SET_COEF_INDEX, 0x0c);
13123 snd_hda_codec_write(codec, 0x20, 0,
13124 AC_VERB_SET_PROC_COEF, 0x680);
13125
13126 snd_hda_codec_write(codec, 0x20, 0,
13127 AC_VERB_SET_COEF_INDEX, 0x0c);
13128 snd_hda_codec_write(codec, 0x20, 0,
13129 AC_VERB_SET_PROC_COEF, 0x480);
13130}
13131
Tony Vroon64154832008-11-06 15:08:49 +000013132/* toggle speaker-output according to the hp-jacks state */
13133static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13134{
13135 unsigned int present;
13136 unsigned char bits;
13137
13138 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013139 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013140
13141 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013142 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013143
13144 bits = present ? AMP_IN_MUTE(0) : 0;
13145 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13146 AMP_IN_MUTE(0), bits);
13147 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13148 AMP_IN_MUTE(0), bits);
13149
13150 snd_hda_codec_write(codec, 0x20, 0,
13151 AC_VERB_SET_COEF_INDEX, 0x0c);
13152 snd_hda_codec_write(codec, 0x20, 0,
13153 AC_VERB_SET_PROC_COEF, 0x680);
13154
13155 snd_hda_codec_write(codec, 0x20, 0,
13156 AC_VERB_SET_COEF_INDEX, 0x0c);
13157 snd_hda_codec_write(codec, 0x20, 0,
13158 AC_VERB_SET_PROC_COEF, 0x480);
13159}
13160
Tony Vroon64154832008-11-06 15:08:49 +000013161static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13162{
13163 unsigned int present_laptop;
13164 unsigned int present_dock;
13165
Wu Fengguang864f92b2009-11-18 12:38:02 +080013166 present_laptop = snd_hda_jack_detect(codec, 0x18);
13167 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000013168
13169 /* Laptop mic port overrides dock mic port, design decision */
13170 if (present_dock)
13171 snd_hda_codec_write(codec, 0x23, 0,
13172 AC_VERB_SET_CONNECT_SEL, 0x3);
13173 if (present_laptop)
13174 snd_hda_codec_write(codec, 0x23, 0,
13175 AC_VERB_SET_CONNECT_SEL, 0x0);
13176 if (!present_dock && !present_laptop)
13177 snd_hda_codec_write(codec, 0x23, 0,
13178 AC_VERB_SET_CONNECT_SEL, 0x1);
13179}
13180
Kailang Yang60db6b52008-08-26 13:13:00 +020013181static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13182 unsigned int res)
13183{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013184 switch (res >> 26) {
13185 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013186 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013187 break;
13188 case ALC880_MIC_EVENT:
13189 alc_mic_automute(codec);
13190 break;
13191 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013192}
13193
Tony Vroon64154832008-11-06 15:08:49 +000013194static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13195 unsigned int res)
13196{
13197 if ((res >> 26) == ALC880_HP_EVENT)
13198 alc269_lifebook_speaker_automute(codec);
13199 if ((res >> 26) == ALC880_MIC_EVENT)
13200 alc269_lifebook_mic_autoswitch(codec);
13201}
13202
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013203static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13204{
13205 struct alc_spec *spec = codec->spec;
13206 spec->ext_mic.pin = 0x18;
13207 spec->ext_mic.mux_idx = 0;
13208 spec->int_mic.pin = 0x19;
13209 spec->int_mic.mux_idx = 1;
13210 spec->auto_mic = 1;
13211}
13212
Kailang Yang60db6b52008-08-26 13:13:00 +020013213static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13214{
13215 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013216 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013217}
13218
Tony Vroon64154832008-11-06 15:08:49 +000013219static void alc269_lifebook_init_hook(struct hda_codec *codec)
13220{
13221 alc269_lifebook_speaker_automute(codec);
13222 alc269_lifebook_mic_autoswitch(codec);
13223}
13224
Kailang Yang60db6b52008-08-26 13:13:00 +020013225static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
13226 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13227 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13228 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13229 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13230 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13231 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13232 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13233 {}
13234};
13235
13236static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
13237 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13238 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13239 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13240 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13241 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13242 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13243 {}
13244};
13245
13246/* toggle speaker-output according to the hp-jack state */
13247static void alc269_speaker_automute(struct hda_codec *codec)
13248{
Kailang Yangebb83ee2009-12-17 12:23:00 +010013249 struct alc_spec *spec = codec->spec;
13250 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020013251 unsigned int present;
13252 unsigned char bits;
13253
Kailang Yangebb83ee2009-12-17 12:23:00 +010013254 present = snd_hda_jack_detect(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020013255 bits = present ? AMP_IN_MUTE(0) : 0;
13256 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13257 AMP_IN_MUTE(0), bits);
13258 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13259 AMP_IN_MUTE(0), bits);
13260}
13261
Kailang Yang60db6b52008-08-26 13:13:00 +020013262/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013263static void alc269_eeepc_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013264 unsigned int res)
13265{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013266 switch (res >> 26) {
13267 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013268 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013269 break;
13270 case ALC880_MIC_EVENT:
13271 alc_mic_automute(codec);
13272 break;
13273 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013274}
13275
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013276static void alc269_eeepc_dmic_setup(struct hda_codec *codec)
13277{
13278 struct alc_spec *spec = codec->spec;
13279 spec->ext_mic.pin = 0x18;
13280 spec->ext_mic.mux_idx = 0;
13281 spec->int_mic.pin = 0x12;
13282 spec->int_mic.mux_idx = 5;
13283 spec->auto_mic = 1;
13284}
13285
13286static void alc269_eeepc_amic_setup(struct hda_codec *codec)
13287{
13288 struct alc_spec *spec = codec->spec;
13289 spec->ext_mic.pin = 0x18;
13290 spec->ext_mic.mux_idx = 0;
13291 spec->int_mic.pin = 0x19;
13292 spec->int_mic.mux_idx = 1;
13293 spec->auto_mic = 1;
13294}
13295
13296static void alc269_eeepc_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013297{
13298 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013299 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013300}
13301
Kailang Yangf6a92242007-12-13 16:52:54 +010013302/*
13303 * generic initialization of ADC, input mixers and output mixers
13304 */
13305static struct hda_verb alc269_init_verbs[] = {
13306 /*
13307 * Unmute ADC0 and set the default input to mic-in
13308 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013309 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013310
13311 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13312 * analog-loopback mixer widget
13313 * Note: PASD motherboards uses the Line In 2 as the input for
13314 * front panel mic (mic 2)
13315 */
13316 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13317 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13318 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13319 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13320 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13321 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13322
13323 /*
13324 * Set up output mixers (0x0c - 0x0e)
13325 */
13326 /* set vol=0 to output mixers */
13327 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13328 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13329
13330 /* set up input amps for analog loopback */
13331 /* Amp Indices: DAC = 0, mixer = 1 */
13332 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13333 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13334 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13335 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13336 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13337 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13338
13339 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13340 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13341 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13342 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13343 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13344 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13345 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13346
13347 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13348 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13349 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13350 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13351 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13352 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13353 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13354
13355 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13356 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13357
13358 /* FIXME: use matrix-type input source selection */
13359 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13360 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013361 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13362 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013363 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13364 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13365
13366 /* set EAPD */
13367 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13368 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13369 { }
13370};
13371
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013372#define alc269_auto_create_multi_out_ctls \
13373 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020013374#define alc269_auto_create_input_ctls \
13375 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013376
13377#ifdef CONFIG_SND_HDA_POWER_SAVE
13378#define alc269_loopbacks alc880_loopbacks
13379#endif
13380
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013381/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013382#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13383#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13384#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13385#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13386
Takashi Iwaif03d3112009-03-05 14:18:16 +010013387static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13388 .substreams = 1,
13389 .channels_min = 2,
13390 .channels_max = 8,
13391 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13392 /* NID is set in alc_build_pcms */
13393 .ops = {
13394 .open = alc880_playback_pcm_open,
13395 .prepare = alc880_playback_pcm_prepare,
13396 .cleanup = alc880_playback_pcm_cleanup
13397 },
13398};
13399
13400static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13401 .substreams = 1,
13402 .channels_min = 2,
13403 .channels_max = 2,
13404 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13405 /* NID is set in alc_build_pcms */
13406};
13407
Kailang Yangf6a92242007-12-13 16:52:54 +010013408/*
13409 * BIOS auto configuration
13410 */
13411static int alc269_parse_auto_config(struct hda_codec *codec)
13412{
13413 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013414 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013415 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13416
13417 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13418 alc269_ignore);
13419 if (err < 0)
13420 return err;
13421
13422 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13423 if (err < 0)
13424 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013425 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010013426 if (err < 0)
13427 return err;
13428
13429 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13430
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013431 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013432 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13433
Takashi Iwai603c4012008-07-30 15:01:44 +020013434 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013435 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013436
Takashi Iwaid88897e2008-10-31 15:01:37 +010013437 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013438 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013439 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013440 /* set default input source */
13441 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13442 0, AC_VERB_SET_CONNECT_SEL,
13443 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013444
13445 err = alc_auto_add_mic_boost(codec);
13446 if (err < 0)
13447 return err;
13448
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013449 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013450 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013451
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013452 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13453
Kailang Yangf6a92242007-12-13 16:52:54 +010013454 return 1;
13455}
13456
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013457#define alc269_auto_init_multi_out alc268_auto_init_multi_out
13458#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010013459#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13460
13461
13462/* init callback for auto-configuration model -- overriding the default init */
13463static void alc269_auto_init(struct hda_codec *codec)
13464{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013465 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013466 alc269_auto_init_multi_out(codec);
13467 alc269_auto_init_hp_out(codec);
13468 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013469 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013470 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013471}
13472
13473/*
13474 * configuration and preset
13475 */
13476static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013477 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013478 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013479 [ALC269_ASUS_AMIC] = "asus-amic",
13480 [ALC269_ASUS_DMIC] = "asus-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000013481 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020013482 [ALC269_LIFEBOOK] = "lifebook",
13483 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010013484};
13485
13486static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013487 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013488 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013489 ALC269_ASUS_AMIC),
13490 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_ASUS_AMIC),
13491 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80JT", ALC269_ASUS_AMIC),
13492 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_ASUS_AMIC),
13493 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_ASUS_AMIC),
13494 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_ASUS_AMIC),
13495 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_ASUS_AMIC),
13496 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_ASUS_AMIC),
13497 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_ASUS_AMIC),
13498 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_ASUS_AMIC),
13499 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_ASUS_AMIC),
13500 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_ASUS_AMIC),
13501 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_ASUS_AMIC),
13502 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_ASUS_AMIC),
13503 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_ASUS_AMIC),
13504 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_ASUS_AMIC),
13505 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_ASUS_AMIC),
13506 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_ASUS_AMIC),
13507 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_ASUS_AMIC),
13508 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_ASUS_AMIC),
13509 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_ASUS_AMIC),
13510 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_AMIC),
13511 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_ASUS_AMIC),
13512 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_AMIC),
13513 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_DMIC),
13514 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_AMIC),
13515 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_AMIC),
13516 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_AMIC),
13517 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020013518 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013519 ALC269_ASUS_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020013520 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013521 ALC269_ASUS_DMIC),
13522 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_ASUS_DMIC),
13523 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_ASUS_DMIC),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013524 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013525 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013526 {}
13527};
13528
13529static struct alc_config_preset alc269_presets[] = {
13530 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013531 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013532 .init_verbs = { alc269_init_verbs },
13533 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13534 .dac_nids = alc269_dac_nids,
13535 .hp_nid = 0x03,
13536 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13537 .channel_mode = alc269_modes,
13538 .input_mux = &alc269_capture_source,
13539 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013540 [ALC269_QUANTA_FL1] = {
13541 .mixers = { alc269_quanta_fl1_mixer },
13542 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13543 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13544 .dac_nids = alc269_dac_nids,
13545 .hp_nid = 0x03,
13546 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13547 .channel_mode = alc269_modes,
13548 .input_mux = &alc269_capture_source,
13549 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013550 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020013551 .init_hook = alc269_quanta_fl1_init_hook,
13552 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010013553 [ALC269_ASUS_AMIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013554 .mixers = { alc269_eeepc_mixer },
13555 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013556 .init_verbs = { alc269_init_verbs,
13557 alc269_eeepc_amic_init_verbs },
13558 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13559 .dac_nids = alc269_dac_nids,
13560 .hp_nid = 0x03,
13561 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13562 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013563 .unsol_event = alc269_eeepc_unsol_event,
13564 .setup = alc269_eeepc_amic_setup,
13565 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013566 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010013567 [ALC269_ASUS_DMIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013568 .mixers = { alc269_eeepc_mixer },
13569 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013570 .init_verbs = { alc269_init_verbs,
13571 alc269_eeepc_dmic_init_verbs },
13572 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13573 .dac_nids = alc269_dac_nids,
13574 .hp_nid = 0x03,
13575 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13576 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013577 .unsol_event = alc269_eeepc_unsol_event,
13578 .setup = alc269_eeepc_dmic_setup,
13579 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013580 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013581 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013582 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013583 .cap_mixer = alc269_epc_capture_mixer,
13584 .init_verbs = { alc269_init_verbs,
13585 alc269_eeepc_dmic_init_verbs },
13586 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13587 .dac_nids = alc269_dac_nids,
13588 .hp_nid = 0x03,
13589 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13590 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013591 .unsol_event = alc269_eeepc_unsol_event,
13592 .setup = alc269_eeepc_dmic_setup,
13593 .init_hook = alc269_eeepc_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010013594 },
Tony Vroon64154832008-11-06 15:08:49 +000013595 [ALC269_LIFEBOOK] = {
13596 .mixers = { alc269_lifebook_mixer },
13597 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13598 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13599 .dac_nids = alc269_dac_nids,
13600 .hp_nid = 0x03,
13601 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13602 .channel_mode = alc269_modes,
13603 .input_mux = &alc269_capture_source,
13604 .unsol_event = alc269_lifebook_unsol_event,
13605 .init_hook = alc269_lifebook_init_hook,
13606 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013607};
13608
13609static int patch_alc269(struct hda_codec *codec)
13610{
13611 struct alc_spec *spec;
13612 int board_config;
13613 int err;
13614
13615 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13616 if (spec == NULL)
13617 return -ENOMEM;
13618
13619 codec->spec = spec;
13620
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013621 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13622
Kailang Yang274693f2009-12-03 10:07:50 +010013623 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
13624 kfree(codec->chip_name);
13625 codec->chip_name = kstrdup("ALC259", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010013626 if (!codec->chip_name) {
13627 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010013628 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010013629 }
Kailang Yang274693f2009-12-03 10:07:50 +010013630 }
13631
Kailang Yangf6a92242007-12-13 16:52:54 +010013632 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13633 alc269_models,
13634 alc269_cfg_tbl);
13635
13636 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013637 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13638 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013639 board_config = ALC269_AUTO;
13640 }
13641
13642 if (board_config == ALC269_AUTO) {
13643 /* automatic parse from the BIOS config */
13644 err = alc269_parse_auto_config(codec);
13645 if (err < 0) {
13646 alc_free(codec);
13647 return err;
13648 } else if (!err) {
13649 printk(KERN_INFO
13650 "hda_codec: Cannot set up configuration "
13651 "from BIOS. Using base mode...\n");
13652 board_config = ALC269_BASIC;
13653 }
13654 }
13655
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013656 err = snd_hda_attach_beep_device(codec, 0x1);
13657 if (err < 0) {
13658 alc_free(codec);
13659 return err;
13660 }
13661
Kailang Yangf6a92242007-12-13 16:52:54 +010013662 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013663 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010013664
Takashi Iwaif03d3112009-03-05 14:18:16 +010013665 if (codec->subsystem_id == 0x17aa3bf8) {
13666 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13667 * fix the sample rate of analog I/O to 44.1kHz
13668 */
13669 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13670 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13671 } else {
13672 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13673 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13674 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013675 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13676 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13677
13678 spec->adc_nids = alc269_adc_nids;
13679 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013680 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013681 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013682 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013683 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013684
Takashi Iwai100d5eb2009-08-10 11:55:51 +020013685 spec->vmaster_nid = 0x02;
13686
Kailang Yangf6a92242007-12-13 16:52:54 +010013687 codec->patch_ops = alc_patch_ops;
13688 if (board_config == ALC269_AUTO)
13689 spec->init_hook = alc269_auto_init;
13690#ifdef CONFIG_SND_HDA_POWER_SAVE
13691 if (!spec->loopback.amplist)
13692 spec->loopback.amplist = alc269_loopbacks;
13693#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013694 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013695
13696 return 0;
13697}
13698
13699/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013700 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13701 */
13702
13703/*
13704 * set the path ways for 2 channel output
13705 * need to set the codec line out and mic 1 pin widgets to inputs
13706 */
13707static struct hda_verb alc861_threestack_ch2_init[] = {
13708 /* set pin widget 1Ah (line in) for input */
13709 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013710 /* set pin widget 18h (mic1/2) for input, for mic also enable
13711 * the vref
13712 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013713 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13714
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013715 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13716#if 0
13717 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13718 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13719#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013720 { } /* end */
13721};
13722/*
13723 * 6ch mode
13724 * need to set the codec line out and mic 1 pin widgets to outputs
13725 */
13726static struct hda_verb alc861_threestack_ch6_init[] = {
13727 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13728 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13729 /* set pin widget 18h (mic1) for output (CLFE)*/
13730 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13731
13732 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013733 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013734
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013735 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13736#if 0
13737 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13738 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13739#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013740 { } /* end */
13741};
13742
13743static struct hda_channel_mode alc861_threestack_modes[2] = {
13744 { 2, alc861_threestack_ch2_init },
13745 { 6, alc861_threestack_ch6_init },
13746};
Takashi Iwai22309c32006-08-09 16:57:28 +020013747/* Set mic1 as input and unmute the mixer */
13748static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13749 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13750 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13751 { } /* end */
13752};
13753/* Set mic1 as output and mute mixer */
13754static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13755 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13756 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13757 { } /* end */
13758};
13759
13760static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13761 { 2, alc861_uniwill_m31_ch2_init },
13762 { 4, alc861_uniwill_m31_ch4_init },
13763};
Kailang Yangdf694da2005-12-05 19:42:22 +010013764
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013765/* Set mic1 and line-in as input and unmute the mixer */
13766static struct hda_verb alc861_asus_ch2_init[] = {
13767 /* set pin widget 1Ah (line in) for input */
13768 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013769 /* set pin widget 18h (mic1/2) for input, for mic also enable
13770 * the vref
13771 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013772 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13773
13774 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13775#if 0
13776 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13777 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13778#endif
13779 { } /* end */
13780};
13781/* Set mic1 nad line-in as output and mute mixer */
13782static struct hda_verb alc861_asus_ch6_init[] = {
13783 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13784 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13785 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13786 /* set pin widget 18h (mic1) for output (CLFE)*/
13787 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13788 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13789 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13790 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13791
13792 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13793#if 0
13794 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13795 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13796#endif
13797 { } /* end */
13798};
13799
13800static struct hda_channel_mode alc861_asus_modes[2] = {
13801 { 2, alc861_asus_ch2_init },
13802 { 6, alc861_asus_ch6_init },
13803};
13804
Kailang Yangdf694da2005-12-05 19:42:22 +010013805/* patch-ALC861 */
13806
13807static struct snd_kcontrol_new alc861_base_mixer[] = {
13808 /* output mixer control */
13809 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13810 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13811 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13812 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13813 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13814
13815 /*Input mixer control */
13816 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13817 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13818 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13819 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13820 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13821 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13822 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13823 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13824 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13825 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013826
Kailang Yangdf694da2005-12-05 19:42:22 +010013827 { } /* end */
13828};
13829
13830static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13831 /* output mixer control */
13832 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13833 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13834 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13835 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13836 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13837
13838 /* Input mixer control */
13839 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13840 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13841 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13842 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13843 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13844 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13845 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13846 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13847 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13848 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013849
Kailang Yangdf694da2005-12-05 19:42:22 +010013850 {
13851 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13852 .name = "Channel Mode",
13853 .info = alc_ch_mode_info,
13854 .get = alc_ch_mode_get,
13855 .put = alc_ch_mode_put,
13856 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13857 },
13858 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013859};
13860
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013861static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013862 /* output mixer control */
13863 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13864 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13865 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013866
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013867 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013868};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013869
Takashi Iwai22309c32006-08-09 16:57:28 +020013870static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13871 /* output mixer control */
13872 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13873 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13874 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13875 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13876 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13877
13878 /* Input mixer control */
13879 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13880 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13881 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13882 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13883 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13884 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13885 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13886 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13887 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13888 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013889
Takashi Iwai22309c32006-08-09 16:57:28 +020013890 {
13891 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13892 .name = "Channel Mode",
13893 .info = alc_ch_mode_info,
13894 .get = alc_ch_mode_get,
13895 .put = alc_ch_mode_put,
13896 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13897 },
13898 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013899};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013900
13901static struct snd_kcontrol_new alc861_asus_mixer[] = {
13902 /* output mixer control */
13903 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13904 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13905 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13906 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13907 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13908
13909 /* Input mixer control */
13910 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13911 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13912 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13913 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13914 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13915 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13916 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13917 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13918 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013919 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13920
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013921 {
13922 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13923 .name = "Channel Mode",
13924 .info = alc_ch_mode_info,
13925 .get = alc_ch_mode_get,
13926 .put = alc_ch_mode_put,
13927 .private_value = ARRAY_SIZE(alc861_asus_modes),
13928 },
13929 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013930};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013931
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013932/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013933static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013934 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13935 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013936 { }
13937};
13938
Kailang Yangdf694da2005-12-05 19:42:22 +010013939/*
13940 * generic initialization of ADC, input mixers and output mixers
13941 */
13942static struct hda_verb alc861_base_init_verbs[] = {
13943 /*
13944 * Unmute ADC0 and set the default input to mic-in
13945 */
13946 /* port-A for surround (rear panel) */
13947 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13948 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13949 /* port-B for mic-in (rear panel) with vref */
13950 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13951 /* port-C for line-in (rear panel) */
13952 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13953 /* port-D for Front */
13954 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13955 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13956 /* port-E for HP out (front panel) */
13957 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13958 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013959 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013960 /* port-F for mic-in (front panel) with vref */
13961 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13962 /* port-G for CLFE (rear panel) */
13963 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13964 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13965 /* port-H for side (rear panel) */
13966 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13967 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13968 /* CD-in */
13969 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13970 /* route front mic to ADC1*/
13971 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13972 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013973
Kailang Yangdf694da2005-12-05 19:42:22 +010013974 /* Unmute DAC0~3 & spdif out*/
13975 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13976 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13977 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13978 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13979 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013980
Kailang Yangdf694da2005-12-05 19:42:22 +010013981 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13982 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13983 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13984 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13985 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013986
Kailang Yangdf694da2005-12-05 19:42:22 +010013987 /* Unmute Stereo Mixer 15 */
13988 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13989 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13990 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013991 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013992
13993 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13994 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13995 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13996 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13997 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13998 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13999 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14000 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014001 /* hp used DAC 3 (Front) */
14002 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014003 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14004
14005 { }
14006};
14007
14008static struct hda_verb alc861_threestack_init_verbs[] = {
14009 /*
14010 * Unmute ADC0 and set the default input to mic-in
14011 */
14012 /* port-A for surround (rear panel) */
14013 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14014 /* port-B for mic-in (rear panel) with vref */
14015 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14016 /* port-C for line-in (rear panel) */
14017 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14018 /* port-D for Front */
14019 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14020 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14021 /* port-E for HP out (front panel) */
14022 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14023 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014024 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014025 /* port-F for mic-in (front panel) with vref */
14026 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14027 /* port-G for CLFE (rear panel) */
14028 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14029 /* port-H for side (rear panel) */
14030 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14031 /* CD-in */
14032 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14033 /* route front mic to ADC1*/
14034 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14035 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14036 /* Unmute DAC0~3 & spdif out*/
14037 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14038 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14039 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14040 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14041 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014042
Kailang Yangdf694da2005-12-05 19:42:22 +010014043 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14044 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14045 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14046 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14047 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014048
Kailang Yangdf694da2005-12-05 19:42:22 +010014049 /* Unmute Stereo Mixer 15 */
14050 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14051 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14052 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014053 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014054
14055 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14056 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14057 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14058 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14059 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14060 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14061 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14062 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014063 /* hp used DAC 3 (Front) */
14064 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014065 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14066 { }
14067};
Takashi Iwai22309c32006-08-09 16:57:28 +020014068
14069static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
14070 /*
14071 * Unmute ADC0 and set the default input to mic-in
14072 */
14073 /* port-A for surround (rear panel) */
14074 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14075 /* port-B for mic-in (rear panel) with vref */
14076 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14077 /* port-C for line-in (rear panel) */
14078 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14079 /* port-D for Front */
14080 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14081 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14082 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014083 /* this has to be set to VREF80 */
14084 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014085 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014086 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014087 /* port-F for mic-in (front panel) with vref */
14088 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14089 /* port-G for CLFE (rear panel) */
14090 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14091 /* port-H for side (rear panel) */
14092 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14093 /* CD-in */
14094 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14095 /* route front mic to ADC1*/
14096 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14097 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14098 /* Unmute DAC0~3 & spdif out*/
14099 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14100 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14101 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14102 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14103 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014104
Takashi Iwai22309c32006-08-09 16:57:28 +020014105 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14106 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14107 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14108 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14109 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014110
Takashi Iwai22309c32006-08-09 16:57:28 +020014111 /* Unmute Stereo Mixer 15 */
14112 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14113 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14114 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014115 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014116
14117 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14118 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14119 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14120 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14121 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14122 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14123 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14124 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014125 /* hp used DAC 3 (Front) */
14126 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014127 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14128 { }
14129};
14130
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014131static struct hda_verb alc861_asus_init_verbs[] = {
14132 /*
14133 * Unmute ADC0 and set the default input to mic-in
14134 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014135 /* port-A for surround (rear panel)
14136 * according to codec#0 this is the HP jack
14137 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014138 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14139 /* route front PCM to HP */
14140 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14141 /* port-B for mic-in (rear panel) with vref */
14142 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14143 /* port-C for line-in (rear panel) */
14144 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14145 /* port-D for Front */
14146 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14147 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14148 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014149 /* this has to be set to VREF80 */
14150 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014151 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014152 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014153 /* port-F for mic-in (front panel) with vref */
14154 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14155 /* port-G for CLFE (rear panel) */
14156 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14157 /* port-H for side (rear panel) */
14158 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14159 /* CD-in */
14160 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14161 /* route front mic to ADC1*/
14162 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14163 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14164 /* Unmute DAC0~3 & spdif out*/
14165 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14166 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14167 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14168 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14169 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14170 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14171 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14172 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14173 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14174 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014175
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014176 /* Unmute Stereo Mixer 15 */
14177 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14178 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14179 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014180 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014181
14182 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14183 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14184 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14185 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14186 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14187 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14188 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14189 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014190 /* hp used DAC 3 (Front) */
14191 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014192 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14193 { }
14194};
14195
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014196/* additional init verbs for ASUS laptops */
14197static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14198 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14199 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14200 { }
14201};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014202
Kailang Yangdf694da2005-12-05 19:42:22 +010014203/*
14204 * generic initialization of ADC, input mixers and output mixers
14205 */
14206static struct hda_verb alc861_auto_init_verbs[] = {
14207 /*
14208 * Unmute ADC0 and set the default input to mic-in
14209 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014210 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014211 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014212
Kailang Yangdf694da2005-12-05 19:42:22 +010014213 /* Unmute DAC0~3 & spdif out*/
14214 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14215 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14216 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14217 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14218 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014219
Kailang Yangdf694da2005-12-05 19:42:22 +010014220 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14221 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14222 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14223 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14224 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014225
Kailang Yangdf694da2005-12-05 19:42:22 +010014226 /* Unmute Stereo Mixer 15 */
14227 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14228 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14229 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14230 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14231
Takashi Iwai1c209302009-07-22 15:17:45 +020014232 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14233 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14234 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14235 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14236 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14237 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14238 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14239 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014240
14241 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14242 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014243 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14244 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014245 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14246 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014247 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14248 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014249
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014250 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014251
14252 { }
14253};
14254
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014255static struct hda_verb alc861_toshiba_init_verbs[] = {
14256 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014257
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014258 { }
14259};
14260
14261/* toggle speaker-output according to the hp-jack state */
14262static void alc861_toshiba_automute(struct hda_codec *codec)
14263{
Wu Fengguang864f92b2009-11-18 12:38:02 +080014264 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014265
Takashi Iwai47fd8302007-08-10 17:11:07 +020014266 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14267 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14268 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14269 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014270}
14271
14272static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14273 unsigned int res)
14274{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014275 if ((res >> 26) == ALC880_HP_EVENT)
14276 alc861_toshiba_automute(codec);
14277}
14278
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014279/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014280#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14281#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14282#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14283#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14284
14285
14286#define ALC861_DIGOUT_NID 0x07
14287
14288static struct hda_channel_mode alc861_8ch_modes[1] = {
14289 { 8, NULL }
14290};
14291
14292static hda_nid_t alc861_dac_nids[4] = {
14293 /* front, surround, clfe, side */
14294 0x03, 0x06, 0x05, 0x04
14295};
14296
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014297static hda_nid_t alc660_dac_nids[3] = {
14298 /* front, clfe, surround */
14299 0x03, 0x05, 0x06
14300};
14301
Kailang Yangdf694da2005-12-05 19:42:22 +010014302static hda_nid_t alc861_adc_nids[1] = {
14303 /* ADC0-2 */
14304 0x08,
14305};
14306
14307static struct hda_input_mux alc861_capture_source = {
14308 .num_items = 5,
14309 .items = {
14310 { "Mic", 0x0 },
14311 { "Front Mic", 0x3 },
14312 { "Line", 0x1 },
14313 { "CD", 0x4 },
14314 { "Mixer", 0x5 },
14315 },
14316};
14317
Takashi Iwai1c209302009-07-22 15:17:45 +020014318static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14319{
14320 struct alc_spec *spec = codec->spec;
14321 hda_nid_t mix, srcs[5];
14322 int i, j, num;
14323
14324 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14325 return 0;
14326 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14327 if (num < 0)
14328 return 0;
14329 for (i = 0; i < num; i++) {
14330 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014331 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014332 if (type != AC_WID_AUD_OUT)
14333 continue;
14334 for (j = 0; j < spec->multiout.num_dacs; j++)
14335 if (spec->multiout.dac_nids[j] == srcs[i])
14336 break;
14337 if (j >= spec->multiout.num_dacs)
14338 return srcs[i];
14339 }
14340 return 0;
14341}
14342
Kailang Yangdf694da2005-12-05 19:42:22 +010014343/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014344static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014345 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014346{
Takashi Iwai1c209302009-07-22 15:17:45 +020014347 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014348 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014349 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014350
14351 spec->multiout.dac_nids = spec->private_dac_nids;
14352 for (i = 0; i < cfg->line_outs; i++) {
14353 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014354 dac = alc861_look_for_dac(codec, nid);
14355 if (!dac)
14356 continue;
14357 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014358 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014359 return 0;
14360}
14361
Takashi Iwai1c209302009-07-22 15:17:45 +020014362static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14363 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014364{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020014365 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020014366 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14367}
14368
14369/* add playback controls from the parsed DAC table */
14370static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14371 const struct auto_pin_cfg *cfg)
14372{
14373 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014374 static const char *chname[4] = {
14375 "Front", "Surround", NULL /*CLFE*/, "Side"
14376 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014377 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014378 int i, err;
14379
14380 if (cfg->line_outs == 1) {
14381 const char *pfx = NULL;
14382 if (!cfg->hp_outs)
14383 pfx = "Master";
14384 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14385 pfx = "Speaker";
14386 if (pfx) {
14387 nid = spec->multiout.dac_nids[0];
14388 return alc861_create_out_sw(codec, pfx, nid, 3);
14389 }
14390 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014391
14392 for (i = 0; i < cfg->line_outs; i++) {
14393 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014394 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014395 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014396 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014397 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014398 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014399 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014400 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014401 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014402 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014403 return err;
14404 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014405 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014406 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014407 return err;
14408 }
14409 }
14410 return 0;
14411}
14412
Takashi Iwai1c209302009-07-22 15:17:45 +020014413static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014414{
Takashi Iwai1c209302009-07-22 15:17:45 +020014415 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014416 int err;
14417 hda_nid_t nid;
14418
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014419 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014420 return 0;
14421
14422 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014423 nid = alc861_look_for_dac(codec, pin);
14424 if (nid) {
14425 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14426 if (err < 0)
14427 return err;
14428 spec->multiout.hp_nid = nid;
14429 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014430 }
14431 return 0;
14432}
14433
14434/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020014435static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014436 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014437{
Takashi Iwai05f5f472009-08-25 13:10:18 +020014438 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014439}
14440
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014441static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14442 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014443 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014444{
Takashi Iwai1c209302009-07-22 15:17:45 +020014445 hda_nid_t mix, srcs[5];
14446 int i, num;
14447
Jacek Luczak564c5be2008-05-03 18:41:23 +020014448 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14449 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014450 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014451 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014452 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14453 return;
14454 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14455 if (num < 0)
14456 return;
14457 for (i = 0; i < num; i++) {
14458 unsigned int mute;
14459 if (srcs[i] == dac || srcs[i] == 0x15)
14460 mute = AMP_IN_UNMUTE(i);
14461 else
14462 mute = AMP_IN_MUTE(i);
14463 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14464 mute);
14465 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014466}
14467
14468static void alc861_auto_init_multi_out(struct hda_codec *codec)
14469{
14470 struct alc_spec *spec = codec->spec;
14471 int i;
14472
14473 for (i = 0; i < spec->autocfg.line_outs; i++) {
14474 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014475 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014476 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014477 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014478 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014479 }
14480}
14481
14482static void alc861_auto_init_hp_out(struct hda_codec *codec)
14483{
14484 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014485
Takashi Iwai15870f02009-10-05 08:25:13 +020014486 if (spec->autocfg.hp_outs)
14487 alc861_auto_set_output_and_unmute(codec,
14488 spec->autocfg.hp_pins[0],
14489 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014490 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020014491 if (spec->autocfg.speaker_outs)
14492 alc861_auto_set_output_and_unmute(codec,
14493 spec->autocfg.speaker_pins[0],
14494 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020014495 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014496}
14497
14498static void alc861_auto_init_analog_input(struct hda_codec *codec)
14499{
14500 struct alc_spec *spec = codec->spec;
14501 int i;
14502
14503 for (i = 0; i < AUTO_PIN_LAST; i++) {
14504 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014505 if (nid >= 0x0c && nid <= 0x11)
14506 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014507 }
14508}
14509
14510/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014511/* return 1 if successful, 0 if the proper config is not found,
14512 * or a negative error code
14513 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014514static int alc861_parse_auto_config(struct hda_codec *codec)
14515{
14516 struct alc_spec *spec = codec->spec;
14517 int err;
14518 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14519
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014520 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14521 alc861_ignore);
14522 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014523 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014524 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014525 return 0; /* can't find valid BIOS pin config */
14526
Takashi Iwai1c209302009-07-22 15:17:45 +020014527 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014528 if (err < 0)
14529 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014530 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014531 if (err < 0)
14532 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014533 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014534 if (err < 0)
14535 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014536 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014537 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014538 return err;
14539
14540 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14541
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014542 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014543 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14544
Takashi Iwai603c4012008-07-30 15:01:44 +020014545 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014546 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014547
Takashi Iwaid88897e2008-10-31 15:01:37 +010014548 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014549
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014550 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014551 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014552
14553 spec->adc_nids = alc861_adc_nids;
14554 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014555 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014556
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014557 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14558
Kailang Yangdf694da2005-12-05 19:42:22 +010014559 return 1;
14560}
14561
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014562/* additional initialization for auto-configuration model */
14563static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014564{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014565 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014566 alc861_auto_init_multi_out(codec);
14567 alc861_auto_init_hp_out(codec);
14568 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014569 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014570 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014571}
14572
Takashi Iwaicb53c622007-08-10 17:21:45 +020014573#ifdef CONFIG_SND_HDA_POWER_SAVE
14574static struct hda_amp_list alc861_loopbacks[] = {
14575 { 0x15, HDA_INPUT, 0 },
14576 { 0x15, HDA_INPUT, 1 },
14577 { 0x15, HDA_INPUT, 2 },
14578 { 0x15, HDA_INPUT, 3 },
14579 { } /* end */
14580};
14581#endif
14582
Kailang Yangdf694da2005-12-05 19:42:22 +010014583
14584/*
14585 * configuration and preset
14586 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014587static const char *alc861_models[ALC861_MODEL_LAST] = {
14588 [ALC861_3ST] = "3stack",
14589 [ALC660_3ST] = "3stack-660",
14590 [ALC861_3ST_DIG] = "3stack-dig",
14591 [ALC861_6ST_DIG] = "6stack-dig",
14592 [ALC861_UNIWILL_M31] = "uniwill-m31",
14593 [ALC861_TOSHIBA] = "toshiba",
14594 [ALC861_ASUS] = "asus",
14595 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14596 [ALC861_AUTO] = "auto",
14597};
14598
14599static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014600 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014601 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14602 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14603 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014604 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014605 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014606 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014607 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14608 * Any other models that need this preset?
14609 */
14610 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014611 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14612 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014613 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14614 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14615 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14616 /* FIXME: the below seems conflict */
14617 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14618 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14619 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014620 {}
14621};
14622
14623static struct alc_config_preset alc861_presets[] = {
14624 [ALC861_3ST] = {
14625 .mixers = { alc861_3ST_mixer },
14626 .init_verbs = { alc861_threestack_init_verbs },
14627 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14628 .dac_nids = alc861_dac_nids,
14629 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14630 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014631 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014632 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14633 .adc_nids = alc861_adc_nids,
14634 .input_mux = &alc861_capture_source,
14635 },
14636 [ALC861_3ST_DIG] = {
14637 .mixers = { alc861_base_mixer },
14638 .init_verbs = { alc861_threestack_init_verbs },
14639 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14640 .dac_nids = alc861_dac_nids,
14641 .dig_out_nid = ALC861_DIGOUT_NID,
14642 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14643 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014644 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014645 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14646 .adc_nids = alc861_adc_nids,
14647 .input_mux = &alc861_capture_source,
14648 },
14649 [ALC861_6ST_DIG] = {
14650 .mixers = { alc861_base_mixer },
14651 .init_verbs = { alc861_base_init_verbs },
14652 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14653 .dac_nids = alc861_dac_nids,
14654 .dig_out_nid = ALC861_DIGOUT_NID,
14655 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14656 .channel_mode = alc861_8ch_modes,
14657 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14658 .adc_nids = alc861_adc_nids,
14659 .input_mux = &alc861_capture_source,
14660 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014661 [ALC660_3ST] = {
14662 .mixers = { alc861_3ST_mixer },
14663 .init_verbs = { alc861_threestack_init_verbs },
14664 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14665 .dac_nids = alc660_dac_nids,
14666 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14667 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014668 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014669 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14670 .adc_nids = alc861_adc_nids,
14671 .input_mux = &alc861_capture_source,
14672 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014673 [ALC861_UNIWILL_M31] = {
14674 .mixers = { alc861_uniwill_m31_mixer },
14675 .init_verbs = { alc861_uniwill_m31_init_verbs },
14676 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14677 .dac_nids = alc861_dac_nids,
14678 .dig_out_nid = ALC861_DIGOUT_NID,
14679 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14680 .channel_mode = alc861_uniwill_m31_modes,
14681 .need_dac_fix = 1,
14682 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14683 .adc_nids = alc861_adc_nids,
14684 .input_mux = &alc861_capture_source,
14685 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014686 [ALC861_TOSHIBA] = {
14687 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014688 .init_verbs = { alc861_base_init_verbs,
14689 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014690 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14691 .dac_nids = alc861_dac_nids,
14692 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14693 .channel_mode = alc883_3ST_2ch_modes,
14694 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14695 .adc_nids = alc861_adc_nids,
14696 .input_mux = &alc861_capture_source,
14697 .unsol_event = alc861_toshiba_unsol_event,
14698 .init_hook = alc861_toshiba_automute,
14699 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014700 [ALC861_ASUS] = {
14701 .mixers = { alc861_asus_mixer },
14702 .init_verbs = { alc861_asus_init_verbs },
14703 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14704 .dac_nids = alc861_dac_nids,
14705 .dig_out_nid = ALC861_DIGOUT_NID,
14706 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14707 .channel_mode = alc861_asus_modes,
14708 .need_dac_fix = 1,
14709 .hp_nid = 0x06,
14710 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14711 .adc_nids = alc861_adc_nids,
14712 .input_mux = &alc861_capture_source,
14713 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014714 [ALC861_ASUS_LAPTOP] = {
14715 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14716 .init_verbs = { alc861_asus_init_verbs,
14717 alc861_asus_laptop_init_verbs },
14718 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14719 .dac_nids = alc861_dac_nids,
14720 .dig_out_nid = ALC861_DIGOUT_NID,
14721 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14722 .channel_mode = alc883_3ST_2ch_modes,
14723 .need_dac_fix = 1,
14724 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14725 .adc_nids = alc861_adc_nids,
14726 .input_mux = &alc861_capture_source,
14727 },
14728};
Kailang Yangdf694da2005-12-05 19:42:22 +010014729
Takashi Iwaicfc9b062009-12-01 12:19:37 +010014730/* Pin config fixes */
14731enum {
14732 PINFIX_FSC_AMILO_PI1505,
14733};
14734
14735static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = {
14736 { 0x0b, 0x0221101f }, /* HP */
14737 { 0x0f, 0x90170310 }, /* speaker */
14738 { }
14739};
14740
14741static const struct alc_fixup alc861_fixups[] = {
14742 [PINFIX_FSC_AMILO_PI1505] = {
14743 .pins = alc861_fsc_amilo_pi1505_pinfix
14744 },
14745};
14746
14747static struct snd_pci_quirk alc861_fixup_tbl[] = {
14748 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
14749 {}
14750};
Kailang Yangdf694da2005-12-05 19:42:22 +010014751
14752static int patch_alc861(struct hda_codec *codec)
14753{
14754 struct alc_spec *spec;
14755 int board_config;
14756 int err;
14757
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014758 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014759 if (spec == NULL)
14760 return -ENOMEM;
14761
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014762 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014763
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014764 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14765 alc861_models,
14766 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014767
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014768 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014769 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14770 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014771 board_config = ALC861_AUTO;
14772 }
14773
Takashi Iwaicfc9b062009-12-01 12:19:37 +010014774 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups);
14775
Kailang Yangdf694da2005-12-05 19:42:22 +010014776 if (board_config == ALC861_AUTO) {
14777 /* automatic parse from the BIOS config */
14778 err = alc861_parse_auto_config(codec);
14779 if (err < 0) {
14780 alc_free(codec);
14781 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014782 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014783 printk(KERN_INFO
14784 "hda_codec: Cannot set up configuration "
14785 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014786 board_config = ALC861_3ST_DIG;
14787 }
14788 }
14789
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014790 err = snd_hda_attach_beep_device(codec, 0x23);
14791 if (err < 0) {
14792 alc_free(codec);
14793 return err;
14794 }
14795
Kailang Yangdf694da2005-12-05 19:42:22 +010014796 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014797 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014798
Kailang Yangdf694da2005-12-05 19:42:22 +010014799 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14800 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14801
Kailang Yangdf694da2005-12-05 19:42:22 +010014802 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14803 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14804
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014805 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14806
Takashi Iwai2134ea42008-01-10 16:53:55 +010014807 spec->vmaster_nid = 0x03;
14808
Kailang Yangdf694da2005-12-05 19:42:22 +010014809 codec->patch_ops = alc_patch_ops;
14810 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014811 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014812#ifdef CONFIG_SND_HDA_POWER_SAVE
14813 if (!spec->loopback.amplist)
14814 spec->loopback.amplist = alc861_loopbacks;
14815#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014816 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014817
Kailang Yangdf694da2005-12-05 19:42:22 +010014818 return 0;
14819}
14820
14821/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014822 * ALC861-VD support
14823 *
14824 * Based on ALC882
14825 *
14826 * In addition, an independent DAC
14827 */
14828#define ALC861VD_DIGOUT_NID 0x06
14829
14830static hda_nid_t alc861vd_dac_nids[4] = {
14831 /* front, surr, clfe, side surr */
14832 0x02, 0x03, 0x04, 0x05
14833};
14834
14835/* dac_nids for ALC660vd are in a different order - according to
14836 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014837 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014838 * of ALC660vd codecs, but for now there is only 3stack mixer
14839 * - and it is the same as in 861vd.
14840 * adc_nids in ALC660vd are (is) the same as in 861vd
14841 */
14842static hda_nid_t alc660vd_dac_nids[3] = {
14843 /* front, rear, clfe, rear_surr */
14844 0x02, 0x04, 0x03
14845};
14846
14847static hda_nid_t alc861vd_adc_nids[1] = {
14848 /* ADC0 */
14849 0x09,
14850};
14851
Takashi Iwaie1406342008-02-11 18:32:32 +010014852static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14853
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014854/* input MUX */
14855/* FIXME: should be a matrix-type input source selection */
14856static struct hda_input_mux alc861vd_capture_source = {
14857 .num_items = 4,
14858 .items = {
14859 { "Mic", 0x0 },
14860 { "Front Mic", 0x1 },
14861 { "Line", 0x2 },
14862 { "CD", 0x4 },
14863 },
14864};
14865
Kailang Yang272a5272007-05-14 11:00:38 +020014866static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014867 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014868 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014869 { "Ext Mic", 0x0 },
14870 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014871 },
14872};
14873
Kailang Yangd1a991a2007-08-15 16:21:59 +020014874static struct hda_input_mux alc861vd_hp_capture_source = {
14875 .num_items = 2,
14876 .items = {
14877 { "Front Mic", 0x0 },
14878 { "ATAPI Mic", 0x1 },
14879 },
14880};
14881
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014882/*
14883 * 2ch mode
14884 */
14885static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14886 { 2, NULL }
14887};
14888
14889/*
14890 * 6ch mode
14891 */
14892static struct hda_verb alc861vd_6stack_ch6_init[] = {
14893 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14894 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14895 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14896 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14897 { } /* end */
14898};
14899
14900/*
14901 * 8ch mode
14902 */
14903static struct hda_verb alc861vd_6stack_ch8_init[] = {
14904 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14905 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14906 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14907 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14908 { } /* end */
14909};
14910
14911static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14912 { 6, alc861vd_6stack_ch6_init },
14913 { 8, alc861vd_6stack_ch8_init },
14914};
14915
14916static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14917 {
14918 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14919 .name = "Channel Mode",
14920 .info = alc_ch_mode_info,
14921 .get = alc_ch_mode_get,
14922 .put = alc_ch_mode_put,
14923 },
14924 { } /* end */
14925};
14926
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014927/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14928 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14929 */
14930static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14931 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14932 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14933
14934 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14935 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14936
14937 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14938 HDA_OUTPUT),
14939 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14940 HDA_OUTPUT),
14941 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14942 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14943
14944 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14945 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14946
14947 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14948
14949 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14950 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14951 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14952
14953 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14954 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14955 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14956
14957 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14958 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14959
14960 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14961 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14962
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014963 { } /* end */
14964};
14965
14966static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14967 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14968 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14969
14970 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14971
14972 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14973 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14974 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14975
14976 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14977 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14978 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14979
14980 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14981 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14982
14983 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14984 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14985
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014986 { } /* end */
14987};
14988
Kailang Yangbdd148a2007-05-08 15:19:08 +020014989static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14990 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14991 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14992 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14993
14994 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14995
14996 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14997 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14998 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14999
15000 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15001 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15002 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15003
15004 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15005 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15006
15007 { } /* end */
15008};
15009
Tobin Davisb419f342008-03-07 11:57:51 +010015010/* Pin assignment: Speaker=0x14, HP = 0x15,
15011 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020015012 */
15013static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010015014 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15015 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015016 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15017 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010015018 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
15019 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15020 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15021 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
15022 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15023 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015024 { } /* end */
15025};
15026
Kailang Yangd1a991a2007-08-15 16:21:59 +020015027/* Pin assignment: Speaker=0x14, Line-out = 0x15,
15028 * Front Mic=0x18, ATAPI Mic = 0x19,
15029 */
15030static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
15031 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15032 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15033 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15034 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
15035 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15036 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15037 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15038 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015039
Kailang Yangd1a991a2007-08-15 16:21:59 +020015040 { } /* end */
15041};
15042
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015043/*
15044 * generic initialization of ADC, input mixers and output mixers
15045 */
15046static struct hda_verb alc861vd_volume_init_verbs[] = {
15047 /*
15048 * Unmute ADC0 and set the default input to mic-in
15049 */
15050 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15051 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15052
15053 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
15054 * the analog-loopback mixer widget
15055 */
15056 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015057 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15058 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15059 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15060 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15061 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015062
15063 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020015064 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15065 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15066 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015067 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015068
15069 /*
15070 * Set up output mixers (0x02 - 0x05)
15071 */
15072 /* set vol=0 to output mixers */
15073 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15074 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15075 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15076 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15077
15078 /* set up input amps for analog loopback */
15079 /* Amp Indices: DAC = 0, mixer = 1 */
15080 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15081 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15082 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15083 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15084 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15085 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15086 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15087 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15088
15089 { }
15090};
15091
15092/*
15093 * 3-stack pin configuration:
15094 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
15095 */
15096static struct hda_verb alc861vd_3stack_init_verbs[] = {
15097 /*
15098 * Set pin mode and muting
15099 */
15100 /* set front pin widgets 0x14 for output */
15101 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15102 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15103 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15104
15105 /* Mic (rear) pin: input vref at 80% */
15106 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15107 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15108 /* Front Mic pin: input vref at 80% */
15109 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15110 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15111 /* Line In pin: input */
15112 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15113 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15114 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15115 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15116 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15117 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15118 /* CD pin widget for input */
15119 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15120
15121 { }
15122};
15123
15124/*
15125 * 6-stack pin configuration:
15126 */
15127static struct hda_verb alc861vd_6stack_init_verbs[] = {
15128 /*
15129 * Set pin mode and muting
15130 */
15131 /* set front pin widgets 0x14 for output */
15132 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15133 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15134 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15135
15136 /* Rear Pin: output 1 (0x0d) */
15137 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15138 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15139 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15140 /* CLFE Pin: output 2 (0x0e) */
15141 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15142 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15143 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15144 /* Side Pin: output 3 (0x0f) */
15145 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15146 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15147 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15148
15149 /* Mic (rear) pin: input vref at 80% */
15150 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15151 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15152 /* Front Mic pin: input vref at 80% */
15153 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15154 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15155 /* Line In pin: input */
15156 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15157 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15158 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15159 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15160 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15161 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15162 /* CD pin widget for input */
15163 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15164
15165 { }
15166};
15167
Kailang Yangbdd148a2007-05-08 15:19:08 +020015168static struct hda_verb alc861vd_eapd_verbs[] = {
15169 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15170 { }
15171};
15172
Kailang Yangf9423e72008-05-27 12:32:25 +020015173static struct hda_verb alc660vd_eapd_verbs[] = {
15174 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15175 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15176 { }
15177};
15178
Kailang Yangbdd148a2007-05-08 15:19:08 +020015179static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15180 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15181 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15182 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15183 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015184 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015185 {}
15186};
15187
Kailang Yangbdd148a2007-05-08 15:19:08 +020015188static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15189{
15190 unsigned int present;
15191 unsigned char bits;
15192
Wu Fengguang864f92b2009-11-18 12:38:02 +080015193 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020015194 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080015195
Takashi Iwai47fd8302007-08-10 17:11:07 +020015196 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15197 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015198}
15199
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015200static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015201{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015202 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015203 spec->autocfg.hp_pins[0] = 0x1b;
15204 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015205}
15206
15207static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15208{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015209 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015210 alc861vd_lenovo_mic_automute(codec);
15211}
15212
15213static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15214 unsigned int res)
15215{
15216 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015217 case ALC880_MIC_EVENT:
15218 alc861vd_lenovo_mic_automute(codec);
15219 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015220 default:
15221 alc_automute_amp_unsol_event(codec, res);
15222 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015223 }
15224}
15225
Kailang Yang272a5272007-05-14 11:00:38 +020015226static struct hda_verb alc861vd_dallas_verbs[] = {
15227 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15228 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15229 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15230 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15231
15232 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15233 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15234 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15235 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15236 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15237 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15238 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15239 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015240
Kailang Yang272a5272007-05-14 11:00:38 +020015241 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15242 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15243 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15244 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15245 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15246 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15247 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15248 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15249
15250 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15251 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15252 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15253 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15254 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15255 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15256 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15257 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15258
15259 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15260 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15261 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15262 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15263
15264 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015265 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015266 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15267
15268 { } /* end */
15269};
15270
15271/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015272static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015273{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015274 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015275
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015276 spec->autocfg.hp_pins[0] = 0x15;
15277 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020015278}
15279
Takashi Iwaicb53c622007-08-10 17:21:45 +020015280#ifdef CONFIG_SND_HDA_POWER_SAVE
15281#define alc861vd_loopbacks alc880_loopbacks
15282#endif
15283
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015284/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015285#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15286#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15287#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15288#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15289
15290/*
15291 * configuration and preset
15292 */
15293static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15294 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015295 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015296 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015297 [ALC861VD_3ST] = "3stack",
15298 [ALC861VD_3ST_DIG] = "3stack-digout",
15299 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015300 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015301 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015302 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015303 [ALC861VD_AUTO] = "auto",
15304};
15305
15306static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015307 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15308 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015309 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015310 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010015311 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015312 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015313 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015314 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015315 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015316 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015317 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015318 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015319 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015320 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015321 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015322 {}
15323};
15324
15325static struct alc_config_preset alc861vd_presets[] = {
15326 [ALC660VD_3ST] = {
15327 .mixers = { alc861vd_3st_mixer },
15328 .init_verbs = { alc861vd_volume_init_verbs,
15329 alc861vd_3stack_init_verbs },
15330 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15331 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015332 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15333 .channel_mode = alc861vd_3stack_2ch_modes,
15334 .input_mux = &alc861vd_capture_source,
15335 },
Mike Crash6963f842007-06-25 12:12:51 +020015336 [ALC660VD_3ST_DIG] = {
15337 .mixers = { alc861vd_3st_mixer },
15338 .init_verbs = { alc861vd_volume_init_verbs,
15339 alc861vd_3stack_init_verbs },
15340 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15341 .dac_nids = alc660vd_dac_nids,
15342 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015343 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15344 .channel_mode = alc861vd_3stack_2ch_modes,
15345 .input_mux = &alc861vd_capture_source,
15346 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015347 [ALC861VD_3ST] = {
15348 .mixers = { alc861vd_3st_mixer },
15349 .init_verbs = { alc861vd_volume_init_verbs,
15350 alc861vd_3stack_init_verbs },
15351 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15352 .dac_nids = alc861vd_dac_nids,
15353 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15354 .channel_mode = alc861vd_3stack_2ch_modes,
15355 .input_mux = &alc861vd_capture_source,
15356 },
15357 [ALC861VD_3ST_DIG] = {
15358 .mixers = { alc861vd_3st_mixer },
15359 .init_verbs = { alc861vd_volume_init_verbs,
15360 alc861vd_3stack_init_verbs },
15361 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15362 .dac_nids = alc861vd_dac_nids,
15363 .dig_out_nid = ALC861VD_DIGOUT_NID,
15364 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15365 .channel_mode = alc861vd_3stack_2ch_modes,
15366 .input_mux = &alc861vd_capture_source,
15367 },
15368 [ALC861VD_6ST_DIG] = {
15369 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15370 .init_verbs = { alc861vd_volume_init_verbs,
15371 alc861vd_6stack_init_verbs },
15372 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15373 .dac_nids = alc861vd_dac_nids,
15374 .dig_out_nid = ALC861VD_DIGOUT_NID,
15375 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15376 .channel_mode = alc861vd_6stack_modes,
15377 .input_mux = &alc861vd_capture_source,
15378 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015379 [ALC861VD_LENOVO] = {
15380 .mixers = { alc861vd_lenovo_mixer },
15381 .init_verbs = { alc861vd_volume_init_verbs,
15382 alc861vd_3stack_init_verbs,
15383 alc861vd_eapd_verbs,
15384 alc861vd_lenovo_unsol_verbs },
15385 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15386 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015387 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15388 .channel_mode = alc861vd_3stack_2ch_modes,
15389 .input_mux = &alc861vd_capture_source,
15390 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015391 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015392 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015393 },
Kailang Yang272a5272007-05-14 11:00:38 +020015394 [ALC861VD_DALLAS] = {
15395 .mixers = { alc861vd_dallas_mixer },
15396 .init_verbs = { alc861vd_dallas_verbs },
15397 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15398 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015399 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15400 .channel_mode = alc861vd_3stack_2ch_modes,
15401 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015402 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015403 .setup = alc861vd_dallas_setup,
15404 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015405 },
15406 [ALC861VD_HP] = {
15407 .mixers = { alc861vd_hp_mixer },
15408 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15409 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15410 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015411 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015412 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15413 .channel_mode = alc861vd_3stack_2ch_modes,
15414 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015415 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015416 .setup = alc861vd_dallas_setup,
15417 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020015418 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015419 [ALC660VD_ASUS_V1S] = {
15420 .mixers = { alc861vd_lenovo_mixer },
15421 .init_verbs = { alc861vd_volume_init_verbs,
15422 alc861vd_3stack_init_verbs,
15423 alc861vd_eapd_verbs,
15424 alc861vd_lenovo_unsol_verbs },
15425 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15426 .dac_nids = alc660vd_dac_nids,
15427 .dig_out_nid = ALC861VD_DIGOUT_NID,
15428 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15429 .channel_mode = alc861vd_3stack_2ch_modes,
15430 .input_mux = &alc861vd_capture_source,
15431 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015432 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015433 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015434 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015435};
15436
15437/*
15438 * BIOS auto configuration
15439 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015440static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15441 const struct auto_pin_cfg *cfg)
15442{
15443 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
15444}
15445
15446
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015447static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15448 hda_nid_t nid, int pin_type, int dac_idx)
15449{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015450 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015451}
15452
15453static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15454{
15455 struct alc_spec *spec = codec->spec;
15456 int i;
15457
15458 for (i = 0; i <= HDA_SIDE; i++) {
15459 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015460 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015461 if (nid)
15462 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015463 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015464 }
15465}
15466
15467
15468static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15469{
15470 struct alc_spec *spec = codec->spec;
15471 hda_nid_t pin;
15472
15473 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015474 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015475 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015476 pin = spec->autocfg.speaker_pins[0];
15477 if (pin)
15478 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015479}
15480
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015481#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15482
15483static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15484{
15485 struct alc_spec *spec = codec->spec;
15486 int i;
15487
15488 for (i = 0; i < AUTO_PIN_LAST; i++) {
15489 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020015490 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015491 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015492 if (nid != ALC861VD_PIN_CD_NID &&
15493 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015494 snd_hda_codec_write(codec, nid, 0,
15495 AC_VERB_SET_AMP_GAIN_MUTE,
15496 AMP_OUT_MUTE);
15497 }
15498 }
15499}
15500
Takashi Iwaif511b012008-08-15 16:46:42 +020015501#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15502
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015503#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15504#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15505
15506/* add playback controls from the parsed DAC table */
15507/* Based on ALC880 version. But ALC861VD has separate,
15508 * different NIDs for mute/unmute switch and volume control */
15509static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15510 const struct auto_pin_cfg *cfg)
15511{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015512 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15513 hda_nid_t nid_v, nid_s;
15514 int i, err;
15515
15516 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015517 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015518 continue;
15519 nid_v = alc861vd_idx_to_mixer_vol(
15520 alc880_dac_to_idx(
15521 spec->multiout.dac_nids[i]));
15522 nid_s = alc861vd_idx_to_mixer_switch(
15523 alc880_dac_to_idx(
15524 spec->multiout.dac_nids[i]));
15525
15526 if (i == 2) {
15527 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015528 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
15529 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015530 HDA_COMPOSE_AMP_VAL(nid_v, 1, 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_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
15535 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015536 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15537 HDA_OUTPUT));
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 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015542 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15543 HDA_INPUT));
15544 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015545 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015546 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
15547 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015548 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15549 HDA_INPUT));
15550 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015551 return err;
15552 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015553 const char *pfx;
15554 if (cfg->line_outs == 1 &&
15555 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
15556 if (!cfg->hp_pins)
15557 pfx = "Speaker";
15558 else
15559 pfx = "PCM";
15560 } else
15561 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015562 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015563 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15564 HDA_OUTPUT));
15565 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015566 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015567 if (cfg->line_outs == 1 &&
15568 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15569 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015570 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015571 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015572 HDA_INPUT));
15573 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015574 return err;
15575 }
15576 }
15577 return 0;
15578}
15579
15580/* add playback controls for speaker and HP outputs */
15581/* Based on ALC880 version. But ALC861VD has separate,
15582 * different NIDs for mute/unmute switch and volume control */
15583static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15584 hda_nid_t pin, const char *pfx)
15585{
15586 hda_nid_t nid_v, nid_s;
15587 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015588
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015589 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015590 return 0;
15591
15592 if (alc880_is_fixed_pin(pin)) {
15593 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15594 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015595 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015596 spec->multiout.hp_nid = nid_v;
15597 else
15598 spec->multiout.extra_out_nid[0] = nid_v;
15599 /* control HP volume/switch on the output mixer amp */
15600 nid_v = alc861vd_idx_to_mixer_vol(
15601 alc880_fixed_pin_idx(pin));
15602 nid_s = alc861vd_idx_to_mixer_switch(
15603 alc880_fixed_pin_idx(pin));
15604
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015605 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015606 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15607 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015608 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015609 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015610 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15611 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015612 return err;
15613 } else if (alc880_is_multi_pin(pin)) {
15614 /* set manual connection */
15615 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015616 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015617 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15618 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015619 return err;
15620 }
15621 return 0;
15622}
15623
15624/* parse the BIOS configuration and set up the alc_spec
15625 * return 1 if successful, 0 if the proper config is not found,
15626 * or a negative error code
15627 * Based on ALC880 version - had to change it to override
15628 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15629static int alc861vd_parse_auto_config(struct hda_codec *codec)
15630{
15631 struct alc_spec *spec = codec->spec;
15632 int err;
15633 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15634
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015635 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15636 alc861vd_ignore);
15637 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015638 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015639 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015640 return 0; /* can't find valid BIOS pin config */
15641
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015642 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15643 if (err < 0)
15644 return err;
15645 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15646 if (err < 0)
15647 return err;
15648 err = alc861vd_auto_create_extra_out(spec,
15649 spec->autocfg.speaker_pins[0],
15650 "Speaker");
15651 if (err < 0)
15652 return err;
15653 err = alc861vd_auto_create_extra_out(spec,
15654 spec->autocfg.hp_pins[0],
15655 "Headphone");
15656 if (err < 0)
15657 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015658 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015659 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015660 return err;
15661
15662 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15663
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015664 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015665 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15666
Takashi Iwai603c4012008-07-30 15:01:44 +020015667 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015668 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015669
Takashi Iwaid88897e2008-10-31 15:01:37 +010015670 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015671
15672 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015673 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015674
Takashi Iwai776e1842007-08-29 15:07:11 +020015675 err = alc_auto_add_mic_boost(codec);
15676 if (err < 0)
15677 return err;
15678
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015679 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15680
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015681 return 1;
15682}
15683
15684/* additional initialization for auto-configuration model */
15685static void alc861vd_auto_init(struct hda_codec *codec)
15686{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015687 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015688 alc861vd_auto_init_multi_out(codec);
15689 alc861vd_auto_init_hp_out(codec);
15690 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015691 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015692 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015693 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015694}
15695
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015696enum {
15697 ALC660VD_FIX_ASUS_GPIO1
15698};
15699
15700/* reset GPIO1 */
15701static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
15702 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
15703 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
15704 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
15705 { }
15706};
15707
15708static const struct alc_fixup alc861vd_fixups[] = {
15709 [ALC660VD_FIX_ASUS_GPIO1] = {
15710 .verbs = alc660vd_fix_asus_gpio1_verbs,
15711 },
15712};
15713
15714static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
15715 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
15716 {}
15717};
15718
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015719static int patch_alc861vd(struct hda_codec *codec)
15720{
15721 struct alc_spec *spec;
15722 int err, board_config;
15723
15724 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15725 if (spec == NULL)
15726 return -ENOMEM;
15727
15728 codec->spec = spec;
15729
15730 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15731 alc861vd_models,
15732 alc861vd_cfg_tbl);
15733
15734 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015735 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15736 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015737 board_config = ALC861VD_AUTO;
15738 }
15739
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015740 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups);
15741
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015742 if (board_config == ALC861VD_AUTO) {
15743 /* automatic parse from the BIOS config */
15744 err = alc861vd_parse_auto_config(codec);
15745 if (err < 0) {
15746 alc_free(codec);
15747 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015748 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015749 printk(KERN_INFO
15750 "hda_codec: Cannot set up configuration "
15751 "from BIOS. Using base mode...\n");
15752 board_config = ALC861VD_3ST;
15753 }
15754 }
15755
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015756 err = snd_hda_attach_beep_device(codec, 0x23);
15757 if (err < 0) {
15758 alc_free(codec);
15759 return err;
15760 }
15761
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015762 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015763 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015764
Kailang Yang2f893282008-05-27 12:14:47 +020015765 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015766 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015767 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015768 }
15769
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015770 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15771 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15772
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015773 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15774 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15775
Takashi Iwaidd704692009-08-11 08:45:11 +020015776 if (!spec->adc_nids) {
15777 spec->adc_nids = alc861vd_adc_nids;
15778 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15779 }
15780 if (!spec->capsrc_nids)
15781 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015782
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015783 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015784 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015785
Takashi Iwai2134ea42008-01-10 16:53:55 +010015786 spec->vmaster_nid = 0x02;
15787
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015788 codec->patch_ops = alc_patch_ops;
15789
15790 if (board_config == ALC861VD_AUTO)
15791 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015792#ifdef CONFIG_SND_HDA_POWER_SAVE
15793 if (!spec->loopback.amplist)
15794 spec->loopback.amplist = alc861vd_loopbacks;
15795#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015796 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015797
15798 return 0;
15799}
15800
15801/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015802 * ALC662 support
15803 *
15804 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15805 * configuration. Each pin widget can choose any input DACs and a mixer.
15806 * Each ADC is connected from a mixer of all inputs. This makes possible
15807 * 6-channel independent captures.
15808 *
15809 * In addition, an independent DAC for the multi-playback (not used in this
15810 * driver yet).
15811 */
15812#define ALC662_DIGOUT_NID 0x06
15813#define ALC662_DIGIN_NID 0x0a
15814
15815static hda_nid_t alc662_dac_nids[4] = {
15816 /* front, rear, clfe, rear_surr */
15817 0x02, 0x03, 0x04
15818};
15819
Kailang Yang622e84c2009-04-21 07:39:04 +020015820static hda_nid_t alc272_dac_nids[2] = {
15821 0x02, 0x03
15822};
15823
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015824static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015825 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015826 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015827};
Takashi Iwaie1406342008-02-11 18:32:32 +010015828
Kailang Yang622e84c2009-04-21 07:39:04 +020015829static hda_nid_t alc272_adc_nids[1] = {
15830 /* ADC1-2 */
15831 0x08,
15832};
15833
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015834static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015835static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15836
Takashi Iwaie1406342008-02-11 18:32:32 +010015837
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015838/* input MUX */
15839/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015840static struct hda_input_mux alc662_capture_source = {
15841 .num_items = 4,
15842 .items = {
15843 { "Mic", 0x0 },
15844 { "Front Mic", 0x1 },
15845 { "Line", 0x2 },
15846 { "CD", 0x4 },
15847 },
15848};
15849
15850static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15851 .num_items = 2,
15852 .items = {
15853 { "Mic", 0x1 },
15854 { "Line", 0x2 },
15855 },
15856};
Kailang Yang291702f2007-10-16 14:28:03 +020015857
Kailang Yang6dda9f42008-05-27 12:05:31 +020015858static struct hda_input_mux alc663_capture_source = {
15859 .num_items = 3,
15860 .items = {
15861 { "Mic", 0x0 },
15862 { "Front Mic", 0x1 },
15863 { "Line", 0x2 },
15864 },
15865};
15866
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015867#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020015868static struct hda_input_mux alc272_nc10_capture_source = {
15869 .num_items = 16,
15870 .items = {
15871 { "Autoselect Mic", 0x0 },
15872 { "Internal Mic", 0x1 },
15873 { "In-0x02", 0x2 },
15874 { "In-0x03", 0x3 },
15875 { "In-0x04", 0x4 },
15876 { "In-0x05", 0x5 },
15877 { "In-0x06", 0x6 },
15878 { "In-0x07", 0x7 },
15879 { "In-0x08", 0x8 },
15880 { "In-0x09", 0x9 },
15881 { "In-0x0a", 0x0a },
15882 { "In-0x0b", 0x0b },
15883 { "In-0x0c", 0x0c },
15884 { "In-0x0d", 0x0d },
15885 { "In-0x0e", 0x0e },
15886 { "In-0x0f", 0x0f },
15887 },
15888};
15889#endif
15890
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015891/*
15892 * 2ch mode
15893 */
15894static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15895 { 2, NULL }
15896};
15897
15898/*
15899 * 2ch mode
15900 */
15901static struct hda_verb alc662_3ST_ch2_init[] = {
15902 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15903 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15904 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15905 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15906 { } /* end */
15907};
15908
15909/*
15910 * 6ch mode
15911 */
15912static struct hda_verb alc662_3ST_ch6_init[] = {
15913 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15914 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15915 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15916 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15917 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15918 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15919 { } /* end */
15920};
15921
15922static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15923 { 2, alc662_3ST_ch2_init },
15924 { 6, alc662_3ST_ch6_init },
15925};
15926
15927/*
15928 * 2ch mode
15929 */
15930static struct hda_verb alc662_sixstack_ch6_init[] = {
15931 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15932 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15933 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15934 { } /* end */
15935};
15936
15937/*
15938 * 6ch mode
15939 */
15940static struct hda_verb alc662_sixstack_ch8_init[] = {
15941 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15942 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15943 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15944 { } /* end */
15945};
15946
15947static struct hda_channel_mode alc662_5stack_modes[2] = {
15948 { 2, alc662_sixstack_ch6_init },
15949 { 6, alc662_sixstack_ch8_init },
15950};
15951
15952/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15953 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15954 */
15955
15956static struct snd_kcontrol_new alc662_base_mixer[] = {
15957 /* output mixer control */
15958 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015959 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015960 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015961 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015962 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15963 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015964 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15965 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015966 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15967
15968 /*Input mixer control */
15969 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15970 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15971 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15972 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15973 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15974 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15975 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15976 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015977 { } /* end */
15978};
15979
15980static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15981 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015982 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015983 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15984 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15985 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15986 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15987 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15988 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15989 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15990 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15991 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015992 { } /* end */
15993};
15994
15995static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15996 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015997 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015998 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015999 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016000 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16001 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016002 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16003 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016004 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16005 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16006 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16007 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16008 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16009 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16010 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16011 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16012 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016013 { } /* end */
16014};
16015
16016static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
16017 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16018 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010016019 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16020 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016021 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16022 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16023 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16024 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16025 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016026 { } /* end */
16027};
16028
Kailang Yang291702f2007-10-16 14:28:03 +020016029static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016030 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16031 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020016032
16033 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
16034 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16035 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16036
16037 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16038 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16039 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16040 { } /* end */
16041};
16042
Kailang Yang8c427222008-01-10 13:03:59 +010016043static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016044 ALC262_HIPPO_MASTER_SWITCH,
16045 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016046 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016047 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16048 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016049 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
16050 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16051 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16052 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16053 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16054 { } /* end */
16055};
16056
Kailang Yangf1d4e282008-08-26 14:03:29 +020016057static struct hda_bind_ctls alc663_asus_bind_master_vol = {
16058 .ops = &snd_hda_bind_vol,
16059 .values = {
16060 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16061 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
16062 0
16063 },
16064};
16065
16066static struct hda_bind_ctls alc663_asus_one_bind_switch = {
16067 .ops = &snd_hda_bind_sw,
16068 .values = {
16069 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16070 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16071 0
16072 },
16073};
16074
Kailang Yang6dda9f42008-05-27 12:05:31 +020016075static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016076 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16077 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
16078 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16079 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16080 { } /* end */
16081};
16082
16083static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
16084 .ops = &snd_hda_bind_sw,
16085 .values = {
16086 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16087 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16088 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16089 0
16090 },
16091};
16092
16093static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
16094 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16095 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
16096 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16097 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16098 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16099 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16100
16101 { } /* end */
16102};
16103
16104static struct hda_bind_ctls alc663_asus_four_bind_switch = {
16105 .ops = &snd_hda_bind_sw,
16106 .values = {
16107 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16108 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16109 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16110 0
16111 },
16112};
16113
16114static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
16115 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16116 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
16117 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16118 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16119 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16120 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16121 { } /* end */
16122};
16123
16124static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016125 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16126 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016127 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16128 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16129 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16130 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16131 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16132 { } /* end */
16133};
16134
16135static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
16136 .ops = &snd_hda_bind_vol,
16137 .values = {
16138 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16139 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16140 0
16141 },
16142};
16143
16144static struct hda_bind_ctls alc663_asus_two_bind_switch = {
16145 .ops = &snd_hda_bind_sw,
16146 .values = {
16147 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16148 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
16149 0
16150 },
16151};
16152
16153static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16154 HDA_BIND_VOL("Master Playback Volume",
16155 &alc663_asus_two_bind_master_vol),
16156 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16157 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016158 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16159 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16160 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016161 { } /* end */
16162};
16163
16164static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16165 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16166 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16167 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16168 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16169 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16170 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016171 { } /* end */
16172};
16173
16174static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16175 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16176 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16177 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16178 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16179 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16180
16181 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16182 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16183 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16184 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16185 { } /* end */
16186};
16187
16188static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16189 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16190 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16191 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16192
16193 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16194 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16195 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16196 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16197 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16198 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16199 { } /* end */
16200};
16201
Kailang Yangebb83ee2009-12-17 12:23:00 +010016202static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
16203 .ops = &snd_hda_bind_sw,
16204 .values = {
16205 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16206 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16207 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16208 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16209 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16210 0
16211 },
16212};
16213
16214static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
16215 .ops = &snd_hda_bind_sw,
16216 .values = {
16217 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16218 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16219 0
16220 },
16221};
16222
16223static struct snd_kcontrol_new alc663_mode7_mixer[] = {
16224 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16225 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16226 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16227 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16228 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16229 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16230 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16231 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16232 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16233 { } /* end */
16234};
16235
16236static struct snd_kcontrol_new alc663_mode8_mixer[] = {
16237 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16238 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16239 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16240 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16241 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16242 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16243 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16244 { } /* end */
16245};
16246
16247
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016248static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16249 {
16250 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16251 .name = "Channel Mode",
16252 .info = alc_ch_mode_info,
16253 .get = alc_ch_mode_get,
16254 .put = alc_ch_mode_put,
16255 },
16256 { } /* end */
16257};
16258
16259static struct hda_verb alc662_init_verbs[] = {
16260 /* ADC: mute amp left and right */
16261 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16262 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16263 /* Front mixer: unmute input/output amp left and right (volume = 0) */
16264
Takashi Iwaicb53c622007-08-10 17:21:45 +020016265 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16266 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16267 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16268 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16269 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016270
Kailang Yangb60dd392007-09-20 12:50:29 +020016271 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16272 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16273 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16274 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16275 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16276 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016277
16278 /* Front Pin: output 0 (0x0c) */
16279 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16280 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16281
16282 /* Rear Pin: output 1 (0x0d) */
16283 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16284 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16285
16286 /* CLFE Pin: output 2 (0x0e) */
16287 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16288 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16289
16290 /* Mic (rear) pin: input vref at 80% */
16291 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16292 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16293 /* Front Mic pin: input vref at 80% */
16294 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16295 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16296 /* Line In pin: input */
16297 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16298 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16299 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16300 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16301 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16302 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16303 /* CD pin widget for input */
16304 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16305
16306 /* FIXME: use matrix-type input source selection */
16307 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16308 /* Input mixer */
16309 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016310 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016311
16312 /* always trun on EAPD */
16313 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16314 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16315
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016316 { }
16317};
16318
16319static struct hda_verb alc662_sue_init_verbs[] = {
16320 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16321 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016322 {}
16323};
16324
16325static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16326 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16327 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16328 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016329};
16330
Kailang Yang8c427222008-01-10 13:03:59 +010016331/* Set Unsolicited Event*/
16332static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16333 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16334 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16335 {}
16336};
16337
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016338/*
16339 * generic initialization of ADC, input mixers and output mixers
16340 */
16341static struct hda_verb alc662_auto_init_verbs[] = {
16342 /*
16343 * Unmute ADC and set the default input to mic-in
16344 */
16345 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16346 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16347
16348 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16349 * mixer widget
16350 * Note: PASD motherboards uses the Line In 2 as the input for front
16351 * panel mic (mic 2)
16352 */
16353 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016354 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16355 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16356 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16357 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16358 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016359
16360 /*
16361 * Set up output mixers (0x0c - 0x0f)
16362 */
16363 /* set vol=0 to output mixers */
16364 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16365 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16366 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16367
16368 /* set up input amps for analog loopback */
16369 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020016370 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16371 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16372 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16373 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16374 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16375 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016376
16377
16378 /* FIXME: use matrix-type input source selection */
16379 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16380 /* Input mixer */
16381 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016382 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016383 { }
16384};
16385
Takashi Iwai24fb9172008-09-02 14:48:20 +020016386/* additional verbs for ALC663 */
16387static struct hda_verb alc663_auto_init_verbs[] = {
16388 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16389 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16390 { }
16391};
16392
Kailang Yang6dda9f42008-05-27 12:05:31 +020016393static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016394 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16395 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016396 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16397 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016398 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16399 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16400 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016401 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16402 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16403 {}
16404};
16405
Kailang Yangf1d4e282008-08-26 14:03:29 +020016406static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16407 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16408 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16409 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16410 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16411 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16412 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16413 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16414 {}
16415};
16416
16417static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16418 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16419 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16420 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16421 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16422 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16423 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16424 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16425 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16426 {}
16427};
16428
16429static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16430 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16431 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16432 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16433 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16434 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16435 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16436 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16437 {}
16438};
16439
16440static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16441 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16442 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16443 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16444 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16445 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16446 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16447 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16448 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16449 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16450 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16451 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16452 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16453 {}
16454};
16455
16456static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16457 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16458 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16459 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16460 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16461 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16462 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16463 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16464 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16465 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16466 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16467 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16468 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16469 {}
16470};
16471
Kailang Yang6dda9f42008-05-27 12:05:31 +020016472static struct hda_verb alc663_g71v_init_verbs[] = {
16473 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16474 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16475 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16476
16477 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16478 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16479 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16480
16481 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16482 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16483 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16484 {}
16485};
16486
16487static struct hda_verb alc663_g50v_init_verbs[] = {
16488 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16489 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16490 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16491
16492 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16493 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16494 {}
16495};
16496
Kailang Yangf1d4e282008-08-26 14:03:29 +020016497static struct hda_verb alc662_ecs_init_verbs[] = {
16498 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16499 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16500 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16501 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16502 {}
16503};
16504
Kailang Yang622e84c2009-04-21 07:39:04 +020016505static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16506 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16507 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16508 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16509 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16510 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16511 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16512 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16513 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16514 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16515 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16516 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16517 {}
16518};
16519
16520static struct hda_verb alc272_dell_init_verbs[] = {
16521 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16522 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16523 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16524 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16525 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16526 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16527 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16528 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16529 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16530 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16531 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16532 {}
16533};
16534
Kailang Yangebb83ee2009-12-17 12:23:00 +010016535static struct hda_verb alc663_mode7_init_verbs[] = {
16536 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16537 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16538 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16539 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16540 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16541 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16542 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
16543 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16544 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16545 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16546 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16547 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16548 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16549 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16550 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16551 {}
16552};
16553
16554static struct hda_verb alc663_mode8_init_verbs[] = {
16555 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16556 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16557 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16558 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16559 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16560 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16561 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16562 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16563 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16564 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16565 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16566 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16567 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16568 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16569 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16570 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16571 {}
16572};
16573
Kailang Yangf1d4e282008-08-26 14:03:29 +020016574static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16575 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16576 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16577 { } /* end */
16578};
16579
Kailang Yang622e84c2009-04-21 07:39:04 +020016580static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16581 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16582 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16583 { } /* end */
16584};
16585
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016586static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16587{
16588 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016589 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016590
Wu Fengguang864f92b2009-11-18 12:38:02 +080016591 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016592 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016593
Takashi Iwai47fd8302007-08-10 17:11:07 +020016594 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16595 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016596}
16597
16598static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16599{
16600 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016601 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016602
Wu Fengguang864f92b2009-11-18 12:38:02 +080016603 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016604 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016605
Takashi Iwai47fd8302007-08-10 17:11:07 +020016606 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16607 HDA_AMP_MUTE, bits);
16608 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16609 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016610}
16611
16612static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16613 unsigned int res)
16614{
16615 if ((res >> 26) == ALC880_HP_EVENT)
16616 alc662_lenovo_101e_all_automute(codec);
16617 if ((res >> 26) == ALC880_FRONT_EVENT)
16618 alc662_lenovo_101e_ispeaker_automute(codec);
16619}
16620
Kailang Yang291702f2007-10-16 14:28:03 +020016621/* unsolicited event for HP jack sensing */
16622static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16623 unsigned int res)
16624{
Kailang Yang291702f2007-10-16 14:28:03 +020016625 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016626 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016627 else
16628 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016629}
16630
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016631static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020016632{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016633 struct alc_spec *spec = codec->spec;
16634
16635 alc262_hippo1_setup(codec);
16636 spec->ext_mic.pin = 0x18;
16637 spec->ext_mic.mux_idx = 0;
16638 spec->int_mic.pin = 0x19;
16639 spec->int_mic.mux_idx = 1;
16640 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020016641}
16642
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016643static void alc662_eeepc_inithook(struct hda_codec *codec)
16644{
16645 alc262_hippo_automute(codec);
16646 alc_mic_automute(codec);
16647}
16648
16649static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010016650{
Takashi Iwai42171c12009-05-08 14:11:43 +020016651 struct alc_spec *spec = codec->spec;
16652
16653 spec->autocfg.hp_pins[0] = 0x14;
16654 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010016655}
16656
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016657#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
16658
Kailang Yang6dda9f42008-05-27 12:05:31 +020016659static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16660{
16661 unsigned int present;
16662 unsigned char bits;
16663
Wu Fengguang864f92b2009-11-18 12:38:02 +080016664 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016665 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016666 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16667 AMP_IN_MUTE(0), bits);
16668 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16669 AMP_IN_MUTE(0), bits);
16670}
16671
16672static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16673{
16674 unsigned int present;
16675 unsigned char bits;
16676
Wu Fengguang864f92b2009-11-18 12:38:02 +080016677 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016678 bits = present ? HDA_AMP_MUTE : 0;
16679 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16680 AMP_IN_MUTE(0), bits);
16681 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16682 AMP_IN_MUTE(0), bits);
16683 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16684 AMP_IN_MUTE(0), bits);
16685 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16686 AMP_IN_MUTE(0), bits);
16687}
16688
16689static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16690{
16691 unsigned int present;
16692 unsigned char bits;
16693
Wu Fengguang864f92b2009-11-18 12:38:02 +080016694 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016695 bits = present ? HDA_AMP_MUTE : 0;
16696 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16697 AMP_IN_MUTE(0), bits);
16698 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16699 AMP_IN_MUTE(0), bits);
16700 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16701 AMP_IN_MUTE(0), bits);
16702 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16703 AMP_IN_MUTE(0), bits);
16704}
16705
16706static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16707{
16708 unsigned int present;
16709 unsigned char bits;
16710
Wu Fengguang864f92b2009-11-18 12:38:02 +080016711 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016712 bits = present ? 0 : PIN_OUT;
16713 snd_hda_codec_write(codec, 0x14, 0,
16714 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16715}
16716
16717static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16718{
16719 unsigned int present1, present2;
16720
Wu Fengguang864f92b2009-11-18 12:38:02 +080016721 present1 = snd_hda_jack_detect(codec, 0x21);
16722 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016723
16724 if (present1 || present2) {
16725 snd_hda_codec_write_cache(codec, 0x14, 0,
16726 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16727 } else {
16728 snd_hda_codec_write_cache(codec, 0x14, 0,
16729 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16730 }
16731}
16732
16733static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16734{
16735 unsigned int present1, present2;
16736
Wu Fengguang864f92b2009-11-18 12:38:02 +080016737 present1 = snd_hda_jack_detect(codec, 0x1b);
16738 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016739
16740 if (present1 || present2) {
16741 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16742 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16743 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16744 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16745 } else {
16746 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16747 AMP_IN_MUTE(0), 0);
16748 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16749 AMP_IN_MUTE(0), 0);
16750 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016751}
16752
Kailang Yangebb83ee2009-12-17 12:23:00 +010016753static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
16754{
16755 unsigned int present1, present2;
16756
16757 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16758 AC_VERB_GET_PIN_SENSE, 0)
16759 & AC_PINSENSE_PRESENCE;
16760 present2 = snd_hda_codec_read(codec, 0x21, 0,
16761 AC_VERB_GET_PIN_SENSE, 0)
16762 & AC_PINSENSE_PRESENCE;
16763
16764 if (present1 || present2) {
16765 snd_hda_codec_write_cache(codec, 0x14, 0,
16766 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16767 snd_hda_codec_write_cache(codec, 0x17, 0,
16768 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16769 } else {
16770 snd_hda_codec_write_cache(codec, 0x14, 0,
16771 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16772 snd_hda_codec_write_cache(codec, 0x17, 0,
16773 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16774 }
16775}
16776
16777static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
16778{
16779 unsigned int present1, present2;
16780
16781 present1 = snd_hda_codec_read(codec, 0x21, 0,
16782 AC_VERB_GET_PIN_SENSE, 0)
16783 & AC_PINSENSE_PRESENCE;
16784 present2 = snd_hda_codec_read(codec, 0x15, 0,
16785 AC_VERB_GET_PIN_SENSE, 0)
16786 & AC_PINSENSE_PRESENCE;
16787
16788 if (present1 || present2) {
16789 snd_hda_codec_write_cache(codec, 0x14, 0,
16790 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16791 snd_hda_codec_write_cache(codec, 0x17, 0,
16792 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16793 } else {
16794 snd_hda_codec_write_cache(codec, 0x14, 0,
16795 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16796 snd_hda_codec_write_cache(codec, 0x17, 0,
16797 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16798 }
16799}
16800
Kailang Yang6dda9f42008-05-27 12:05:31 +020016801static void alc663_m51va_unsol_event(struct hda_codec *codec,
16802 unsigned int res)
16803{
16804 switch (res >> 26) {
16805 case ALC880_HP_EVENT:
16806 alc663_m51va_speaker_automute(codec);
16807 break;
16808 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016809 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016810 break;
16811 }
16812}
16813
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016814static void alc663_m51va_setup(struct hda_codec *codec)
16815{
16816 struct alc_spec *spec = codec->spec;
16817 spec->ext_mic.pin = 0x18;
16818 spec->ext_mic.mux_idx = 0;
16819 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010016820 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016821 spec->auto_mic = 1;
16822}
16823
Kailang Yang6dda9f42008-05-27 12:05:31 +020016824static void alc663_m51va_inithook(struct hda_codec *codec)
16825{
16826 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016827 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016828}
16829
Kailang Yangf1d4e282008-08-26 14:03:29 +020016830/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016831#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010016832
16833static void alc663_mode1_setup(struct hda_codec *codec)
16834{
16835 struct alc_spec *spec = codec->spec;
16836 spec->ext_mic.pin = 0x18;
16837 spec->ext_mic.mux_idx = 0;
16838 spec->int_mic.pin = 0x19;
16839 spec->int_mic.mux_idx = 1;
16840 spec->auto_mic = 1;
16841}
16842
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016843#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020016844
Kailang Yangf1d4e282008-08-26 14:03:29 +020016845/* ***************** Mode2 ******************************/
16846static void alc662_mode2_unsol_event(struct hda_codec *codec,
16847 unsigned int res)
16848{
16849 switch (res >> 26) {
16850 case ALC880_HP_EVENT:
16851 alc662_f5z_speaker_automute(codec);
16852 break;
16853 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016854 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016855 break;
16856 }
16857}
16858
Kailang Yangebb83ee2009-12-17 12:23:00 +010016859#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016860
Kailang Yangf1d4e282008-08-26 14:03:29 +020016861static void alc662_mode2_inithook(struct hda_codec *codec)
16862{
16863 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016864 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016865}
16866/* ***************** Mode3 ******************************/
16867static void alc663_mode3_unsol_event(struct hda_codec *codec,
16868 unsigned int res)
16869{
16870 switch (res >> 26) {
16871 case ALC880_HP_EVENT:
16872 alc663_two_hp_m1_speaker_automute(codec);
16873 break;
16874 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016875 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016876 break;
16877 }
16878}
16879
Kailang Yangebb83ee2009-12-17 12:23:00 +010016880#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016881
Kailang Yangf1d4e282008-08-26 14:03:29 +020016882static void alc663_mode3_inithook(struct hda_codec *codec)
16883{
16884 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016885 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016886}
16887/* ***************** Mode4 ******************************/
16888static void alc663_mode4_unsol_event(struct hda_codec *codec,
16889 unsigned int res)
16890{
16891 switch (res >> 26) {
16892 case ALC880_HP_EVENT:
16893 alc663_21jd_two_speaker_automute(codec);
16894 break;
16895 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016896 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016897 break;
16898 }
16899}
16900
Kailang Yangebb83ee2009-12-17 12:23:00 +010016901#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016902
Kailang Yangf1d4e282008-08-26 14:03:29 +020016903static void alc663_mode4_inithook(struct hda_codec *codec)
16904{
16905 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016906 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016907}
16908/* ***************** Mode5 ******************************/
16909static void alc663_mode5_unsol_event(struct hda_codec *codec,
16910 unsigned int res)
16911{
16912 switch (res >> 26) {
16913 case ALC880_HP_EVENT:
16914 alc663_15jd_two_speaker_automute(codec);
16915 break;
16916 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016917 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016918 break;
16919 }
16920}
16921
Kailang Yangebb83ee2009-12-17 12:23:00 +010016922#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016923
Kailang Yangf1d4e282008-08-26 14:03:29 +020016924static void alc663_mode5_inithook(struct hda_codec *codec)
16925{
16926 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016927 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016928}
16929/* ***************** Mode6 ******************************/
16930static void alc663_mode6_unsol_event(struct hda_codec *codec,
16931 unsigned int res)
16932{
16933 switch (res >> 26) {
16934 case ALC880_HP_EVENT:
16935 alc663_two_hp_m2_speaker_automute(codec);
16936 break;
16937 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016938 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016939 break;
16940 }
16941}
16942
Kailang Yangebb83ee2009-12-17 12:23:00 +010016943#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016944
Kailang Yangf1d4e282008-08-26 14:03:29 +020016945static void alc663_mode6_inithook(struct hda_codec *codec)
16946{
16947 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016948 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016949}
16950
Kailang Yangebb83ee2009-12-17 12:23:00 +010016951/* ***************** Mode7 ******************************/
16952static void alc663_mode7_unsol_event(struct hda_codec *codec,
16953 unsigned int res)
16954{
16955 switch (res >> 26) {
16956 case ALC880_HP_EVENT:
16957 alc663_two_hp_m7_speaker_automute(codec);
16958 break;
16959 case ALC880_MIC_EVENT:
16960 alc_mic_automute(codec);
16961 break;
16962 }
16963}
16964
16965#define alc663_mode7_setup alc663_mode1_setup
16966
16967static void alc663_mode7_inithook(struct hda_codec *codec)
16968{
16969 alc663_two_hp_m7_speaker_automute(codec);
16970 alc_mic_automute(codec);
16971}
16972
16973/* ***************** Mode8 ******************************/
16974static void alc663_mode8_unsol_event(struct hda_codec *codec,
16975 unsigned int res)
16976{
16977 switch (res >> 26) {
16978 case ALC880_HP_EVENT:
16979 alc663_two_hp_m8_speaker_automute(codec);
16980 break;
16981 case ALC880_MIC_EVENT:
16982 alc_mic_automute(codec);
16983 break;
16984 }
16985}
16986
16987#define alc663_mode8_setup alc663_m51va_setup
16988
16989static void alc663_mode8_inithook(struct hda_codec *codec)
16990{
16991 alc663_two_hp_m8_speaker_automute(codec);
16992 alc_mic_automute(codec);
16993}
16994
Kailang Yang6dda9f42008-05-27 12:05:31 +020016995static void alc663_g71v_hp_automute(struct hda_codec *codec)
16996{
16997 unsigned int present;
16998 unsigned char bits;
16999
Wu Fengguang864f92b2009-11-18 12:38:02 +080017000 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017001 bits = present ? HDA_AMP_MUTE : 0;
17002 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17003 HDA_AMP_MUTE, bits);
17004 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17005 HDA_AMP_MUTE, bits);
17006}
17007
17008static void alc663_g71v_front_automute(struct hda_codec *codec)
17009{
17010 unsigned int present;
17011 unsigned char bits;
17012
Wu Fengguang864f92b2009-11-18 12:38:02 +080017013 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017014 bits = present ? HDA_AMP_MUTE : 0;
17015 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17016 HDA_AMP_MUTE, bits);
17017}
17018
17019static void alc663_g71v_unsol_event(struct hda_codec *codec,
17020 unsigned int res)
17021{
17022 switch (res >> 26) {
17023 case ALC880_HP_EVENT:
17024 alc663_g71v_hp_automute(codec);
17025 break;
17026 case ALC880_FRONT_EVENT:
17027 alc663_g71v_front_automute(codec);
17028 break;
17029 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017030 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017031 break;
17032 }
17033}
17034
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017035#define alc663_g71v_setup alc663_m51va_setup
17036
Kailang Yang6dda9f42008-05-27 12:05:31 +020017037static void alc663_g71v_inithook(struct hda_codec *codec)
17038{
17039 alc663_g71v_front_automute(codec);
17040 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017041 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017042}
17043
17044static void alc663_g50v_unsol_event(struct hda_codec *codec,
17045 unsigned int res)
17046{
17047 switch (res >> 26) {
17048 case ALC880_HP_EVENT:
17049 alc663_m51va_speaker_automute(codec);
17050 break;
17051 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017052 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017053 break;
17054 }
17055}
17056
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017057#define alc663_g50v_setup alc663_m51va_setup
17058
Kailang Yang6dda9f42008-05-27 12:05:31 +020017059static void alc663_g50v_inithook(struct hda_codec *codec)
17060{
17061 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017062 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017063}
17064
Kailang Yangf1d4e282008-08-26 14:03:29 +020017065static struct snd_kcontrol_new alc662_ecs_mixer[] = {
17066 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020017067 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017068
17069 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
17070 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
17071 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
17072
17073 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17074 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17075 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17076 { } /* end */
17077};
17078
Chris Pockelé9541ba12009-05-12 08:08:53 +020017079static struct snd_kcontrol_new alc272_nc10_mixer[] = {
17080 /* Master Playback automatically created from Speaker and Headphone */
17081 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17082 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17083 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17084 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17085
17086 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17087 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17088 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
17089
17090 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17091 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17092 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
17093 { } /* end */
17094};
17095
Takashi Iwaicb53c622007-08-10 17:21:45 +020017096#ifdef CONFIG_SND_HDA_POWER_SAVE
17097#define alc662_loopbacks alc880_loopbacks
17098#endif
17099
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017100
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017101/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017102#define alc662_pcm_analog_playback alc880_pcm_analog_playback
17103#define alc662_pcm_analog_capture alc880_pcm_analog_capture
17104#define alc662_pcm_digital_playback alc880_pcm_digital_playback
17105#define alc662_pcm_digital_capture alc880_pcm_digital_capture
17106
17107/*
17108 * configuration and preset
17109 */
17110static const char *alc662_models[ALC662_MODEL_LAST] = {
17111 [ALC662_3ST_2ch_DIG] = "3stack-dig",
17112 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
17113 [ALC662_3ST_6ch] = "3stack-6ch",
17114 [ALC662_5ST_DIG] = "6stack-dig",
17115 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020017116 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010017117 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017118 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020017119 [ALC663_ASUS_M51VA] = "m51va",
17120 [ALC663_ASUS_G71V] = "g71v",
17121 [ALC663_ASUS_H13] = "h13",
17122 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017123 [ALC663_ASUS_MODE1] = "asus-mode1",
17124 [ALC662_ASUS_MODE2] = "asus-mode2",
17125 [ALC663_ASUS_MODE3] = "asus-mode3",
17126 [ALC663_ASUS_MODE4] = "asus-mode4",
17127 [ALC663_ASUS_MODE5] = "asus-mode5",
17128 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010017129 [ALC663_ASUS_MODE7] = "asus-mode7",
17130 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020017131 [ALC272_DELL] = "dell",
17132 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020017133 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017134 [ALC662_AUTO] = "auto",
17135};
17136
17137static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010017138 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020017139 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
17140 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017141 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
17142 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
17143 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
17144 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
17145 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
17146 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017147 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
17148 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017149 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017150 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
17151 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
17152 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
17153 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
17154 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017155 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017156 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
17157 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017158 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
17159 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
17160 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
17161 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017162 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017163 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
17164 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
17165 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017166 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
17167 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
17168 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
17169 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017170 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017171 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
17172 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017173 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017174 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
17175 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
17176 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017177 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
17178 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
17179 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017180 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
17181 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
17182 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017183 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017184 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
17185 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017186 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017187 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020017188 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017189 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
17190 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
17191 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017192 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017193 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
17194 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010017195 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020017196 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010017197 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017198 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030017199 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
17200 ALC662_3ST_6ch_DIG),
Manoj Iyer3db6c032009-09-22 18:33:29 -050017201 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB200", ALC663_ASUS_MODE4),
Chris Pockelé9541ba12009-05-12 08:08:53 +020017202 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030017203 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
17204 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020017205 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020017206 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017207 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020017208 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020017209 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017210 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
17211 ALC663_ASUS_H13),
David Santinoli7aee6742009-12-09 12:34:26 +010017212 SND_PCI_QUIRK(0x8086, 0xd604, "Intel mobo", ALC662_3ST_2ch_DIG),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017213 {}
17214};
17215
17216static struct alc_config_preset alc662_presets[] = {
17217 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017218 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017219 .init_verbs = { alc662_init_verbs },
17220 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17221 .dac_nids = alc662_dac_nids,
17222 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017223 .dig_in_nid = ALC662_DIGIN_NID,
17224 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17225 .channel_mode = alc662_3ST_2ch_modes,
17226 .input_mux = &alc662_capture_source,
17227 },
17228 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017229 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017230 .init_verbs = { alc662_init_verbs },
17231 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17232 .dac_nids = alc662_dac_nids,
17233 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017234 .dig_in_nid = ALC662_DIGIN_NID,
17235 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17236 .channel_mode = alc662_3ST_6ch_modes,
17237 .need_dac_fix = 1,
17238 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017239 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017240 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017241 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017242 .init_verbs = { alc662_init_verbs },
17243 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17244 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017245 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17246 .channel_mode = alc662_3ST_6ch_modes,
17247 .need_dac_fix = 1,
17248 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017249 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017250 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017251 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017252 .init_verbs = { alc662_init_verbs },
17253 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17254 .dac_nids = alc662_dac_nids,
17255 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017256 .dig_in_nid = ALC662_DIGIN_NID,
17257 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
17258 .channel_mode = alc662_5stack_modes,
17259 .input_mux = &alc662_capture_source,
17260 },
17261 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017262 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017263 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
17264 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17265 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017266 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17267 .channel_mode = alc662_3ST_2ch_modes,
17268 .input_mux = &alc662_lenovo_101e_capture_source,
17269 .unsol_event = alc662_lenovo_101e_unsol_event,
17270 .init_hook = alc662_lenovo_101e_all_automute,
17271 },
Kailang Yang291702f2007-10-16 14:28:03 +020017272 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017273 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020017274 .init_verbs = { alc662_init_verbs,
17275 alc662_eeepc_sue_init_verbs },
17276 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17277 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020017278 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17279 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020017280 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017281 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020017282 .init_hook = alc662_eeepc_inithook,
17283 },
Kailang Yang8c427222008-01-10 13:03:59 +010017284 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017285 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010017286 alc662_chmode_mixer },
17287 .init_verbs = { alc662_init_verbs,
17288 alc662_eeepc_ep20_sue_init_verbs },
17289 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17290 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010017291 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17292 .channel_mode = alc662_3ST_6ch_modes,
17293 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020017294 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017295 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010017296 .init_hook = alc662_eeepc_ep20_inithook,
17297 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017298 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017299 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017300 .init_verbs = { alc662_init_verbs,
17301 alc662_ecs_init_verbs },
17302 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17303 .dac_nids = alc662_dac_nids,
17304 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17305 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017306 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017307 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017308 .init_hook = alc662_eeepc_inithook,
17309 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017310 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017311 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017312 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17313 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17314 .dac_nids = alc662_dac_nids,
17315 .dig_out_nid = ALC662_DIGOUT_NID,
17316 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17317 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017318 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017319 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017320 .init_hook = alc663_m51va_inithook,
17321 },
17322 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017323 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017324 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
17325 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17326 .dac_nids = alc662_dac_nids,
17327 .dig_out_nid = ALC662_DIGOUT_NID,
17328 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17329 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017330 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017331 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017332 .init_hook = alc663_g71v_inithook,
17333 },
17334 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017335 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017336 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17337 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17338 .dac_nids = alc662_dac_nids,
17339 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17340 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017341 .unsol_event = alc663_m51va_unsol_event,
17342 .init_hook = alc663_m51va_inithook,
17343 },
17344 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017345 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017346 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17347 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17348 .dac_nids = alc662_dac_nids,
17349 .dig_out_nid = ALC662_DIGOUT_NID,
17350 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17351 .channel_mode = alc662_3ST_6ch_modes,
17352 .input_mux = &alc663_capture_source,
17353 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017354 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017355 .init_hook = alc663_g50v_inithook,
17356 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017357 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017358 .mixers = { alc663_m51va_mixer },
17359 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017360 .init_verbs = { alc662_init_verbs,
17361 alc663_21jd_amic_init_verbs },
17362 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17363 .hp_nid = 0x03,
17364 .dac_nids = alc662_dac_nids,
17365 .dig_out_nid = ALC662_DIGOUT_NID,
17366 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17367 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017368 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017369 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017370 .init_hook = alc663_mode1_inithook,
17371 },
17372 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017373 .mixers = { alc662_1bjd_mixer },
17374 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017375 .init_verbs = { alc662_init_verbs,
17376 alc662_1bjd_amic_init_verbs },
17377 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17378 .dac_nids = alc662_dac_nids,
17379 .dig_out_nid = ALC662_DIGOUT_NID,
17380 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17381 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017382 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017383 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017384 .init_hook = alc662_mode2_inithook,
17385 },
17386 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017387 .mixers = { alc663_two_hp_m1_mixer },
17388 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017389 .init_verbs = { alc662_init_verbs,
17390 alc663_two_hp_amic_m1_init_verbs },
17391 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17392 .hp_nid = 0x03,
17393 .dac_nids = alc662_dac_nids,
17394 .dig_out_nid = ALC662_DIGOUT_NID,
17395 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17396 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017397 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017398 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017399 .init_hook = alc663_mode3_inithook,
17400 },
17401 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017402 .mixers = { alc663_asus_21jd_clfe_mixer },
17403 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017404 .init_verbs = { alc662_init_verbs,
17405 alc663_21jd_amic_init_verbs},
17406 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17407 .hp_nid = 0x03,
17408 .dac_nids = alc662_dac_nids,
17409 .dig_out_nid = ALC662_DIGOUT_NID,
17410 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17411 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017412 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017413 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017414 .init_hook = alc663_mode4_inithook,
17415 },
17416 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017417 .mixers = { alc663_asus_15jd_clfe_mixer },
17418 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017419 .init_verbs = { alc662_init_verbs,
17420 alc663_15jd_amic_init_verbs },
17421 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17422 .hp_nid = 0x03,
17423 .dac_nids = alc662_dac_nids,
17424 .dig_out_nid = ALC662_DIGOUT_NID,
17425 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17426 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017427 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017428 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017429 .init_hook = alc663_mode5_inithook,
17430 },
17431 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017432 .mixers = { alc663_two_hp_m2_mixer },
17433 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017434 .init_verbs = { alc662_init_verbs,
17435 alc663_two_hp_amic_m2_init_verbs },
17436 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17437 .hp_nid = 0x03,
17438 .dac_nids = alc662_dac_nids,
17439 .dig_out_nid = ALC662_DIGOUT_NID,
17440 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17441 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017442 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017443 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017444 .init_hook = alc663_mode6_inithook,
17445 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010017446 [ALC663_ASUS_MODE7] = {
17447 .mixers = { alc663_mode7_mixer },
17448 .cap_mixer = alc662_auto_capture_mixer,
17449 .init_verbs = { alc662_init_verbs,
17450 alc663_mode7_init_verbs },
17451 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17452 .hp_nid = 0x03,
17453 .dac_nids = alc662_dac_nids,
17454 .dig_out_nid = ALC662_DIGOUT_NID,
17455 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17456 .channel_mode = alc662_3ST_2ch_modes,
17457 .unsol_event = alc663_mode7_unsol_event,
17458 .setup = alc663_mode7_setup,
17459 .init_hook = alc663_mode7_inithook,
17460 },
17461 [ALC663_ASUS_MODE8] = {
17462 .mixers = { alc663_mode8_mixer },
17463 .cap_mixer = alc662_auto_capture_mixer,
17464 .init_verbs = { alc662_init_verbs,
17465 alc663_mode8_init_verbs },
17466 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17467 .hp_nid = 0x03,
17468 .dac_nids = alc662_dac_nids,
17469 .dig_out_nid = ALC662_DIGOUT_NID,
17470 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17471 .channel_mode = alc662_3ST_2ch_modes,
17472 .unsol_event = alc663_mode8_unsol_event,
17473 .setup = alc663_mode8_setup,
17474 .init_hook = alc663_mode8_inithook,
17475 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017476 [ALC272_DELL] = {
17477 .mixers = { alc663_m51va_mixer },
17478 .cap_mixer = alc272_auto_capture_mixer,
17479 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17480 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17481 .dac_nids = alc662_dac_nids,
17482 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17483 .adc_nids = alc272_adc_nids,
17484 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17485 .capsrc_nids = alc272_capsrc_nids,
17486 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017487 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017488 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017489 .init_hook = alc663_m51va_inithook,
17490 },
17491 [ALC272_DELL_ZM1] = {
17492 .mixers = { alc663_m51va_mixer },
17493 .cap_mixer = alc662_auto_capture_mixer,
17494 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17495 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17496 .dac_nids = alc662_dac_nids,
17497 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17498 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017499 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020017500 .capsrc_nids = alc662_capsrc_nids,
17501 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017502 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017503 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017504 .init_hook = alc663_m51va_inithook,
17505 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017506 [ALC272_SAMSUNG_NC10] = {
17507 .mixers = { alc272_nc10_mixer },
17508 .init_verbs = { alc662_init_verbs,
17509 alc663_21jd_amic_init_verbs },
17510 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17511 .dac_nids = alc272_dac_nids,
17512 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17513 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017514 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020017515 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017516 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020017517 .init_hook = alc663_mode4_inithook,
17518 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017519};
17520
17521
17522/*
17523 * BIOS auto configuration
17524 */
17525
Takashi Iwai7085ec12009-10-02 09:03:58 +020017526/* convert from MIX nid to DAC */
17527static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
17528{
17529 if (nid == 0x0f)
17530 return 0x02;
17531 else if (nid >= 0x0c && nid <= 0x0e)
17532 return nid - 0x0c + 0x02;
17533 else
17534 return 0;
17535}
17536
17537/* get MIX nid connected to the given pin targeted to DAC */
17538static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
17539 hda_nid_t dac)
17540{
17541 hda_nid_t mix[4];
17542 int i, num;
17543
17544 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
17545 for (i = 0; i < num; i++) {
17546 if (alc662_mix_to_dac(mix[i]) == dac)
17547 return mix[i];
17548 }
17549 return 0;
17550}
17551
17552/* look for an empty DAC slot */
17553static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
17554{
17555 struct alc_spec *spec = codec->spec;
17556 hda_nid_t srcs[5];
17557 int i, j, num;
17558
17559 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
17560 if (num < 0)
17561 return 0;
17562 for (i = 0; i < num; i++) {
17563 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
17564 if (!nid)
17565 continue;
17566 for (j = 0; j < spec->multiout.num_dacs; j++)
17567 if (spec->multiout.dac_nids[j] == nid)
17568 break;
17569 if (j >= spec->multiout.num_dacs)
17570 return nid;
17571 }
17572 return 0;
17573}
17574
17575/* fill in the dac_nids table from the parsed pin configuration */
17576static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
17577 const struct auto_pin_cfg *cfg)
17578{
17579 struct alc_spec *spec = codec->spec;
17580 int i;
17581 hda_nid_t dac;
17582
17583 spec->multiout.dac_nids = spec->private_dac_nids;
17584 for (i = 0; i < cfg->line_outs; i++) {
17585 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
17586 if (!dac)
17587 continue;
17588 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
17589 }
17590 return 0;
17591}
17592
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017593static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017594 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017595{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017596 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017597 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
17598}
17599
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017600static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017601 hda_nid_t nid, unsigned int chs)
17602{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017603 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017604 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
17605}
17606
17607#define alc662_add_stereo_vol(spec, pfx, nid) \
17608 alc662_add_vol_ctl(spec, pfx, nid, 3)
17609#define alc662_add_stereo_sw(spec, pfx, nid) \
17610 alc662_add_sw_ctl(spec, pfx, nid, 3)
17611
17612/* add playback controls from the parsed DAC table */
17613static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
17614 const struct auto_pin_cfg *cfg)
17615{
17616 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017617 static const char *chname[4] = {
17618 "Front", "Surround", NULL /*CLFE*/, "Side"
17619 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020017620 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017621 int i, err;
17622
17623 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017624 nid = spec->multiout.dac_nids[i];
17625 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017626 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017627 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
17628 if (!mix)
17629 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017630 if (i == 2) {
17631 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017632 err = alc662_add_vol_ctl(spec, "Center", nid, 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_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017636 if (err < 0)
17637 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017638 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017639 if (err < 0)
17640 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017641 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017642 if (err < 0)
17643 return err;
17644 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017645 const char *pfx;
17646 if (cfg->line_outs == 1 &&
17647 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017648 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017649 pfx = "Speaker";
17650 else
17651 pfx = "PCM";
17652 } else
17653 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017654 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017655 if (err < 0)
17656 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017657 if (cfg->line_outs == 1 &&
17658 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
17659 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020017660 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017661 if (err < 0)
17662 return err;
17663 }
17664 }
17665 return 0;
17666}
17667
17668/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017669/* return DAC nid if any new DAC is assigned */
17670static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017671 const char *pfx)
17672{
Takashi Iwai7085ec12009-10-02 09:03:58 +020017673 struct alc_spec *spec = codec->spec;
17674 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017675 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017676
17677 if (!pin)
17678 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017679 nid = alc662_look_for_dac(codec, pin);
17680 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017681 /* the corresponding DAC is already occupied */
17682 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
17683 return 0; /* no way */
17684 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017685 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017686 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17687 }
17688
17689 mix = alc662_dac_to_mix(codec, pin, nid);
17690 if (!mix)
17691 return 0;
17692 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
17693 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020017694 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017695 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
17696 if (err < 0)
17697 return err;
17698 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017699}
17700
17701/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017702#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020017703 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017704
17705static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17706 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017707 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017708{
Takashi Iwai7085ec12009-10-02 09:03:58 +020017709 int i, num;
17710 hda_nid_t srcs[4];
17711
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017712 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017713 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017714 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
17715 if (num <= 1)
17716 return;
17717 for (i = 0; i < num; i++) {
17718 if (alc662_mix_to_dac(srcs[i]) != dac)
17719 continue;
17720 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
17721 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017722 }
17723}
17724
17725static void alc662_auto_init_multi_out(struct hda_codec *codec)
17726{
17727 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017728 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017729 int i;
17730
17731 for (i = 0; i <= HDA_SIDE; i++) {
17732 hda_nid_t nid = spec->autocfg.line_out_pins[i];
17733 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017734 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017735 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017736 }
17737}
17738
17739static void alc662_auto_init_hp_out(struct hda_codec *codec)
17740{
17741 struct alc_spec *spec = codec->spec;
17742 hda_nid_t pin;
17743
17744 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017745 if (pin)
17746 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
17747 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017748 pin = spec->autocfg.speaker_pins[0];
17749 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020017750 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
17751 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017752}
17753
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017754#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17755
17756static void alc662_auto_init_analog_input(struct hda_codec *codec)
17757{
17758 struct alc_spec *spec = codec->spec;
17759 int i;
17760
17761 for (i = 0; i < AUTO_PIN_LAST; i++) {
17762 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020017763 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017764 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017765 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017766 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017767 snd_hda_codec_write(codec, nid, 0,
17768 AC_VERB_SET_AMP_GAIN_MUTE,
17769 AMP_OUT_MUTE);
17770 }
17771 }
17772}
17773
Takashi Iwaif511b012008-08-15 16:46:42 +020017774#define alc662_auto_init_input_src alc882_auto_init_input_src
17775
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017776static int alc662_parse_auto_config(struct hda_codec *codec)
17777{
17778 struct alc_spec *spec = codec->spec;
17779 int err;
17780 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17781
17782 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17783 alc662_ignore);
17784 if (err < 0)
17785 return err;
17786 if (!spec->autocfg.line_outs)
17787 return 0; /* can't find valid BIOS pin config */
17788
Takashi Iwai7085ec12009-10-02 09:03:58 +020017789 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017790 if (err < 0)
17791 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017792 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017793 if (err < 0)
17794 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017795 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017796 spec->autocfg.speaker_pins[0],
17797 "Speaker");
17798 if (err < 0)
17799 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017800 if (err)
17801 spec->multiout.extra_out_nid[0] = err;
17802 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017803 "Headphone");
17804 if (err < 0)
17805 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017806 if (err)
17807 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017808 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017809 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017810 return err;
17811
17812 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17813
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017814 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017815 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17816
Takashi Iwai603c4012008-07-30 15:01:44 +020017817 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017818 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017819
17820 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017821 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017822
Takashi Iwaid88897e2008-10-31 15:01:37 +010017823 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017824 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017825 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017826
17827 err = alc_auto_add_mic_boost(codec);
17828 if (err < 0)
17829 return err;
17830
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017831 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17832
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017833 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017834}
17835
17836/* additional initialization for auto-configuration model */
17837static void alc662_auto_init(struct hda_codec *codec)
17838{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017839 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017840 alc662_auto_init_multi_out(codec);
17841 alc662_auto_init_hp_out(codec);
17842 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017843 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017844 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017845 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017846}
17847
17848static int patch_alc662(struct hda_codec *codec)
17849{
17850 struct alc_spec *spec;
17851 int err, board_config;
17852
17853 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17854 if (!spec)
17855 return -ENOMEM;
17856
17857 codec->spec = spec;
17858
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017859 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17860
Kailang Yang274693f2009-12-03 10:07:50 +010017861 if (alc_read_coef_idx(codec, 0)==0x8020){
17862 kfree(codec->chip_name);
17863 codec->chip_name = kstrdup("ALC661", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017864 if (!codec->chip_name) {
17865 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010017866 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017867 }
Kailang Yang274693f2009-12-03 10:07:50 +010017868 }
17869
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017870 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17871 alc662_models,
17872 alc662_cfg_tbl);
17873 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017874 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17875 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017876 board_config = ALC662_AUTO;
17877 }
17878
17879 if (board_config == ALC662_AUTO) {
17880 /* automatic parse from the BIOS config */
17881 err = alc662_parse_auto_config(codec);
17882 if (err < 0) {
17883 alc_free(codec);
17884 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017885 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017886 printk(KERN_INFO
17887 "hda_codec: Cannot set up configuration "
17888 "from BIOS. Using base mode...\n");
17889 board_config = ALC662_3ST_2ch_DIG;
17890 }
17891 }
17892
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017893 err = snd_hda_attach_beep_device(codec, 0x1);
17894 if (err < 0) {
17895 alc_free(codec);
17896 return err;
17897 }
17898
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017899 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017900 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017901
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017902 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17903 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17904
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017905 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17906 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17907
Takashi Iwaidd704692009-08-11 08:45:11 +020017908 if (!spec->adc_nids) {
17909 spec->adc_nids = alc662_adc_nids;
17910 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17911 }
17912 if (!spec->capsrc_nids)
17913 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017914
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017915 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017916 set_capture_mixer(codec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017917 if (codec->vendor_id == 0x10ec0662)
17918 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17919 else
17920 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017921
Takashi Iwai2134ea42008-01-10 16:53:55 +010017922 spec->vmaster_nid = 0x02;
17923
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017924 codec->patch_ops = alc_patch_ops;
17925 if (board_config == ALC662_AUTO)
17926 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017927#ifdef CONFIG_SND_HDA_POWER_SAVE
17928 if (!spec->loopback.amplist)
17929 spec->loopback.amplist = alc662_loopbacks;
17930#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017931 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017932
17933 return 0;
17934}
17935
Kailang Yang274693f2009-12-03 10:07:50 +010017936static int patch_alc888(struct hda_codec *codec)
17937{
17938 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
17939 kfree(codec->chip_name);
17940 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017941 if (!codec->chip_name) {
17942 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010017943 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017944 }
17945 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010017946 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017947 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010017948}
17949
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017950/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017951 * patch entries
17952 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017953static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017954 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017955 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017956 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017957 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017958 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010017959 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017960 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010017961 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017962 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017963 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017964 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17965 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17966 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017967 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017968 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017969 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17970 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017971 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017972 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017973 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017974 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020017975 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017976 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020017977 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017978 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017979 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017980 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020017981 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017982 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010017983 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017984 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010017985 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017986 {} /* terminator */
17987};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017988
17989MODULE_ALIAS("snd-hda-codec-id:10ec*");
17990
17991MODULE_LICENSE("GPL");
17992MODULE_DESCRIPTION("Realtek HD-audio codec");
17993
17994static struct hda_codec_preset_list realtek_list = {
17995 .preset = snd_hda_preset_realtek,
17996 .owner = THIS_MODULE,
17997};
17998
17999static int __init patch_realtek_init(void)
18000{
18001 return snd_hda_add_codec_preset(&realtek_list);
18002}
18003
18004static void __exit patch_realtek_exit(void)
18005{
18006 snd_hda_delete_codec_preset(&realtek_list);
18007}
18008
18009module_init(patch_realtek_init)
18010module_exit(patch_realtek_exit)