blob: 3f92def752fd727d8924ca21605e3a50e4a63a67 [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);
Hector Martinf5de24b2009-12-20 22:51:31 +0100340#ifdef CONFIG_SND_HDA_POWER_SAVE
341 void (*power_hook)(struct hda_codec *codec, int power);
342#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100343
Takashi Iwai834be882006-03-01 14:16:17 +0100344 /* for pin sensing */
345 unsigned int sense_updated: 1;
346 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100347 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200348 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200349
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100350 /* other flags */
351 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200352 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100353
Takashi Iwai2134ea42008-01-10 16:53:55 +0100354 /* for virtual master */
355 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200356#ifdef CONFIG_SND_HDA_POWER_SAVE
357 struct hda_loopback_check loopback;
358#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200359
360 /* for PLL fix */
361 hda_nid_t pll_nid;
362 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100363};
364
365/*
366 * configuration template - to be copied to the spec instance
367 */
368struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200369 struct snd_kcontrol_new *mixers[5]; /* should be identical size
370 * with spec
371 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100372 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100373 const struct hda_verb *init_verbs[5];
374 unsigned int num_dacs;
375 hda_nid_t *dac_nids;
376 hda_nid_t dig_out_nid; /* optional */
377 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800378 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100379 unsigned int num_adc_nids;
380 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100381 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100382 hda_nid_t dig_in_nid;
383 unsigned int num_channel_mode;
384 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200385 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200386 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200387 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100388 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100389 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200390 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100391 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200392#ifdef CONFIG_SND_HDA_POWER_SAVE
393 struct hda_amp_list *loopbacks;
Hector Martinf5de24b2009-12-20 22:51:31 +0100394 void (*power_hook)(struct hda_codec *codec, int power);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200395#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396};
397
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398
399/*
400 * input MUX handling
401 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200402static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
403 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404{
405 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
406 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200407 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
408 if (mux_idx >= spec->num_mux_defs)
409 mux_idx = 0;
410 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411}
412
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200413static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
414 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415{
416 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
417 struct alc_spec *spec = codec->spec;
418 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
419
420 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
421 return 0;
422}
423
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200424static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
425 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426{
427 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
428 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100429 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100431 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100432 hda_nid_t nid = spec->capsrc_nids ?
433 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200434 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435
Takashi Iwaicd896c32008-11-18 12:36:33 +0100436 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
437 imux = &spec->input_mux[mux_idx];
438
Takashi Iwaia22d5432009-07-27 12:54:26 +0200439 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200440 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100441 /* Matrix-mixer style (e.g. ALC882) */
442 unsigned int *cur_val = &spec->cur_mux[adc_idx];
443 unsigned int i, idx;
444
445 idx = ucontrol->value.enumerated.item[0];
446 if (idx >= imux->num_items)
447 idx = imux->num_items - 1;
448 if (*cur_val == idx)
449 return 0;
450 for (i = 0; i < imux->num_items; i++) {
451 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
452 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
453 imux->items[i].index,
454 HDA_AMP_MUTE, v);
455 }
456 *cur_val = idx;
457 return 1;
458 } else {
459 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100460 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100461 &spec->cur_mux[adc_idx]);
462 }
463}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200464
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465/*
466 * channel mode setting
467 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200468static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
469 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470{
471 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
472 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100473 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
474 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475}
476
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200477static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
478 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479{
480 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
481 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100482 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200483 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200484 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485}
486
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200487static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
488 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489{
490 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
491 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200492 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
493 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200494 &spec->ext_channel_count);
495 if (err >= 0 && !spec->const_channel_count) {
496 spec->multiout.max_channels = spec->ext_channel_count;
497 if (spec->need_dac_fix)
498 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
499 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200500 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501}
502
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100504 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200505 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100506 * being part of a format specifier. Maximum allowed length of a value is
507 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100508 *
509 * Note: some retasking pin complexes seem to ignore requests for input
510 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
511 * are requested. Therefore order this list so that this behaviour will not
512 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200513 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
514 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200515 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100516static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100517 "Mic 50pc bias", "Mic 80pc bias",
518 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100519};
520static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100521 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100522};
523/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200524 * in the pin being assumed to be exclusively an input or an output pin. In
525 * addition, "input" pins may or may not process the mic bias option
526 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
527 * accept requests for bias as of chip versions up to March 2006) and/or
528 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100529 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200530#define ALC_PIN_DIR_IN 0x00
531#define ALC_PIN_DIR_OUT 0x01
532#define ALC_PIN_DIR_INOUT 0x02
533#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
534#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100535
Kailang Yangea1fb292008-08-26 12:58:38 +0200536/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100537 * For each direction the minimum and maximum values are given.
538 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200539static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100540 { 0, 2 }, /* ALC_PIN_DIR_IN */
541 { 3, 4 }, /* ALC_PIN_DIR_OUT */
542 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200543 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
544 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100545};
546#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
547#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
548#define alc_pin_mode_n_items(_dir) \
549 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
550
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200551static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
552 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200553{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100554 unsigned int item_num = uinfo->value.enumerated.item;
555 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
556
557 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200558 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100559 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
560
561 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
562 item_num = alc_pin_mode_min(dir);
563 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200564 return 0;
565}
566
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200567static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
568 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200569{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100570 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200571 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
572 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100573 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200574 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200575 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
576 AC_VERB_GET_PIN_WIDGET_CONTROL,
577 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200578
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100579 /* Find enumerated value for current pinctl setting */
580 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200581 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100582 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200583 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100584 return 0;
585}
586
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200587static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
588 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100589{
590 signed int change;
591 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
592 hda_nid_t nid = kcontrol->private_value & 0xffff;
593 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
594 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200595 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
596 AC_VERB_GET_PIN_WIDGET_CONTROL,
597 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100598
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200599 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100600 val = alc_pin_mode_min(dir);
601
602 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100603 if (change) {
604 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200605 snd_hda_codec_write_cache(codec, nid, 0,
606 AC_VERB_SET_PIN_WIDGET_CONTROL,
607 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100608
Kailang Yangea1fb292008-08-26 12:58:38 +0200609 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100610 * for the requested pin mode. Enum values of 2 or less are
611 * input modes.
612 *
613 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200614 * reduces noise slightly (particularly on input) so we'll
615 * do it. However, having both input and output buffers
616 * enabled simultaneously doesn't seem to be problematic if
617 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100618 */
619 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200620 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
621 HDA_AMP_MUTE, HDA_AMP_MUTE);
622 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
623 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100624 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200625 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
626 HDA_AMP_MUTE, HDA_AMP_MUTE);
627 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
628 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100629 }
630 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200631 return change;
632}
633
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100634#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200635 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100636 .info = alc_pin_mode_info, \
637 .get = alc_pin_mode_get, \
638 .put = alc_pin_mode_put, \
639 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100640
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100641/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
642 * together using a mask with more than one bit set. This control is
643 * currently used only by the ALC260 test model. At this stage they are not
644 * needed for any "production" models.
645 */
646#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200647#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200648
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200649static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
650 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100651{
652 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
653 hda_nid_t nid = kcontrol->private_value & 0xffff;
654 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
655 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200656 unsigned int val = snd_hda_codec_read(codec, nid, 0,
657 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100658
659 *valp = (val & mask) != 0;
660 return 0;
661}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200662static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
663 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100664{
665 signed int change;
666 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
667 hda_nid_t nid = kcontrol->private_value & 0xffff;
668 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
669 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200670 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
671 AC_VERB_GET_GPIO_DATA,
672 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100673
674 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200675 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
676 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100677 gpio_data &= ~mask;
678 else
679 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200680 snd_hda_codec_write_cache(codec, nid, 0,
681 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100682
683 return change;
684}
685#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
686 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
687 .info = alc_gpio_data_info, \
688 .get = alc_gpio_data_get, \
689 .put = alc_gpio_data_put, \
690 .private_value = nid | (mask<<16) }
691#endif /* CONFIG_SND_DEBUG */
692
Jonathan Woithe92621f12006-02-28 11:47:47 +0100693/* A switch control to allow the enabling of the digital IO pins on the
694 * ALC260. This is incredibly simplistic; the intention of this control is
695 * to provide something in the test model allowing digital outputs to be
696 * identified if present. If models are found which can utilise these
697 * outputs a more complete mixer control can be devised for those models if
698 * necessary.
699 */
700#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200701#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200702
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200703static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
704 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100705{
706 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
707 hda_nid_t nid = kcontrol->private_value & 0xffff;
708 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
709 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200710 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100711 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100712
713 *valp = (val & mask) != 0;
714 return 0;
715}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200716static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
717 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100718{
719 signed int change;
720 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
721 hda_nid_t nid = kcontrol->private_value & 0xffff;
722 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
723 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200724 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100725 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200726 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100727
728 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200729 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100730 if (val==0)
731 ctrl_data &= ~mask;
732 else
733 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200734 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
735 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100736
737 return change;
738}
739#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
740 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
741 .info = alc_spdif_ctrl_info, \
742 .get = alc_spdif_ctrl_get, \
743 .put = alc_spdif_ctrl_put, \
744 .private_value = nid | (mask<<16) }
745#endif /* CONFIG_SND_DEBUG */
746
Jonathan Woithef8225f62008-01-08 12:16:54 +0100747/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
748 * Again, this is only used in the ALC26x test models to help identify when
749 * the EAPD line must be asserted for features to work.
750 */
751#ifdef CONFIG_SND_DEBUG
752#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
753
754static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
755 struct snd_ctl_elem_value *ucontrol)
756{
757 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
758 hda_nid_t nid = kcontrol->private_value & 0xffff;
759 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
760 long *valp = ucontrol->value.integer.value;
761 unsigned int val = snd_hda_codec_read(codec, nid, 0,
762 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
763
764 *valp = (val & mask) != 0;
765 return 0;
766}
767
768static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
769 struct snd_ctl_elem_value *ucontrol)
770{
771 int change;
772 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
773 hda_nid_t nid = kcontrol->private_value & 0xffff;
774 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
775 long val = *ucontrol->value.integer.value;
776 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
777 AC_VERB_GET_EAPD_BTLENABLE,
778 0x00);
779
780 /* Set/unset the masked control bit(s) as needed */
781 change = (!val ? 0 : mask) != (ctrl_data & mask);
782 if (!val)
783 ctrl_data &= ~mask;
784 else
785 ctrl_data |= mask;
786 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
787 ctrl_data);
788
789 return change;
790}
791
792#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
793 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
794 .info = alc_eapd_ctrl_info, \
795 .get = alc_eapd_ctrl_get, \
796 .put = alc_eapd_ctrl_put, \
797 .private_value = nid | (mask<<16) }
798#endif /* CONFIG_SND_DEBUG */
799
Kailang Yangdf694da2005-12-05 19:42:22 +0100800/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100801 * set up the input pin config (depending on the given auto-pin type)
802 */
803static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
804 int auto_pin_type)
805{
806 unsigned int val = PIN_IN;
807
808 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
809 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100810 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100811 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
812 if (pincap & AC_PINCAP_VREF_80)
813 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200814 else if (pincap & AC_PINCAP_VREF_50)
815 val = PIN_VREF50;
816 else if (pincap & AC_PINCAP_VREF_100)
817 val = PIN_VREF100;
818 else if (pincap & AC_PINCAP_VREF_GRD)
819 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100820 }
821 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
822}
823
824/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100825 */
826static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
827{
828 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
829 return;
830 spec->mixers[spec->num_mixers++] = mix;
831}
832
833static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
834{
835 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
836 return;
837 spec->init_verbs[spec->num_init_verbs++] = verb;
838}
839
Takashi Iwaidaead532008-11-28 12:55:36 +0100840#ifdef CONFIG_PROC_FS
841/*
842 * hook for proc
843 */
844static void print_realtek_coef(struct snd_info_buffer *buffer,
845 struct hda_codec *codec, hda_nid_t nid)
846{
847 int coeff;
848
849 if (nid != 0x20)
850 return;
851 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
852 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
853 coeff = snd_hda_codec_read(codec, nid, 0,
854 AC_VERB_GET_COEF_INDEX, 0);
855 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
856}
857#else
858#define print_realtek_coef NULL
859#endif
860
Takashi Iwaid88897e2008-10-31 15:01:37 +0100861/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100862 * set up from the preset table
863 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200864static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200865 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100866{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200867 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100868 int i;
869
870 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100871 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100872 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200873 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
874 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100875 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200876
Kailang Yangdf694da2005-12-05 19:42:22 +0100877 spec->channel_mode = preset->channel_mode;
878 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200879 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200880 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100881
Hector Martin3b315d72009-06-02 10:54:19 +0200882 if (preset->const_channel_count)
883 spec->multiout.max_channels = preset->const_channel_count;
884 else
885 spec->multiout.max_channels = spec->channel_mode[0].channels;
886 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100887
888 spec->multiout.num_dacs = preset->num_dacs;
889 spec->multiout.dac_nids = preset->dac_nids;
890 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800891 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100892 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200893
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200894 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200895 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200896 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100897 spec->input_mux = preset->input_mux;
898
899 spec->num_adc_nids = preset->num_adc_nids;
900 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100901 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100902 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100903
904 spec->unsol_event = preset->unsol_event;
905 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200906#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100907 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200908 spec->loopback.amplist = preset->loopbacks;
909#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200910
911 if (preset->setup)
912 preset->setup(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100913}
914
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200915/* Enable GPIO mask and set output */
916static struct hda_verb alc_gpio1_init_verbs[] = {
917 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
918 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
919 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
920 { }
921};
922
923static struct hda_verb alc_gpio2_init_verbs[] = {
924 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
925 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
926 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
927 { }
928};
929
Kailang Yangbdd148a2007-05-08 15:19:08 +0200930static struct hda_verb alc_gpio3_init_verbs[] = {
931 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
932 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
933 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
934 { }
935};
936
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200937/*
938 * Fix hardware PLL issue
939 * On some codecs, the analog PLL gating control must be off while
940 * the default value is 1.
941 */
942static void alc_fix_pll(struct hda_codec *codec)
943{
944 struct alc_spec *spec = codec->spec;
945 unsigned int val;
946
947 if (!spec->pll_nid)
948 return;
949 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
950 spec->pll_coef_idx);
951 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
952 AC_VERB_GET_PROC_COEF, 0);
953 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
954 spec->pll_coef_idx);
955 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
956 val & ~(1 << spec->pll_coef_bit));
957}
958
959static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
960 unsigned int coef_idx, unsigned int coef_bit)
961{
962 struct alc_spec *spec = codec->spec;
963 spec->pll_nid = nid;
964 spec->pll_coef_idx = coef_idx;
965 spec->pll_coef_bit = coef_bit;
966 alc_fix_pll(codec);
967}
968
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200969static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200970{
971 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200972 unsigned int nid = spec->autocfg.hp_pins[0];
973 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200974
Takashi Iwaiad87c642009-11-02 14:23:15 +0100975 if (!nid)
976 return;
Wu Fengguang864f92b2009-11-18 12:38:02 +0800977 spec->jack_present = snd_hda_jack_detect(codec, nid);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200978 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
979 nid = spec->autocfg.speaker_pins[i];
980 if (!nid)
981 break;
982 snd_hda_codec_write(codec, nid, 0,
983 AC_VERB_SET_PIN_WIDGET_CONTROL,
984 spec->jack_present ? 0 : PIN_OUT);
985 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200986}
987
Takashi Iwai6c819492009-08-10 18:47:44 +0200988static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
989 hda_nid_t nid)
990{
991 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
992 int i, nums;
993
994 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
995 for (i = 0; i < nums; i++)
996 if (conn[i] == nid)
997 return i;
998 return -1;
999}
1000
Kailang Yang7fb0d782008-10-15 11:12:35 +02001001static void alc_mic_automute(struct hda_codec *codec)
1002{
1003 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001004 struct alc_mic_route *dead, *alive;
1005 unsigned int present, type;
1006 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001007
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001008 if (!spec->auto_mic)
1009 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001010 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1011 return;
1012 if (snd_BUG_ON(!spec->adc_nids))
1013 return;
1014
1015 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1016
Wu Fengguang864f92b2009-11-18 12:38:02 +08001017 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001018 if (present) {
1019 alive = &spec->ext_mic;
1020 dead = &spec->int_mic;
1021 } else {
1022 alive = &spec->int_mic;
1023 dead = &spec->ext_mic;
1024 }
1025
Takashi Iwai6c819492009-08-10 18:47:44 +02001026 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1027 if (type == AC_WID_AUD_MIX) {
1028 /* Matrix-mixer style (e.g. ALC882) */
1029 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1030 alive->mux_idx,
1031 HDA_AMP_MUTE, 0);
1032 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1033 dead->mux_idx,
1034 HDA_AMP_MUTE, HDA_AMP_MUTE);
1035 } else {
1036 /* MUX style (e.g. ALC880) */
1037 snd_hda_codec_write_cache(codec, cap_nid, 0,
1038 AC_VERB_SET_CONNECT_SEL,
1039 alive->mux_idx);
1040 }
1041
1042 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001043}
1044
Kailang Yangc9b58002007-10-16 14:30:01 +02001045/* unsolicited event for HP jack sensing */
1046static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1047{
1048 if (codec->vendor_id == 0x10ec0880)
1049 res >>= 28;
1050 else
1051 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001052 switch (res) {
1053 case ALC880_HP_EVENT:
1054 alc_automute_pin(codec);
1055 break;
1056 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001057 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001058 break;
1059 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001060}
1061
1062static void alc_inithook(struct hda_codec *codec)
1063{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001064 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001065 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001066}
1067
Kailang Yangf9423e72008-05-27 12:32:25 +02001068/* additional initialization for ALC888 variants */
1069static void alc888_coef_init(struct hda_codec *codec)
1070{
1071 unsigned int tmp;
1072
1073 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1074 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1075 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001076 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001077 /* alc888S-VC */
1078 snd_hda_codec_read(codec, 0x20, 0,
1079 AC_VERB_SET_PROC_COEF, 0x830);
1080 else
1081 /* alc888-VB */
1082 snd_hda_codec_read(codec, 0x20, 0,
1083 AC_VERB_SET_PROC_COEF, 0x3030);
1084}
1085
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001086static void alc889_coef_init(struct hda_codec *codec)
1087{
1088 unsigned int tmp;
1089
1090 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1091 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1092 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1093 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1094}
1095
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001096static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001097{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001098 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001099
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001100 switch (type) {
1101 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001102 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1103 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001104 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001105 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1106 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001107 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001108 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1109 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001110 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001111 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001112 case 0x10ec0260:
1113 snd_hda_codec_write(codec, 0x0f, 0,
1114 AC_VERB_SET_EAPD_BTLENABLE, 2);
1115 snd_hda_codec_write(codec, 0x10, 0,
1116 AC_VERB_SET_EAPD_BTLENABLE, 2);
1117 break;
1118 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001119 case 0x10ec0267:
1120 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001121 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001122 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001123 case 0x10ec0660:
1124 case 0x10ec0662:
1125 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001126 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001127 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001128 snd_hda_codec_write(codec, 0x14, 0,
1129 AC_VERB_SET_EAPD_BTLENABLE, 2);
1130 snd_hda_codec_write(codec, 0x15, 0,
1131 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001132 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001133 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001134 switch (codec->vendor_id) {
1135 case 0x10ec0260:
1136 snd_hda_codec_write(codec, 0x1a, 0,
1137 AC_VERB_SET_COEF_INDEX, 7);
1138 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1139 AC_VERB_GET_PROC_COEF, 0);
1140 snd_hda_codec_write(codec, 0x1a, 0,
1141 AC_VERB_SET_COEF_INDEX, 7);
1142 snd_hda_codec_write(codec, 0x1a, 0,
1143 AC_VERB_SET_PROC_COEF,
1144 tmp | 0x2010);
1145 break;
1146 case 0x10ec0262:
1147 case 0x10ec0880:
1148 case 0x10ec0882:
1149 case 0x10ec0883:
1150 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001151 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001152 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001153 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001154 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001155 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001156 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001157 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001158 case 0x10ec0267:
1159 case 0x10ec0268:
1160 snd_hda_codec_write(codec, 0x20, 0,
1161 AC_VERB_SET_COEF_INDEX, 7);
1162 tmp = snd_hda_codec_read(codec, 0x20, 0,
1163 AC_VERB_GET_PROC_COEF, 0);
1164 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001165 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001166 snd_hda_codec_write(codec, 0x20, 0,
1167 AC_VERB_SET_PROC_COEF,
1168 tmp | 0x3000);
1169 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001170 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001171 break;
1172 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001173}
Kailang Yangea1fb292008-08-26 12:58:38 +02001174
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001175static void alc_init_auto_hp(struct hda_codec *codec)
1176{
1177 struct alc_spec *spec = codec->spec;
1178
1179 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001180 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001181
Kailang Yangc9b58002007-10-16 14:30:01 +02001182 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001183 if (spec->autocfg.line_out_pins[0] &&
1184 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001185 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001186 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001187 else
1188 return;
1189 }
1190
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001191 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1192 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001193 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1194 AC_VERB_SET_UNSOLICITED_ENABLE,
1195 AC_USRSP_EN | ALC880_HP_EVENT);
1196 spec->unsol_event = alc_sku_unsol_event;
1197}
1198
Takashi Iwai6c819492009-08-10 18:47:44 +02001199static void alc_init_auto_mic(struct hda_codec *codec)
1200{
1201 struct alc_spec *spec = codec->spec;
1202 struct auto_pin_cfg *cfg = &spec->autocfg;
1203 hda_nid_t fixed, ext;
1204 int i;
1205
1206 /* there must be only two mic inputs exclusively */
1207 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1208 if (cfg->input_pins[i])
1209 return;
1210
1211 fixed = ext = 0;
1212 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1213 hda_nid_t nid = cfg->input_pins[i];
1214 unsigned int defcfg;
1215 if (!nid)
1216 return;
1217 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1218 switch (get_defcfg_connect(defcfg)) {
1219 case AC_JACK_PORT_FIXED:
1220 if (fixed)
1221 return; /* already occupied */
1222 fixed = nid;
1223 break;
1224 case AC_JACK_PORT_COMPLEX:
1225 if (ext)
1226 return; /* already occupied */
1227 ext = nid;
1228 break;
1229 default:
1230 return; /* invalid entry */
1231 }
1232 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001233 if (!ext || !fixed)
1234 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001235 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1236 return; /* no unsol support */
1237 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1238 ext, fixed);
1239 spec->ext_mic.pin = ext;
1240 spec->int_mic.pin = fixed;
1241 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1242 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1243 spec->auto_mic = 1;
1244 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1245 AC_VERB_SET_UNSOLICITED_ENABLE,
1246 AC_USRSP_EN | ALC880_MIC_EVENT);
1247 spec->unsol_event = alc_sku_unsol_event;
1248}
1249
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001250/* check subsystem ID and set up device-specific initialization;
1251 * return 1 if initialized, 0 if invalid SSID
1252 */
1253/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1254 * 31 ~ 16 : Manufacture ID
1255 * 15 ~ 8 : SKU ID
1256 * 7 ~ 0 : Assembly ID
1257 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1258 */
1259static int alc_subsystem_id(struct hda_codec *codec,
1260 hda_nid_t porta, hda_nid_t porte,
1261 hda_nid_t portd)
1262{
1263 unsigned int ass, tmp, i;
1264 unsigned nid;
1265 struct alc_spec *spec = codec->spec;
1266
1267 ass = codec->subsystem_id & 0xffff;
1268 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1269 goto do_sku;
1270
1271 /* invalid SSID, check the special NID pin defcfg instead */
1272 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001273 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001274 * 29~21 : reserve
1275 * 20 : PCBEEP input
1276 * 19~16 : Check sum (15:1)
1277 * 15~1 : Custom
1278 * 0 : override
1279 */
1280 nid = 0x1d;
1281 if (codec->vendor_id == 0x10ec0260)
1282 nid = 0x17;
1283 ass = snd_hda_codec_get_pincfg(codec, nid);
1284 snd_printd("realtek: No valid SSID, "
1285 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001286 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001287 if (!(ass & 1) && !(ass & 0x100000))
1288 return 0;
1289 if ((ass >> 30) != 1) /* no physical connection */
1290 return 0;
1291
1292 /* check sum */
1293 tmp = 0;
1294 for (i = 1; i < 16; i++) {
1295 if ((ass >> i) & 1)
1296 tmp++;
1297 }
1298 if (((ass >> 16) & 0xf) != tmp)
1299 return 0;
1300do_sku:
1301 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1302 ass & 0xffff, codec->vendor_id);
1303 /*
1304 * 0 : override
1305 * 1 : Swap Jack
1306 * 2 : 0 --> Desktop, 1 --> Laptop
1307 * 3~5 : External Amplifier control
1308 * 7~6 : Reserved
1309 */
1310 tmp = (ass & 0x38) >> 3; /* external Amp control */
1311 switch (tmp) {
1312 case 1:
1313 spec->init_amp = ALC_INIT_GPIO1;
1314 break;
1315 case 3:
1316 spec->init_amp = ALC_INIT_GPIO2;
1317 break;
1318 case 7:
1319 spec->init_amp = ALC_INIT_GPIO3;
1320 break;
1321 case 5:
1322 spec->init_amp = ALC_INIT_DEFAULT;
1323 break;
1324 }
1325
1326 /* is laptop or Desktop and enable the function "Mute internal speaker
1327 * when the external headphone out jack is plugged"
1328 */
1329 if (!(ass & 0x8000))
1330 return 1;
1331 /*
1332 * 10~8 : Jack location
1333 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1334 * 14~13: Resvered
1335 * 15 : 1 --> enable the function "Mute internal speaker
1336 * when the external headphone out jack is plugged"
1337 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001338 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001339 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001340 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1341 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001342 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001343 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001344 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001345 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001346 nid = portd;
Kailang Yangc9b58002007-10-16 14:30:01 +02001347 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001348 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001349 for (i = 0; i < spec->autocfg.line_outs; i++)
1350 if (spec->autocfg.line_out_pins[i] == nid)
1351 return 1;
1352 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001353 }
1354
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001355 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001356 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001357 return 1;
1358}
Kailang Yangea1fb292008-08-26 12:58:38 +02001359
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001360static void alc_ssid_check(struct hda_codec *codec,
1361 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1362{
1363 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1364 struct alc_spec *spec = codec->spec;
1365 snd_printd("realtek: "
1366 "Enable default setup for auto mode as fallback\n");
1367 spec->init_amp = ALC_INIT_DEFAULT;
1368 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001369 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001370 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001371}
1372
Takashi Iwai41e41f12005-06-08 14:48:49 +02001373/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001374 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001375 */
1376
1377struct alc_pincfg {
1378 hda_nid_t nid;
1379 u32 val;
1380};
1381
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001382struct alc_fixup {
1383 const struct alc_pincfg *pins;
1384 const struct hda_verb *verbs;
1385};
1386
1387static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001388 const struct snd_pci_quirk *quirk,
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001389 const struct alc_fixup *fix)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001390{
1391 const struct alc_pincfg *cfg;
1392
1393 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1394 if (!quirk)
1395 return;
1396
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001397 fix += quirk->value;
1398 cfg = fix->pins;
1399 if (cfg) {
1400 for (; cfg->nid; cfg++)
1401 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1402 }
1403 if (fix->verbs)
1404 add_verb(codec->spec, fix->verbs);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001405}
1406
Kailang Yang274693f2009-12-03 10:07:50 +01001407static int alc_read_coef_idx(struct hda_codec *codec,
1408 unsigned int coef_idx)
1409{
1410 unsigned int val;
1411 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1412 coef_idx);
1413 val = snd_hda_codec_read(codec, 0x20, 0,
1414 AC_VERB_GET_PROC_COEF, 0);
1415 return val;
1416}
1417
Takashi Iwaif95474e2007-07-10 00:47:43 +02001418/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001419 * ALC888
1420 */
1421
1422/*
1423 * 2ch mode
1424 */
1425static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1426/* Mic-in jack as mic in */
1427 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1428 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1429/* Line-in jack as Line in */
1430 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1431 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1432/* Line-Out as Front */
1433 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1434 { } /* end */
1435};
1436
1437/*
1438 * 4ch mode
1439 */
1440static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1441/* Mic-in jack as mic in */
1442 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1443 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1444/* Line-in jack as Surround */
1445 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1446 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1447/* Line-Out as Front */
1448 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1449 { } /* end */
1450};
1451
1452/*
1453 * 6ch mode
1454 */
1455static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1456/* Mic-in jack as CLFE */
1457 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1458 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1459/* Line-in jack as Surround */
1460 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1461 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1462/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1463 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1464 { } /* end */
1465};
1466
1467/*
1468 * 8ch mode
1469 */
1470static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1471/* Mic-in jack as CLFE */
1472 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1473 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1474/* Line-in jack as Surround */
1475 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1476 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1477/* Line-Out as Side */
1478 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1479 { } /* end */
1480};
1481
1482static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1483 { 2, alc888_4ST_ch2_intel_init },
1484 { 4, alc888_4ST_ch4_intel_init },
1485 { 6, alc888_4ST_ch6_intel_init },
1486 { 8, alc888_4ST_ch8_intel_init },
1487};
1488
1489/*
1490 * ALC888 Fujitsu Siemens Amillo xa3530
1491 */
1492
1493static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1494/* Front Mic: set to PIN_IN (empty by default) */
1495 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1496/* Connect Internal HP to Front */
1497 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1498 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1499 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1500/* Connect Bass HP to Front */
1501 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1502 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1503 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1504/* Connect Line-Out side jack (SPDIF) to Side */
1505 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1506 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1507 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1508/* Connect Mic jack to CLFE */
1509 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1510 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1511 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1512/* Connect Line-in jack to Surround */
1513 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1514 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1515 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1516/* Connect HP out jack to Front */
1517 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1518 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1519 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1520/* Enable unsolicited event for HP jack and Line-out jack */
1521 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1522 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1523 {}
1524};
1525
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001526static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001527{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001528 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001529 unsigned int mute;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001530 hda_nid_t nid;
1531 int i;
1532
1533 spec->jack_present = 0;
1534 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1535 nid = spec->autocfg.hp_pins[i];
1536 if (!nid)
1537 break;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001538 if (snd_hda_jack_detect(codec, nid)) {
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001539 spec->jack_present = 1;
1540 break;
1541 }
1542 }
1543
1544 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001545 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001546 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1547 nid = spec->autocfg.speaker_pins[i];
1548 if (!nid)
1549 break;
1550 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1551 HDA_AMP_MUTE, mute);
1552 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001553}
1554
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001555static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1556 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001557{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001558 if (codec->vendor_id == 0x10ec0880)
1559 res >>= 28;
1560 else
1561 res >>= 26;
1562 if (res == ALC880_HP_EVENT)
1563 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001564}
1565
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001566static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001567{
1568 struct alc_spec *spec = codec->spec;
1569
1570 spec->autocfg.hp_pins[0] = 0x15;
1571 spec->autocfg.speaker_pins[0] = 0x14;
1572 spec->autocfg.speaker_pins[1] = 0x16;
1573 spec->autocfg.speaker_pins[2] = 0x17;
1574 spec->autocfg.speaker_pins[3] = 0x19;
1575 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001576}
1577
1578static void alc889_intel_init_hook(struct hda_codec *codec)
1579{
1580 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001581 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001582}
1583
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001584static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001585{
1586 struct alc_spec *spec = codec->spec;
1587
1588 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1589 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1590 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1591 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001592}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001593
1594/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001595 * ALC888 Acer Aspire 4930G model
1596 */
1597
1598static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1599/* Front Mic: set to PIN_IN (empty by default) */
1600 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1601/* Unselect Front Mic by default in input mixer 3 */
1602 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001603/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001604 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1605/* Connect Internal HP to front */
1606 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1607 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1608 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1609/* Connect HP out to front */
1610 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1611 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1612 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1613 { }
1614};
1615
Hector Martin3b315d72009-06-02 10:54:19 +02001616/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001617 * ALC888 Acer Aspire 6530G model
1618 */
1619
1620static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1621/* Bias voltage on for external mic port */
1622 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001623/* Front Mic: set to PIN_IN (empty by default) */
1624 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1625/* Unselect Front Mic by default in input mixer 3 */
1626 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001627/* Enable unsolicited event for HP jack */
1628 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1629/* Enable speaker output */
1630 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1631 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1632/* Enable headphone output */
1633 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1634 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1635 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1636 { }
1637};
1638
1639/*
Hector Martin018df412009-06-04 00:13:40 +02001640 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001641 */
1642
Hector Martin018df412009-06-04 00:13:40 +02001643static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001644/* Front Mic: set to PIN_IN (empty by default) */
1645 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1646/* Unselect Front Mic by default in input mixer 3 */
1647 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1648/* Enable unsolicited event for HP jack */
1649 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1650/* Connect Internal Front to Front */
1651 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1652 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1653 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1654/* Connect Internal Rear to Rear */
1655 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1656 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1657 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1658/* Connect Internal CLFE to CLFE */
1659 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1660 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1661 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1662/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001663 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001664 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1665 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1666/* Enable all DACs */
1667/* DAC DISABLE/MUTE 1? */
1668/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1669 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1670 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1671/* DAC DISABLE/MUTE 2? */
1672/* some bit here disables the other DACs. Init=0x4900 */
1673 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1674 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02001675/* DMIC fix
1676 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1677 * which makes the stereo useless. However, either the mic or the ALC889
1678 * makes the signal become a difference/sum signal instead of standard
1679 * stereo, which is annoying. So instead we flip this bit which makes the
1680 * codec replicate the sum signal to both channels, turning it into a
1681 * normal mono mic.
1682 */
1683/* DMIC_CONTROL? Init value = 0x0001 */
1684 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1685 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001686 { }
1687};
1688
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001689static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001690 /* Front mic only available on one ADC */
1691 {
1692 .num_items = 4,
1693 .items = {
1694 { "Mic", 0x0 },
1695 { "Line", 0x2 },
1696 { "CD", 0x4 },
1697 { "Front Mic", 0xb },
1698 },
1699 },
1700 {
1701 .num_items = 3,
1702 .items = {
1703 { "Mic", 0x0 },
1704 { "Line", 0x2 },
1705 { "CD", 0x4 },
1706 },
1707 }
1708};
1709
Tony Vroond2fd4b02009-06-21 00:40:10 +01001710static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1711 /* Interal mic only available on one ADC */
1712 {
Tony Vroon684a8842009-06-26 09:27:50 +01001713 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001714 .items = {
1715 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001716 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001717 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001718 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001719 { "Int Mic", 0xb },
1720 },
1721 },
1722 {
Tony Vroon684a8842009-06-26 09:27:50 +01001723 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001724 .items = {
1725 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001726 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001727 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001728 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001729 },
1730 }
1731};
1732
Hector Martin018df412009-06-04 00:13:40 +02001733static struct hda_input_mux alc889_capture_sources[3] = {
1734 /* Digital mic only available on first "ADC" */
1735 {
1736 .num_items = 5,
1737 .items = {
1738 { "Mic", 0x0 },
1739 { "Line", 0x2 },
1740 { "CD", 0x4 },
1741 { "Front Mic", 0xb },
1742 { "Input Mix", 0xa },
1743 },
1744 },
1745 {
1746 .num_items = 4,
1747 .items = {
1748 { "Mic", 0x0 },
1749 { "Line", 0x2 },
1750 { "CD", 0x4 },
1751 { "Input Mix", 0xa },
1752 },
1753 },
1754 {
1755 .num_items = 4,
1756 .items = {
1757 { "Mic", 0x0 },
1758 { "Line", 0x2 },
1759 { "CD", 0x4 },
1760 { "Input Mix", 0xa },
1761 },
1762 }
1763};
1764
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001765static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001766 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1767 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1768 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1769 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1770 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1771 HDA_OUTPUT),
1772 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1773 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1774 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1775 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1776 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1777 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1778 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1779 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1780 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1781 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1782 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1783 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001784 { } /* end */
1785};
1786
Hector Martin556eea92009-12-20 22:51:23 +01001787static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
1788 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1789 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1790 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1791 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1792 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1793 HDA_OUTPUT),
1794 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1795 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1796 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1797 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1798 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1799 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1800 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1801 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1802 { } /* end */
1803};
1804
1805
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001806static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001807{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001808 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001809
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001810 spec->autocfg.hp_pins[0] = 0x15;
1811 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01001812 spec->autocfg.speaker_pins[1] = 0x16;
1813 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001814}
1815
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001816static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001817{
1818 struct alc_spec *spec = codec->spec;
1819
1820 spec->autocfg.hp_pins[0] = 0x15;
1821 spec->autocfg.speaker_pins[0] = 0x14;
1822 spec->autocfg.speaker_pins[1] = 0x16;
1823 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001824}
1825
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001826static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001827{
1828 struct alc_spec *spec = codec->spec;
1829
1830 spec->autocfg.hp_pins[0] = 0x15;
1831 spec->autocfg.speaker_pins[0] = 0x14;
1832 spec->autocfg.speaker_pins[1] = 0x16;
1833 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001834}
1835
Hector Martinf5de24b2009-12-20 22:51:31 +01001836#ifdef CONFIG_SND_HDA_POWER_SAVE
1837static void alc889_power_eapd(struct hda_codec *codec, int power)
1838{
1839 snd_hda_codec_write(codec, 0x14, 0,
1840 AC_VERB_SET_EAPD_BTLENABLE, power ? 2 : 0);
1841 snd_hda_codec_write(codec, 0x15, 0,
1842 AC_VERB_SET_EAPD_BTLENABLE, power ? 2 : 0);
1843}
1844#endif
1845
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001846/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001847 * ALC880 3-stack model
1848 *
1849 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001850 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1851 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001852 */
1853
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001854static hda_nid_t alc880_dac_nids[4] = {
1855 /* front, rear, clfe, rear_surr */
1856 0x02, 0x05, 0x04, 0x03
1857};
1858
1859static hda_nid_t alc880_adc_nids[3] = {
1860 /* ADC0-2 */
1861 0x07, 0x08, 0x09,
1862};
1863
1864/* The datasheet says the node 0x07 is connected from inputs,
1865 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001866 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001867 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001868static hda_nid_t alc880_adc_nids_alt[2] = {
1869 /* ADC1-2 */
1870 0x08, 0x09,
1871};
1872
1873#define ALC880_DIGOUT_NID 0x06
1874#define ALC880_DIGIN_NID 0x0a
1875
1876static struct hda_input_mux alc880_capture_source = {
1877 .num_items = 4,
1878 .items = {
1879 { "Mic", 0x0 },
1880 { "Front Mic", 0x3 },
1881 { "Line", 0x2 },
1882 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001883 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001884};
1885
1886/* channel source setting (2/6 channel selection for 3-stack) */
1887/* 2ch mode */
1888static struct hda_verb alc880_threestack_ch2_init[] = {
1889 /* set line-in to input, mute it */
1890 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1891 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1892 /* set mic-in to input vref 80%, mute it */
1893 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1894 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001895 { } /* end */
1896};
1897
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001898/* 6ch mode */
1899static struct hda_verb alc880_threestack_ch6_init[] = {
1900 /* set line-in to output, unmute it */
1901 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1902 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1903 /* set mic-in to output, unmute it */
1904 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1905 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1906 { } /* end */
1907};
1908
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001909static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001910 { 2, alc880_threestack_ch2_init },
1911 { 6, alc880_threestack_ch6_init },
1912};
1913
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001914static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001915 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001916 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001917 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001918 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001919 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1920 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001921 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1922 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001923 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1924 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1925 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1926 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1927 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1928 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1929 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1930 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001931 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001932 {
1933 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1934 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001935 .info = alc_ch_mode_info,
1936 .get = alc_ch_mode_get,
1937 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001938 },
1939 { } /* end */
1940};
1941
1942/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001943static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1944 struct snd_ctl_elem_info *uinfo)
1945{
1946 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1947 struct alc_spec *spec = codec->spec;
1948 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001949
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001950 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001951 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1952 HDA_INPUT);
1953 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001954 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001955 return err;
1956}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001957
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001958static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1959 unsigned int size, unsigned int __user *tlv)
1960{
1961 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1962 struct alc_spec *spec = codec->spec;
1963 int err;
1964
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001965 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001966 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1967 HDA_INPUT);
1968 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001969 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001970 return err;
1971}
1972
1973typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1974 struct snd_ctl_elem_value *ucontrol);
1975
1976static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1977 struct snd_ctl_elem_value *ucontrol,
1978 getput_call_t func)
1979{
1980 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1981 struct alc_spec *spec = codec->spec;
1982 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1983 int err;
1984
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001985 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001986 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1987 3, 0, HDA_INPUT);
1988 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001989 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001990 return err;
1991}
1992
1993static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1994 struct snd_ctl_elem_value *ucontrol)
1995{
1996 return alc_cap_getput_caller(kcontrol, ucontrol,
1997 snd_hda_mixer_amp_volume_get);
1998}
1999
2000static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2001 struct snd_ctl_elem_value *ucontrol)
2002{
2003 return alc_cap_getput_caller(kcontrol, ucontrol,
2004 snd_hda_mixer_amp_volume_put);
2005}
2006
2007/* capture mixer elements */
2008#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2009
2010static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2011 struct snd_ctl_elem_value *ucontrol)
2012{
2013 return alc_cap_getput_caller(kcontrol, ucontrol,
2014 snd_hda_mixer_amp_switch_get);
2015}
2016
2017static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2018 struct snd_ctl_elem_value *ucontrol)
2019{
2020 return alc_cap_getput_caller(kcontrol, ucontrol,
2021 snd_hda_mixer_amp_switch_put);
2022}
2023
Takashi Iwaia23b6882009-03-23 15:21:36 +01002024#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002025 { \
2026 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2027 .name = "Capture Switch", \
2028 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2029 .count = num, \
2030 .info = alc_cap_sw_info, \
2031 .get = alc_cap_sw_get, \
2032 .put = alc_cap_sw_put, \
2033 }, \
2034 { \
2035 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2036 .name = "Capture Volume", \
2037 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2038 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2039 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2040 .count = num, \
2041 .info = alc_cap_vol_info, \
2042 .get = alc_cap_vol_get, \
2043 .put = alc_cap_vol_put, \
2044 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002045 }
2046
2047#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002048 { \
2049 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2050 /* .name = "Capture Source", */ \
2051 .name = "Input Source", \
2052 .count = num, \
2053 .info = alc_mux_enum_info, \
2054 .get = alc_mux_enum_get, \
2055 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002056 }
2057
2058#define DEFINE_CAPMIX(num) \
2059static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2060 _DEFINE_CAPMIX(num), \
2061 _DEFINE_CAPSRC(num), \
2062 { } /* end */ \
2063}
2064
2065#define DEFINE_CAPMIX_NOSRC(num) \
2066static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2067 _DEFINE_CAPMIX(num), \
2068 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002069}
2070
2071/* up to three ADCs */
2072DEFINE_CAPMIX(1);
2073DEFINE_CAPMIX(2);
2074DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002075DEFINE_CAPMIX_NOSRC(1);
2076DEFINE_CAPMIX_NOSRC(2);
2077DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002078
2079/*
2080 * ALC880 5-stack model
2081 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002082 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2083 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002084 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2085 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2086 */
2087
2088/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002089static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002090 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002091 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002092 { } /* end */
2093};
2094
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002095/* channel source setting (6/8 channel selection for 5-stack) */
2096/* 6ch mode */
2097static struct hda_verb alc880_fivestack_ch6_init[] = {
2098 /* set line-in to input, mute it */
2099 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2100 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002101 { } /* end */
2102};
2103
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002104/* 8ch mode */
2105static struct hda_verb alc880_fivestack_ch8_init[] = {
2106 /* set line-in to output, unmute it */
2107 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2108 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2109 { } /* end */
2110};
2111
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002112static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002113 { 6, alc880_fivestack_ch6_init },
2114 { 8, alc880_fivestack_ch8_init },
2115};
2116
2117
2118/*
2119 * ALC880 6-stack model
2120 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002121 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2122 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002123 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2124 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2125 */
2126
2127static hda_nid_t alc880_6st_dac_nids[4] = {
2128 /* front, rear, clfe, rear_surr */
2129 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002130};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002131
2132static struct hda_input_mux alc880_6stack_capture_source = {
2133 .num_items = 4,
2134 .items = {
2135 { "Mic", 0x0 },
2136 { "Front Mic", 0x1 },
2137 { "Line", 0x2 },
2138 { "CD", 0x4 },
2139 },
2140};
2141
2142/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002143static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002144 { 8, NULL },
2145};
2146
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002147static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002148 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002149 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002150 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002151 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002152 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2153 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002154 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2155 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002156 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002157 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002158 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2159 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2160 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2161 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2162 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2163 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2164 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2165 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002166 {
2167 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2168 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002169 .info = alc_ch_mode_info,
2170 .get = alc_ch_mode_get,
2171 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002172 },
2173 { } /* end */
2174};
2175
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002176
2177/*
2178 * ALC880 W810 model
2179 *
2180 * W810 has rear IO for:
2181 * Front (DAC 02)
2182 * Surround (DAC 03)
2183 * Center/LFE (DAC 04)
2184 * Digital out (06)
2185 *
2186 * The system also has a pair of internal speakers, and a headphone jack.
2187 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002188 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002189 * There is a variable resistor to control the speaker or headphone
2190 * volume. This is a hardware-only device without a software API.
2191 *
2192 * Plugging headphones in will disable the internal speakers. This is
2193 * implemented in hardware, not via the driver using jack sense. In
2194 * a similar fashion, plugging into the rear socket marked "front" will
2195 * disable both the speakers and headphones.
2196 *
2197 * For input, there's a microphone jack, and an "audio in" jack.
2198 * These may not do anything useful with this driver yet, because I
2199 * haven't setup any initialization verbs for these yet...
2200 */
2201
2202static hda_nid_t alc880_w810_dac_nids[3] = {
2203 /* front, rear/surround, clfe */
2204 0x02, 0x03, 0x04
2205};
2206
2207/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002208static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002209 { 6, NULL }
2210};
2211
2212/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002213static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002214 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002215 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002216 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002217 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002218 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2219 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002220 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2221 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002222 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2223 { } /* end */
2224};
2225
2226
2227/*
2228 * Z710V model
2229 *
2230 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002231 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2232 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002233 */
2234
2235static hda_nid_t alc880_z71v_dac_nids[1] = {
2236 0x02
2237};
2238#define ALC880_Z71V_HP_DAC 0x03
2239
2240/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002241static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002242 { 2, NULL }
2243};
2244
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002245static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002246 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002247 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002248 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002249 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002250 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2251 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2252 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2253 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2254 { } /* end */
2255};
2256
2257
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002258/*
2259 * ALC880 F1734 model
2260 *
2261 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2262 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2263 */
2264
2265static hda_nid_t alc880_f1734_dac_nids[1] = {
2266 0x03
2267};
2268#define ALC880_F1734_HP_DAC 0x02
2269
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002270static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002271 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002272 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002273 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2274 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 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),
Takashi Iwai937b4162008-02-11 14:52:36 +01002277 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2278 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002279 { } /* end */
2280};
2281
Takashi Iwai937b4162008-02-11 14:52:36 +01002282static struct hda_input_mux alc880_f1734_capture_source = {
2283 .num_items = 2,
2284 .items = {
2285 { "Mic", 0x1 },
2286 { "CD", 0x4 },
2287 },
2288};
2289
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002290
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002291/*
2292 * ALC880 ASUS 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
2297 */
2298
2299#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2300#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2301
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002302static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002303 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002304 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002305 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002306 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002307 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2308 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002309 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2310 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002311 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("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2314 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2315 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2316 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002317 {
2318 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2319 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002320 .info = alc_ch_mode_info,
2321 .get = alc_ch_mode_get,
2322 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002323 },
2324 { } /* end */
2325};
2326
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002327/*
2328 * ALC880 ASUS W1V model
2329 *
2330 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2331 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2332 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2333 */
2334
2335/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002336static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002337 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2338 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002339 { } /* end */
2340};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002341
Kailang Yangdf694da2005-12-05 19:42:22 +01002342/* TCL S700 */
2343static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2344 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2345 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2346 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2347 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2348 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2349 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2350 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2351 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2352 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002353 { } /* end */
2354};
2355
Kailang Yangccc656c2006-10-17 12:32:26 +02002356/* Uniwill */
2357static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002358 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2359 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2360 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2361 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002362 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2363 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2364 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2365 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2366 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2367 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2368 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2369 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2370 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2371 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2372 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2373 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002374 {
2375 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2376 .name = "Channel Mode",
2377 .info = alc_ch_mode_info,
2378 .get = alc_ch_mode_get,
2379 .put = alc_ch_mode_put,
2380 },
2381 { } /* end */
2382};
2383
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002384static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2385 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2386 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2387 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2388 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2389 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2390 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2391 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2392 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2393 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2394 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2395 { } /* end */
2396};
2397
Kailang Yangccc656c2006-10-17 12:32:26 +02002398static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002399 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2400 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2401 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2402 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002403 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2404 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2405 { } /* end */
2406};
2407
Linus Torvalds1da177e2005-04-16 15:20:36 -07002408/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002409 * virtual master controls
2410 */
2411
2412/*
2413 * slave controls for virtual master
2414 */
2415static const char *alc_slave_vols[] = {
2416 "Front Playback Volume",
2417 "Surround Playback Volume",
2418 "Center Playback Volume",
2419 "LFE Playback Volume",
2420 "Side Playback Volume",
2421 "Headphone Playback Volume",
2422 "Speaker Playback Volume",
2423 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002424 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002425 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002426 NULL,
2427};
2428
2429static const char *alc_slave_sws[] = {
2430 "Front Playback Switch",
2431 "Surround Playback Switch",
2432 "Center Playback Switch",
2433 "LFE Playback Switch",
2434 "Side Playback Switch",
2435 "Headphone Playback Switch",
2436 "Speaker Playback Switch",
2437 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002438 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002439 "Line-Out Playback Switch",
2440 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002441 NULL,
2442};
2443
2444/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002445 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002446 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002447
2448static void alc_free_kctls(struct hda_codec *codec);
2449
Takashi Iwai67d634c2009-11-16 15:35:59 +01002450#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002451/* additional beep mixers; the actual parameters are overwritten at build */
2452static struct snd_kcontrol_new alc_beep_mixer[] = {
2453 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002454 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002455 { } /* end */
2456};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002457#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002458
Linus Torvalds1da177e2005-04-16 15:20:36 -07002459static int alc_build_controls(struct hda_codec *codec)
2460{
2461 struct alc_spec *spec = codec->spec;
2462 int err;
2463 int i;
2464
2465 for (i = 0; i < spec->num_mixers; i++) {
2466 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2467 if (err < 0)
2468 return err;
2469 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002470 if (spec->cap_mixer) {
2471 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2472 if (err < 0)
2473 return err;
2474 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002475 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002476 err = snd_hda_create_spdif_out_ctls(codec,
2477 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002478 if (err < 0)
2479 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002480 if (!spec->no_analog) {
2481 err = snd_hda_create_spdif_share_sw(codec,
2482 &spec->multiout);
2483 if (err < 0)
2484 return err;
2485 spec->multiout.share_spdif = 1;
2486 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002487 }
2488 if (spec->dig_in_nid) {
2489 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2490 if (err < 0)
2491 return err;
2492 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002493
Takashi Iwai67d634c2009-11-16 15:35:59 +01002494#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002495 /* create beep controls if needed */
2496 if (spec->beep_amp) {
2497 struct snd_kcontrol_new *knew;
2498 for (knew = alc_beep_mixer; knew->name; knew++) {
2499 struct snd_kcontrol *kctl;
2500 kctl = snd_ctl_new1(knew, codec);
2501 if (!kctl)
2502 return -ENOMEM;
2503 kctl->private_value = spec->beep_amp;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01002504 err = snd_hda_ctl_add(codec,
2505 get_amp_nid_(spec->beep_amp), kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002506 if (err < 0)
2507 return err;
2508 }
2509 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002510#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002511
Takashi Iwai2134ea42008-01-10 16:53:55 +01002512 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002513 if (!spec->no_analog &&
2514 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002515 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002516 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002517 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002518 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002519 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002520 if (err < 0)
2521 return err;
2522 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002523 if (!spec->no_analog &&
2524 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002525 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2526 NULL, alc_slave_sws);
2527 if (err < 0)
2528 return err;
2529 }
2530
Takashi Iwai603c4012008-07-30 15:01:44 +02002531 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002532 return 0;
2533}
2534
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002535
Linus Torvalds1da177e2005-04-16 15:20:36 -07002536/*
2537 * initialize the codec volumes, etc
2538 */
2539
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002540/*
2541 * generic initialization of ADC, input mixers and output mixers
2542 */
2543static struct hda_verb alc880_volume_init_verbs[] = {
2544 /*
2545 * Unmute ADC0-2 and set the default input to mic-in
2546 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002547 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002548 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002549 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002550 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002551 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002552 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002553
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002554 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2555 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002556 * Note: PASD motherboards uses the Line In 2 as the input for front
2557 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002558 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002559 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002560 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2561 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2562 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2563 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2564 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2565 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2566 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002567
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002568 /*
2569 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002570 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002571 /* set vol=0 to output mixers */
2572 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2573 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2574 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2575 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2576 /* set up input amps for analog loopback */
2577 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002578 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2579 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002580 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2581 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002582 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2583 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002584 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2585 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002586
2587 { }
2588};
2589
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002590/*
2591 * 3-stack pin configuration:
2592 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2593 */
2594static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2595 /*
2596 * preset connection lists of input pins
2597 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2598 */
2599 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2600 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2601 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2602
2603 /*
2604 * Set pin mode and muting
2605 */
2606 /* set front pin widgets 0x14 for output */
2607 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2608 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2609 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2610 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2611 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2612 /* Mic2 (as headphone out) for HP output */
2613 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2614 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2615 /* Line In pin widget for input */
2616 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2617 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2618 /* Line2 (as front mic) pin widget for input and vref at 80% */
2619 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2620 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2621 /* CD pin widget for input */
2622 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2623
2624 { }
2625};
2626
2627/*
2628 * 5-stack pin configuration:
2629 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2630 * line-in/side = 0x1a, f-mic = 0x1b
2631 */
2632static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2633 /*
2634 * preset connection lists of input pins
2635 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2636 */
2637 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2638 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2639
2640 /*
2641 * Set pin mode and muting
2642 */
2643 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002644 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2645 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2646 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2647 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002648 /* unmute pins for output (no gain on this amp) */
2649 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2650 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2651 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2652 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2653
Linus Torvalds1da177e2005-04-16 15:20:36 -07002654 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002655 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002656 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2657 /* Mic2 (as headphone out) for HP output */
2658 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002659 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002660 /* Line In pin widget for input */
2661 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2662 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2663 /* Line2 (as front mic) pin widget for input and vref at 80% */
2664 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2665 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2666 /* CD pin widget for input */
2667 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002668
2669 { }
2670};
2671
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002672/*
2673 * W810 pin configuration:
2674 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2675 */
2676static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002677 /* hphone/speaker input selector: front DAC */
2678 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2679
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002680 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2681 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2682 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2683 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2684 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2685 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2686
2687 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002688 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002689
Linus Torvalds1da177e2005-04-16 15:20:36 -07002690 { }
2691};
2692
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002693/*
2694 * Z71V pin configuration:
2695 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2696 */
2697static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002698 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002699 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002700 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002701 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002702
Takashi Iwai16ded522005-06-10 19:58:24 +02002703 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002704 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002705 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002706 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002707
2708 { }
2709};
2710
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002711/*
2712 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002713 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2714 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002715 */
2716static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2717 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2718
Takashi Iwai16ded522005-06-10 19:58:24 +02002719 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002720 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002721 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002722 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002723 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002724 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002725 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002726 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2727
Takashi Iwai16ded522005-06-10 19:58:24 +02002728 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002729 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002730 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002731 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002732 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002733 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002734 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002735 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002736 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002737
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002738 { }
2739};
Takashi Iwai16ded522005-06-10 19:58:24 +02002740
Kailang Yangccc656c2006-10-17 12:32:26 +02002741/*
2742 * Uniwill pin configuration:
2743 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2744 * line = 0x1a
2745 */
2746static struct hda_verb alc880_uniwill_init_verbs[] = {
2747 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2748
2749 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2750 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2751 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2752 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2753 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2754 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2755 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2756 {0x17, 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 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2771 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2772 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2773
2774 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2775 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2776
2777 { }
2778};
2779
2780/*
2781* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002782* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002783 */
2784static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2785 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2786
2787 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2788 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2789 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2790 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2791 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2792 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2793 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2794 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2795 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2796 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2797 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2798 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2799
2800 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2801 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2802 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2803 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2804 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2805 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2806
2807 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2808 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2809
2810 { }
2811};
2812
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002813static struct hda_verb alc880_beep_init_verbs[] = {
2814 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2815 { }
2816};
2817
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002818/* auto-toggle front mic */
2819static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2820{
2821 unsigned int present;
2822 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002823
Wu Fengguang864f92b2009-11-18 12:38:02 +08002824 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002825 bits = present ? HDA_AMP_MUTE : 0;
2826 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002827}
2828
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002829static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002830{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002831 struct alc_spec *spec = codec->spec;
2832
2833 spec->autocfg.hp_pins[0] = 0x14;
2834 spec->autocfg.speaker_pins[0] = 0x15;
2835 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002836}
2837
2838static void alc880_uniwill_init_hook(struct hda_codec *codec)
2839{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002840 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002841 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002842}
2843
2844static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2845 unsigned int res)
2846{
2847 /* Looks like the unsol event is incompatible with the standard
2848 * definition. 4bit tag is placed at 28 bit!
2849 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002850 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002851 case ALC880_MIC_EVENT:
2852 alc880_uniwill_mic_automute(codec);
2853 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002854 default:
2855 alc_automute_amp_unsol_event(codec, res);
2856 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002857 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002858}
2859
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002860static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002861{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002862 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002863
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002864 spec->autocfg.hp_pins[0] = 0x14;
2865 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02002866}
2867
2868static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2869{
2870 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002871
Kailang Yangccc656c2006-10-17 12:32:26 +02002872 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002873 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2874 present &= HDA_AMP_VOLMASK;
2875 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2876 HDA_AMP_VOLMASK, present);
2877 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2878 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002879}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002880
Kailang Yangccc656c2006-10-17 12:32:26 +02002881static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2882 unsigned int res)
2883{
2884 /* Looks like the unsol event is incompatible with the standard
2885 * definition. 4bit tag is placed at 28 bit!
2886 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002887 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002888 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002889 else
2890 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002891}
2892
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002893/*
2894 * F1734 pin configuration:
2895 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2896 */
2897static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002898 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002899 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2900 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2901 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2902 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2903
2904 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2905 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2906 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2907 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2908
2909 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2910 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002911 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002912 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2913 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2914 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2915 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2916 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2917 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002918
Takashi Iwai937b4162008-02-11 14:52:36 +01002919 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2920 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2921
Takashi Iwai16ded522005-06-10 19:58:24 +02002922 { }
2923};
2924
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002925/*
2926 * ASUS pin configuration:
2927 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2928 */
2929static struct hda_verb alc880_pin_asus_init_verbs[] = {
2930 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2931 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2932 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2933 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2934
2935 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2936 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2937 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2938 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2939 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2940 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2941 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2942 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2943
2944 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2945 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2946 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2947 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2948 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2949 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2950 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2951 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2952 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002953
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002954 { }
2955};
2956
2957/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002958#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2959#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02002960#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002961
Kailang Yangdf694da2005-12-05 19:42:22 +01002962/* Clevo m520g init */
2963static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2964 /* headphone output */
2965 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2966 /* line-out */
2967 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2968 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2969 /* Line-in */
2970 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2971 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2972 /* CD */
2973 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2974 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2975 /* Mic1 (rear panel) */
2976 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2977 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2978 /* Mic2 (front panel) */
2979 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2980 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2981 /* headphone */
2982 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2983 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2984 /* change to EAPD mode */
2985 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2986 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2987
2988 { }
2989};
2990
2991static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002992 /* change to EAPD mode */
2993 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2994 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2995
Kailang Yangdf694da2005-12-05 19:42:22 +01002996 /* Headphone output */
2997 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2998 /* Front output*/
2999 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3000 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3001
3002 /* Line In pin widget for input */
3003 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3004 /* CD pin widget for input */
3005 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3006 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3007 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3008
3009 /* change to EAPD mode */
3010 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3011 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3012
3013 { }
3014};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003015
3016/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003017 * LG m1 express dual
3018 *
3019 * Pin assignment:
3020 * Rear Line-In/Out (blue): 0x14
3021 * Build-in Mic-In: 0x15
3022 * Speaker-out: 0x17
3023 * HP-Out (green): 0x1b
3024 * Mic-In/Out (red): 0x19
3025 * SPDIF-Out: 0x1e
3026 */
3027
3028/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3029static hda_nid_t alc880_lg_dac_nids[3] = {
3030 0x05, 0x02, 0x03
3031};
3032
3033/* seems analog CD is not working */
3034static struct hda_input_mux alc880_lg_capture_source = {
3035 .num_items = 3,
3036 .items = {
3037 { "Mic", 0x1 },
3038 { "Line", 0x5 },
3039 { "Internal Mic", 0x6 },
3040 },
3041};
3042
3043/* 2,4,6 channel modes */
3044static struct hda_verb alc880_lg_ch2_init[] = {
3045 /* set line-in and mic-in to input */
3046 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3047 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3048 { }
3049};
3050
3051static struct hda_verb alc880_lg_ch4_init[] = {
3052 /* set line-in to out and mic-in to input */
3053 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3054 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3055 { }
3056};
3057
3058static struct hda_verb alc880_lg_ch6_init[] = {
3059 /* set line-in and mic-in to output */
3060 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3061 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3062 { }
3063};
3064
3065static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3066 { 2, alc880_lg_ch2_init },
3067 { 4, alc880_lg_ch4_init },
3068 { 6, alc880_lg_ch6_init },
3069};
3070
3071static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003072 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3073 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003074 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3075 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3076 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3077 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3078 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3079 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3080 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3081 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3082 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3083 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3084 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3085 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3086 {
3087 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3088 .name = "Channel Mode",
3089 .info = alc_ch_mode_info,
3090 .get = alc_ch_mode_get,
3091 .put = alc_ch_mode_put,
3092 },
3093 { } /* end */
3094};
3095
3096static struct hda_verb alc880_lg_init_verbs[] = {
3097 /* set capture source to mic-in */
3098 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3099 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3100 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3101 /* mute all amp mixer inputs */
3102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3104 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003105 /* line-in to input */
3106 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3107 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3108 /* built-in mic */
3109 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3110 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3111 /* speaker-out */
3112 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3113 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3114 /* mic-in to input */
3115 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3116 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3117 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3118 /* HP-out */
3119 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3120 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3121 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3122 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003123 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003124 { }
3125};
3126
3127/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003128static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003129{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003130 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003131
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003132 spec->autocfg.hp_pins[0] = 0x1b;
3133 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003134}
3135
3136/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003137 * LG LW20
3138 *
3139 * Pin assignment:
3140 * Speaker-out: 0x14
3141 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003142 * Built-in Mic-In: 0x19
3143 * Line-In: 0x1b
3144 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003145 * SPDIF-Out: 0x1e
3146 */
3147
Takashi Iwaid6815182006-03-23 16:06:23 +01003148static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003149 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003150 .items = {
3151 { "Mic", 0x0 },
3152 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003153 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003154 },
3155};
3156
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003157#define alc880_lg_lw_modes alc880_threestack_modes
3158
Takashi Iwaid6815182006-03-23 16:06:23 +01003159static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003160 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3161 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3162 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3163 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3164 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3165 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3166 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3167 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3168 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3169 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003170 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3171 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3172 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3173 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003174 {
3175 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3176 .name = "Channel Mode",
3177 .info = alc_ch_mode_info,
3178 .get = alc_ch_mode_get,
3179 .put = alc_ch_mode_put,
3180 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003181 { } /* end */
3182};
3183
3184static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003185 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3186 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3187 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3188
Takashi Iwaid6815182006-03-23 16:06:23 +01003189 /* set capture source to mic-in */
3190 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3191 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3192 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003193 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003194 /* speaker-out */
3195 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3196 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3197 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003198 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3199 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3200 /* mic-in to input */
3201 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3202 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3203 /* built-in mic */
3204 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3205 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3206 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003207 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003208 { }
3209};
3210
3211/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003212static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003213{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003214 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003215
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003216 spec->autocfg.hp_pins[0] = 0x1b;
3217 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003218}
3219
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003220static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3221 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3222 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3223 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3224 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3225 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3226 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3227 { } /* end */
3228};
3229
3230static struct hda_input_mux alc880_medion_rim_capture_source = {
3231 .num_items = 2,
3232 .items = {
3233 { "Mic", 0x0 },
3234 { "Internal Mic", 0x1 },
3235 },
3236};
3237
3238static struct hda_verb alc880_medion_rim_init_verbs[] = {
3239 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3240
3241 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3242 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3243
3244 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3245 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3246 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3247 /* Mic2 (as headphone out) for HP output */
3248 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3249 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3250 /* Internal Speaker */
3251 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3252 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3253
3254 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3255 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3256
3257 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3258 { }
3259};
3260
3261/* toggle speaker-output according to the hp-jack state */
3262static void alc880_medion_rim_automute(struct hda_codec *codec)
3263{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003264 struct alc_spec *spec = codec->spec;
3265 alc_automute_amp(codec);
3266 /* toggle EAPD */
3267 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003268 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3269 else
3270 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3271}
3272
3273static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3274 unsigned int res)
3275{
3276 /* Looks like the unsol event is incompatible with the standard
3277 * definition. 4bit tag is placed at 28 bit!
3278 */
3279 if ((res >> 28) == ALC880_HP_EVENT)
3280 alc880_medion_rim_automute(codec);
3281}
3282
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003283static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003284{
3285 struct alc_spec *spec = codec->spec;
3286
3287 spec->autocfg.hp_pins[0] = 0x14;
3288 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003289}
3290
Takashi Iwaicb53c622007-08-10 17:21:45 +02003291#ifdef CONFIG_SND_HDA_POWER_SAVE
3292static struct hda_amp_list alc880_loopbacks[] = {
3293 { 0x0b, HDA_INPUT, 0 },
3294 { 0x0b, HDA_INPUT, 1 },
3295 { 0x0b, HDA_INPUT, 2 },
3296 { 0x0b, HDA_INPUT, 3 },
3297 { 0x0b, HDA_INPUT, 4 },
3298 { } /* end */
3299};
3300
3301static struct hda_amp_list alc880_lg_loopbacks[] = {
3302 { 0x0b, HDA_INPUT, 1 },
3303 { 0x0b, HDA_INPUT, 6 },
3304 { 0x0b, HDA_INPUT, 7 },
3305 { } /* end */
3306};
3307#endif
3308
Takashi Iwaid6815182006-03-23 16:06:23 +01003309/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003310 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003311 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003312
Linus Torvalds1da177e2005-04-16 15:20:36 -07003313static int alc_init(struct hda_codec *codec)
3314{
3315 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003316 unsigned int i;
3317
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003318 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003319 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003320
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003321 for (i = 0; i < spec->num_init_verbs; i++)
3322 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003323
3324 if (spec->init_hook)
3325 spec->init_hook(codec);
3326
Linus Torvalds1da177e2005-04-16 15:20:36 -07003327 return 0;
3328}
3329
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003330static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3331{
3332 struct alc_spec *spec = codec->spec;
3333
3334 if (spec->unsol_event)
3335 spec->unsol_event(codec, res);
3336}
3337
Takashi Iwaicb53c622007-08-10 17:21:45 +02003338#ifdef CONFIG_SND_HDA_POWER_SAVE
3339static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3340{
3341 struct alc_spec *spec = codec->spec;
3342 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3343}
3344#endif
3345
Linus Torvalds1da177e2005-04-16 15:20:36 -07003346/*
3347 * Analog playback callbacks
3348 */
3349static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3350 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003351 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003352{
3353 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003354 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3355 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003356}
3357
3358static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3359 struct hda_codec *codec,
3360 unsigned int stream_tag,
3361 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003362 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003363{
3364 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003365 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3366 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003367}
3368
3369static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3370 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003371 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003372{
3373 struct alc_spec *spec = codec->spec;
3374 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3375}
3376
3377/*
3378 * Digital out
3379 */
3380static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3381 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003382 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003383{
3384 struct alc_spec *spec = codec->spec;
3385 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3386}
3387
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003388static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3389 struct hda_codec *codec,
3390 unsigned int stream_tag,
3391 unsigned int format,
3392 struct snd_pcm_substream *substream)
3393{
3394 struct alc_spec *spec = codec->spec;
3395 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3396 stream_tag, format, substream);
3397}
3398
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003399static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3400 struct hda_codec *codec,
3401 struct snd_pcm_substream *substream)
3402{
3403 struct alc_spec *spec = codec->spec;
3404 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3405}
3406
Linus Torvalds1da177e2005-04-16 15:20:36 -07003407static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3408 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003409 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003410{
3411 struct alc_spec *spec = codec->spec;
3412 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3413}
3414
3415/*
3416 * Analog capture
3417 */
Takashi Iwai63300792008-01-24 15:31:36 +01003418static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003419 struct hda_codec *codec,
3420 unsigned int stream_tag,
3421 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003422 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003423{
3424 struct alc_spec *spec = codec->spec;
3425
Takashi Iwai63300792008-01-24 15:31:36 +01003426 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003427 stream_tag, 0, format);
3428 return 0;
3429}
3430
Takashi Iwai63300792008-01-24 15:31:36 +01003431static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003432 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003433 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003434{
3435 struct alc_spec *spec = codec->spec;
3436
Takashi Iwai888afa12008-03-18 09:57:50 +01003437 snd_hda_codec_cleanup_stream(codec,
3438 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003439 return 0;
3440}
3441
3442
3443/*
3444 */
3445static struct hda_pcm_stream alc880_pcm_analog_playback = {
3446 .substreams = 1,
3447 .channels_min = 2,
3448 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003449 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003450 .ops = {
3451 .open = alc880_playback_pcm_open,
3452 .prepare = alc880_playback_pcm_prepare,
3453 .cleanup = alc880_playback_pcm_cleanup
3454 },
3455};
3456
3457static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003458 .substreams = 1,
3459 .channels_min = 2,
3460 .channels_max = 2,
3461 /* NID is set in alc_build_pcms */
3462};
3463
3464static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3465 .substreams = 1,
3466 .channels_min = 2,
3467 .channels_max = 2,
3468 /* NID is set in alc_build_pcms */
3469};
3470
3471static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3472 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003473 .channels_min = 2,
3474 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003475 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003476 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003477 .prepare = alc880_alt_capture_pcm_prepare,
3478 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003479 },
3480};
3481
3482static struct hda_pcm_stream alc880_pcm_digital_playback = {
3483 .substreams = 1,
3484 .channels_min = 2,
3485 .channels_max = 2,
3486 /* NID is set in alc_build_pcms */
3487 .ops = {
3488 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003489 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003490 .prepare = alc880_dig_playback_pcm_prepare,
3491 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003492 },
3493};
3494
3495static struct hda_pcm_stream alc880_pcm_digital_capture = {
3496 .substreams = 1,
3497 .channels_min = 2,
3498 .channels_max = 2,
3499 /* NID is set in alc_build_pcms */
3500};
3501
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003502/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003503static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003504 .substreams = 0,
3505 .channels_min = 0,
3506 .channels_max = 0,
3507};
3508
Linus Torvalds1da177e2005-04-16 15:20:36 -07003509static int alc_build_pcms(struct hda_codec *codec)
3510{
3511 struct alc_spec *spec = codec->spec;
3512 struct hda_pcm *info = spec->pcm_rec;
3513 int i;
3514
3515 codec->num_pcms = 1;
3516 codec->pcm_info = info;
3517
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003518 if (spec->no_analog)
3519 goto skip_analog;
3520
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003521 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3522 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003523 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003524
Takashi Iwai4a471b72005-12-07 13:56:29 +01003525 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003526 if (snd_BUG_ON(!spec->multiout.dac_nids))
3527 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003528 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3529 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3530 }
3531 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003532 if (snd_BUG_ON(!spec->adc_nids))
3533 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003534 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3535 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3536 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003537
Takashi Iwai4a471b72005-12-07 13:56:29 +01003538 if (spec->channel_mode) {
3539 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3540 for (i = 0; i < spec->num_channel_mode; i++) {
3541 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3542 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3543 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003544 }
3545 }
3546
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003547 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003548 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003549 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003550 snprintf(spec->stream_name_digital,
3551 sizeof(spec->stream_name_digital),
3552 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003553 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003554 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003555 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003556 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003557 if (spec->dig_out_type)
3558 info->pcm_type = spec->dig_out_type;
3559 else
3560 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003561 if (spec->multiout.dig_out_nid &&
3562 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003563 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3564 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3565 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003566 if (spec->dig_in_nid &&
3567 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003568 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3569 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3570 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003571 /* FIXME: do we need this for all Realtek codec models? */
3572 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003573 }
3574
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003575 if (spec->no_analog)
3576 return 0;
3577
Takashi Iwaie08a0072006-09-07 17:52:14 +02003578 /* If the use of more than one ADC is requested for the current
3579 * model, configure a second analog capture-only PCM.
3580 */
3581 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003582 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3583 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003584 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003585 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003586 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003587 if (spec->alt_dac_nid) {
3588 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3589 *spec->stream_analog_alt_playback;
3590 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3591 spec->alt_dac_nid;
3592 } else {
3593 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3594 alc_pcm_null_stream;
3595 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3596 }
3597 if (spec->num_adc_nids > 1) {
3598 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3599 *spec->stream_analog_alt_capture;
3600 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3601 spec->adc_nids[1];
3602 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3603 spec->num_adc_nids - 1;
3604 } else {
3605 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3606 alc_pcm_null_stream;
3607 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003608 }
3609 }
3610
Linus Torvalds1da177e2005-04-16 15:20:36 -07003611 return 0;
3612}
3613
Takashi Iwai603c4012008-07-30 15:01:44 +02003614static void alc_free_kctls(struct hda_codec *codec)
3615{
3616 struct alc_spec *spec = codec->spec;
3617
3618 if (spec->kctls.list) {
3619 struct snd_kcontrol_new *kctl = spec->kctls.list;
3620 int i;
3621 for (i = 0; i < spec->kctls.used; i++)
3622 kfree(kctl[i].name);
3623 }
3624 snd_array_free(&spec->kctls);
3625}
3626
Linus Torvalds1da177e2005-04-16 15:20:36 -07003627static void alc_free(struct hda_codec *codec)
3628{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003629 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003630
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003631 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003632 return;
3633
Takashi Iwai603c4012008-07-30 15:01:44 +02003634 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003635 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003636 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003637}
3638
Hector Martinf5de24b2009-12-20 22:51:31 +01003639#ifdef CONFIG_SND_HDA_POWER_SAVE
3640static int alc_suspend(struct hda_codec *codec, pm_message_t state)
3641{
3642 struct alc_spec *spec = codec->spec;
3643 if (spec && spec->power_hook)
3644 spec->power_hook(codec, 0);
3645 return 0;
3646}
3647#endif
3648
Takashi Iwaie044c392008-10-27 16:56:24 +01003649#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003650static int alc_resume(struct hda_codec *codec)
3651{
Hector Martinf5de24b2009-12-20 22:51:31 +01003652#ifdef CONFIG_SND_HDA_POWER_SAVE
3653 struct alc_spec *spec = codec->spec;
3654#endif
Takashi Iwaie044c392008-10-27 16:56:24 +01003655 codec->patch_ops.init(codec);
3656 snd_hda_codec_resume_amp(codec);
3657 snd_hda_codec_resume_cache(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003658#ifdef CONFIG_SND_HDA_POWER_SAVE
3659 if (spec && spec->power_hook)
3660 spec->power_hook(codec, 1);
3661#endif
Takashi Iwaie044c392008-10-27 16:56:24 +01003662 return 0;
3663}
Takashi Iwaie044c392008-10-27 16:56:24 +01003664#endif
3665
Linus Torvalds1da177e2005-04-16 15:20:36 -07003666/*
3667 */
3668static struct hda_codec_ops alc_patch_ops = {
3669 .build_controls = alc_build_controls,
3670 .build_pcms = alc_build_pcms,
3671 .init = alc_init,
3672 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003673 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003674#ifdef SND_HDA_NEEDS_RESUME
3675 .resume = alc_resume,
3676#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003677#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01003678 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003679 .check_power_status = alc_check_power_status,
3680#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003681};
3682
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003683
3684/*
3685 * Test configuration for debugging
3686 *
3687 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3688 * enum controls.
3689 */
3690#ifdef CONFIG_SND_DEBUG
3691static hda_nid_t alc880_test_dac_nids[4] = {
3692 0x02, 0x03, 0x04, 0x05
3693};
3694
3695static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003696 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003697 .items = {
3698 { "In-1", 0x0 },
3699 { "In-2", 0x1 },
3700 { "In-3", 0x2 },
3701 { "In-4", 0x3 },
3702 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003703 { "Front", 0x5 },
3704 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003705 },
3706};
3707
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003708static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003709 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003710 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003711 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003712 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003713};
3714
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003715static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3716 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003717{
3718 static char *texts[] = {
3719 "N/A", "Line Out", "HP Out",
3720 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3721 };
3722 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3723 uinfo->count = 1;
3724 uinfo->value.enumerated.items = 8;
3725 if (uinfo->value.enumerated.item >= 8)
3726 uinfo->value.enumerated.item = 7;
3727 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3728 return 0;
3729}
3730
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003731static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3732 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003733{
3734 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3735 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3736 unsigned int pin_ctl, item = 0;
3737
3738 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3739 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3740 if (pin_ctl & AC_PINCTL_OUT_EN) {
3741 if (pin_ctl & AC_PINCTL_HP_EN)
3742 item = 2;
3743 else
3744 item = 1;
3745 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3746 switch (pin_ctl & AC_PINCTL_VREFEN) {
3747 case AC_PINCTL_VREF_HIZ: item = 3; break;
3748 case AC_PINCTL_VREF_50: item = 4; break;
3749 case AC_PINCTL_VREF_GRD: item = 5; break;
3750 case AC_PINCTL_VREF_80: item = 6; break;
3751 case AC_PINCTL_VREF_100: item = 7; break;
3752 }
3753 }
3754 ucontrol->value.enumerated.item[0] = item;
3755 return 0;
3756}
3757
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003758static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3759 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003760{
3761 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3762 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3763 static unsigned int ctls[] = {
3764 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3765 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3766 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3767 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3768 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3769 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3770 };
3771 unsigned int old_ctl, new_ctl;
3772
3773 old_ctl = snd_hda_codec_read(codec, nid, 0,
3774 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3775 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3776 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003777 int val;
3778 snd_hda_codec_write_cache(codec, nid, 0,
3779 AC_VERB_SET_PIN_WIDGET_CONTROL,
3780 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003781 val = ucontrol->value.enumerated.item[0] >= 3 ?
3782 HDA_AMP_MUTE : 0;
3783 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3784 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003785 return 1;
3786 }
3787 return 0;
3788}
3789
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003790static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3791 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003792{
3793 static char *texts[] = {
3794 "Front", "Surround", "CLFE", "Side"
3795 };
3796 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3797 uinfo->count = 1;
3798 uinfo->value.enumerated.items = 4;
3799 if (uinfo->value.enumerated.item >= 4)
3800 uinfo->value.enumerated.item = 3;
3801 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3802 return 0;
3803}
3804
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003805static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3806 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003807{
3808 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3809 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3810 unsigned int sel;
3811
3812 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3813 ucontrol->value.enumerated.item[0] = sel & 3;
3814 return 0;
3815}
3816
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003817static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3818 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003819{
3820 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3821 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3822 unsigned int sel;
3823
3824 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3825 if (ucontrol->value.enumerated.item[0] != sel) {
3826 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003827 snd_hda_codec_write_cache(codec, nid, 0,
3828 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003829 return 1;
3830 }
3831 return 0;
3832}
3833
3834#define PIN_CTL_TEST(xname,nid) { \
3835 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3836 .name = xname, \
3837 .info = alc_test_pin_ctl_info, \
3838 .get = alc_test_pin_ctl_get, \
3839 .put = alc_test_pin_ctl_put, \
3840 .private_value = nid \
3841 }
3842
3843#define PIN_SRC_TEST(xname,nid) { \
3844 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3845 .name = xname, \
3846 .info = alc_test_pin_src_info, \
3847 .get = alc_test_pin_src_get, \
3848 .put = alc_test_pin_src_put, \
3849 .private_value = nid \
3850 }
3851
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003852static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003853 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3854 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3855 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3856 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003857 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3858 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3859 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3860 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003861 PIN_CTL_TEST("Front Pin Mode", 0x14),
3862 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3863 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3864 PIN_CTL_TEST("Side Pin Mode", 0x17),
3865 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3866 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3867 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3868 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3869 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3870 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3871 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3872 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3873 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3874 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3875 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3876 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3877 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3878 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3879 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3880 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3881 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3882 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003883 {
3884 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3885 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003886 .info = alc_ch_mode_info,
3887 .get = alc_ch_mode_get,
3888 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003889 },
3890 { } /* end */
3891};
3892
3893static struct hda_verb alc880_test_init_verbs[] = {
3894 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003895 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3896 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3897 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3898 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3899 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3900 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3901 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3902 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003903 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003904 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3905 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3906 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3907 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003908 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003909 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3910 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3911 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3912 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003913 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003914 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3915 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3916 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3917 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003918 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003919 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3920 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003921 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3922 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3923 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003924 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003925 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3926 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3927 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3928 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003929 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003930 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003931 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003932 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003933 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003934 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003935 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003936 /* Analog input/passthru */
3937 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3938 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3939 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3940 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3941 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003942 { }
3943};
3944#endif
3945
Linus Torvalds1da177e2005-04-16 15:20:36 -07003946/*
3947 */
3948
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003949static const char *alc880_models[ALC880_MODEL_LAST] = {
3950 [ALC880_3ST] = "3stack",
3951 [ALC880_TCL_S700] = "tcl",
3952 [ALC880_3ST_DIG] = "3stack-digout",
3953 [ALC880_CLEVO] = "clevo",
3954 [ALC880_5ST] = "5stack",
3955 [ALC880_5ST_DIG] = "5stack-digout",
3956 [ALC880_W810] = "w810",
3957 [ALC880_Z71V] = "z71v",
3958 [ALC880_6ST] = "6stack",
3959 [ALC880_6ST_DIG] = "6stack-digout",
3960 [ALC880_ASUS] = "asus",
3961 [ALC880_ASUS_W1V] = "asus-w1v",
3962 [ALC880_ASUS_DIG] = "asus-dig",
3963 [ALC880_ASUS_DIG2] = "asus-dig2",
3964 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003965 [ALC880_UNIWILL_P53] = "uniwill-p53",
3966 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003967 [ALC880_F1734] = "F1734",
3968 [ALC880_LG] = "lg",
3969 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003970 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003971#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003972 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003973#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003974 [ALC880_AUTO] = "auto",
3975};
3976
3977static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003978 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003979 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3980 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3981 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3982 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3983 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3984 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3985 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3986 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003987 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3988 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003989 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3990 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3991 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3992 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3993 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3994 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3995 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3996 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3997 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3998 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003999 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004000 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4001 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4002 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004003 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004004 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004005 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4006 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004007 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4008 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004009 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4010 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4011 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4012 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004013 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4014 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004015 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004016 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004017 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004018 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004019 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4020 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004021 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004022 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004023 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004024 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004025 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004026 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004027 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004028 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004029 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004030 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4031 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004032 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004033 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4034 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4035 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4036 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004037 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4038 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004039 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004040 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004041 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4042 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004043 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4044 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4045 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004046 /* default Intel */
4047 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004048 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4049 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004050 {}
4051};
4052
Takashi Iwai16ded522005-06-10 19:58:24 +02004053/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004054 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004055 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004056static struct alc_config_preset alc880_presets[] = {
4057 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004058 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004059 .init_verbs = { alc880_volume_init_verbs,
4060 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004061 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004062 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004063 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4064 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004065 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004066 .input_mux = &alc880_capture_source,
4067 },
4068 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004069 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004070 .init_verbs = { alc880_volume_init_verbs,
4071 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004072 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004073 .dac_nids = alc880_dac_nids,
4074 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004075 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4076 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004077 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004078 .input_mux = &alc880_capture_source,
4079 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004080 [ALC880_TCL_S700] = {
4081 .mixers = { alc880_tcl_s700_mixer },
4082 .init_verbs = { alc880_volume_init_verbs,
4083 alc880_pin_tcl_S700_init_verbs,
4084 alc880_gpio2_init_verbs },
4085 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4086 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004087 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4088 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004089 .hp_nid = 0x03,
4090 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4091 .channel_mode = alc880_2_jack_modes,
4092 .input_mux = &alc880_capture_source,
4093 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004094 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004095 .mixers = { alc880_three_stack_mixer,
4096 alc880_five_stack_mixer},
4097 .init_verbs = { alc880_volume_init_verbs,
4098 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004099 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4100 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004101 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4102 .channel_mode = alc880_fivestack_modes,
4103 .input_mux = &alc880_capture_source,
4104 },
4105 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004106 .mixers = { alc880_three_stack_mixer,
4107 alc880_five_stack_mixer },
4108 .init_verbs = { alc880_volume_init_verbs,
4109 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004110 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4111 .dac_nids = alc880_dac_nids,
4112 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004113 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4114 .channel_mode = alc880_fivestack_modes,
4115 .input_mux = &alc880_capture_source,
4116 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004117 [ALC880_6ST] = {
4118 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004119 .init_verbs = { alc880_volume_init_verbs,
4120 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004121 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4122 .dac_nids = alc880_6st_dac_nids,
4123 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4124 .channel_mode = alc880_sixstack_modes,
4125 .input_mux = &alc880_6stack_capture_source,
4126 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004127 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004128 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004129 .init_verbs = { alc880_volume_init_verbs,
4130 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004131 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4132 .dac_nids = alc880_6st_dac_nids,
4133 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004134 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4135 .channel_mode = alc880_sixstack_modes,
4136 .input_mux = &alc880_6stack_capture_source,
4137 },
4138 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004139 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004140 .init_verbs = { alc880_volume_init_verbs,
4141 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004142 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004143 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4144 .dac_nids = alc880_w810_dac_nids,
4145 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004146 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4147 .channel_mode = alc880_w810_modes,
4148 .input_mux = &alc880_capture_source,
4149 },
4150 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004151 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004152 .init_verbs = { alc880_volume_init_verbs,
4153 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004154 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4155 .dac_nids = alc880_z71v_dac_nids,
4156 .dig_out_nid = ALC880_DIGOUT_NID,
4157 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004158 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4159 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004160 .input_mux = &alc880_capture_source,
4161 },
4162 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004163 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004164 .init_verbs = { alc880_volume_init_verbs,
4165 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004166 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4167 .dac_nids = alc880_f1734_dac_nids,
4168 .hp_nid = 0x02,
4169 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4170 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004171 .input_mux = &alc880_f1734_capture_source,
4172 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004173 .setup = alc880_uniwill_p53_setup,
4174 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004175 },
4176 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004177 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004178 .init_verbs = { alc880_volume_init_verbs,
4179 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004180 alc880_gpio1_init_verbs },
4181 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4182 .dac_nids = alc880_asus_dac_nids,
4183 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4184 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004185 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004186 .input_mux = &alc880_capture_source,
4187 },
4188 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004189 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004190 .init_verbs = { alc880_volume_init_verbs,
4191 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004192 alc880_gpio1_init_verbs },
4193 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4194 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004195 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004196 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4197 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004198 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004199 .input_mux = &alc880_capture_source,
4200 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004201 [ALC880_ASUS_DIG2] = {
4202 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004203 .init_verbs = { alc880_volume_init_verbs,
4204 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004205 alc880_gpio2_init_verbs }, /* use GPIO2 */
4206 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4207 .dac_nids = alc880_asus_dac_nids,
4208 .dig_out_nid = ALC880_DIGOUT_NID,
4209 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4210 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004211 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004212 .input_mux = &alc880_capture_source,
4213 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004214 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004215 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004216 .init_verbs = { alc880_volume_init_verbs,
4217 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004218 alc880_gpio1_init_verbs },
4219 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4220 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004221 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004222 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4223 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004224 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004225 .input_mux = &alc880_capture_source,
4226 },
4227 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004228 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004229 .init_verbs = { alc880_volume_init_verbs,
4230 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004231 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4232 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004233 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004234 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4235 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004236 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004237 .input_mux = &alc880_capture_source,
4238 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004239 [ALC880_UNIWILL] = {
4240 .mixers = { alc880_uniwill_mixer },
4241 .init_verbs = { alc880_volume_init_verbs,
4242 alc880_uniwill_init_verbs },
4243 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4244 .dac_nids = alc880_asus_dac_nids,
4245 .dig_out_nid = ALC880_DIGOUT_NID,
4246 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4247 .channel_mode = alc880_threestack_modes,
4248 .need_dac_fix = 1,
4249 .input_mux = &alc880_capture_source,
4250 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004251 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004252 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004253 },
4254 [ALC880_UNIWILL_P53] = {
4255 .mixers = { alc880_uniwill_p53_mixer },
4256 .init_verbs = { alc880_volume_init_verbs,
4257 alc880_uniwill_p53_init_verbs },
4258 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4259 .dac_nids = alc880_asus_dac_nids,
4260 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004261 .channel_mode = alc880_threestack_modes,
4262 .input_mux = &alc880_capture_source,
4263 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004264 .setup = alc880_uniwill_p53_setup,
4265 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004266 },
4267 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004268 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004269 .init_verbs = { alc880_volume_init_verbs,
4270 alc880_uniwill_p53_init_verbs,
4271 alc880_beep_init_verbs },
4272 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4273 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004274 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004275 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4276 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004277 .input_mux = &alc880_capture_source,
4278 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004279 .setup = alc880_uniwill_p53_setup,
4280 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004281 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004282 [ALC880_CLEVO] = {
4283 .mixers = { alc880_three_stack_mixer },
4284 .init_verbs = { alc880_volume_init_verbs,
4285 alc880_pin_clevo_init_verbs },
4286 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4287 .dac_nids = alc880_dac_nids,
4288 .hp_nid = 0x03,
4289 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4290 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004291 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004292 .input_mux = &alc880_capture_source,
4293 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004294 [ALC880_LG] = {
4295 .mixers = { alc880_lg_mixer },
4296 .init_verbs = { alc880_volume_init_verbs,
4297 alc880_lg_init_verbs },
4298 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4299 .dac_nids = alc880_lg_dac_nids,
4300 .dig_out_nid = ALC880_DIGOUT_NID,
4301 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4302 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004303 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004304 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004305 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004306 .setup = alc880_lg_setup,
4307 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004308#ifdef CONFIG_SND_HDA_POWER_SAVE
4309 .loopbacks = alc880_lg_loopbacks,
4310#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004311 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004312 [ALC880_LG_LW] = {
4313 .mixers = { alc880_lg_lw_mixer },
4314 .init_verbs = { alc880_volume_init_verbs,
4315 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004316 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004317 .dac_nids = alc880_dac_nids,
4318 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004319 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4320 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004321 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004322 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004323 .setup = alc880_lg_lw_setup,
4324 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004325 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004326 [ALC880_MEDION_RIM] = {
4327 .mixers = { alc880_medion_rim_mixer },
4328 .init_verbs = { alc880_volume_init_verbs,
4329 alc880_medion_rim_init_verbs,
4330 alc_gpio2_init_verbs },
4331 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4332 .dac_nids = alc880_dac_nids,
4333 .dig_out_nid = ALC880_DIGOUT_NID,
4334 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4335 .channel_mode = alc880_2_jack_modes,
4336 .input_mux = &alc880_medion_rim_capture_source,
4337 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004338 .setup = alc880_medion_rim_setup,
4339 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004340 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004341#ifdef CONFIG_SND_DEBUG
4342 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004343 .mixers = { alc880_test_mixer },
4344 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004345 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4346 .dac_nids = alc880_test_dac_nids,
4347 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004348 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4349 .channel_mode = alc880_test_modes,
4350 .input_mux = &alc880_test_capture_source,
4351 },
4352#endif
4353};
4354
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004355/*
4356 * Automatic parse of I/O pins from the BIOS configuration
4357 */
4358
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004359enum {
4360 ALC_CTL_WIDGET_VOL,
4361 ALC_CTL_WIDGET_MUTE,
4362 ALC_CTL_BIND_MUTE,
4363};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004364static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004365 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4366 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004367 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004368};
4369
4370/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004371static int add_control(struct alc_spec *spec, int type, const char *name,
4372 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004373{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004374 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004375
Takashi Iwai603c4012008-07-30 15:01:44 +02004376 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4377 knew = snd_array_new(&spec->kctls);
4378 if (!knew)
4379 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004380 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004381 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004382 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004383 return -ENOMEM;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004384 if (get_amp_nid_(val))
Takashi Iwai9c96fa52009-11-16 11:25:33 +01004385 knew->subdevice = HDA_SUBDEV_NID_FLAG | get_amp_nid_(val);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004386 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004387 return 0;
4388}
4389
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004390static int add_control_with_pfx(struct alc_spec *spec, int type,
4391 const char *pfx, const char *dir,
4392 const char *sfx, unsigned long val)
4393{
4394 char name[32];
4395 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
4396 return add_control(spec, type, name, val);
4397}
4398
4399#define add_pb_vol_ctrl(spec, type, pfx, val) \
4400 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val)
4401#define add_pb_sw_ctrl(spec, type, pfx, val) \
4402 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val)
4403
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004404#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4405#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4406#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4407#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004408#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4409#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4410#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4411#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4412#define ALC880_PIN_CD_NID 0x1c
4413
4414/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004415static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4416 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004417{
4418 hda_nid_t nid;
4419 int assigned[4];
4420 int i, j;
4421
4422 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004423 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004424
4425 /* check the pins hardwired to audio widget */
4426 for (i = 0; i < cfg->line_outs; i++) {
4427 nid = cfg->line_out_pins[i];
4428 if (alc880_is_fixed_pin(nid)) {
4429 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004430 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004431 assigned[idx] = 1;
4432 }
4433 }
4434 /* left pins can be connect to any audio widget */
4435 for (i = 0; i < cfg->line_outs; i++) {
4436 nid = cfg->line_out_pins[i];
4437 if (alc880_is_fixed_pin(nid))
4438 continue;
4439 /* search for an empty channel */
4440 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004441 if (!assigned[j]) {
4442 spec->multiout.dac_nids[i] =
4443 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004444 assigned[j] = 1;
4445 break;
4446 }
4447 }
4448 }
4449 spec->multiout.num_dacs = cfg->line_outs;
4450 return 0;
4451}
4452
4453/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004454static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4455 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004456{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004457 static const char *chname[4] = {
4458 "Front", "Surround", NULL /*CLFE*/, "Side"
4459 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004460 hda_nid_t nid;
4461 int i, err;
4462
4463 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004464 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004465 continue;
4466 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4467 if (i == 2) {
4468 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004469 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4470 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004471 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4472 HDA_OUTPUT));
4473 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004474 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004475 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4476 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004477 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4478 HDA_OUTPUT));
4479 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004480 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004481 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4482 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004483 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4484 HDA_INPUT));
4485 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004486 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004487 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4488 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004489 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4490 HDA_INPUT));
4491 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004492 return err;
4493 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004494 const char *pfx;
4495 if (cfg->line_outs == 1 &&
4496 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4497 pfx = "Speaker";
4498 else
4499 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004500 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004501 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4502 HDA_OUTPUT));
4503 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004504 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004505 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004506 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4507 HDA_INPUT));
4508 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004509 return err;
4510 }
4511 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004512 return 0;
4513}
4514
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004515/* add playback controls for speaker and HP outputs */
4516static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4517 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004518{
4519 hda_nid_t nid;
4520 int err;
4521
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004522 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004523 return 0;
4524
4525 if (alc880_is_fixed_pin(pin)) {
4526 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004527 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004528 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004529 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004530 else
4531 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004532 /* control HP volume/switch on the output mixer amp */
4533 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004534 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004535 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4536 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004537 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004538 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004539 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4540 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004541 return err;
4542 } else if (alc880_is_multi_pin(pin)) {
4543 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004544 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004545 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004546 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4547 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004548 return err;
4549 }
4550 return 0;
4551}
4552
4553/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004554static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4555 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004556 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004557{
Kailang Yangdf694da2005-12-05 19:42:22 +01004558 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004559
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004560 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004561 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4562 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004563 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004564 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004565 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4566 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004567 return err;
4568 return 0;
4569}
4570
Takashi Iwai05f5f472009-08-25 13:10:18 +02004571static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004572{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004573 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4574 return (pincap & AC_PINCAP_IN) != 0;
4575}
4576
4577/* create playback/capture controls for input pins */
4578static int alc_auto_create_input_ctls(struct hda_codec *codec,
4579 const struct auto_pin_cfg *cfg,
4580 hda_nid_t mixer,
4581 hda_nid_t cap1, hda_nid_t cap2)
4582{
4583 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004584 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004585 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004586
4587 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004588 hda_nid_t pin;
4589
4590 pin = cfg->input_pins[i];
4591 if (!alc_is_input_pin(codec, pin))
4592 continue;
4593
4594 if (mixer) {
4595 idx = get_connection_index(codec, mixer, pin);
4596 if (idx >= 0) {
4597 err = new_analog_input(spec, pin,
4598 auto_pin_cfg_labels[i],
4599 idx, mixer);
4600 if (err < 0)
4601 return err;
4602 }
4603 }
4604
4605 if (!cap1)
4606 continue;
4607 idx = get_connection_index(codec, cap1, pin);
4608 if (idx < 0 && cap2)
4609 idx = get_connection_index(codec, cap2, pin);
4610 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004611 imux->items[imux->num_items].label =
4612 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004613 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004614 imux->num_items++;
4615 }
4616 }
4617 return 0;
4618}
4619
Takashi Iwai05f5f472009-08-25 13:10:18 +02004620static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4621 const struct auto_pin_cfg *cfg)
4622{
4623 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4624}
4625
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004626static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4627 unsigned int pin_type)
4628{
4629 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4630 pin_type);
4631 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004632 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4633 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004634}
4635
Kailang Yangdf694da2005-12-05 19:42:22 +01004636static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4637 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004638 int dac_idx)
4639{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004640 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004641 /* need the manual connection? */
4642 if (alc880_is_multi_pin(nid)) {
4643 struct alc_spec *spec = codec->spec;
4644 int idx = alc880_multi_pin_idx(nid);
4645 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4646 AC_VERB_SET_CONNECT_SEL,
4647 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4648 }
4649}
4650
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004651static int get_pin_type(int line_out_type)
4652{
4653 if (line_out_type == AUTO_PIN_HP_OUT)
4654 return PIN_HP;
4655 else
4656 return PIN_OUT;
4657}
4658
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004659static void alc880_auto_init_multi_out(struct hda_codec *codec)
4660{
4661 struct alc_spec *spec = codec->spec;
4662 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004663
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004664 for (i = 0; i < spec->autocfg.line_outs; i++) {
4665 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004666 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4667 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004668 }
4669}
4670
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004671static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004672{
4673 struct alc_spec *spec = codec->spec;
4674 hda_nid_t pin;
4675
Takashi Iwai82bc9552006-03-21 11:24:42 +01004676 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004677 if (pin) /* connect to front */
4678 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004679 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004680 if (pin) /* connect to front */
4681 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4682}
4683
4684static void alc880_auto_init_analog_input(struct hda_codec *codec)
4685{
4686 struct alc_spec *spec = codec->spec;
4687 int i;
4688
4689 for (i = 0; i < AUTO_PIN_LAST; i++) {
4690 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004691 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004692 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004693 if (nid != ALC880_PIN_CD_NID &&
4694 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004695 snd_hda_codec_write(codec, nid, 0,
4696 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004697 AMP_OUT_MUTE);
4698 }
4699 }
4700}
4701
4702/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004703/* return 1 if successful, 0 if the proper config is not found,
4704 * or a negative error code
4705 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004706static int alc880_parse_auto_config(struct hda_codec *codec)
4707{
4708 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004709 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004710 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004711
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004712 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4713 alc880_ignore);
4714 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004715 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004716 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004717 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004718
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004719 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4720 if (err < 0)
4721 return err;
4722 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4723 if (err < 0)
4724 return err;
4725 err = alc880_auto_create_extra_out(spec,
4726 spec->autocfg.speaker_pins[0],
4727 "Speaker");
4728 if (err < 0)
4729 return err;
4730 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4731 "Headphone");
4732 if (err < 0)
4733 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004734 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004735 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004736 return err;
4737
4738 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4739
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004740 /* check multiple SPDIF-out (for recent codecs) */
4741 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4742 hda_nid_t dig_nid;
4743 err = snd_hda_get_connections(codec,
4744 spec->autocfg.dig_out_pins[i],
4745 &dig_nid, 1);
4746 if (err < 0)
4747 continue;
4748 if (!i)
4749 spec->multiout.dig_out_nid = dig_nid;
4750 else {
4751 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004752 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004753 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004754 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004755 }
4756 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004757 if (spec->autocfg.dig_in_pin)
4758 spec->dig_in_nid = ALC880_DIGIN_NID;
4759
Takashi Iwai603c4012008-07-30 15:01:44 +02004760 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004761 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004762
Takashi Iwaid88897e2008-10-31 15:01:37 +01004763 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004764
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004765 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004766 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004767
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004768 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4769
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004770 return 1;
4771}
4772
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004773/* additional initialization for auto-configuration model */
4774static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004775{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004776 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004777 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004778 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004779 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004780 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004781 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004782}
4783
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004784/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4785 * one of two digital mic pins, e.g. on ALC272
4786 */
4787static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004788{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004789 struct alc_spec *spec = codec->spec;
4790 int i;
4791
4792 for (i = 0; i < spec->num_adc_nids; i++) {
4793 hda_nid_t cap = spec->capsrc_nids ?
4794 spec->capsrc_nids[i] : spec->adc_nids[i];
4795 int iidx, eidx;
4796
4797 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4798 if (iidx < 0)
4799 continue;
4800 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4801 if (eidx < 0)
4802 continue;
4803 spec->int_mic.mux_idx = iidx;
4804 spec->ext_mic.mux_idx = eidx;
4805 if (spec->capsrc_nids)
4806 spec->capsrc_nids += i;
4807 spec->adc_nids += i;
4808 spec->num_adc_nids = 1;
4809 return;
4810 }
4811 snd_printd(KERN_INFO "hda_codec: %s: "
4812 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4813 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4814 spec->auto_mic = 0; /* disable auto-mic to be sure */
4815}
4816
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004817/* choose the ADC/MUX containing the input pin and initialize the setup */
4818static void fixup_single_adc(struct hda_codec *codec)
4819{
4820 struct alc_spec *spec = codec->spec;
4821 hda_nid_t pin;
4822 int i;
4823
4824 /* search for the input pin; there must be only one */
4825 for (i = 0; i < AUTO_PIN_LAST; i++) {
4826 if (spec->autocfg.input_pins[i]) {
4827 pin = spec->autocfg.input_pins[i];
4828 break;
4829 }
4830 }
4831 if (!pin)
4832 return;
4833
4834 /* set the default connection to that pin */
4835 for (i = 0; i < spec->num_adc_nids; i++) {
4836 hda_nid_t cap = spec->capsrc_nids ?
4837 spec->capsrc_nids[i] : spec->adc_nids[i];
4838 int idx;
4839
4840 idx = get_connection_index(codec, cap, pin);
4841 if (idx < 0)
4842 continue;
4843 /* use only this ADC */
4844 if (spec->capsrc_nids)
4845 spec->capsrc_nids += i;
4846 spec->adc_nids += i;
4847 spec->num_adc_nids = 1;
4848 /* select or unmute this route */
4849 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
4850 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
4851 HDA_AMP_MUTE, 0);
4852 } else {
4853 snd_hda_codec_write_cache(codec, cap, 0,
4854 AC_VERB_SET_CONNECT_SEL, idx);
4855 }
4856 return;
4857 }
4858}
4859
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004860static void set_capture_mixer(struct hda_codec *codec)
4861{
4862 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01004863 static struct snd_kcontrol_new *caps[2][3] = {
4864 { alc_capture_mixer_nosrc1,
4865 alc_capture_mixer_nosrc2,
4866 alc_capture_mixer_nosrc3 },
4867 { alc_capture_mixer1,
4868 alc_capture_mixer2,
4869 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004870 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004871 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004872 int mux = 0;
4873 if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004874 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004875 else if (spec->input_mux) {
4876 if (spec->input_mux->num_items > 1)
4877 mux = 1;
4878 else if (spec->input_mux->num_items == 1)
4879 fixup_single_adc(codec);
4880 }
Takashi Iwaia23b6882009-03-23 15:21:36 +01004881 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4882 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004883}
4884
Takashi Iwai67d634c2009-11-16 15:35:59 +01004885#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004886#define set_beep_amp(spec, nid, idx, dir) \
4887 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwai67d634c2009-11-16 15:35:59 +01004888#else
4889#define set_beep_amp(spec, nid, idx, dir) /* NOP */
4890#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004891
4892/*
4893 * OK, here we have finally the patch for ALC880
4894 */
4895
Linus Torvalds1da177e2005-04-16 15:20:36 -07004896static int patch_alc880(struct hda_codec *codec)
4897{
4898 struct alc_spec *spec;
4899 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004900 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004901
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004902 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004903 if (spec == NULL)
4904 return -ENOMEM;
4905
4906 codec->spec = spec;
4907
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004908 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4909 alc880_models,
4910 alc880_cfg_tbl);
4911 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004912 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4913 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004914 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004915 }
4916
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004917 if (board_config == ALC880_AUTO) {
4918 /* automatic parse from the BIOS config */
4919 err = alc880_parse_auto_config(codec);
4920 if (err < 0) {
4921 alc_free(codec);
4922 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004923 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004924 printk(KERN_INFO
4925 "hda_codec: Cannot set up configuration "
4926 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004927 board_config = ALC880_3ST;
4928 }
4929 }
4930
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004931 err = snd_hda_attach_beep_device(codec, 0x1);
4932 if (err < 0) {
4933 alc_free(codec);
4934 return err;
4935 }
4936
Kailang Yangdf694da2005-12-05 19:42:22 +01004937 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02004938 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004939
Linus Torvalds1da177e2005-04-16 15:20:36 -07004940 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4941 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004942 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004943
Linus Torvalds1da177e2005-04-16 15:20:36 -07004944 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4945 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4946
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004947 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004948 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004949 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004950 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02004951 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004952 if (wcap != AC_WID_AUD_IN) {
4953 spec->adc_nids = alc880_adc_nids_alt;
4954 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004955 } else {
4956 spec->adc_nids = alc880_adc_nids;
4957 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004958 }
4959 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004960 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004961 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004962
Takashi Iwai2134ea42008-01-10 16:53:55 +01004963 spec->vmaster_nid = 0x0c;
4964
Linus Torvalds1da177e2005-04-16 15:20:36 -07004965 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004966 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004967 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004968#ifdef CONFIG_SND_HDA_POWER_SAVE
4969 if (!spec->loopback.amplist)
4970 spec->loopback.amplist = alc880_loopbacks;
4971#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004972 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004973
4974 return 0;
4975}
4976
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004977
Linus Torvalds1da177e2005-04-16 15:20:36 -07004978/*
4979 * ALC260 support
4980 */
4981
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004982static hda_nid_t alc260_dac_nids[1] = {
4983 /* front */
4984 0x02,
4985};
4986
4987static hda_nid_t alc260_adc_nids[1] = {
4988 /* ADC0 */
4989 0x04,
4990};
4991
Kailang Yangdf694da2005-12-05 19:42:22 +01004992static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004993 /* ADC1 */
4994 0x05,
4995};
4996
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004997/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4998 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4999 */
5000static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005001 /* ADC0, ADC1 */
5002 0x04, 0x05
5003};
5004
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005005#define ALC260_DIGOUT_NID 0x03
5006#define ALC260_DIGIN_NID 0x06
5007
5008static struct hda_input_mux alc260_capture_source = {
5009 .num_items = 4,
5010 .items = {
5011 { "Mic", 0x0 },
5012 { "Front Mic", 0x1 },
5013 { "Line", 0x2 },
5014 { "CD", 0x4 },
5015 },
5016};
5017
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005018/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005019 * headphone jack and the internal CD lines since these are the only pins at
5020 * which audio can appear. For flexibility, also allow the option of
5021 * recording the mixer output on the second ADC (ADC0 doesn't have a
5022 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005023 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005024static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5025 {
5026 .num_items = 3,
5027 .items = {
5028 { "Mic/Line", 0x0 },
5029 { "CD", 0x4 },
5030 { "Headphone", 0x2 },
5031 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005032 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005033 {
5034 .num_items = 4,
5035 .items = {
5036 { "Mic/Line", 0x0 },
5037 { "CD", 0x4 },
5038 { "Headphone", 0x2 },
5039 { "Mixer", 0x5 },
5040 },
5041 },
5042
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005043};
5044
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005045/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5046 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005047 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005048static struct hda_input_mux alc260_acer_capture_sources[2] = {
5049 {
5050 .num_items = 4,
5051 .items = {
5052 { "Mic", 0x0 },
5053 { "Line", 0x2 },
5054 { "CD", 0x4 },
5055 { "Headphone", 0x5 },
5056 },
5057 },
5058 {
5059 .num_items = 5,
5060 .items = {
5061 { "Mic", 0x0 },
5062 { "Line", 0x2 },
5063 { "CD", 0x4 },
5064 { "Headphone", 0x6 },
5065 { "Mixer", 0x5 },
5066 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005067 },
5068};
Michael Schwingencc959482009-02-22 18:58:45 +01005069
5070/* Maxdata Favorit 100XS */
5071static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5072 {
5073 .num_items = 2,
5074 .items = {
5075 { "Line/Mic", 0x0 },
5076 { "CD", 0x4 },
5077 },
5078 },
5079 {
5080 .num_items = 3,
5081 .items = {
5082 { "Line/Mic", 0x0 },
5083 { "CD", 0x4 },
5084 { "Mixer", 0x5 },
5085 },
5086 },
5087};
5088
Linus Torvalds1da177e2005-04-16 15:20:36 -07005089/*
5090 * This is just place-holder, so there's something for alc_build_pcms to look
5091 * at when it calculates the maximum number of channels. ALC260 has no mixer
5092 * element which allows changing the channel mode, so the verb list is
5093 * never used.
5094 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005095static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005096 { 2, NULL },
5097};
5098
Kailang Yangdf694da2005-12-05 19:42:22 +01005099
5100/* Mixer combinations
5101 *
5102 * basic: base_output + input + pc_beep + capture
5103 * HP: base_output + input + capture_alt
5104 * HP_3013: hp_3013 + input + capture
5105 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005106 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005107 */
5108
5109static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005110 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005111 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005112 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5113 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5114 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5115 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5116 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005117};
Kailang Yangdf694da2005-12-05 19:42:22 +01005118
5119static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005120 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5121 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5122 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5123 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5124 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5125 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5126 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5127 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005128 { } /* end */
5129};
5130
Takashi Iwaibec15c32008-01-28 18:16:30 +01005131/* update HP, line and mono out pins according to the master switch */
5132static void alc260_hp_master_update(struct hda_codec *codec,
5133 hda_nid_t hp, hda_nid_t line,
5134 hda_nid_t mono)
5135{
5136 struct alc_spec *spec = codec->spec;
5137 unsigned int val = spec->master_sw ? PIN_HP : 0;
5138 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005139 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005140 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005141 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005142 val);
5143 /* mono (speaker) depending on the HP jack sense */
5144 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005145 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005146 val);
5147}
5148
5149static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5150 struct snd_ctl_elem_value *ucontrol)
5151{
5152 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5153 struct alc_spec *spec = codec->spec;
5154 *ucontrol->value.integer.value = spec->master_sw;
5155 return 0;
5156}
5157
5158static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5159 struct snd_ctl_elem_value *ucontrol)
5160{
5161 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5162 struct alc_spec *spec = codec->spec;
5163 int val = !!*ucontrol->value.integer.value;
5164 hda_nid_t hp, line, mono;
5165
5166 if (val == spec->master_sw)
5167 return 0;
5168 spec->master_sw = val;
5169 hp = (kcontrol->private_value >> 16) & 0xff;
5170 line = (kcontrol->private_value >> 8) & 0xff;
5171 mono = kcontrol->private_value & 0xff;
5172 alc260_hp_master_update(codec, hp, line, mono);
5173 return 1;
5174}
5175
5176static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5177 {
5178 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5179 .name = "Master Playback Switch",
5180 .info = snd_ctl_boolean_mono_info,
5181 .get = alc260_hp_master_sw_get,
5182 .put = alc260_hp_master_sw_put,
5183 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5184 },
5185 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5186 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5187 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5188 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5189 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5190 HDA_OUTPUT),
5191 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5192 { } /* end */
5193};
5194
5195static struct hda_verb alc260_hp_unsol_verbs[] = {
5196 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5197 {},
5198};
5199
5200static void alc260_hp_automute(struct hda_codec *codec)
5201{
5202 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005203
Wu Fengguang864f92b2009-11-18 12:38:02 +08005204 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005205 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5206}
5207
5208static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5209{
5210 if ((res >> 26) == ALC880_HP_EVENT)
5211 alc260_hp_automute(codec);
5212}
5213
Kailang Yangdf694da2005-12-05 19:42:22 +01005214static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005215 {
5216 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5217 .name = "Master Playback Switch",
5218 .info = snd_ctl_boolean_mono_info,
5219 .get = alc260_hp_master_sw_get,
5220 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005221 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005222 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005223 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5224 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5225 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5226 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5227 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5228 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005229 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5230 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005231 { } /* end */
5232};
5233
Kailang Yang3f878302008-08-26 13:02:23 +02005234static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5235 .ops = &snd_hda_bind_vol,
5236 .values = {
5237 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5238 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5239 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5240 0
5241 },
5242};
5243
5244static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5245 .ops = &snd_hda_bind_sw,
5246 .values = {
5247 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5248 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5249 0
5250 },
5251};
5252
5253static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5254 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5255 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5256 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5257 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5258 { } /* end */
5259};
5260
Takashi Iwaibec15c32008-01-28 18:16:30 +01005261static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5262 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5263 {},
5264};
5265
5266static void alc260_hp_3013_automute(struct hda_codec *codec)
5267{
5268 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005269
Wu Fengguang864f92b2009-11-18 12:38:02 +08005270 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005271 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005272}
5273
5274static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5275 unsigned int res)
5276{
5277 if ((res >> 26) == ALC880_HP_EVENT)
5278 alc260_hp_3013_automute(codec);
5279}
5280
Kailang Yang3f878302008-08-26 13:02:23 +02005281static void alc260_hp_3012_automute(struct hda_codec *codec)
5282{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005283 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005284
Kailang Yang3f878302008-08-26 13:02:23 +02005285 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5286 bits);
5287 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5288 bits);
5289 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5290 bits);
5291}
5292
5293static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5294 unsigned int res)
5295{
5296 if ((res >> 26) == ALC880_HP_EVENT)
5297 alc260_hp_3012_automute(codec);
5298}
5299
5300/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005301 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5302 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005303static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005304 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005305 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005306 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005307 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5308 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5309 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5310 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005311 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005312 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5313 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005314 { } /* end */
5315};
5316
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005317/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5318 * versions of the ALC260 don't act on requests to enable mic bias from NID
5319 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5320 * datasheet doesn't mention this restriction. At this stage it's not clear
5321 * whether this behaviour is intentional or is a hardware bug in chip
5322 * revisions available in early 2006. Therefore for now allow the
5323 * "Headphone Jack Mode" control to span all choices, but if it turns out
5324 * that the lack of mic bias for this NID is intentional we could change the
5325 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5326 *
5327 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5328 * don't appear to make the mic bias available from the "line" jack, even
5329 * though the NID used for this jack (0x14) can supply it. The theory is
5330 * that perhaps Acer have included blocking capacitors between the ALC260
5331 * and the output jack. If this turns out to be the case for all such
5332 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5333 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005334 *
5335 * The C20x Tablet series have a mono internal speaker which is controlled
5336 * via the chip's Mono sum widget and pin complex, so include the necessary
5337 * controls for such models. On models without a "mono speaker" the control
5338 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005339 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005340static struct snd_kcontrol_new alc260_acer_mixer[] = {
5341 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5342 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005343 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005344 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005345 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005346 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005347 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005348 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5349 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5350 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5351 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5352 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5353 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5354 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5355 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005356 { } /* end */
5357};
5358
Michael Schwingencc959482009-02-22 18:58:45 +01005359/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5360 */
5361static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5362 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5363 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5364 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5365 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5366 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5367 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5368 { } /* end */
5369};
5370
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005371/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5372 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5373 */
5374static struct snd_kcontrol_new alc260_will_mixer[] = {
5375 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5376 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5377 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5378 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5379 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5380 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5381 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5382 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5383 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5384 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005385 { } /* end */
5386};
5387
5388/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5389 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5390 */
5391static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5392 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5393 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5394 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5395 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5396 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5397 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5398 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5399 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5400 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5401 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5402 { } /* end */
5403};
5404
Kailang Yangdf694da2005-12-05 19:42:22 +01005405/*
5406 * initialization verbs
5407 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005408static struct hda_verb alc260_init_verbs[] = {
5409 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005410 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005411 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005412 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005413 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005414 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005415 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005416 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005417 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005418 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005419 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005420 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005421 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005422 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005423 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005424 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005425 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005426 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5427 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005428 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005429 /* set connection select to line in (default select for this ADC) */
5430 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005431 /* mute capture amp left and right */
5432 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5433 /* set connection select to line in (default select for this ADC) */
5434 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005435 /* set vol=0 Line-Out mixer amp left and right */
5436 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5437 /* unmute pin widget amp left and right (no gain on this amp) */
5438 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5439 /* set vol=0 HP mixer amp left and right */
5440 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5441 /* unmute pin widget amp left and right (no gain on this amp) */
5442 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5443 /* set vol=0 Mono mixer amp left and right */
5444 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5445 /* unmute pin widget amp left and right (no gain on this amp) */
5446 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5447 /* unmute LINE-2 out pin */
5448 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005449 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5450 * Line In 2 = 0x03
5451 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005452 /* mute analog inputs */
5453 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5454 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5455 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5456 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5457 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005458 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005459 /* mute Front out path */
5460 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5461 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5462 /* mute Headphone out path */
5463 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5464 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5465 /* mute Mono out path */
5466 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5467 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005468 { }
5469};
5470
Takashi Iwai474167d2006-05-17 17:17:43 +02005471#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005472static struct hda_verb alc260_hp_init_verbs[] = {
5473 /* Headphone and output */
5474 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5475 /* mono output */
5476 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5477 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5478 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5479 /* Mic2 (front panel) pin widget for input and vref at 80% */
5480 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5481 /* Line In pin widget for input */
5482 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5483 /* Line-2 pin widget for output */
5484 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5485 /* CD pin widget for input */
5486 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5487 /* unmute amp left and right */
5488 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5489 /* set connection select to line in (default select for this ADC) */
5490 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5491 /* unmute Line-Out mixer amp left and right (volume = 0) */
5492 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5493 /* mute pin widget amp left and right (no gain on this amp) */
5494 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5495 /* unmute HP mixer amp left and right (volume = 0) */
5496 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5497 /* mute pin widget amp left and right (no gain on this amp) */
5498 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005499 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5500 * Line In 2 = 0x03
5501 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005502 /* mute analog inputs */
5503 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5504 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5505 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5506 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5507 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005508 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5509 /* Unmute Front out path */
5510 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5511 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5512 /* Unmute Headphone out path */
5513 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5514 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5515 /* Unmute Mono out path */
5516 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5517 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5518 { }
5519};
Takashi Iwai474167d2006-05-17 17:17:43 +02005520#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005521
5522static struct hda_verb alc260_hp_3013_init_verbs[] = {
5523 /* Line out and output */
5524 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5525 /* mono output */
5526 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5527 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5528 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5529 /* Mic2 (front panel) pin widget for input and vref at 80% */
5530 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5531 /* Line In pin widget for input */
5532 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5533 /* Headphone pin widget for output */
5534 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5535 /* CD pin widget for input */
5536 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5537 /* unmute amp left and right */
5538 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5539 /* set connection select to line in (default select for this ADC) */
5540 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5541 /* unmute Line-Out mixer amp left and right (volume = 0) */
5542 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5543 /* mute pin widget amp left and right (no gain on this amp) */
5544 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5545 /* unmute HP mixer amp left and right (volume = 0) */
5546 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5547 /* mute pin widget amp left and right (no gain on this amp) */
5548 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005549 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5550 * Line In 2 = 0x03
5551 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005552 /* mute analog inputs */
5553 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5554 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5555 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5556 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5557 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005558 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5559 /* Unmute Front out path */
5560 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5561 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5562 /* Unmute Headphone out path */
5563 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5564 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5565 /* Unmute Mono out path */
5566 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5567 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5568 { }
5569};
5570
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005571/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005572 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5573 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005574 */
5575static struct hda_verb alc260_fujitsu_init_verbs[] = {
5576 /* Disable all GPIOs */
5577 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5578 /* Internal speaker is connected to headphone pin */
5579 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5580 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5581 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005582 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5583 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5584 /* Ensure all other unused pins are disabled and muted. */
5585 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5586 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005587 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005588 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005589 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005590 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5591 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5592 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005593
Jonathan Woithef7ace402006-02-28 11:46:14 +01005594 /* Disable digital (SPDIF) pins */
5595 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5596 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005597
Kailang Yangea1fb292008-08-26 12:58:38 +02005598 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005599 * when acting as an output.
5600 */
5601 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5602
5603 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005604 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5605 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5606 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5607 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5608 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5609 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5610 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5611 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5612 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005613
Jonathan Woithef7ace402006-02-28 11:46:14 +01005614 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5615 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5616 /* Unmute Line1 pin widget output buffer since it starts as an output.
5617 * If the pin mode is changed by the user the pin mode control will
5618 * take care of enabling the pin's input/output buffers as needed.
5619 * Therefore there's no need to enable the input buffer at this
5620 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005621 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005622 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005623 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005624 * mixer ctrl)
5625 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005626 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005627
Jonathan Woithef7ace402006-02-28 11:46:14 +01005628 /* Mute capture amp left and right */
5629 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005630 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005631 * in (on mic1 pin)
5632 */
5633 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005634
Jonathan Woithef7ace402006-02-28 11:46:14 +01005635 /* Do the same for the second ADC: mute capture input amp and
5636 * set ADC connection to line in (on mic1 pin)
5637 */
5638 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5639 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005640
Jonathan Woithef7ace402006-02-28 11:46:14 +01005641 /* Mute all inputs to mixer widget (even unconnected ones) */
5642 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5643 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5644 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5645 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5646 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5647 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5648 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5649 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005650
5651 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005652};
5653
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005654/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5655 * similar laptops (adapted from Fujitsu init verbs).
5656 */
5657static struct hda_verb alc260_acer_init_verbs[] = {
5658 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5659 * the headphone jack. Turn this on and rely on the standard mute
5660 * methods whenever the user wants to turn these outputs off.
5661 */
5662 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5663 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5664 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5665 /* Internal speaker/Headphone jack is connected to Line-out pin */
5666 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5667 /* Internal microphone/Mic jack is connected to Mic1 pin */
5668 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5669 /* Line In jack is connected to Line1 pin */
5670 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005671 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5672 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005673 /* Ensure all other unused pins are disabled and muted. */
5674 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5675 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005676 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5677 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5678 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5679 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5680 /* Disable digital (SPDIF) pins */
5681 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5682 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5683
Kailang Yangea1fb292008-08-26 12:58:38 +02005684 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005685 * bus when acting as outputs.
5686 */
5687 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5688 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5689
5690 /* Start with output sum widgets muted and their output gains at min */
5691 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5692 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5693 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5694 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5695 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5696 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5697 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5698 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5699 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5700
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005701 /* Unmute Line-out pin widget amp left and right
5702 * (no equiv mixer ctrl)
5703 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005704 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005705 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5706 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005707 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5708 * inputs. If the pin mode is changed by the user the pin mode control
5709 * will take care of enabling the pin's input/output buffers as needed.
5710 * Therefore there's no need to enable the input buffer at this
5711 * stage.
5712 */
5713 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5714 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5715
5716 /* Mute capture amp left and right */
5717 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5718 /* Set ADC connection select to match default mixer setting - mic
5719 * (on mic1 pin)
5720 */
5721 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5722
5723 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005724 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005725 */
5726 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005727 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005728
5729 /* Mute all inputs to mixer widget (even unconnected ones) */
5730 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5731 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5732 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5733 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5734 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5735 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5736 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5737 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5738
5739 { }
5740};
5741
Michael Schwingencc959482009-02-22 18:58:45 +01005742/* Initialisation sequence for Maxdata Favorit 100XS
5743 * (adapted from Acer init verbs).
5744 */
5745static struct hda_verb alc260_favorit100_init_verbs[] = {
5746 /* GPIO 0 enables the output jack.
5747 * Turn this on and rely on the standard mute
5748 * methods whenever the user wants to turn these outputs off.
5749 */
5750 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5751 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5752 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5753 /* Line/Mic input jack is connected to Mic1 pin */
5754 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5755 /* Ensure all other unused pins are disabled and muted. */
5756 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5757 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5758 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5759 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5760 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5761 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5762 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5763 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5764 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5765 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5766 /* Disable digital (SPDIF) pins */
5767 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5768 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5769
5770 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5771 * bus when acting as outputs.
5772 */
5773 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5774 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5775
5776 /* Start with output sum widgets muted and their output gains at min */
5777 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5778 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5779 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5780 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5781 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5782 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5783 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5784 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5785 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5786
5787 /* Unmute Line-out pin widget amp left and right
5788 * (no equiv mixer ctrl)
5789 */
5790 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5791 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5792 * inputs. If the pin mode is changed by the user the pin mode control
5793 * will take care of enabling the pin's input/output buffers as needed.
5794 * Therefore there's no need to enable the input buffer at this
5795 * stage.
5796 */
5797 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5798
5799 /* Mute capture amp left and right */
5800 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5801 /* Set ADC connection select to match default mixer setting - mic
5802 * (on mic1 pin)
5803 */
5804 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5805
5806 /* Do similar with the second ADC: mute capture input amp and
5807 * set ADC connection to mic to match ALSA's default state.
5808 */
5809 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5810 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5811
5812 /* Mute all inputs to mixer widget (even unconnected ones) */
5813 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5814 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5815 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5816 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5817 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5818 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5819 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5820 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5821
5822 { }
5823};
5824
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005825static struct hda_verb alc260_will_verbs[] = {
5826 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5827 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5828 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5829 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5830 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5831 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5832 {}
5833};
5834
5835static struct hda_verb alc260_replacer_672v_verbs[] = {
5836 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5837 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5838 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5839
5840 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5841 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5842 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5843
5844 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5845 {}
5846};
5847
5848/* toggle speaker-output according to the hp-jack state */
5849static void alc260_replacer_672v_automute(struct hda_codec *codec)
5850{
5851 unsigned int present;
5852
5853 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08005854 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005855 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005856 snd_hda_codec_write_cache(codec, 0x01, 0,
5857 AC_VERB_SET_GPIO_DATA, 1);
5858 snd_hda_codec_write_cache(codec, 0x0f, 0,
5859 AC_VERB_SET_PIN_WIDGET_CONTROL,
5860 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005861 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005862 snd_hda_codec_write_cache(codec, 0x01, 0,
5863 AC_VERB_SET_GPIO_DATA, 0);
5864 snd_hda_codec_write_cache(codec, 0x0f, 0,
5865 AC_VERB_SET_PIN_WIDGET_CONTROL,
5866 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005867 }
5868}
5869
5870static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5871 unsigned int res)
5872{
5873 if ((res >> 26) == ALC880_HP_EVENT)
5874 alc260_replacer_672v_automute(codec);
5875}
5876
Kailang Yang3f878302008-08-26 13:02:23 +02005877static struct hda_verb alc260_hp_dc7600_verbs[] = {
5878 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5879 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5880 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5881 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5882 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5883 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5884 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5885 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5886 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5887 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5888 {}
5889};
5890
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005891/* Test configuration for debugging, modelled after the ALC880 test
5892 * configuration.
5893 */
5894#ifdef CONFIG_SND_DEBUG
5895static hda_nid_t alc260_test_dac_nids[1] = {
5896 0x02,
5897};
5898static hda_nid_t alc260_test_adc_nids[2] = {
5899 0x04, 0x05,
5900};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005901/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005902 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005903 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005904 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005905static struct hda_input_mux alc260_test_capture_sources[2] = {
5906 {
5907 .num_items = 7,
5908 .items = {
5909 { "MIC1 pin", 0x0 },
5910 { "MIC2 pin", 0x1 },
5911 { "LINE1 pin", 0x2 },
5912 { "LINE2 pin", 0x3 },
5913 { "CD pin", 0x4 },
5914 { "LINE-OUT pin", 0x5 },
5915 { "HP-OUT pin", 0x6 },
5916 },
5917 },
5918 {
5919 .num_items = 8,
5920 .items = {
5921 { "MIC1 pin", 0x0 },
5922 { "MIC2 pin", 0x1 },
5923 { "LINE1 pin", 0x2 },
5924 { "LINE2 pin", 0x3 },
5925 { "CD pin", 0x4 },
5926 { "Mixer", 0x5 },
5927 { "LINE-OUT pin", 0x6 },
5928 { "HP-OUT pin", 0x7 },
5929 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005930 },
5931};
5932static struct snd_kcontrol_new alc260_test_mixer[] = {
5933 /* Output driver widgets */
5934 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5935 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5936 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5937 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5938 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5939 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5940
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005941 /* Modes for retasking pin widgets
5942 * Note: the ALC260 doesn't seem to act on requests to enable mic
5943 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5944 * mention this restriction. At this stage it's not clear whether
5945 * this behaviour is intentional or is a hardware bug in chip
5946 * revisions available at least up until early 2006. Therefore for
5947 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5948 * choices, but if it turns out that the lack of mic bias for these
5949 * NIDs is intentional we could change their modes from
5950 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5951 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005952 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5953 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5954 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5955 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5956 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5957 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5958
5959 /* Loopback mixer controls */
5960 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5961 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5962 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5963 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5964 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5965 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5966 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5967 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5968 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5969 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005970 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5971 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5972 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5973 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005974
5975 /* Controls for GPIO pins, assuming they are configured as outputs */
5976 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5977 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5978 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5979 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5980
Jonathan Woithe92621f12006-02-28 11:47:47 +01005981 /* Switches to allow the digital IO pins to be enabled. The datasheet
5982 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005983 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005984 */
5985 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5986 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5987
Jonathan Woithef8225f62008-01-08 12:16:54 +01005988 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5989 * this output to turn on an external amplifier.
5990 */
5991 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5992 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5993
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005994 { } /* end */
5995};
5996static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005997 /* Enable all GPIOs as outputs with an initial value of 0 */
5998 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5999 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6000 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6001
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006002 /* Enable retasking pins as output, initially without power amp */
6003 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6004 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6005 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6006 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6007 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6008 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6009
Jonathan Woithe92621f12006-02-28 11:47:47 +01006010 /* Disable digital (SPDIF) pins initially, but users can enable
6011 * them via a mixer switch. In the case of SPDIF-out, this initverb
6012 * payload also sets the generation to 0, output to be in "consumer"
6013 * PCM format, copyright asserted, no pre-emphasis and no validity
6014 * control.
6015 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006016 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6017 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6018
Kailang Yangea1fb292008-08-26 12:58:38 +02006019 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006020 * OUT1 sum bus when acting as an output.
6021 */
6022 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6023 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6024 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6025 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6026
6027 /* Start with output sum widgets muted and their output gains at min */
6028 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6029 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6030 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6031 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6032 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6033 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6034 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6035 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6036 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6037
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006038 /* Unmute retasking pin widget output buffers since the default
6039 * state appears to be output. As the pin mode is changed by the
6040 * user the pin mode control will take care of enabling the pin's
6041 * input/output buffers as needed.
6042 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006043 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6044 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6045 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6046 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6047 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6048 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6049 /* Also unmute the mono-out pin widget */
6050 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6051
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006052 /* Mute capture amp left and right */
6053 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006054 /* Set ADC connection select to match default mixer setting (mic1
6055 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006056 */
6057 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6058
6059 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006060 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006061 */
6062 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6063 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6064
6065 /* Mute all inputs to mixer widget (even unconnected ones) */
6066 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6067 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6068 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6069 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6070 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6071 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6072 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6073 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6074
6075 { }
6076};
6077#endif
6078
Takashi Iwai63300792008-01-24 15:31:36 +01006079#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6080#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006081
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006082#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6083#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6084
Kailang Yangdf694da2005-12-05 19:42:22 +01006085/*
6086 * for BIOS auto-configuration
6087 */
6088
6089static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006090 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006091{
6092 hda_nid_t nid_vol;
6093 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006094 int err;
6095
6096 if (nid >= 0x0f && nid < 0x11) {
6097 nid_vol = nid - 0x7;
6098 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6099 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6100 } else if (nid == 0x11) {
6101 nid_vol = nid - 0x7;
6102 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6103 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6104 } else if (nid >= 0x12 && nid <= 0x15) {
6105 nid_vol = 0x08;
6106 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6107 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6108 } else
6109 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006110
Takashi Iwai863b4512008-10-21 17:01:47 +02006111 if (!(*vol_bits & (1 << nid_vol))) {
6112 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006113 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006114 if (err < 0)
6115 return err;
6116 *vol_bits |= (1 << nid_vol);
6117 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006118 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006119 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006120 return err;
6121 return 1;
6122}
6123
6124/* add playback controls from the parsed DAC table */
6125static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6126 const struct auto_pin_cfg *cfg)
6127{
6128 hda_nid_t nid;
6129 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006130 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006131
6132 spec->multiout.num_dacs = 1;
6133 spec->multiout.dac_nids = spec->private_dac_nids;
6134 spec->multiout.dac_nids[0] = 0x02;
6135
6136 nid = cfg->line_out_pins[0];
6137 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006138 const char *pfx;
6139 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6140 pfx = "Master";
6141 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6142 pfx = "Speaker";
6143 else
6144 pfx = "Front";
6145 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006146 if (err < 0)
6147 return err;
6148 }
6149
Takashi Iwai82bc9552006-03-21 11:24:42 +01006150 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006151 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006152 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006153 if (err < 0)
6154 return err;
6155 }
6156
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006157 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006158 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006159 err = alc260_add_playback_controls(spec, nid, "Headphone",
6160 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006161 if (err < 0)
6162 return err;
6163 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006164 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006165}
6166
6167/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006168static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006169 const struct auto_pin_cfg *cfg)
6170{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006171 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006172}
6173
6174static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6175 hda_nid_t nid, int pin_type,
6176 int sel_idx)
6177{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006178 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006179 /* need the manual connection? */
6180 if (nid >= 0x12) {
6181 int idx = nid - 0x12;
6182 snd_hda_codec_write(codec, idx + 0x0b, 0,
6183 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006184 }
6185}
6186
6187static void alc260_auto_init_multi_out(struct hda_codec *codec)
6188{
6189 struct alc_spec *spec = codec->spec;
6190 hda_nid_t nid;
6191
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006192 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006193 if (nid) {
6194 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6195 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6196 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006197
Takashi Iwai82bc9552006-03-21 11:24:42 +01006198 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006199 if (nid)
6200 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6201
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006202 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006203 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006204 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006205}
Kailang Yangdf694da2005-12-05 19:42:22 +01006206
6207#define ALC260_PIN_CD_NID 0x16
6208static void alc260_auto_init_analog_input(struct hda_codec *codec)
6209{
6210 struct alc_spec *spec = codec->spec;
6211 int i;
6212
6213 for (i = 0; i < AUTO_PIN_LAST; i++) {
6214 hda_nid_t nid = spec->autocfg.input_pins[i];
6215 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006216 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006217 if (nid != ALC260_PIN_CD_NID &&
6218 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006219 snd_hda_codec_write(codec, nid, 0,
6220 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006221 AMP_OUT_MUTE);
6222 }
6223 }
6224}
6225
6226/*
6227 * generic initialization of ADC, input mixers and output mixers
6228 */
6229static struct hda_verb alc260_volume_init_verbs[] = {
6230 /*
6231 * Unmute ADC0-1 and set the default input to mic-in
6232 */
6233 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6234 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6235 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6236 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006237
Kailang Yangdf694da2005-12-05 19:42:22 +01006238 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6239 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006240 * Note: PASD motherboards uses the Line In 2 as the input for
6241 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006242 */
6243 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006244 /* mute analog inputs */
6245 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6246 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6247 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6248 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6249 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006250
6251 /*
6252 * Set up output mixers (0x08 - 0x0a)
6253 */
6254 /* set vol=0 to output mixers */
6255 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6256 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6257 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6258 /* set up input amps for analog loopback */
6259 /* Amp Indices: DAC = 0, mixer = 1 */
6260 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6261 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6262 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6263 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6264 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6265 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006266
Kailang Yangdf694da2005-12-05 19:42:22 +01006267 { }
6268};
6269
6270static int alc260_parse_auto_config(struct hda_codec *codec)
6271{
6272 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006273 int err;
6274 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6275
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006276 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6277 alc260_ignore);
6278 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006279 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006280 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6281 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006282 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006283 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006284 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006285 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006286 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006287 return err;
6288
6289 spec->multiout.max_channels = 2;
6290
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006291 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006292 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006293 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006294 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006295
Takashi Iwaid88897e2008-10-31 15:01:37 +01006296 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006297
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006298 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006299 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006300
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006301 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6302
Kailang Yangdf694da2005-12-05 19:42:22 +01006303 return 1;
6304}
6305
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006306/* additional initialization for auto-configuration model */
6307static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006308{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006309 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006310 alc260_auto_init_multi_out(codec);
6311 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006312 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006313 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006314}
6315
Takashi Iwaicb53c622007-08-10 17:21:45 +02006316#ifdef CONFIG_SND_HDA_POWER_SAVE
6317static struct hda_amp_list alc260_loopbacks[] = {
6318 { 0x07, HDA_INPUT, 0 },
6319 { 0x07, HDA_INPUT, 1 },
6320 { 0x07, HDA_INPUT, 2 },
6321 { 0x07, HDA_INPUT, 3 },
6322 { 0x07, HDA_INPUT, 4 },
6323 { } /* end */
6324};
6325#endif
6326
Kailang Yangdf694da2005-12-05 19:42:22 +01006327/*
6328 * ALC260 configurations
6329 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006330static const char *alc260_models[ALC260_MODEL_LAST] = {
6331 [ALC260_BASIC] = "basic",
6332 [ALC260_HP] = "hp",
6333 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006334 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006335 [ALC260_FUJITSU_S702X] = "fujitsu",
6336 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006337 [ALC260_WILL] = "will",
6338 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006339 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006340#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006341 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006342#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006343 [ALC260_AUTO] = "auto",
6344};
6345
6346static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006347 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006348 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006349 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006350 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006351 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006352 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006353 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006354 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006355 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006356 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6357 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6358 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6359 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6360 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6361 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6362 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6363 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6364 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006365 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006366 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006367 {}
6368};
6369
Kailang Yangdf694da2005-12-05 19:42:22 +01006370static struct alc_config_preset alc260_presets[] = {
6371 [ALC260_BASIC] = {
6372 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006373 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006374 .init_verbs = { alc260_init_verbs },
6375 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6376 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006377 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006378 .adc_nids = alc260_adc_nids,
6379 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6380 .channel_mode = alc260_modes,
6381 .input_mux = &alc260_capture_source,
6382 },
6383 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006384 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006385 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006386 .init_verbs = { alc260_init_verbs,
6387 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006388 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6389 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006390 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6391 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006392 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6393 .channel_mode = alc260_modes,
6394 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006395 .unsol_event = alc260_hp_unsol_event,
6396 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006397 },
Kailang Yang3f878302008-08-26 13:02:23 +02006398 [ALC260_HP_DC7600] = {
6399 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006400 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006401 .init_verbs = { alc260_init_verbs,
6402 alc260_hp_dc7600_verbs },
6403 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6404 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006405 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6406 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006407 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6408 .channel_mode = alc260_modes,
6409 .input_mux = &alc260_capture_source,
6410 .unsol_event = alc260_hp_3012_unsol_event,
6411 .init_hook = alc260_hp_3012_automute,
6412 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006413 [ALC260_HP_3013] = {
6414 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006415 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006416 .init_verbs = { alc260_hp_3013_init_verbs,
6417 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006418 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6419 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006420 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6421 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006422 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6423 .channel_mode = alc260_modes,
6424 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006425 .unsol_event = alc260_hp_3013_unsol_event,
6426 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006427 },
6428 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006429 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006430 .init_verbs = { alc260_fujitsu_init_verbs },
6431 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6432 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006433 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6434 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006435 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6436 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006437 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6438 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006439 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006440 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006441 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006442 .init_verbs = { alc260_acer_init_verbs },
6443 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6444 .dac_nids = alc260_dac_nids,
6445 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6446 .adc_nids = alc260_dual_adc_nids,
6447 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6448 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006449 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6450 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006451 },
Michael Schwingencc959482009-02-22 18:58:45 +01006452 [ALC260_FAVORIT100] = {
6453 .mixers = { alc260_favorit100_mixer },
6454 .init_verbs = { alc260_favorit100_init_verbs },
6455 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6456 .dac_nids = alc260_dac_nids,
6457 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6458 .adc_nids = alc260_dual_adc_nids,
6459 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6460 .channel_mode = alc260_modes,
6461 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6462 .input_mux = alc260_favorit100_capture_sources,
6463 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006464 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006465 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006466 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6467 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6468 .dac_nids = alc260_dac_nids,
6469 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6470 .adc_nids = alc260_adc_nids,
6471 .dig_out_nid = ALC260_DIGOUT_NID,
6472 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6473 .channel_mode = alc260_modes,
6474 .input_mux = &alc260_capture_source,
6475 },
6476 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006477 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006478 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6479 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6480 .dac_nids = alc260_dac_nids,
6481 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6482 .adc_nids = alc260_adc_nids,
6483 .dig_out_nid = ALC260_DIGOUT_NID,
6484 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6485 .channel_mode = alc260_modes,
6486 .input_mux = &alc260_capture_source,
6487 .unsol_event = alc260_replacer_672v_unsol_event,
6488 .init_hook = alc260_replacer_672v_automute,
6489 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006490#ifdef CONFIG_SND_DEBUG
6491 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006492 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006493 .init_verbs = { alc260_test_init_verbs },
6494 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6495 .dac_nids = alc260_test_dac_nids,
6496 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6497 .adc_nids = alc260_test_adc_nids,
6498 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6499 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006500 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6501 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006502 },
6503#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006504};
6505
Linus Torvalds1da177e2005-04-16 15:20:36 -07006506static int patch_alc260(struct hda_codec *codec)
6507{
6508 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006509 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006510
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006511 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006512 if (spec == NULL)
6513 return -ENOMEM;
6514
6515 codec->spec = spec;
6516
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006517 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6518 alc260_models,
6519 alc260_cfg_tbl);
6520 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006521 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006522 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006523 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006524 }
6525
Kailang Yangdf694da2005-12-05 19:42:22 +01006526 if (board_config == ALC260_AUTO) {
6527 /* automatic parse from the BIOS config */
6528 err = alc260_parse_auto_config(codec);
6529 if (err < 0) {
6530 alc_free(codec);
6531 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006532 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006533 printk(KERN_INFO
6534 "hda_codec: Cannot set up configuration "
6535 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006536 board_config = ALC260_BASIC;
6537 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006538 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006539
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006540 err = snd_hda_attach_beep_device(codec, 0x1);
6541 if (err < 0) {
6542 alc_free(codec);
6543 return err;
6544 }
6545
Kailang Yangdf694da2005-12-05 19:42:22 +01006546 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006547 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006548
Linus Torvalds1da177e2005-04-16 15:20:36 -07006549 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6550 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6551
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006552 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6553 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6554
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006555 if (!spec->adc_nids && spec->input_mux) {
6556 /* check whether NID 0x04 is valid */
6557 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006558 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006559 /* get type */
6560 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6561 spec->adc_nids = alc260_adc_nids_alt;
6562 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6563 } else {
6564 spec->adc_nids = alc260_adc_nids;
6565 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6566 }
6567 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006568 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006569 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006570
Takashi Iwai2134ea42008-01-10 16:53:55 +01006571 spec->vmaster_nid = 0x08;
6572
Linus Torvalds1da177e2005-04-16 15:20:36 -07006573 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006574 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006575 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006576#ifdef CONFIG_SND_HDA_POWER_SAVE
6577 if (!spec->loopback.amplist)
6578 spec->loopback.amplist = alc260_loopbacks;
6579#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006580 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006581
6582 return 0;
6583}
6584
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006585
Linus Torvalds1da177e2005-04-16 15:20:36 -07006586/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006587 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006588 *
6589 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6590 * configuration. Each pin widget can choose any input DACs and a mixer.
6591 * Each ADC is connected from a mixer of all inputs. This makes possible
6592 * 6-channel independent captures.
6593 *
6594 * In addition, an independent DAC for the multi-playback (not used in this
6595 * driver yet).
6596 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006597#define ALC882_DIGOUT_NID 0x06
6598#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006599#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6600#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6601#define ALC1200_DIGOUT_NID 0x10
6602
Linus Torvalds1da177e2005-04-16 15:20:36 -07006603
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006604static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006605 { 8, NULL }
6606};
6607
Takashi Iwai4953550a2009-06-30 15:28:30 +02006608/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006609static hda_nid_t alc882_dac_nids[4] = {
6610 /* front, rear, clfe, rear_surr */
6611 0x02, 0x03, 0x04, 0x05
6612};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006613#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006614
Takashi Iwai4953550a2009-06-30 15:28:30 +02006615/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006616#define alc882_adc_nids alc880_adc_nids
6617#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006618#define alc883_adc_nids alc882_adc_nids_alt
6619static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6620static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6621#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006622
Takashi Iwaie1406342008-02-11 18:32:32 +01006623static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6624static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006625#define alc883_capsrc_nids alc882_capsrc_nids_alt
6626static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6627#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006628
Linus Torvalds1da177e2005-04-16 15:20:36 -07006629/* input MUX */
6630/* FIXME: should be a matrix-type input source selection */
6631
6632static struct hda_input_mux alc882_capture_source = {
6633 .num_items = 4,
6634 .items = {
6635 { "Mic", 0x0 },
6636 { "Front Mic", 0x1 },
6637 { "Line", 0x2 },
6638 { "CD", 0x4 },
6639 },
6640};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006641
Takashi Iwai4953550a2009-06-30 15:28:30 +02006642#define alc883_capture_source alc882_capture_source
6643
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006644static struct hda_input_mux alc889_capture_source = {
6645 .num_items = 3,
6646 .items = {
6647 { "Front Mic", 0x0 },
6648 { "Mic", 0x3 },
6649 { "Line", 0x2 },
6650 },
6651};
6652
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006653static struct hda_input_mux mb5_capture_source = {
6654 .num_items = 3,
6655 .items = {
6656 { "Mic", 0x1 },
6657 { "Line", 0x2 },
6658 { "CD", 0x4 },
6659 },
6660};
6661
Takashi Iwai4953550a2009-06-30 15:28:30 +02006662static struct hda_input_mux alc883_3stack_6ch_intel = {
6663 .num_items = 4,
6664 .items = {
6665 { "Mic", 0x1 },
6666 { "Front Mic", 0x0 },
6667 { "Line", 0x2 },
6668 { "CD", 0x4 },
6669 },
6670};
6671
6672static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6673 .num_items = 2,
6674 .items = {
6675 { "Mic", 0x1 },
6676 { "Line", 0x2 },
6677 },
6678};
6679
6680static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6681 .num_items = 4,
6682 .items = {
6683 { "Mic", 0x0 },
6684 { "iMic", 0x1 },
6685 { "Line", 0x2 },
6686 { "CD", 0x4 },
6687 },
6688};
6689
6690static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6691 .num_items = 2,
6692 .items = {
6693 { "Mic", 0x0 },
6694 { "Int Mic", 0x1 },
6695 },
6696};
6697
6698static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6699 .num_items = 3,
6700 .items = {
6701 { "Mic", 0x0 },
6702 { "Front Mic", 0x1 },
6703 { "Line", 0x4 },
6704 },
6705};
6706
6707static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6708 .num_items = 2,
6709 .items = {
6710 { "Mic", 0x0 },
6711 { "Line", 0x2 },
6712 },
6713};
6714
6715static struct hda_input_mux alc889A_mb31_capture_source = {
6716 .num_items = 2,
6717 .items = {
6718 { "Mic", 0x0 },
6719 /* Front Mic (0x01) unused */
6720 { "Line", 0x2 },
6721 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02006722 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006723 },
6724};
6725
6726/*
6727 * 2ch mode
6728 */
6729static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6730 { 2, NULL }
6731};
6732
Kailang Yangdf694da2005-12-05 19:42:22 +01006733/*
Kailang Yang272a5272007-05-14 11:00:38 +02006734 * 2ch mode
6735 */
6736static struct hda_verb alc882_3ST_ch2_init[] = {
6737 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6738 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6739 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6740 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6741 { } /* end */
6742};
6743
6744/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006745 * 4ch mode
6746 */
6747static struct hda_verb alc882_3ST_ch4_init[] = {
6748 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6749 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6750 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6751 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6752 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6753 { } /* end */
6754};
6755
6756/*
Kailang Yang272a5272007-05-14 11:00:38 +02006757 * 6ch mode
6758 */
6759static struct hda_verb alc882_3ST_ch6_init[] = {
6760 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6761 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6762 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6763 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6764 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6765 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6766 { } /* end */
6767};
6768
Takashi Iwai4953550a2009-06-30 15:28:30 +02006769static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006770 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006771 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006772 { 6, alc882_3ST_ch6_init },
6773};
6774
Takashi Iwai4953550a2009-06-30 15:28:30 +02006775#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6776
Kailang Yang272a5272007-05-14 11:00:38 +02006777/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04306778 * 2ch mode
6779 */
6780static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6781 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6782 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6783 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6784 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6785 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6786 { } /* end */
6787};
6788
6789/*
6790 * 4ch mode
6791 */
6792static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
6793 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6794 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6795 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6796 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6797 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6798 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6799 { } /* end */
6800};
6801
6802/*
6803 * 6ch mode
6804 */
6805static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
6806 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6807 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6808 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6809 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6810 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6811 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6812 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6813 { } /* end */
6814};
6815
6816static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
6817 { 2, alc883_3ST_ch2_clevo_init },
6818 { 4, alc883_3ST_ch4_clevo_init },
6819 { 6, alc883_3ST_ch6_clevo_init },
6820};
6821
6822
6823/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006824 * 6ch mode
6825 */
6826static struct hda_verb alc882_sixstack_ch6_init[] = {
6827 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6828 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6829 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6830 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6831 { } /* end */
6832};
6833
6834/*
6835 * 8ch mode
6836 */
6837static struct hda_verb alc882_sixstack_ch8_init[] = {
6838 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6839 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6840 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6841 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6842 { } /* end */
6843};
6844
6845static struct hda_channel_mode alc882_sixstack_modes[2] = {
6846 { 6, alc882_sixstack_ch6_init },
6847 { 8, alc882_sixstack_ch8_init },
6848};
6849
Takashi Iwai87350ad2007-08-16 18:19:38 +02006850/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006851 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006852 */
6853
6854/*
6855 * 2ch mode
6856 */
6857static struct hda_verb alc885_mbp_ch2_init[] = {
6858 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6859 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6860 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6861 { } /* end */
6862};
6863
6864/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006865 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02006866 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006867static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006868 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6869 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6870 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6871 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6872 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6873 { } /* end */
6874};
6875
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006876static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006877 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006878 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006879};
6880
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006881/*
6882 * 2ch
6883 * Speakers/Woofer/HP = Front
6884 * LineIn = Input
6885 */
6886static struct hda_verb alc885_mb5_ch2_init[] = {
6887 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6888 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6889 { } /* end */
6890};
6891
6892/*
6893 * 6ch mode
6894 * Speakers/HP = Front
6895 * Woofer = LFE
6896 * LineIn = Surround
6897 */
6898static struct hda_verb alc885_mb5_ch6_init[] = {
6899 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6900 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6901 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6902 { } /* end */
6903};
6904
6905static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6906 { 2, alc885_mb5_ch2_init },
6907 { 6, alc885_mb5_ch6_init },
6908};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006909
Takashi Iwai4953550a2009-06-30 15:28:30 +02006910
6911/*
6912 * 2ch mode
6913 */
6914static struct hda_verb alc883_4ST_ch2_init[] = {
6915 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6916 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6917 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6918 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6919 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6920 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6921 { } /* end */
6922};
6923
6924/*
6925 * 4ch mode
6926 */
6927static struct hda_verb alc883_4ST_ch4_init[] = {
6928 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6929 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6930 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6931 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6932 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6933 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6934 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6935 { } /* end */
6936};
6937
6938/*
6939 * 6ch mode
6940 */
6941static struct hda_verb alc883_4ST_ch6_init[] = {
6942 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6943 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6944 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6945 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6946 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6947 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6948 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6949 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6950 { } /* end */
6951};
6952
6953/*
6954 * 8ch mode
6955 */
6956static struct hda_verb alc883_4ST_ch8_init[] = {
6957 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6958 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6959 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6960 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6961 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6962 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6963 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6964 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6965 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6966 { } /* end */
6967};
6968
6969static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6970 { 2, alc883_4ST_ch2_init },
6971 { 4, alc883_4ST_ch4_init },
6972 { 6, alc883_4ST_ch6_init },
6973 { 8, alc883_4ST_ch8_init },
6974};
6975
6976
6977/*
6978 * 2ch mode
6979 */
6980static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6981 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6982 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6983 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6984 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6985 { } /* end */
6986};
6987
6988/*
6989 * 4ch mode
6990 */
6991static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6992 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6993 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6994 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6995 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6996 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6997 { } /* end */
6998};
6999
7000/*
7001 * 6ch mode
7002 */
7003static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7004 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7005 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7006 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7007 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7008 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7009 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7010 { } /* end */
7011};
7012
7013static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7014 { 2, alc883_3ST_ch2_intel_init },
7015 { 4, alc883_3ST_ch4_intel_init },
7016 { 6, alc883_3ST_ch6_intel_init },
7017};
7018
7019/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007020 * 2ch mode
7021 */
7022static struct hda_verb alc889_ch2_intel_init[] = {
7023 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7024 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7025 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7026 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7027 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7028 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7029 { } /* end */
7030};
7031
7032/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007033 * 6ch mode
7034 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007035static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007036 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7037 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7038 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7039 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7040 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007041 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7042 { } /* end */
7043};
7044
7045/*
7046 * 8ch mode
7047 */
7048static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007049 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7050 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7051 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7052 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7053 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007054 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7055 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007056 { } /* end */
7057};
7058
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007059static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7060 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007061 { 6, alc889_ch6_intel_init },
7062 { 8, alc889_ch8_intel_init },
7063};
7064
7065/*
7066 * 6ch mode
7067 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007068static struct hda_verb alc883_sixstack_ch6_init[] = {
7069 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7070 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7071 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7072 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7073 { } /* end */
7074};
7075
7076/*
7077 * 8ch mode
7078 */
7079static struct hda_verb alc883_sixstack_ch8_init[] = {
7080 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7081 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7082 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7083 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7084 { } /* end */
7085};
7086
7087static struct hda_channel_mode alc883_sixstack_modes[2] = {
7088 { 6, alc883_sixstack_ch6_init },
7089 { 8, alc883_sixstack_ch8_init },
7090};
7091
7092
Linus Torvalds1da177e2005-04-16 15:20:36 -07007093/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7094 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7095 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007096static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007097 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007098 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007099 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007100 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007101 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7102 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007103 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7104 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007105 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007106 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007107 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 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("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007113 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007114 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7115 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007116 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007117 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007118 { } /* end */
7119};
7120
Takashi Iwai87350ad2007-08-16 18:19:38 +02007121static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007122 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7123 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7124 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7125 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7126 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007127 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7128 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007129 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7130 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007131 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007132 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7133 { } /* end */
7134};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007135
7136static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007137 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7138 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7139 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7140 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7141 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7142 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307143 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7144 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007145 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7146 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7147 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7148 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7149 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7150 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7151 { } /* end */
7152};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007153
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007154static struct snd_kcontrol_new alc885_imac91_mixer[] = {
7155 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7156 HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
7157 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
7158 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7159 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7160 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7161 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7162 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7163 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7164 { } /* end */
7165};
7166
7167
Kailang Yangbdd148a2007-05-08 15:19:08 +02007168static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7169 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7170 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7171 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7172 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7173 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7174 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7175 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7176 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7177 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007178 { } /* end */
7179};
7180
Kailang Yang272a5272007-05-14 11:00:38 +02007181static struct snd_kcontrol_new alc882_targa_mixer[] = {
7182 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7183 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7184 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7185 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7186 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7187 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7188 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7189 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7190 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007191 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007192 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7193 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007194 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007195 { } /* end */
7196};
7197
7198/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7199 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7200 */
7201static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7202 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7203 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7204 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7205 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7206 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7207 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7208 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7209 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7210 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7211 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7212 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7213 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007214 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007215 { } /* end */
7216};
7217
Takashi Iwai914759b2007-09-06 14:52:04 +02007218static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7219 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7220 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7221 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7222 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7223 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7224 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7225 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7226 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7227 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7228 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007229 { } /* end */
7230};
7231
Kailang Yangdf694da2005-12-05 19:42:22 +01007232static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7233 {
7234 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7235 .name = "Channel Mode",
7236 .info = alc_ch_mode_info,
7237 .get = alc_ch_mode_get,
7238 .put = alc_ch_mode_put,
7239 },
7240 { } /* end */
7241};
7242
Takashi Iwai4953550a2009-06-30 15:28:30 +02007243static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007244 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007245 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7246 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7247 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007248 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007249 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7250 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7251 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007252 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007253 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7254 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7255 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007256 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007257 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7258 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7259 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007260
Takashi Iwaicb638122009-07-03 10:56:10 +02007261 /* mute analog input loopbacks */
7262 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7263 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7264 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7265 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7266 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7267
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007268 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007269 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007270 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007271 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007272 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007273 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007274 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007275 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007276 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007277 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007278 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007279 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007280 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007281 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007282 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007283 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007284 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007285 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007286 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7287 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007288 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007289 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7290 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007291 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007292 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7293 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7294 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7295 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7296 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007297 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007298 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007299
7300 /* FIXME: use matrix-type input source selection */
7301 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007302 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007303 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7304 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7305 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7306 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007307 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007308 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7309 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7310 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7311 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007312 /* ADC2: mute amp left and right */
7313 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007314 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007315 /* ADC3: mute amp left and right */
7316 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007317 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007318
7319 { }
7320};
7321
Takashi Iwai4953550a2009-06-30 15:28:30 +02007322static struct hda_verb alc882_adc1_init_verbs[] = {
7323 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7324 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7325 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7326 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7327 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7328 /* ADC1: mute amp left and right */
7329 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7330 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7331 { }
7332};
7333
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007334static struct hda_verb alc882_eapd_verbs[] = {
7335 /* change to EAPD mode */
7336 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007337 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007338 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007339};
7340
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007341static struct hda_verb alc889_eapd_verbs[] = {
7342 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7343 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7344 { }
7345};
7346
Wu Fengguang6732bd02009-07-30 09:19:14 +02007347static struct hda_verb alc_hp15_unsol_verbs[] = {
7348 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7349 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7350 {}
7351};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007352
7353static struct hda_verb alc885_init_verbs[] = {
7354 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7355 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7356 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7357 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7358 /* Rear mixer */
7359 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7360 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7361 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7362 /* CLFE mixer */
7363 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7364 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7365 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7366 /* Side mixer */
7367 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7368 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7369 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7370
7371 /* mute analog input loopbacks */
7372 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7373 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7374 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7375
7376 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007377 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007378 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7379 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7380 /* Front Pin: output 0 (0x0c) */
7381 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7382 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7383 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7384 /* Rear Pin: output 1 (0x0d) */
7385 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7386 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7387 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7388 /* CLFE Pin: output 2 (0x0e) */
7389 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7390 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7391 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7392 /* Side Pin: output 3 (0x0f) */
7393 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7394 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7395 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7396 /* Mic (rear) pin: input vref at 80% */
7397 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7398 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7399 /* Front Mic pin: input vref at 80% */
7400 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7401 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7402 /* Line In pin: input */
7403 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7404 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7405
7406 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7407 /* Input mixer1 */
7408 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7409 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7410 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7411 /* Input mixer2 */
7412 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7413 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7414 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7415 /* Input mixer3 */
7416 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7417 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7418 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7419 /* ADC2: mute amp left and right */
7420 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7421 /* ADC3: mute amp left and right */
7422 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7423
7424 { }
7425};
7426
7427static struct hda_verb alc885_init_input_verbs[] = {
7428 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7429 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7430 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7431 { }
7432};
7433
7434
7435/* Unmute Selector 24h and set the default input to front mic */
7436static struct hda_verb alc889_init_input_verbs[] = {
7437 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7438 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7439 { }
7440};
7441
7442
Takashi Iwai4953550a2009-06-30 15:28:30 +02007443#define alc883_init_verbs alc882_base_init_verbs
7444
Tobin Davis9102cd12006-12-15 10:02:12 +01007445/* Mac Pro test */
7446static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7447 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7448 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7449 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7450 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7451 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007452 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007453 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7454 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007455 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007456 { } /* end */
7457};
7458
7459static struct hda_verb alc882_macpro_init_verbs[] = {
7460 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7461 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7462 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7463 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7464 /* Front Pin: output 0 (0x0c) */
7465 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7466 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7467 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7468 /* Front Mic pin: input vref at 80% */
7469 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7470 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7471 /* Speaker: output */
7472 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7473 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7474 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7475 /* Headphone output (output 0 - 0x0c) */
7476 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7477 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7478 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7479
7480 /* FIXME: use matrix-type input source selection */
7481 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7482 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7483 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7484 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7485 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7486 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7487 /* Input mixer2 */
7488 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7489 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7490 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7491 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7492 /* Input mixer3 */
7493 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7494 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7495 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7496 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7497 /* ADC1: mute amp left and right */
7498 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7499 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7500 /* ADC2: mute amp left and right */
7501 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7502 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7503 /* ADC3: mute amp left and right */
7504 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7505 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7506
7507 { }
7508};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007509
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007510/* Macbook 5,1 */
7511static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007512 /* DACs */
7513 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7514 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7515 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7516 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007517 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007518 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7519 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7520 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007521 /* Surround mixer */
7522 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7523 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7524 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7525 /* LFE mixer */
7526 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7527 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7528 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7529 /* HP mixer */
7530 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7531 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7532 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7533 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007534 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7535 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007536 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7537 /* LFE Pin (0x0e) */
7538 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7539 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7540 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7541 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007542 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7543 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007544 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10307545 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007546 /* Front Mic pin: input vref at 80% */
7547 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7548 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7549 /* Line In pin */
7550 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7551 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7552
7553 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7554 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7555 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7556 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7557 { }
7558};
7559
Takashi Iwai87350ad2007-08-16 18:19:38 +02007560/* Macbook Pro rev3 */
7561static struct hda_verb alc885_mbp3_init_verbs[] = {
7562 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7563 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7564 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7565 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7566 /* Rear mixer */
7567 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7568 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7569 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007570 /* HP mixer */
7571 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7572 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7573 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007574 /* Front Pin: output 0 (0x0c) */
7575 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7576 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7577 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007578 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007579 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007580 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7581 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007582 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7583 /* Mic (rear) pin: input vref at 80% */
7584 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7585 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7586 /* Front Mic pin: input vref at 80% */
7587 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7588 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7589 /* Line In pin: use output 1 when in LineOut mode */
7590 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7591 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7592 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7593
7594 /* FIXME: use matrix-type input source selection */
7595 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7596 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7597 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7598 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7599 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7600 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7601 /* Input mixer2 */
7602 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7603 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7604 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7605 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7606 /* Input mixer3 */
7607 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7608 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7609 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7610 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7611 /* ADC1: mute amp left and right */
7612 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7613 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7614 /* ADC2: mute amp left and right */
7615 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7616 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7617 /* ADC3: mute amp left and right */
7618 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7619 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7620
7621 { }
7622};
7623
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007624/* iMac 9,1 */
7625static struct hda_verb alc885_imac91_init_verbs[] = {
7626 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
7627 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7628 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7629 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7630 /* Rear mixer */
7631 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7632 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7633 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7634 /* HP Pin: output 0 (0x0c) */
7635 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7636 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7637 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7638 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7639 /* Internal Speakers: output 0 (0x0d) */
7640 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7641 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7642 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7643 /* Mic (rear) pin: input vref at 80% */
7644 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7645 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7646 /* Front Mic pin: input vref at 80% */
7647 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7648 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7649 /* Line In pin: use output 1 when in LineOut mode */
7650 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7651 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7652 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7653
7654 /* FIXME: use matrix-type input source selection */
7655 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7656 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7657 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7658 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7659 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7660 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7661 /* Input mixer2 */
7662 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7663 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7664 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7665 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7666 /* Input mixer3 */
7667 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7668 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7669 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7670 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7671 /* ADC1: mute amp left and right */
7672 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7673 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7674 /* ADC2: mute amp left and right */
7675 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7676 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7677 /* ADC3: mute amp left and right */
7678 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7679 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7680
7681 { }
7682};
7683
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007684/* iMac 24 mixer. */
7685static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7686 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7687 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7688 { } /* end */
7689};
7690
7691/* iMac 24 init verbs. */
7692static struct hda_verb alc885_imac24_init_verbs[] = {
7693 /* Internal speakers: output 0 (0x0c) */
7694 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7695 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7696 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7697 /* Internal speakers: output 0 (0x0c) */
7698 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7699 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7700 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7701 /* Headphone: output 0 (0x0c) */
7702 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7703 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7704 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7705 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7706 /* Front Mic: input vref at 80% */
7707 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7708 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7709 { }
7710};
7711
7712/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007713static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007714{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007715 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007716
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007717 spec->autocfg.hp_pins[0] = 0x14;
7718 spec->autocfg.speaker_pins[0] = 0x18;
7719 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007720}
7721
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007722static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007723{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007724 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007725
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007726 spec->autocfg.hp_pins[0] = 0x15;
7727 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02007728}
7729
Alex Murraya76221d2010-01-13 23:15:03 +10307730static void alc885_mb5_automute(struct hda_codec *codec)
7731{
7732 unsigned int present;
7733
7734 present = snd_hda_codec_read(codec, 0x14, 0,
7735 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7736 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
7737 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7738 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
7739 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7740
7741}
7742
7743static void alc885_mb5_unsol_event(struct hda_codec *codec,
7744 unsigned int res)
7745{
7746 /* Headphone insertion or removal. */
7747 if ((res >> 26) == ALC880_HP_EVENT)
7748 alc885_mb5_automute(codec);
7749}
7750
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007751static void alc885_imac91_automute(struct hda_codec *codec)
7752{
7753 unsigned int present;
7754
7755 present = snd_hda_codec_read(codec, 0x14, 0,
7756 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7757 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7758 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7759 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
7760 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7761
7762}
7763
7764static void alc885_imac91_unsol_event(struct hda_codec *codec,
7765 unsigned int res)
7766{
7767 /* Headphone insertion or removal. */
7768 if ((res >> 26) == ALC880_HP_EVENT)
7769 alc885_imac91_automute(codec);
7770}
Takashi Iwai87350ad2007-08-16 18:19:38 +02007771
Kailang Yang272a5272007-05-14 11:00:38 +02007772static struct hda_verb alc882_targa_verbs[] = {
7773 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7774 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7775
7776 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7777 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007778
Kailang Yang272a5272007-05-14 11:00:38 +02007779 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7780 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7781 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7782
7783 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007784 { } /* end */
7785};
7786
7787/* toggle speaker-output according to the hp-jack state */
7788static void alc882_targa_automute(struct hda_codec *codec)
7789{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007790 struct alc_spec *spec = codec->spec;
7791 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007792 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007793 spec->jack_present ? 1 : 3);
7794}
7795
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007796static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007797{
7798 struct alc_spec *spec = codec->spec;
7799
7800 spec->autocfg.hp_pins[0] = 0x14;
7801 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02007802}
7803
7804static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7805{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007806 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007807 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007808}
7809
7810static struct hda_verb alc882_asus_a7j_verbs[] = {
7811 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7812 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7813
7814 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7815 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7816 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007817
Kailang Yang272a5272007-05-14 11:00:38 +02007818 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7819 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7820 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7821
7822 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7823 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7824 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7825 { } /* end */
7826};
7827
Takashi Iwai914759b2007-09-06 14:52:04 +02007828static struct hda_verb alc882_asus_a7m_verbs[] = {
7829 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7830 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7831
7832 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7833 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7834 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007835
Takashi Iwai914759b2007-09-06 14:52:04 +02007836 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7837 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7838 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7839
7840 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7841 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7842 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7843 { } /* end */
7844};
7845
Tobin Davis9102cd12006-12-15 10:02:12 +01007846static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7847{
7848 unsigned int gpiostate, gpiomask, gpiodir;
7849
7850 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7851 AC_VERB_GET_GPIO_DATA, 0);
7852
7853 if (!muted)
7854 gpiostate |= (1 << pin);
7855 else
7856 gpiostate &= ~(1 << pin);
7857
7858 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7859 AC_VERB_GET_GPIO_MASK, 0);
7860 gpiomask |= (1 << pin);
7861
7862 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7863 AC_VERB_GET_GPIO_DIRECTION, 0);
7864 gpiodir |= (1 << pin);
7865
7866
7867 snd_hda_codec_write(codec, codec->afg, 0,
7868 AC_VERB_SET_GPIO_MASK, gpiomask);
7869 snd_hda_codec_write(codec, codec->afg, 0,
7870 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7871
7872 msleep(1);
7873
7874 snd_hda_codec_write(codec, codec->afg, 0,
7875 AC_VERB_SET_GPIO_DATA, gpiostate);
7876}
7877
Takashi Iwai7debbe52007-08-16 15:01:03 +02007878/* set up GPIO at initialization */
7879static void alc885_macpro_init_hook(struct hda_codec *codec)
7880{
7881 alc882_gpio_mute(codec, 0, 0);
7882 alc882_gpio_mute(codec, 1, 0);
7883}
7884
7885/* set up GPIO and update auto-muting at initialization */
7886static void alc885_imac24_init_hook(struct hda_codec *codec)
7887{
7888 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007889 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007890}
7891
Kailang Yangdf694da2005-12-05 19:42:22 +01007892/*
7893 * generic initialization of ADC, input mixers and output mixers
7894 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007895static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007896 /*
7897 * Unmute ADC0-2 and set the default input to mic-in
7898 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007899 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7900 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7901 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7902 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7903
Takashi Iwaicb53c622007-08-10 17:21:45 +02007904 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007905 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007906 * Note: PASD motherboards uses the Line In 2 as the input for
7907 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007908 */
7909 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007910 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7911 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7912 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7913 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7914 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007915
7916 /*
7917 * Set up output mixers (0x0c - 0x0f)
7918 */
7919 /* set vol=0 to output mixers */
7920 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7921 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7922 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7923 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7924 /* set up input amps for analog loopback */
7925 /* Amp Indices: DAC = 0, mixer = 1 */
7926 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7927 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7928 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7929 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7930 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7931 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7932 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7933 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7934 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7935 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7936
7937 /* FIXME: use matrix-type input source selection */
7938 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01007939 /* Input mixer2 */
7940 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7941 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7942 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7943 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7944 /* Input mixer3 */
7945 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7946 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7947 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7948 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7949
7950 { }
7951};
7952
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007953/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7954static struct hda_verb alc889A_mb31_ch2_init[] = {
7955 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7956 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7957 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7958 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7959 { } /* end */
7960};
7961
7962/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7963static struct hda_verb alc889A_mb31_ch4_init[] = {
7964 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7965 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7966 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7967 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7968 { } /* end */
7969};
7970
7971/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7972static struct hda_verb alc889A_mb31_ch5_init[] = {
7973 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7974 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7975 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7976 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7977 { } /* end */
7978};
7979
7980/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7981static struct hda_verb alc889A_mb31_ch6_init[] = {
7982 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7983 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7984 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7985 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7986 { } /* end */
7987};
7988
7989static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7990 { 2, alc889A_mb31_ch2_init },
7991 { 4, alc889A_mb31_ch4_init },
7992 { 5, alc889A_mb31_ch5_init },
7993 { 6, alc889A_mb31_ch6_init },
7994};
7995
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007996static struct hda_verb alc883_medion_eapd_verbs[] = {
7997 /* eanable EAPD on medion laptop */
7998 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7999 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8000 { }
8001};
8002
Takashi Iwai4953550a2009-06-30 15:28:30 +02008003#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008004
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008005static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8006 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8007 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8008 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8009 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8010 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8011 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8012 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8013 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8014 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8015 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8016 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8017 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8018 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008019 { } /* end */
8020};
8021
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008022static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008023 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8024 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8025 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8026 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8027 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8028 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8029 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8030 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8031 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8032 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008033 { } /* end */
8034};
8035
Jiang zhefb97dc62008-03-06 11:07:11 +01008036static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8037 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8038 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8039 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8040 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8041 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8042 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8043 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8044 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8045 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8046 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008047 { } /* end */
8048};
8049
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008050static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8051 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8052 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8053 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8054 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8055 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8056 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8057 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8058 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008059 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008060 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8061 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008062 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008063 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008064 { } /* end */
8065};
8066
8067static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8068 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8069 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8070 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8071 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8072 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8073 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8074 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8075 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8076 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8077 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8078 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8079 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8080 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8081 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008082 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008083 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8084 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008085 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008086 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008087 { } /* end */
8088};
8089
Jiang zhe17bba1b2008-06-04 12:11:07 +02008090static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8091 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8092 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8093 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8094 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8095 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8096 HDA_OUTPUT),
8097 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8098 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8099 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8100 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8101 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8102 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8103 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8104 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8105 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8106 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8107 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8108 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8109 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8110 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008111 { } /* end */
8112};
8113
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008114static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8115 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8116 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8117 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8118 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8119 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8120 HDA_OUTPUT),
8121 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8122 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8123 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8124 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8125 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8126 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8127 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8128 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8129 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8130 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8131 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8132 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8133 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8134 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8135 { } /* end */
8136};
8137
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008138static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008139 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008140 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008141 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008142 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008143 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8144 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008145 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8146 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008147 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8148 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8149 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8150 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8151 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8152 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008153 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008154 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8155 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008156 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008157 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008158 { } /* end */
8159};
8160
Sasha Alexandrc2592492009-06-16 14:52:54 -04008161static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008162 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008163 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008164 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008165 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008166 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8167 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8168 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8169 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8170 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8171 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8172 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8173 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8174 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8175 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8176 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008177 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008178 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008179 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008180};
Kailang Yangccc656c2006-10-17 12:32:26 +02008181
Sasha Alexandrc2592492009-06-16 14:52:54 -04008182static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008183 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008184 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008185 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008186 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008187 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8188 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8189 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008190 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008191 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008192 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8193 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8194 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008195 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008196};
Kailang Yangccc656c2006-10-17 12:32:26 +02008197
Takashi Iwaib99dba32009-09-17 18:23:00 +02008198static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8199 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8200 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8201 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8202 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8203 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8204 { } /* end */
8205};
8206
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008207static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8208 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8209 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008210 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8211 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008212 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8213 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8214 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8215 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008216 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008217};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008218
Kailang Yang272a5272007-05-14 11:00:38 +02008219static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8220 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8221 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8222 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8223 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8224 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8225 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8226 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8227 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8228 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008229 { } /* end */
8230};
8231
8232static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8233 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8234 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8235 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8236 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8237 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8238 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8239 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8240 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8241 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008242 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008243};
Kailang Yang272a5272007-05-14 11:00:38 +02008244
Tobin Davis2880a862007-08-07 11:50:26 +02008245static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008246 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8247 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008248 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008249 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8250 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008251 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8252 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8253 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008254 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008255};
Tobin Davis2880a862007-08-07 11:50:26 +02008256
Tony Vroond2fd4b02009-06-21 00:40:10 +01008257static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8258 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8259 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8260 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8261 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008262 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8263 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008264 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8265 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8266 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8267 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8268 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8269 { } /* end */
8270};
8271
Kailang Yange2757d52008-08-26 13:17:46 +02008272static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8273 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8274 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8275 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8276 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8277 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8278 0x0d, 1, 0x0, HDA_OUTPUT),
8279 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8280 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8281 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8282 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8283 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008284 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8285 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8286 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8287 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8288 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8289 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8290 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8291 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8292 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8293 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008294 { } /* end */
8295};
8296
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008297static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8298 /* Output mixers */
8299 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8300 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8301 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8302 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8303 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8304 HDA_OUTPUT),
8305 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8306 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8307 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8308 /* Output switches */
8309 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8310 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8311 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8312 /* Boost mixers */
8313 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8314 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8315 /* Input mixers */
8316 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8317 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8318 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8319 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8320 { } /* end */
8321};
8322
Guido Günther3e1647c2009-06-05 00:47:26 +02008323static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8324 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8325 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8326 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8327 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8328 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8329 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8330 { } /* end */
8331};
8332
Kailang Yange2757d52008-08-26 13:17:46 +02008333static struct hda_bind_ctls alc883_bind_cap_vol = {
8334 .ops = &snd_hda_bind_vol,
8335 .values = {
8336 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8337 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8338 0
8339 },
8340};
8341
8342static struct hda_bind_ctls alc883_bind_cap_switch = {
8343 .ops = &snd_hda_bind_sw,
8344 .values = {
8345 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8346 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8347 0
8348 },
8349};
8350
8351static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8352 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8353 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8354 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8355 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8356 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8357 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8358 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8359 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008360 { } /* end */
8361};
8362
8363static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008364 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8365 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8366 {
8367 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8368 /* .name = "Capture Source", */
8369 .name = "Input Source",
8370 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008371 .info = alc_mux_enum_info,
8372 .get = alc_mux_enum_get,
8373 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008374 },
8375 { } /* end */
8376};
8377
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008378static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8379 {
8380 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8381 .name = "Channel Mode",
8382 .info = alc_ch_mode_info,
8383 .get = alc_ch_mode_get,
8384 .put = alc_ch_mode_put,
8385 },
8386 { } /* end */
8387};
8388
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008389/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008390static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008391{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008392 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008393
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008394 spec->autocfg.hp_pins[0] = 0x15;
8395 spec->autocfg.speaker_pins[0] = 0x14;
8396 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008397}
8398
8399/* auto-toggle front mic */
8400/*
8401static void alc883_mitac_mic_automute(struct hda_codec *codec)
8402{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008403 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008404
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008405 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8406}
8407*/
8408
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008409static struct hda_verb alc883_mitac_verbs[] = {
8410 /* HP */
8411 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8412 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8413 /* Subwoofer */
8414 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8415 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8416
8417 /* enable unsolicited event */
8418 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8419 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8420
8421 { } /* end */
8422};
8423
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308424static struct hda_verb alc883_clevo_m540r_verbs[] = {
8425 /* HP */
8426 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8427 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8428 /* Int speaker */
8429 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8430
8431 /* enable unsolicited event */
8432 /*
8433 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8434 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8435 */
8436
8437 { } /* end */
8438};
8439
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008440static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008441 /* HP */
8442 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8443 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8444 /* Int speaker */
8445 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8446 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8447
8448 /* enable unsolicited event */
8449 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008450 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008451
8452 { } /* end */
8453};
8454
Jiang zhefb97dc62008-03-06 11:07:11 +01008455static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8456 /* HP */
8457 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8458 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8459 /* Subwoofer */
8460 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8461 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8462
8463 /* enable unsolicited event */
8464 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8465
8466 { } /* end */
8467};
8468
Sasha Alexandrc2592492009-06-16 14:52:54 -04008469static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008470 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8471 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8472
8473 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8474 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008475
David Heidelberger64a8be72009-06-08 16:15:18 +02008476/* Connect Line-Out side jack (SPDIF) to Side */
8477 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8478 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8479 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8480/* Connect Mic jack to CLFE */
8481 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8482 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8483 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8484/* Connect Line-in jack to Surround */
8485 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8486 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8487 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8488/* Connect HP out jack to Front */
8489 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8490 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8491 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008492
8493 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008494
8495 { } /* end */
8496};
8497
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008498static struct hda_verb alc883_lenovo_101e_verbs[] = {
8499 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8500 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8501 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8502 { } /* end */
8503};
8504
Kailang Yang272a5272007-05-14 11:00:38 +02008505static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8506 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8507 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8508 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8509 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8510 { } /* end */
8511};
8512
8513static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8514 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8515 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8516 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8517 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8518 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8519 { } /* end */
8520};
8521
Kailang Yang189609a2007-08-20 11:31:23 +02008522static struct hda_verb alc883_haier_w66_verbs[] = {
8523 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8524 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8525
8526 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8527
8528 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8529 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8530 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8531 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8532 { } /* end */
8533};
8534
Kailang Yange2757d52008-08-26 13:17:46 +02008535static struct hda_verb alc888_lenovo_sky_verbs[] = {
8536 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8537 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8538 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8539 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8540 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8541 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8542 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8543 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8544 { } /* end */
8545};
8546
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008547static struct hda_verb alc888_6st_dell_verbs[] = {
8548 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8549 { }
8550};
8551
Guido Günther3e1647c2009-06-05 00:47:26 +02008552static struct hda_verb alc883_vaiott_verbs[] = {
8553 /* HP */
8554 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8555 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8556
8557 /* enable unsolicited event */
8558 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8559
8560 { } /* end */
8561};
8562
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008563static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008564{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008565 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008566
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008567 spec->autocfg.hp_pins[0] = 0x1b;
8568 spec->autocfg.speaker_pins[0] = 0x14;
8569 spec->autocfg.speaker_pins[1] = 0x16;
8570 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008571}
8572
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008573static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008574 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008575 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8576 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008577 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008578 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008579};
8580
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008581/*
8582 * 2ch mode
8583 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008584static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008585 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8586 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8587 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8588 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008589 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008590};
8591
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008592/*
8593 * 4ch mode
8594 */
8595static struct hda_verb alc888_3st_hp_4ch_init[] = {
8596 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8597 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8598 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8599 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8600 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8601 { } /* end */
8602};
8603
8604/*
8605 * 6ch mode
8606 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008607static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008608 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8609 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008610 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008611 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8612 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008613 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8614 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008615};
8616
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008617static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008618 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008619 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008620 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008621};
8622
Kailang Yang272a5272007-05-14 11:00:38 +02008623/* toggle front-jack and RCA according to the hp-jack state */
8624static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8625{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008626 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02008627
Takashi Iwai47fd8302007-08-10 17:11:07 +02008628 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8629 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8630 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8631 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008632}
8633
8634/* toggle RCA according to the front-jack state */
8635static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8636{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008637 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02008638
Takashi Iwai47fd8302007-08-10 17:11:07 +02008639 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8640 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008641}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008642
Kailang Yang272a5272007-05-14 11:00:38 +02008643static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8644 unsigned int res)
8645{
8646 if ((res >> 26) == ALC880_HP_EVENT)
8647 alc888_lenovo_ms7195_front_automute(codec);
8648 if ((res >> 26) == ALC880_FRONT_EVENT)
8649 alc888_lenovo_ms7195_rca_automute(codec);
8650}
8651
8652static struct hda_verb alc883_medion_md2_verbs[] = {
8653 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8654 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8655
8656 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8657
8658 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8659 { } /* end */
8660};
8661
8662/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008663static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008664{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008665 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008666
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008667 spec->autocfg.hp_pins[0] = 0x14;
8668 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008669}
8670
Kailang Yangccc656c2006-10-17 12:32:26 +02008671/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008672#define alc883_targa_init_hook alc882_targa_init_hook
8673#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008674
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008675static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8676{
8677 unsigned int present;
8678
Takashi Iwaid56757a2009-11-18 08:00:14 +01008679 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008680 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8681 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8682}
8683
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008684static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008685{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008686 struct alc_spec *spec = codec->spec;
8687
8688 spec->autocfg.hp_pins[0] = 0x15;
8689 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008690}
8691
8692static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8693{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008694 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008695 alc883_clevo_m720_mic_automute(codec);
8696}
8697
8698static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008699 unsigned int res)
8700{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008701 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008702 case ALC880_MIC_EVENT:
8703 alc883_clevo_m720_mic_automute(codec);
8704 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008705 default:
8706 alc_automute_amp_unsol_event(codec, res);
8707 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008708 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008709}
8710
Jiang zhefb97dc62008-03-06 11:07:11 +01008711/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008712static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008713{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008714 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008715
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008716 spec->autocfg.hp_pins[0] = 0x14;
8717 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01008718}
8719
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008720static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008721{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008722 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008723
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008724 spec->autocfg.hp_pins[0] = 0x1b;
8725 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02008726}
8727
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008728static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8729{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008730 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008731
Takashi Iwai47fd8302007-08-10 17:11:07 +02008732 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8733 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008734}
8735
8736static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8737{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008738 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008739
Takashi Iwai47fd8302007-08-10 17:11:07 +02008740 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8741 HDA_AMP_MUTE, bits);
8742 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8743 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008744}
8745
8746static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8747 unsigned int res)
8748{
8749 if ((res >> 26) == ALC880_HP_EVENT)
8750 alc883_lenovo_101e_all_automute(codec);
8751 if ((res >> 26) == ALC880_FRONT_EVENT)
8752 alc883_lenovo_101e_ispeaker_automute(codec);
8753}
8754
Takashi Iwai676a9b52007-08-16 15:23:35 +02008755/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008756static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008757{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008758 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008759
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008760 spec->autocfg.hp_pins[0] = 0x14;
8761 spec->autocfg.speaker_pins[0] = 0x15;
8762 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02008763}
8764
Kailang Yangd1a991a2007-08-15 16:21:59 +02008765static struct hda_verb alc883_acer_eapd_verbs[] = {
8766 /* HP Pin: output 0 (0x0c) */
8767 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8768 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8769 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8770 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008771 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8772 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008773 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008774 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8775 /* eanable EAPD on medion laptop */
8776 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8777 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008778 /* enable unsolicited event */
8779 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008780 { }
8781};
8782
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008783static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8784 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8785 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8786 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8787 { } /* end */
8788};
8789
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008790static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008791{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008792 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008793
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008794 spec->autocfg.hp_pins[0] = 0x1b;
8795 spec->autocfg.speaker_pins[0] = 0x14;
8796 spec->autocfg.speaker_pins[1] = 0x15;
8797 spec->autocfg.speaker_pins[2] = 0x16;
8798 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008799}
8800
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008801static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008802{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008803 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008804
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008805 spec->autocfg.hp_pins[0] = 0x1b;
8806 spec->autocfg.speaker_pins[0] = 0x14;
8807 spec->autocfg.speaker_pins[1] = 0x15;
8808 spec->autocfg.speaker_pins[2] = 0x16;
8809 spec->autocfg.speaker_pins[3] = 0x17;
8810 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02008811}
8812
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008813static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02008814{
8815 struct alc_spec *spec = codec->spec;
8816
8817 spec->autocfg.hp_pins[0] = 0x15;
8818 spec->autocfg.speaker_pins[0] = 0x14;
8819 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02008820}
8821
Kailang Yange2757d52008-08-26 13:17:46 +02008822static struct hda_verb alc888_asus_m90v_verbs[] = {
8823 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8824 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8825 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8826 /* enable unsolicited event */
8827 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8828 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8829 { } /* end */
8830};
8831
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008832static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008833{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008834 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008835
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008836 spec->autocfg.hp_pins[0] = 0x1b;
8837 spec->autocfg.speaker_pins[0] = 0x14;
8838 spec->autocfg.speaker_pins[1] = 0x15;
8839 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008840 spec->ext_mic.pin = 0x18;
8841 spec->int_mic.pin = 0x19;
8842 spec->ext_mic.mux_idx = 0;
8843 spec->int_mic.mux_idx = 1;
8844 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02008845}
8846
8847static struct hda_verb alc888_asus_eee1601_verbs[] = {
8848 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8849 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8850 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8851 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8852 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8853 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8854 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8855 /* enable unsolicited event */
8856 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8857 { } /* end */
8858};
8859
Kailang Yange2757d52008-08-26 13:17:46 +02008860static void alc883_eee1601_inithook(struct hda_codec *codec)
8861{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008862 struct alc_spec *spec = codec->spec;
8863
8864 spec->autocfg.hp_pins[0] = 0x14;
8865 spec->autocfg.speaker_pins[0] = 0x1b;
8866 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008867}
8868
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008869static struct hda_verb alc889A_mb31_verbs[] = {
8870 /* Init rear pin (used as headphone output) */
8871 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8872 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8873 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8874 /* Init line pin (used as output in 4ch and 6ch mode) */
8875 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8876 /* Init line 2 pin (used as headphone out by default) */
8877 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8878 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8879 { } /* end */
8880};
8881
8882/* Mute speakers according to the headphone jack state */
8883static void alc889A_mb31_automute(struct hda_codec *codec)
8884{
8885 unsigned int present;
8886
8887 /* Mute only in 2ch or 4ch mode */
8888 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8889 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08008890 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008891 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8892 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8893 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8894 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8895 }
8896}
8897
8898static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8899{
8900 if ((res >> 26) == ALC880_HP_EVENT)
8901 alc889A_mb31_automute(codec);
8902}
8903
Takashi Iwai4953550a2009-06-30 15:28:30 +02008904
Takashi Iwaicb53c622007-08-10 17:21:45 +02008905#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02008906#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02008907#endif
8908
Sasha Alexandrdef319f2009-06-16 16:00:15 -04008909/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008910#define alc882_pcm_analog_playback alc880_pcm_analog_playback
8911#define alc882_pcm_analog_capture alc880_pcm_analog_capture
8912#define alc882_pcm_digital_playback alc880_pcm_digital_playback
8913#define alc882_pcm_digital_capture alc880_pcm_digital_capture
8914
8915static hda_nid_t alc883_slave_dig_outs[] = {
8916 ALC1200_DIGOUT_NID, 0,
8917};
8918
8919static hda_nid_t alc1200_slave_dig_outs[] = {
8920 ALC883_DIGOUT_NID, 0,
8921};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008922
8923/*
8924 * configuration and preset
8925 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008926static const char *alc882_models[ALC882_MODEL_LAST] = {
8927 [ALC882_3ST_DIG] = "3stack-dig",
8928 [ALC882_6ST_DIG] = "6stack-dig",
8929 [ALC882_ARIMA] = "arima",
8930 [ALC882_W2JC] = "w2jc",
8931 [ALC882_TARGA] = "targa",
8932 [ALC882_ASUS_A7J] = "asus-a7j",
8933 [ALC882_ASUS_A7M] = "asus-a7m",
8934 [ALC885_MACPRO] = "macpro",
8935 [ALC885_MB5] = "mb5",
8936 [ALC885_MBP3] = "mbp3",
8937 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008938 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008939 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008940 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8941 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008942 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008943 [ALC883_TARGA_DIG] = "targa-dig",
8944 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02008945 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008946 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008947 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008948 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02008949 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02008950 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008951 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008952 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008953 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008954 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008955 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008956 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8957 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008958 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008959 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008960 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008961 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008962 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308963 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008964 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008965 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008966 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008967 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008968 [ALC889A_INTEL] = "intel-alc889a",
8969 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008970 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008971 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02008972 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008973 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008974};
8975
Takashi Iwai4953550a2009-06-30 15:28:30 +02008976static struct snd_pci_quirk alc882_cfg_tbl[] = {
8977 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8978
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008979 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008980 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008981 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008982 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8983 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008984 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008985 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8986 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008987 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01008988 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02008989 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8990 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02008991 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
8992 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008993 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
8994 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008995 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02008996 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008997 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01008998 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008999 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9000 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009001 /* default Acer -- disabled as it causes more problems.
9002 * model=auto should work fine now
9003 */
9004 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009005
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009006 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009007
Tobin Davisfebe3372007-06-12 11:27:46 +02009008 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009009 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9010 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009011 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009012 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009013 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009014
9015 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9016 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9017 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009018 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009019 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9020 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9021 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009022 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009023 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009024 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009025 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009026
9027 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009028 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009029 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009030 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009031 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9032 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009033 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009034 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009035 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9036
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009037 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9038 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9039 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009040 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009041 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009042 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009043 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009044 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009045 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9046 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9047 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9048 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9049 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9050 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009051 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009052 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9053 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9054 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009055 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009056 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9057 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009058 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009059 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009060 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009061 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009062 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009063 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009064 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009065 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009066
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009067 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009068 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9069 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309070 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009071 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009072 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009073 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009074 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009075 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009076 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009077 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009078 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009079 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009080 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009081 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9082 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009083 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009084 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009085 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009086 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009087 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009088
Jiang zhe17bba1b2008-06-04 12:11:07 +02009089 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9090 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009091 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009092 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9093 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9094 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009095 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009096
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009097 {}
9098};
9099
Takashi Iwai4953550a2009-06-30 15:28:30 +02009100/* codec SSID table for Intel Mac */
9101static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9102 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9103 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9104 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9105 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9106 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9107 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9108 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
9109 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9110 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9111 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009112 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009113 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009114 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9115 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009116 */
9117 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009118 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009119 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009120};
9121
Takashi Iwai4953550a2009-06-30 15:28:30 +02009122static struct alc_config_preset alc882_presets[] = {
9123 [ALC882_3ST_DIG] = {
9124 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009125 .init_verbs = { alc882_base_init_verbs,
9126 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009127 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9128 .dac_nids = alc882_dac_nids,
9129 .dig_out_nid = ALC882_DIGOUT_NID,
9130 .dig_in_nid = ALC882_DIGIN_NID,
9131 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9132 .channel_mode = alc882_ch_modes,
9133 .need_dac_fix = 1,
9134 .input_mux = &alc882_capture_source,
9135 },
9136 [ALC882_6ST_DIG] = {
9137 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009138 .init_verbs = { alc882_base_init_verbs,
9139 alc882_adc1_init_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 .dig_in_nid = ALC882_DIGIN_NID,
9144 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9145 .channel_mode = alc882_sixstack_modes,
9146 .input_mux = &alc882_capture_source,
9147 },
9148 [ALC882_ARIMA] = {
9149 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009150 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9151 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009152 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9153 .dac_nids = alc882_dac_nids,
9154 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9155 .channel_mode = alc882_sixstack_modes,
9156 .input_mux = &alc882_capture_source,
9157 },
9158 [ALC882_W2JC] = {
9159 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009160 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9161 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009162 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9163 .dac_nids = alc882_dac_nids,
9164 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9165 .channel_mode = alc880_threestack_modes,
9166 .need_dac_fix = 1,
9167 .input_mux = &alc882_capture_source,
9168 .dig_out_nid = ALC882_DIGOUT_NID,
9169 },
9170 [ALC885_MBP3] = {
9171 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9172 .init_verbs = { alc885_mbp3_init_verbs,
9173 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009174 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009175 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009176 .hp_nid = 0x04,
9177 .channel_mode = alc885_mbp_4ch_modes,
9178 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009179 .input_mux = &alc882_capture_source,
9180 .dig_out_nid = ALC882_DIGOUT_NID,
9181 .dig_in_nid = ALC882_DIGIN_NID,
9182 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009183 .setup = alc885_mbp3_setup,
9184 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009185 },
9186 [ALC885_MB5] = {
9187 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9188 .init_verbs = { alc885_mb5_init_verbs,
9189 alc880_gpio1_init_verbs },
9190 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9191 .dac_nids = alc882_dac_nids,
9192 .channel_mode = alc885_mb5_6ch_modes,
9193 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9194 .input_mux = &mb5_capture_source,
9195 .dig_out_nid = ALC882_DIGOUT_NID,
9196 .dig_in_nid = ALC882_DIGIN_NID,
Alex Murraya76221d2010-01-13 23:15:03 +10309197 .unsol_event = alc885_mb5_unsol_event,
9198 .init_hook = alc885_mb5_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009199 },
9200 [ALC885_MACPRO] = {
9201 .mixers = { alc882_macpro_mixer },
9202 .init_verbs = { alc882_macpro_init_verbs },
9203 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9204 .dac_nids = alc882_dac_nids,
9205 .dig_out_nid = ALC882_DIGOUT_NID,
9206 .dig_in_nid = ALC882_DIGIN_NID,
9207 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9208 .channel_mode = alc882_ch_modes,
9209 .input_mux = &alc882_capture_source,
9210 .init_hook = alc885_macpro_init_hook,
9211 },
9212 [ALC885_IMAC24] = {
9213 .mixers = { alc885_imac24_mixer },
9214 .init_verbs = { alc885_imac24_init_verbs },
9215 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9216 .dac_nids = alc882_dac_nids,
9217 .dig_out_nid = ALC882_DIGOUT_NID,
9218 .dig_in_nid = ALC882_DIGIN_NID,
9219 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9220 .channel_mode = alc882_ch_modes,
9221 .input_mux = &alc882_capture_source,
9222 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009223 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009224 .init_hook = alc885_imac24_init_hook,
9225 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009226 [ALC885_IMAC91] = {
9227 .mixers = { alc885_imac91_mixer, alc882_chmode_mixer },
9228 .init_verbs = { alc885_imac91_init_verbs,
9229 alc880_gpio1_init_verbs },
9230 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9231 .dac_nids = alc882_dac_nids,
9232 .channel_mode = alc885_mbp_4ch_modes,
9233 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
9234 .input_mux = &alc882_capture_source,
9235 .dig_out_nid = ALC882_DIGOUT_NID,
9236 .dig_in_nid = ALC882_DIGIN_NID,
9237 .unsol_event = alc885_imac91_unsol_event,
9238 .init_hook = alc885_imac91_automute,
9239 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009240 [ALC882_TARGA] = {
9241 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009242 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009243 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009244 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9245 .dac_nids = alc882_dac_nids,
9246 .dig_out_nid = ALC882_DIGOUT_NID,
9247 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9248 .adc_nids = alc882_adc_nids,
9249 .capsrc_nids = alc882_capsrc_nids,
9250 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9251 .channel_mode = alc882_3ST_6ch_modes,
9252 .need_dac_fix = 1,
9253 .input_mux = &alc882_capture_source,
9254 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009255 .setup = alc882_targa_setup,
9256 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009257 },
9258 [ALC882_ASUS_A7J] = {
9259 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009260 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9261 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009262 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9263 .dac_nids = alc882_dac_nids,
9264 .dig_out_nid = ALC882_DIGOUT_NID,
9265 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9266 .adc_nids = alc882_adc_nids,
9267 .capsrc_nids = alc882_capsrc_nids,
9268 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9269 .channel_mode = alc882_3ST_6ch_modes,
9270 .need_dac_fix = 1,
9271 .input_mux = &alc882_capture_source,
9272 },
9273 [ALC882_ASUS_A7M] = {
9274 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009275 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9276 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009277 alc882_asus_a7m_verbs },
9278 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9279 .dac_nids = alc882_dac_nids,
9280 .dig_out_nid = ALC882_DIGOUT_NID,
9281 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9282 .channel_mode = alc880_threestack_modes,
9283 .need_dac_fix = 1,
9284 .input_mux = &alc882_capture_source,
9285 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009286 [ALC883_3ST_2ch_DIG] = {
9287 .mixers = { alc883_3ST_2ch_mixer },
9288 .init_verbs = { alc883_init_verbs },
9289 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9290 .dac_nids = alc883_dac_nids,
9291 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009292 .dig_in_nid = ALC883_DIGIN_NID,
9293 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9294 .channel_mode = alc883_3ST_2ch_modes,
9295 .input_mux = &alc883_capture_source,
9296 },
9297 [ALC883_3ST_6ch_DIG] = {
9298 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9299 .init_verbs = { alc883_init_verbs },
9300 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9301 .dac_nids = alc883_dac_nids,
9302 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009303 .dig_in_nid = ALC883_DIGIN_NID,
9304 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9305 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009306 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009307 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009308 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009309 [ALC883_3ST_6ch] = {
9310 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9311 .init_verbs = { alc883_init_verbs },
9312 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9313 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009314 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9315 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009316 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009317 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009318 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009319 [ALC883_3ST_6ch_INTEL] = {
9320 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9321 .init_verbs = { alc883_init_verbs },
9322 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9323 .dac_nids = alc883_dac_nids,
9324 .dig_out_nid = ALC883_DIGOUT_NID,
9325 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009326 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009327 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9328 .channel_mode = alc883_3ST_6ch_intel_modes,
9329 .need_dac_fix = 1,
9330 .input_mux = &alc883_3stack_6ch_intel,
9331 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009332 [ALC889A_INTEL] = {
9333 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009334 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9335 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009336 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9337 .dac_nids = alc883_dac_nids,
9338 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9339 .adc_nids = alc889_adc_nids,
9340 .dig_out_nid = ALC883_DIGOUT_NID,
9341 .dig_in_nid = ALC883_DIGIN_NID,
9342 .slave_dig_outs = alc883_slave_dig_outs,
9343 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9344 .channel_mode = alc889_8ch_intel_modes,
9345 .capsrc_nids = alc889_capsrc_nids,
9346 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009347 .setup = alc889_automute_setup,
9348 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009349 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009350 .need_dac_fix = 1,
9351 },
9352 [ALC889_INTEL] = {
9353 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9354 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009355 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009356 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9357 .dac_nids = alc883_dac_nids,
9358 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9359 .adc_nids = alc889_adc_nids,
9360 .dig_out_nid = ALC883_DIGOUT_NID,
9361 .dig_in_nid = ALC883_DIGIN_NID,
9362 .slave_dig_outs = alc883_slave_dig_outs,
9363 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9364 .channel_mode = alc889_8ch_intel_modes,
9365 .capsrc_nids = alc889_capsrc_nids,
9366 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009367 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009368 .init_hook = alc889_intel_init_hook,
9369 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009370 .need_dac_fix = 1,
9371 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009372 [ALC883_6ST_DIG] = {
9373 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9374 .init_verbs = { alc883_init_verbs },
9375 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9376 .dac_nids = alc883_dac_nids,
9377 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009378 .dig_in_nid = ALC883_DIGIN_NID,
9379 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9380 .channel_mode = alc883_sixstack_modes,
9381 .input_mux = &alc883_capture_source,
9382 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009383 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009384 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009385 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9386 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009387 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9388 .dac_nids = alc883_dac_nids,
9389 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009390 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9391 .channel_mode = alc883_3ST_6ch_modes,
9392 .need_dac_fix = 1,
9393 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009394 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009395 .setup = alc882_targa_setup,
9396 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009397 },
9398 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009399 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009400 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9401 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009402 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9403 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009404 .adc_nids = alc883_adc_nids_alt,
9405 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009406 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +02009407 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009408 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9409 .channel_mode = alc883_3ST_2ch_modes,
9410 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009411 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009412 .setup = alc882_targa_setup,
9413 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009414 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009415 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009416 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9417 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +02009418 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009419 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009420 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9421 .dac_nids = alc883_dac_nids,
9422 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9423 .adc_nids = alc883_adc_nids_rev,
9424 .capsrc_nids = alc883_capsrc_nids_rev,
9425 .dig_out_nid = ALC883_DIGOUT_NID,
9426 .dig_in_nid = ALC883_DIGIN_NID,
9427 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9428 .channel_mode = alc883_4ST_8ch_modes,
9429 .need_dac_fix = 1,
9430 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009431 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009432 .setup = alc882_targa_setup,
9433 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009434 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009435 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009436 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009437 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9438 * and the headphone jack. Turn this on and rely on the
9439 * standard mute methods whenever the user wants to turn
9440 * these outputs off.
9441 */
9442 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9443 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9444 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009445 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9446 .channel_mode = alc883_3ST_2ch_modes,
9447 .input_mux = &alc883_capture_source,
9448 },
Tobin Davis2880a862007-08-07 11:50:26 +02009449 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009450 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009451 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009452 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9453 .dac_nids = alc883_dac_nids,
9454 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009455 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9456 .channel_mode = alc883_3ST_2ch_modes,
9457 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009458 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009459 .setup = alc883_acer_aspire_setup,
9460 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009461 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009462 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009463 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009464 alc883_chmode_mixer },
9465 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9466 alc888_acer_aspire_4930g_verbs },
9467 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9468 .dac_nids = alc883_dac_nids,
9469 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9470 .adc_nids = alc883_adc_nids_rev,
9471 .capsrc_nids = alc883_capsrc_nids_rev,
9472 .dig_out_nid = ALC883_DIGOUT_NID,
9473 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9474 .channel_mode = alc883_3ST_6ch_modes,
9475 .need_dac_fix = 1,
9476 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009477 ARRAY_SIZE(alc888_2_capture_sources),
9478 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009479 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009480 .setup = alc888_acer_aspire_4930g_setup,
9481 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009482 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009483 [ALC888_ACER_ASPIRE_6530G] = {
9484 .mixers = { alc888_acer_aspire_6530_mixer },
9485 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9486 alc888_acer_aspire_6530g_verbs },
9487 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9488 .dac_nids = alc883_dac_nids,
9489 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9490 .adc_nids = alc883_adc_nids_rev,
9491 .capsrc_nids = alc883_capsrc_nids_rev,
9492 .dig_out_nid = ALC883_DIGOUT_NID,
9493 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9494 .channel_mode = alc883_3ST_2ch_modes,
9495 .num_mux_defs =
9496 ARRAY_SIZE(alc888_2_capture_sources),
9497 .input_mux = alc888_acer_aspire_6530_sources,
9498 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009499 .setup = alc888_acer_aspire_6530g_setup,
9500 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009501 },
Hector Martin3b315d72009-06-02 10:54:19 +02009502 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +01009503 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +02009504 alc883_chmode_mixer },
9505 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +01009506 alc889_acer_aspire_8930g_verbs,
9507 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +02009508 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9509 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009510 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9511 .adc_nids = alc889_adc_nids,
9512 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009513 .dig_out_nid = ALC883_DIGOUT_NID,
9514 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9515 .channel_mode = alc883_3ST_6ch_modes,
9516 .need_dac_fix = 1,
9517 .const_channel_count = 6,
9518 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009519 ARRAY_SIZE(alc889_capture_sources),
9520 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009521 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009522 .setup = alc889_acer_aspire_8930g_setup,
9523 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +01009524#ifdef CONFIG_SND_HDA_POWER_SAVE
9525 .power_hook = alc889_power_eapd,
9526#endif
Hector Martin3b315d72009-06-02 10:54:19 +02009527 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009528 [ALC888_ACER_ASPIRE_7730G] = {
9529 .mixers = { alc883_3ST_6ch_mixer,
9530 alc883_chmode_mixer },
9531 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9532 alc888_acer_aspire_7730G_verbs },
9533 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9534 .dac_nids = alc883_dac_nids,
9535 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9536 .adc_nids = alc883_adc_nids_rev,
9537 .capsrc_nids = alc883_capsrc_nids_rev,
9538 .dig_out_nid = ALC883_DIGOUT_NID,
9539 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9540 .channel_mode = alc883_3ST_6ch_modes,
9541 .need_dac_fix = 1,
9542 .const_channel_count = 6,
9543 .input_mux = &alc883_capture_source,
9544 .unsol_event = alc_automute_amp_unsol_event,
9545 .setup = alc888_acer_aspire_6530g_setup,
9546 .init_hook = alc_automute_amp,
9547 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009548 [ALC883_MEDION] = {
9549 .mixers = { alc883_fivestack_mixer,
9550 alc883_chmode_mixer },
9551 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009552 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009553 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9554 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009555 .adc_nids = alc883_adc_nids_alt,
9556 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009557 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02009558 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9559 .channel_mode = alc883_sixstack_modes,
9560 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009561 },
Kailang Yang272a5272007-05-14 11:00:38 +02009562 [ALC883_MEDION_MD2] = {
9563 .mixers = { alc883_medion_md2_mixer},
9564 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9565 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9566 .dac_nids = alc883_dac_nids,
9567 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009568 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9569 .channel_mode = alc883_3ST_2ch_modes,
9570 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009571 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009572 .setup = alc883_medion_md2_setup,
9573 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009574 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009575 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009576 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009577 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9578 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9579 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009580 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9581 .channel_mode = alc883_3ST_2ch_modes,
9582 .input_mux = &alc883_capture_source,
9583 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309584 [ALC883_CLEVO_M540R] = {
9585 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9586 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9587 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9588 .dac_nids = alc883_dac_nids,
9589 .dig_out_nid = ALC883_DIGOUT_NID,
9590 .dig_in_nid = ALC883_DIGIN_NID,
9591 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9592 .channel_mode = alc883_3ST_6ch_clevo_modes,
9593 .need_dac_fix = 1,
9594 .input_mux = &alc883_capture_source,
9595 /* This machine has the hardware HP auto-muting, thus
9596 * we need no software mute via unsol event
9597 */
9598 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009599 [ALC883_CLEVO_M720] = {
9600 .mixers = { alc883_clevo_m720_mixer },
9601 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009602 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9603 .dac_nids = alc883_dac_nids,
9604 .dig_out_nid = ALC883_DIGOUT_NID,
9605 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9606 .channel_mode = alc883_3ST_2ch_modes,
9607 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009608 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009609 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009610 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009611 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009612 [ALC883_LENOVO_101E_2ch] = {
9613 .mixers = { alc883_lenovo_101e_2ch_mixer},
9614 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9615 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9616 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009617 .adc_nids = alc883_adc_nids_alt,
9618 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009619 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009620 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9621 .channel_mode = alc883_3ST_2ch_modes,
9622 .input_mux = &alc883_lenovo_101e_capture_source,
9623 .unsol_event = alc883_lenovo_101e_unsol_event,
9624 .init_hook = alc883_lenovo_101e_all_automute,
9625 },
Kailang Yang272a5272007-05-14 11:00:38 +02009626 [ALC883_LENOVO_NB0763] = {
9627 .mixers = { alc883_lenovo_nb0763_mixer },
9628 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9629 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9630 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009631 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9632 .channel_mode = alc883_3ST_2ch_modes,
9633 .need_dac_fix = 1,
9634 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009635 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009636 .setup = alc883_medion_md2_setup,
9637 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009638 },
9639 [ALC888_LENOVO_MS7195_DIG] = {
9640 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9641 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9642 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9643 .dac_nids = alc883_dac_nids,
9644 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009645 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9646 .channel_mode = alc883_3ST_6ch_modes,
9647 .need_dac_fix = 1,
9648 .input_mux = &alc883_capture_source,
9649 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9650 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009651 },
9652 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009653 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009654 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9655 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9656 .dac_nids = alc883_dac_nids,
9657 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009658 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9659 .channel_mode = alc883_3ST_2ch_modes,
9660 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009661 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009662 .setup = alc883_haier_w66_setup,
9663 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009664 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009665 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009666 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009667 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009668 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9669 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009670 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9671 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009672 .need_dac_fix = 1,
9673 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009674 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009675 .setup = alc888_3st_hp_setup,
9676 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009677 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009678 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009679 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009680 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9681 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9682 .dac_nids = alc883_dac_nids,
9683 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009684 .dig_in_nid = ALC883_DIGIN_NID,
9685 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9686 .channel_mode = alc883_sixstack_modes,
9687 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009688 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009689 .setup = alc888_6st_dell_setup,
9690 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009691 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009692 [ALC883_MITAC] = {
9693 .mixers = { alc883_mitac_mixer },
9694 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9695 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9696 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009697 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9698 .channel_mode = alc883_3ST_2ch_modes,
9699 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009700 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009701 .setup = alc883_mitac_setup,
9702 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009703 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009704 [ALC883_FUJITSU_PI2515] = {
9705 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9706 .init_verbs = { alc883_init_verbs,
9707 alc883_2ch_fujitsu_pi2515_verbs},
9708 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9709 .dac_nids = alc883_dac_nids,
9710 .dig_out_nid = ALC883_DIGOUT_NID,
9711 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9712 .channel_mode = alc883_3ST_2ch_modes,
9713 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009714 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009715 .setup = alc883_2ch_fujitsu_pi2515_setup,
9716 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +01009717 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009718 [ALC888_FUJITSU_XA3530] = {
9719 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9720 .init_verbs = { alc883_init_verbs,
9721 alc888_fujitsu_xa3530_verbs },
9722 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9723 .dac_nids = alc883_dac_nids,
9724 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9725 .adc_nids = alc883_adc_nids_rev,
9726 .capsrc_nids = alc883_capsrc_nids_rev,
9727 .dig_out_nid = ALC883_DIGOUT_NID,
9728 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9729 .channel_mode = alc888_4ST_8ch_intel_modes,
9730 .num_mux_defs =
9731 ARRAY_SIZE(alc888_2_capture_sources),
9732 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009733 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009734 .setup = alc888_fujitsu_xa3530_setup,
9735 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009736 },
Kailang Yange2757d52008-08-26 13:17:46 +02009737 [ALC888_LENOVO_SKY] = {
9738 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9739 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9740 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9741 .dac_nids = alc883_dac_nids,
9742 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009743 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9744 .channel_mode = alc883_sixstack_modes,
9745 .need_dac_fix = 1,
9746 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009747 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009748 .setup = alc888_lenovo_sky_setup,
9749 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +02009750 },
9751 [ALC888_ASUS_M90V] = {
9752 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9753 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9754 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9755 .dac_nids = alc883_dac_nids,
9756 .dig_out_nid = ALC883_DIGOUT_NID,
9757 .dig_in_nid = ALC883_DIGIN_NID,
9758 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9759 .channel_mode = alc883_3ST_6ch_modes,
9760 .need_dac_fix = 1,
9761 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009762 .unsol_event = alc_sku_unsol_event,
9763 .setup = alc883_mode2_setup,
9764 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +02009765 },
9766 [ALC888_ASUS_EEE1601] = {
9767 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009768 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009769 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9770 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9771 .dac_nids = alc883_dac_nids,
9772 .dig_out_nid = ALC883_DIGOUT_NID,
9773 .dig_in_nid = ALC883_DIGIN_NID,
9774 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9775 .channel_mode = alc883_3ST_2ch_modes,
9776 .need_dac_fix = 1,
9777 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009778 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009779 .init_hook = alc883_eee1601_inithook,
9780 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009781 [ALC1200_ASUS_P5Q] = {
9782 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9783 .init_verbs = { alc883_init_verbs },
9784 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9785 .dac_nids = alc883_dac_nids,
9786 .dig_out_nid = ALC1200_DIGOUT_NID,
9787 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009788 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009789 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9790 .channel_mode = alc883_sixstack_modes,
9791 .input_mux = &alc883_capture_source,
9792 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009793 [ALC889A_MB31] = {
9794 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9795 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9796 alc880_gpio1_init_verbs },
9797 .adc_nids = alc883_adc_nids,
9798 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009799 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009800 .dac_nids = alc883_dac_nids,
9801 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9802 .channel_mode = alc889A_mb31_6ch_modes,
9803 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9804 .input_mux = &alc889A_mb31_capture_source,
9805 .dig_out_nid = ALC883_DIGOUT_NID,
9806 .unsol_event = alc889A_mb31_unsol_event,
9807 .init_hook = alc889A_mb31_automute,
9808 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009809 [ALC883_SONY_VAIO_TT] = {
9810 .mixers = { alc883_vaiott_mixer },
9811 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9812 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9813 .dac_nids = alc883_dac_nids,
9814 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9815 .channel_mode = alc883_3ST_2ch_modes,
9816 .input_mux = &alc883_capture_source,
9817 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009818 .setup = alc883_vaiott_setup,
9819 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +02009820 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009821};
9822
9823
9824/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02009825 * Pin config fixes
9826 */
9827enum {
9828 PINFIX_ABIT_AW9D_MAX
9829};
9830
9831static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9832 { 0x15, 0x01080104 }, /* side */
9833 { 0x16, 0x01011012 }, /* rear */
9834 { 0x17, 0x01016011 }, /* clfe */
9835 { }
9836};
9837
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009838static const struct alc_fixup alc882_fixups[] = {
9839 [PINFIX_ABIT_AW9D_MAX] = {
9840 .pins = alc882_abit_aw9d_pinfix
9841 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009842};
9843
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009844static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009845 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9846 {}
9847};
9848
9849/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009850 * BIOS auto configuration
9851 */
Takashi Iwai05f5f472009-08-25 13:10:18 +02009852static int alc882_auto_create_input_ctls(struct hda_codec *codec,
9853 const struct auto_pin_cfg *cfg)
9854{
9855 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
9856}
9857
Takashi Iwai4953550a2009-06-30 15:28:30 +02009858static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009859 hda_nid_t nid, int pin_type,
9860 int dac_idx)
9861{
9862 /* set as output */
9863 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009864 int idx;
9865
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009866 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009867 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9868 idx = 4;
9869 else
9870 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009871 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9872
9873}
9874
Takashi Iwai4953550a2009-06-30 15:28:30 +02009875static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009876{
9877 struct alc_spec *spec = codec->spec;
9878 int i;
9879
9880 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009881 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009882 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009883 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009884 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009885 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009886 }
9887}
9888
Takashi Iwai4953550a2009-06-30 15:28:30 +02009889static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009890{
9891 struct alc_spec *spec = codec->spec;
9892 hda_nid_t pin;
9893
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009894 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009895 if (pin) /* connect to front */
9896 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009897 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009898 pin = spec->autocfg.speaker_pins[0];
9899 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009900 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009901}
9902
Takashi Iwai4953550a2009-06-30 15:28:30 +02009903static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009904{
9905 struct alc_spec *spec = codec->spec;
9906 int i;
9907
9908 for (i = 0; i < AUTO_PIN_LAST; i++) {
9909 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +02009910 if (!nid)
9911 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +02009912 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009913 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9914 snd_hda_codec_write(codec, nid, 0,
9915 AC_VERB_SET_AMP_GAIN_MUTE,
9916 AMP_OUT_MUTE);
9917 }
9918}
9919
9920static void alc882_auto_init_input_src(struct hda_codec *codec)
9921{
9922 struct alc_spec *spec = codec->spec;
9923 int c;
9924
9925 for (c = 0; c < spec->num_adc_nids; c++) {
9926 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9927 hda_nid_t nid = spec->capsrc_nids[c];
9928 unsigned int mux_idx;
9929 const struct hda_input_mux *imux;
9930 int conns, mute, idx, item;
9931
9932 conns = snd_hda_get_connections(codec, nid, conn_list,
9933 ARRAY_SIZE(conn_list));
9934 if (conns < 0)
9935 continue;
9936 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9937 imux = &spec->input_mux[mux_idx];
9938 for (idx = 0; idx < conns; idx++) {
9939 /* if the current connection is the selected one,
9940 * unmute it as default - otherwise mute it
9941 */
9942 mute = AMP_IN_MUTE(idx);
9943 for (item = 0; item < imux->num_items; item++) {
9944 if (imux->items[item].index == idx) {
9945 if (spec->cur_mux[c] == item)
9946 mute = AMP_IN_UNMUTE(idx);
9947 break;
9948 }
9949 }
9950 /* check if we have a selector or mixer
9951 * we could check for the widget type instead, but
9952 * just check for Amp-In presence (in case of mixer
9953 * without amp-in there is something wrong, this
9954 * function shouldn't be used or capsrc nid is wrong)
9955 */
9956 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009957 snd_hda_codec_write(codec, nid, 0,
9958 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009959 mute);
9960 else if (mute != AMP_IN_MUTE(idx))
9961 snd_hda_codec_write(codec, nid, 0,
9962 AC_VERB_SET_CONNECT_SEL,
9963 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009964 }
9965 }
9966}
9967
Takashi Iwai4953550a2009-06-30 15:28:30 +02009968/* add mic boosts if needed */
9969static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009970{
9971 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009972 int err;
9973 hda_nid_t nid;
9974
9975 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9976 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9977 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9978 "Mic Boost",
9979 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9980 if (err < 0)
9981 return err;
9982 }
9983 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9984 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9985 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9986 "Front Mic Boost",
9987 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9988 if (err < 0)
9989 return err;
9990 }
9991 return 0;
9992}
9993
9994/* almost identical with ALC880 parser... */
9995static int alc882_parse_auto_config(struct hda_codec *codec)
9996{
9997 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009998 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
9999 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010000
Takashi Iwai05f5f472009-08-25 13:10:18 +020010001 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10002 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010003 if (err < 0)
10004 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010005 if (!spec->autocfg.line_outs)
10006 return 0; /* can't find valid BIOS pin config */
10007
10008 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10009 if (err < 0)
10010 return err;
10011 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10012 if (err < 0)
10013 return err;
10014 err = alc880_auto_create_extra_out(spec,
10015 spec->autocfg.speaker_pins[0],
10016 "Speaker");
10017 if (err < 0)
10018 return err;
10019 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10020 "Headphone");
10021 if (err < 0)
10022 return err;
10023 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10024 if (err < 0)
10025 return err;
10026
10027 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10028
10029 /* check multiple SPDIF-out (for recent codecs) */
10030 for (i = 0; i < spec->autocfg.dig_outs; i++) {
10031 hda_nid_t dig_nid;
10032 err = snd_hda_get_connections(codec,
10033 spec->autocfg.dig_out_pins[i],
10034 &dig_nid, 1);
10035 if (err < 0)
10036 continue;
10037 if (!i)
10038 spec->multiout.dig_out_nid = dig_nid;
10039 else {
10040 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010041 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai05f5f472009-08-25 13:10:18 +020010042 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010043 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010044 }
10045 }
10046 if (spec->autocfg.dig_in_pin)
10047 spec->dig_in_nid = ALC880_DIGIN_NID;
10048
10049 if (spec->kctls.list)
10050 add_mixer(spec, spec->kctls.list);
10051
10052 add_verb(spec, alc883_auto_init_verbs);
10053 /* if ADC 0x07 is available, initialize it, too */
10054 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10055 add_verb(spec, alc882_adc1_init_verbs);
10056
10057 spec->num_mux_defs = 1;
10058 spec->input_mux = &spec->private_imux[0];
10059
10060 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
Takashi Iwai776e1842007-08-29 15:07:11 +020010061
10062 err = alc_auto_add_mic_boost(codec);
10063 if (err < 0)
10064 return err;
10065
Takashi Iwai776e1842007-08-29 15:07:11 +020010066 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010067}
10068
10069/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010070static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010071{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010072 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010073 alc882_auto_init_multi_out(codec);
10074 alc882_auto_init_hp_out(codec);
10075 alc882_auto_init_analog_input(codec);
10076 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010077 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010078 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010079}
10080
Takashi Iwai4953550a2009-06-30 15:28:30 +020010081static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010082{
10083 struct alc_spec *spec;
10084 int err, board_config;
10085
10086 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10087 if (spec == NULL)
10088 return -ENOMEM;
10089
10090 codec->spec = spec;
10091
Takashi Iwai4953550a2009-06-30 15:28:30 +020010092 switch (codec->vendor_id) {
10093 case 0x10ec0882:
10094 case 0x10ec0885:
10095 break;
10096 default:
10097 /* ALC883 and variants */
10098 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10099 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010100 }
10101
Takashi Iwai4953550a2009-06-30 15:28:30 +020010102 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10103 alc882_models,
10104 alc882_cfg_tbl);
10105
10106 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10107 board_config = snd_hda_check_board_codec_sid_config(codec,
10108 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10109
10110 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010111 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010112 codec->chip_name);
10113 board_config = ALC882_AUTO;
10114 }
10115
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010116 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010117
10118 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010119 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010120 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010121 if (err < 0) {
10122 alc_free(codec);
10123 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010124 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010125 printk(KERN_INFO
10126 "hda_codec: Cannot set up configuration "
10127 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010128 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010129 }
10130 }
10131
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010132 err = snd_hda_attach_beep_device(codec, 0x1);
10133 if (err < 0) {
10134 alc_free(codec);
10135 return err;
10136 }
10137
Takashi Iwai4953550a2009-06-30 15:28:30 +020010138 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010139 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010140
Takashi Iwai4953550a2009-06-30 15:28:30 +020010141 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10142 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10143 /* FIXME: setup DAC5 */
10144 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10145 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10146
10147 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10148 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10149
10150 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010151 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010152
10153 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010154 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010155 spec->num_adc_nids = 0;
10156 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010157 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010158 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010159 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010160 hda_nid_t nid = alc882_adc_nids[i];
10161 unsigned int wcap = get_wcaps(codec, nid);
10162 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010163 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010164 if (wcap != AC_WID_AUD_IN)
10165 continue;
10166 spec->private_adc_nids[spec->num_adc_nids] = nid;
10167 err = snd_hda_get_connections(codec, nid, &cap, 1);
10168 if (err < 0)
10169 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010170 err = snd_hda_get_connections(codec, cap, items,
10171 ARRAY_SIZE(items));
10172 if (err < 0)
10173 continue;
10174 for (j = 0; j < imux->num_items; j++)
10175 if (imux->items[j].index >= err)
10176 break;
10177 if (j < imux->num_items)
10178 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010179 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10180 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010181 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010182 spec->adc_nids = spec->private_adc_nids;
10183 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010184 }
10185
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010186 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010010187 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010188
Takashi Iwai2134ea42008-01-10 16:53:55 +010010189 spec->vmaster_nid = 0x0c;
10190
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010191 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010192 if (board_config == ALC882_AUTO)
10193 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010194#ifdef CONFIG_SND_HDA_POWER_SAVE
10195 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010196 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010197#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010010198 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010199
10200 return 0;
10201}
10202
Takashi Iwai4953550a2009-06-30 15:28:30 +020010203
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010204/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010205 * ALC262 support
10206 */
10207
10208#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10209#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10210
10211#define alc262_dac_nids alc260_dac_nids
10212#define alc262_adc_nids alc882_adc_nids
10213#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010214#define alc262_capsrc_nids alc882_capsrc_nids
10215#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010216
10217#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010218#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010219
Kailang Yang4e555fe2008-08-26 13:05:55 +020010220static hda_nid_t alc262_dmic_adc_nids[1] = {
10221 /* ADC0 */
10222 0x09
10223};
10224
10225static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10226
Kailang Yangdf694da2005-12-05 19:42:22 +010010227static struct snd_kcontrol_new alc262_base_mixer[] = {
10228 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10229 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10230 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10231 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10232 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10233 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10234 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10235 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010236 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010237 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10238 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010239 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010240 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10241 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10242 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10243 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010244 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010245};
10246
Takashi Iwaice875f02008-01-28 18:17:43 +010010247/* update HP, line and mono-out pins according to the master switch */
10248static void alc262_hp_master_update(struct hda_codec *codec)
10249{
10250 struct alc_spec *spec = codec->spec;
10251 int val = spec->master_sw;
10252
10253 /* HP & line-out */
10254 snd_hda_codec_write_cache(codec, 0x1b, 0,
10255 AC_VERB_SET_PIN_WIDGET_CONTROL,
10256 val ? PIN_HP : 0);
10257 snd_hda_codec_write_cache(codec, 0x15, 0,
10258 AC_VERB_SET_PIN_WIDGET_CONTROL,
10259 val ? PIN_HP : 0);
10260 /* mono (speaker) depending on the HP jack sense */
10261 val = val && !spec->jack_present;
10262 snd_hda_codec_write_cache(codec, 0x16, 0,
10263 AC_VERB_SET_PIN_WIDGET_CONTROL,
10264 val ? PIN_OUT : 0);
10265}
10266
10267static void alc262_hp_bpc_automute(struct hda_codec *codec)
10268{
10269 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010270
10271 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010272 alc262_hp_master_update(codec);
10273}
10274
10275static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10276{
10277 if ((res >> 26) != ALC880_HP_EVENT)
10278 return;
10279 alc262_hp_bpc_automute(codec);
10280}
10281
10282static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10283{
10284 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010285
10286 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010287 alc262_hp_master_update(codec);
10288}
10289
10290static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10291 unsigned int res)
10292{
10293 if ((res >> 26) != ALC880_HP_EVENT)
10294 return;
10295 alc262_hp_wildwest_automute(codec);
10296}
10297
Takashi Iwaib72519b2009-05-08 14:31:55 +020010298#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010299
10300static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10301 struct snd_ctl_elem_value *ucontrol)
10302{
10303 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10304 struct alc_spec *spec = codec->spec;
10305 int val = !!*ucontrol->value.integer.value;
10306
10307 if (val == spec->master_sw)
10308 return 0;
10309 spec->master_sw = val;
10310 alc262_hp_master_update(codec);
10311 return 1;
10312}
10313
Takashi Iwaib72519b2009-05-08 14:31:55 +020010314#define ALC262_HP_MASTER_SWITCH \
10315 { \
10316 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10317 .name = "Master Playback Switch", \
10318 .info = snd_ctl_boolean_mono_info, \
10319 .get = alc262_hp_master_sw_get, \
10320 .put = alc262_hp_master_sw_put, \
10321 }
10322
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010323static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010324 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010325 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10326 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10327 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010328 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10329 HDA_OUTPUT),
10330 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10331 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010332 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10333 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010334 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010335 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10336 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010337 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010338 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10339 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10340 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10341 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010342 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10343 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10344 { } /* end */
10345};
10346
Kailang Yangcd7509a2007-01-26 18:33:17 +010010347static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010348 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010349 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10350 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10351 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10352 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010353 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10354 HDA_OUTPUT),
10355 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10356 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010357 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10358 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010359 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010360 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10361 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10362 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10363 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010364 { } /* end */
10365};
10366
10367static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10368 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10369 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010370 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010371 { } /* end */
10372};
10373
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010374/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010375static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010376{
10377 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010378
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010379 spec->autocfg.hp_pins[0] = 0x15;
10380 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010381}
10382
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010383static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010384 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10385 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010386 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10387 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10388 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10389 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10390 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10391 { } /* end */
10392};
10393
10394static struct hda_verb alc262_hp_t5735_verbs[] = {
10395 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10396 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10397
10398 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10399 { }
10400};
10401
Kailang Yang8c427222008-01-10 13:03:59 +010010402static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010403 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10404 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010405 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10406 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010407 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10408 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10409 { } /* end */
10410};
10411
10412static struct hda_verb alc262_hp_rp5700_verbs[] = {
10413 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10414 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10415 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10416 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10417 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10418 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10419 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10420 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10421 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10422 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10423 {}
10424};
10425
10426static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10427 .num_items = 1,
10428 .items = {
10429 { "Line", 0x1 },
10430 },
10431};
10432
Takashi Iwai42171c12009-05-08 14:11:43 +020010433/* bind hp and internal speaker mute (with plug check) as master switch */
10434static void alc262_hippo_master_update(struct hda_codec *codec)
10435{
10436 struct alc_spec *spec = codec->spec;
10437 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10438 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10439 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10440 unsigned int mute;
10441
10442 /* HP */
10443 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10444 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10445 HDA_AMP_MUTE, mute);
10446 /* mute internal speaker per jack sense */
10447 if (spec->jack_present)
10448 mute = HDA_AMP_MUTE;
10449 if (line_nid)
10450 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10451 HDA_AMP_MUTE, mute);
10452 if (speaker_nid && speaker_nid != line_nid)
10453 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10454 HDA_AMP_MUTE, mute);
10455}
10456
10457#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10458
10459static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10460 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010461{
10462 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010463 struct alc_spec *spec = codec->spec;
10464 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010465
Takashi Iwai42171c12009-05-08 14:11:43 +020010466 if (val == spec->master_sw)
10467 return 0;
10468 spec->master_sw = val;
10469 alc262_hippo_master_update(codec);
10470 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010471}
Takashi Iwai5b319542007-07-26 11:49:22 +020010472
Takashi Iwai42171c12009-05-08 14:11:43 +020010473#define ALC262_HIPPO_MASTER_SWITCH \
10474 { \
10475 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10476 .name = "Master Playback Switch", \
10477 .info = snd_ctl_boolean_mono_info, \
10478 .get = alc262_hippo_master_sw_get, \
10479 .put = alc262_hippo_master_sw_put, \
10480 }
10481
10482static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10483 ALC262_HIPPO_MASTER_SWITCH,
10484 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10485 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10486 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10487 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10488 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10489 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10490 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10491 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10492 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10493 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10494 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10495 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10496 { } /* end */
10497};
10498
10499static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10500 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10501 ALC262_HIPPO_MASTER_SWITCH,
10502 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10503 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10504 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10505 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10506 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10507 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10508 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10509 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10510 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10511 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10512 { } /* end */
10513};
10514
10515/* mute/unmute internal speaker according to the hp jack and mute state */
10516static void alc262_hippo_automute(struct hda_codec *codec)
10517{
10518 struct alc_spec *spec = codec->spec;
10519 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020010520
Wu Fengguang864f92b2009-11-18 12:38:02 +080010521 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020010522 alc262_hippo_master_update(codec);
10523}
10524
10525static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10526{
10527 if ((res >> 26) != ALC880_HP_EVENT)
10528 return;
10529 alc262_hippo_automute(codec);
10530}
10531
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010532static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010533{
10534 struct alc_spec *spec = codec->spec;
10535
10536 spec->autocfg.hp_pins[0] = 0x15;
10537 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010538}
10539
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010540static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010541{
10542 struct alc_spec *spec = codec->spec;
10543
10544 spec->autocfg.hp_pins[0] = 0x1b;
10545 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010546}
10547
10548
Kailang Yang272a5272007-05-14 11:00:38 +020010549static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010550 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010551 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010552 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10553 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10554 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10555 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10556 { } /* end */
10557};
10558
Kailang Yang83c34212007-07-05 11:43:05 +020010559static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010560 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10561 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010562 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10563 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10564 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10565 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10566 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10567 { } /* end */
10568};
Kailang Yang272a5272007-05-14 11:00:38 +020010569
Tony Vroonba340e82009-02-02 19:01:30 +000010570static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10571 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10572 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10573 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10574 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10575 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10576 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10577 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10578 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10579 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10580 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10581 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10582 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10583 { } /* end */
10584};
10585
10586static struct hda_verb alc262_tyan_verbs[] = {
10587 /* Headphone automute */
10588 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10589 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10590 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10591
10592 /* P11 AUX_IN, white 4-pin connector */
10593 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10594 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10595 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10596 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10597
10598 {}
10599};
10600
10601/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010602static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010603{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010604 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010605
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010606 spec->autocfg.hp_pins[0] = 0x1b;
10607 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010608}
10609
Tony Vroonba340e82009-02-02 19:01:30 +000010610
Kailang Yangdf694da2005-12-05 19:42:22 +010010611#define alc262_capture_mixer alc882_capture_mixer
10612#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10613
10614/*
10615 * generic initialization of ADC, input mixers and output mixers
10616 */
10617static struct hda_verb alc262_init_verbs[] = {
10618 /*
10619 * Unmute ADC0-2 and set the default input to mic-in
10620 */
10621 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10622 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10623 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10624 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10625 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10626 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10627
Takashi Iwaicb53c622007-08-10 17:21:45 +020010628 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010629 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010630 * Note: PASD motherboards uses the Line In 2 as the input for
10631 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010632 */
10633 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010634 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10635 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10636 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10637 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10638 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010639
10640 /*
10641 * Set up output mixers (0x0c - 0x0e)
10642 */
10643 /* set vol=0 to output mixers */
10644 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10645 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10646 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10647 /* set up input amps for analog loopback */
10648 /* Amp Indices: DAC = 0, mixer = 1 */
10649 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10650 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10651 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10652 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10653 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10654 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10655
10656 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10657 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10658 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10659 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10660 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10661 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10662
10663 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10664 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10665 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10666 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10667 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010668
Kailang Yangdf694da2005-12-05 19:42:22 +010010669 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10670 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010671
Kailang Yangdf694da2005-12-05 19:42:22 +010010672 /* FIXME: use matrix-type input source selection */
10673 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10674 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10675 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10676 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10677 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10678 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10679 /* Input mixer2 */
10680 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10681 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10682 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10683 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10684 /* Input mixer3 */
10685 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10686 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10687 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010688 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010689
10690 { }
10691};
10692
Kailang Yang4e555fe2008-08-26 13:05:55 +020010693static struct hda_verb alc262_eapd_verbs[] = {
10694 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10695 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10696 { }
10697};
10698
Kailang Yangccc656c2006-10-17 12:32:26 +020010699static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10700 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10701 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10702 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10703
10704 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10705 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10706 {}
10707};
10708
Kailang Yang272a5272007-05-14 11:00:38 +020010709static struct hda_verb alc262_sony_unsol_verbs[] = {
10710 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10711 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10712 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10713
10714 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10715 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010716 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010717};
10718
Kailang Yang4e555fe2008-08-26 13:05:55 +020010719static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10720 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10721 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10722 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10723 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10724 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010725 { } /* end */
10726};
10727
10728static struct hda_verb alc262_toshiba_s06_verbs[] = {
10729 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10730 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10731 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10732 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10733 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10734 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10735 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10736 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10737 {}
10738};
10739
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010740static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020010741{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010742 struct alc_spec *spec = codec->spec;
10743
10744 spec->autocfg.hp_pins[0] = 0x15;
10745 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010746 spec->ext_mic.pin = 0x18;
10747 spec->ext_mic.mux_idx = 0;
10748 spec->int_mic.pin = 0x12;
10749 spec->int_mic.mux_idx = 9;
10750 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020010751}
10752
Takashi Iwai834be882006-03-01 14:16:17 +010010753/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010754 * nec model
10755 * 0x15 = headphone
10756 * 0x16 = internal speaker
10757 * 0x18 = external mic
10758 */
10759
10760static struct snd_kcontrol_new alc262_nec_mixer[] = {
10761 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10762 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10763
10764 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10765 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10766 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10767
10768 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10769 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10770 { } /* end */
10771};
10772
10773static struct hda_verb alc262_nec_verbs[] = {
10774 /* Unmute Speaker */
10775 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10776
10777 /* Headphone */
10778 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10779 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10780
10781 /* External mic to headphone */
10782 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10783 /* External mic to speaker */
10784 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10785 {}
10786};
10787
10788/*
Takashi Iwai834be882006-03-01 14:16:17 +010010789 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010790 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10791 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010792 */
10793
10794#define ALC_HP_EVENT 0x37
10795
10796static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10797 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10798 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010799 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10800 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010801 {}
10802};
10803
Jiang zhe0e31daf2008-03-20 12:12:39 +010010804static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10805 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10806 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10807 {}
10808};
10809
Daniel T Chene2595322009-12-19 18:19:02 -050010810static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
10811 /* Front Mic pin: input vref at 50% */
10812 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10813 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10814 {}
10815};
10816
Takashi Iwai834be882006-03-01 14:16:17 +010010817static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010818 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010819 .items = {
10820 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010821 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010822 { "CD", 0x4 },
10823 },
10824};
10825
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010826static struct hda_input_mux alc262_HP_capture_source = {
10827 .num_items = 5,
10828 .items = {
10829 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010830 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010831 { "Line", 0x2 },
10832 { "CD", 0x4 },
10833 { "AUX IN", 0x6 },
10834 },
10835};
10836
zhejiangaccbe492007-08-31 12:36:05 +020010837static struct hda_input_mux alc262_HP_D7000_capture_source = {
10838 .num_items = 4,
10839 .items = {
10840 { "Mic", 0x0 },
10841 { "Front Mic", 0x2 },
10842 { "Line", 0x1 },
10843 { "CD", 0x4 },
10844 },
10845};
10846
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010847/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010848static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10849{
10850 struct alc_spec *spec = codec->spec;
10851 unsigned int mute;
10852
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010853 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080010854 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
10855 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010010856 spec->sense_updated = 1;
10857 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010858 /* unmute internal speaker only if both HPs are unplugged and
10859 * master switch is on
10860 */
10861 if (spec->jack_present)
10862 mute = HDA_AMP_MUTE;
10863 else
Takashi Iwai834be882006-03-01 14:16:17 +010010864 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010865 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10866 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010867}
10868
10869/* unsolicited event for HP jack sensing */
10870static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10871 unsigned int res)
10872{
10873 if ((res >> 26) != ALC_HP_EVENT)
10874 return;
10875 alc262_fujitsu_automute(codec, 1);
10876}
10877
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010878static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10879{
10880 alc262_fujitsu_automute(codec, 1);
10881}
10882
Takashi Iwai834be882006-03-01 14:16:17 +010010883/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010884static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10885 .ops = &snd_hda_bind_vol,
10886 .values = {
10887 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10888 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10889 0
10890 },
10891};
Takashi Iwai834be882006-03-01 14:16:17 +010010892
Jiang zhe0e31daf2008-03-20 12:12:39 +010010893/* mute/unmute internal speaker according to the hp jack and mute state */
10894static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10895{
10896 struct alc_spec *spec = codec->spec;
10897 unsigned int mute;
10898
10899 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080010900 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010901 spec->sense_updated = 1;
10902 }
10903 if (spec->jack_present) {
10904 /* mute internal speaker */
10905 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10906 HDA_AMP_MUTE, HDA_AMP_MUTE);
10907 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10908 HDA_AMP_MUTE, HDA_AMP_MUTE);
10909 } else {
10910 /* unmute internal speaker if necessary */
10911 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10912 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10913 HDA_AMP_MUTE, mute);
10914 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10915 HDA_AMP_MUTE, mute);
10916 }
10917}
10918
10919/* unsolicited event for HP jack sensing */
10920static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10921 unsigned int res)
10922{
10923 if ((res >> 26) != ALC_HP_EVENT)
10924 return;
10925 alc262_lenovo_3000_automute(codec, 1);
10926}
10927
Takashi Iwai8de56b72009-07-24 16:51:47 +020010928static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10929 int dir, int idx, long *valp)
10930{
10931 int i, change = 0;
10932
10933 for (i = 0; i < 2; i++, valp++)
10934 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10935 HDA_AMP_MUTE,
10936 *valp ? 0 : HDA_AMP_MUTE);
10937 return change;
10938}
10939
Takashi Iwai834be882006-03-01 14:16:17 +010010940/* bind hp and internal speaker mute (with plug check) */
10941static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10942 struct snd_ctl_elem_value *ucontrol)
10943{
10944 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10945 long *valp = ucontrol->value.integer.value;
10946 int change;
10947
Takashi Iwai8de56b72009-07-24 16:51:47 +020010948 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10949 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010950 if (change)
10951 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010952 return change;
10953}
10954
10955static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010956 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010957 {
10958 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10959 .name = "Master Playback Switch",
10960 .info = snd_hda_mixer_amp_switch_info,
10961 .get = snd_hda_mixer_amp_switch_get,
10962 .put = alc262_fujitsu_master_sw_put,
10963 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10964 },
10965 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10966 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10967 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10968 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10969 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010970 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10971 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10972 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010973 { } /* end */
10974};
10975
Jiang zhe0e31daf2008-03-20 12:12:39 +010010976/* bind hp and internal speaker mute (with plug check) */
10977static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10978 struct snd_ctl_elem_value *ucontrol)
10979{
10980 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10981 long *valp = ucontrol->value.integer.value;
10982 int change;
10983
Takashi Iwai8de56b72009-07-24 16:51:47 +020010984 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010985 if (change)
10986 alc262_lenovo_3000_automute(codec, 0);
10987 return change;
10988}
10989
10990static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10991 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10992 {
10993 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10994 .name = "Master Playback Switch",
10995 .info = snd_hda_mixer_amp_switch_info,
10996 .get = snd_hda_mixer_amp_switch_get,
10997 .put = alc262_lenovo_3000_master_sw_put,
10998 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10999 },
11000 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11001 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11002 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11003 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11004 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11005 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11006 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11007 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11008 { } /* end */
11009};
11010
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011011static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11012 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011013 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011014 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11015 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11016 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11017 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11018 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11019 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11020 { } /* end */
11021};
11022
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011023/* additional init verbs for Benq laptops */
11024static struct hda_verb alc262_EAPD_verbs[] = {
11025 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11026 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11027 {}
11028};
11029
Kailang Yang83c34212007-07-05 11:43:05 +020011030static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11031 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11032 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11033
11034 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11035 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11036 {}
11037};
11038
Tobin Davisf651b502007-10-26 12:40:47 +020011039/* Samsung Q1 Ultra Vista model setup */
11040static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011041 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11042 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011043 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11044 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11045 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011046 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011047 { } /* end */
11048};
11049
11050static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011051 /* output mixer */
11052 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11053 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11054 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11055 /* speaker */
11056 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11057 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11058 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11059 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11060 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011061 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011062 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11063 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11064 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11065 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11066 /* internal mic */
11067 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11068 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11069 /* ADC, choose mic */
11070 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11071 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11072 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11073 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11074 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11075 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11076 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11077 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11078 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11079 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011080 {}
11081};
11082
Tobin Davisf651b502007-10-26 12:40:47 +020011083/* mute/unmute internal speaker according to the hp jack and mute state */
11084static void alc262_ultra_automute(struct hda_codec *codec)
11085{
11086 struct alc_spec *spec = codec->spec;
11087 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011088
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011089 mute = 0;
11090 /* auto-mute only when HP is used as HP */
11091 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011092 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011093 if (spec->jack_present)
11094 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011095 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011096 /* mute/unmute internal speaker */
11097 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11098 HDA_AMP_MUTE, mute);
11099 /* mute/unmute HP */
11100 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11101 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011102}
11103
11104/* unsolicited event for HP jack sensing */
11105static void alc262_ultra_unsol_event(struct hda_codec *codec,
11106 unsigned int res)
11107{
11108 if ((res >> 26) != ALC880_HP_EVENT)
11109 return;
11110 alc262_ultra_automute(codec);
11111}
11112
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011113static struct hda_input_mux alc262_ultra_capture_source = {
11114 .num_items = 2,
11115 .items = {
11116 { "Mic", 0x1 },
11117 { "Headphone", 0x7 },
11118 },
11119};
11120
11121static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11122 struct snd_ctl_elem_value *ucontrol)
11123{
11124 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11125 struct alc_spec *spec = codec->spec;
11126 int ret;
11127
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011128 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011129 if (!ret)
11130 return 0;
11131 /* reprogram the HP pin as mic or HP according to the input source */
11132 snd_hda_codec_write_cache(codec, 0x15, 0,
11133 AC_VERB_SET_PIN_WIDGET_CONTROL,
11134 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11135 alc262_ultra_automute(codec); /* mute/unmute HP */
11136 return ret;
11137}
11138
11139static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11140 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11141 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11142 {
11143 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11144 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011145 .info = alc_mux_enum_info,
11146 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011147 .put = alc262_ultra_mux_enum_put,
11148 },
11149 { } /* end */
11150};
11151
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011152/* We use two mixers depending on the output pin; 0x16 is a mono output
11153 * and thus it's bound with a different mixer.
11154 * This function returns which mixer amp should be used.
11155 */
11156static int alc262_check_volbit(hda_nid_t nid)
11157{
11158 if (!nid)
11159 return 0;
11160 else if (nid == 0x16)
11161 return 2;
11162 else
11163 return 1;
11164}
11165
11166static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
11167 const char *pfx, int *vbits)
11168{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011169 unsigned long val;
11170 int vbit;
11171
11172 vbit = alc262_check_volbit(nid);
11173 if (!vbit)
11174 return 0;
11175 if (*vbits & vbit) /* a volume control for this mixer already there */
11176 return 0;
11177 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011178 if (vbit == 2)
11179 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11180 else
11181 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011182 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011183}
11184
11185static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
11186 const char *pfx)
11187{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011188 unsigned long val;
11189
11190 if (!nid)
11191 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011192 if (nid == 0x16)
11193 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11194 else
11195 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011196 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011197}
11198
Kailang Yangdf694da2005-12-05 19:42:22 +010011199/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011200static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11201 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011202{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011203 const char *pfx;
11204 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010011205 int err;
11206
11207 spec->multiout.num_dacs = 1; /* only use one dac */
11208 spec->multiout.dac_nids = spec->private_dac_nids;
11209 spec->multiout.dac_nids[0] = 2;
11210
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011211 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11212 pfx = "Master";
11213 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11214 pfx = "Speaker";
11215 else
11216 pfx = "Front";
11217 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11218 if (err < 0)
11219 return err;
11220 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11221 if (err < 0)
11222 return err;
11223 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11224 if (err < 0)
11225 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011226
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011227 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11228 alc262_check_volbit(cfg->speaker_pins[0]) |
11229 alc262_check_volbit(cfg->hp_pins[0]);
11230 if (vbits == 1 || vbits == 2)
11231 pfx = "Master"; /* only one mixer is used */
11232 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11233 pfx = "Speaker";
11234 else
11235 pfx = "Front";
11236 vbits = 0;
11237 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11238 if (err < 0)
11239 return err;
11240 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11241 &vbits);
11242 if (err < 0)
11243 return err;
11244 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11245 &vbits);
11246 if (err < 0)
11247 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011248 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011249}
11250
Takashi Iwai05f5f472009-08-25 13:10:18 +020011251#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010011252 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011253
11254/*
11255 * generic initialization of ADC, input mixers and output mixers
11256 */
11257static struct hda_verb alc262_volume_init_verbs[] = {
11258 /*
11259 * Unmute ADC0-2 and set the default input to mic-in
11260 */
11261 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11262 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11263 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11264 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11265 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11266 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11267
Takashi Iwaicb53c622007-08-10 17:21:45 +020011268 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011269 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011270 * Note: PASD motherboards uses the Line In 2 as the input for
11271 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011272 */
11273 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011274 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11275 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11276 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11277 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11278 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011279
11280 /*
11281 * Set up output mixers (0x0c - 0x0f)
11282 */
11283 /* set vol=0 to output mixers */
11284 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11285 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11286 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011287
Kailang Yangdf694da2005-12-05 19:42:22 +010011288 /* set up input amps for analog loopback */
11289 /* Amp Indices: DAC = 0, mixer = 1 */
11290 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11291 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11292 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11293 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11294 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11295 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11296
11297 /* FIXME: use matrix-type input source selection */
11298 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11299 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11300 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11301 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11302 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11303 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11304 /* Input mixer2 */
11305 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11306 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11307 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11308 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11309 /* Input mixer3 */
11310 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11311 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11312 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11313 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11314
11315 { }
11316};
11317
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011318static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11319 /*
11320 * Unmute ADC0-2 and set the default input to mic-in
11321 */
11322 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11323 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11324 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11325 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11326 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11327 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11328
Takashi Iwaicb53c622007-08-10 17:21:45 +020011329 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011330 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011331 * Note: PASD motherboards uses the Line In 2 as the input for
11332 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011333 */
11334 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011335 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11336 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11337 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11338 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11339 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11340 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11341 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011342
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011343 /*
11344 * Set up output mixers (0x0c - 0x0e)
11345 */
11346 /* set vol=0 to output mixers */
11347 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11348 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11349 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11350
11351 /* set up input amps for analog loopback */
11352 /* Amp Indices: DAC = 0, mixer = 1 */
11353 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11354 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11355 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11356 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11357 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11358 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11359
Takashi Iwaice875f02008-01-28 18:17:43 +010011360 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011361 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11362 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11363
11364 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11365 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11366
11367 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11368 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11369
11370 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11371 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11372 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11373 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11374 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11375
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011376 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011377 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11378 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011379 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011380 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11381 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11382
11383
11384 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011385 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11386 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011387 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011388 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11389 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11390 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11391 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11392 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11393 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11394 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11395 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011396 /* Input mixer2 */
11397 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011398 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11399 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11400 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11401 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11402 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11403 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11404 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11405 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011406 /* Input mixer3 */
11407 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011408 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11409 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11410 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11411 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11412 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11413 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11414 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11415 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011416
Takashi Iwaice875f02008-01-28 18:17:43 +010011417 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11418
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011419 { }
11420};
11421
Kailang Yangcd7509a2007-01-26 18:33:17 +010011422static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11423 /*
11424 * Unmute ADC0-2 and set the default input to mic-in
11425 */
11426 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11427 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11428 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11429 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11430 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11431 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11432
Takashi Iwaicb53c622007-08-10 17:21:45 +020011433 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011434 * mixer widget
11435 * Note: PASD motherboards uses the Line In 2 as the input for front
11436 * panel mic (mic 2)
11437 */
11438 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011439 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11440 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11441 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11442 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11443 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11444 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11445 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11446 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011447 /*
11448 * Set up output mixers (0x0c - 0x0e)
11449 */
11450 /* set vol=0 to output mixers */
11451 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11452 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11453 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11454
11455 /* set up input amps for analog loopback */
11456 /* Amp Indices: DAC = 0, mixer = 1 */
11457 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11458 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11459 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11460 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11461 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11462 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11463
11464
11465 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11466 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11467 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11468 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11469 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11470 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11471 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11472
11473 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11474 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11475
11476 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11477 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11478
11479 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11480 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11481 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11482 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11483 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11484 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11485
11486 /* FIXME: use matrix-type input source selection */
11487 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11488 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11489 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11490 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11491 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11492 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11493 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11494 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11495 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11496 /* Input mixer2 */
11497 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11498 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11499 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11500 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11501 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11502 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11503 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11504 /* Input mixer3 */
11505 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11506 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11507 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11508 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11509 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11510 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11511 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11512
Takashi Iwaice875f02008-01-28 18:17:43 +010011513 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11514
Kailang Yangcd7509a2007-01-26 18:33:17 +010011515 { }
11516};
11517
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011518static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11519
11520 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11521 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11522 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11523
11524 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11525 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11526 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11527 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11528
11529 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11530 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11531 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11532 {}
11533};
11534
11535
Takashi Iwaicb53c622007-08-10 17:21:45 +020011536#ifdef CONFIG_SND_HDA_POWER_SAVE
11537#define alc262_loopbacks alc880_loopbacks
11538#endif
11539
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011540/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011541#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11542#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11543#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11544#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11545
11546/*
11547 * BIOS auto configuration
11548 */
11549static int alc262_parse_auto_config(struct hda_codec *codec)
11550{
11551 struct alc_spec *spec = codec->spec;
11552 int err;
11553 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11554
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011555 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11556 alc262_ignore);
11557 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011558 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011559 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011560 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011561 spec->multiout.max_channels = 2;
11562 spec->no_analog = 1;
11563 goto dig_only;
11564 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011565 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011566 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011567 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11568 if (err < 0)
11569 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011570 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011571 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011572 return err;
11573
11574 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11575
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011576 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011577 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011578 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011579 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011580 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011581 if (spec->autocfg.dig_in_pin)
11582 spec->dig_in_nid = ALC262_DIGIN_NID;
11583
Takashi Iwai603c4012008-07-30 15:01:44 +020011584 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011585 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011586
Takashi Iwaid88897e2008-10-31 15:01:37 +010011587 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011588 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011589 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011590
Takashi Iwai776e1842007-08-29 15:07:11 +020011591 err = alc_auto_add_mic_boost(codec);
11592 if (err < 0)
11593 return err;
11594
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011595 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11596
Kailang Yangdf694da2005-12-05 19:42:22 +010011597 return 1;
11598}
11599
11600#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11601#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11602#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011603#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011604
11605
11606/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011607static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011608{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011609 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011610 alc262_auto_init_multi_out(codec);
11611 alc262_auto_init_hp_out(codec);
11612 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011613 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011614 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011615 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011616}
11617
11618/*
11619 * configuration and preset
11620 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011621static const char *alc262_models[ALC262_MODEL_LAST] = {
11622 [ALC262_BASIC] = "basic",
11623 [ALC262_HIPPO] = "hippo",
11624 [ALC262_HIPPO_1] = "hippo_1",
11625 [ALC262_FUJITSU] = "fujitsu",
11626 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011627 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011628 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011629 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011630 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011631 [ALC262_BENQ_T31] = "benq-t31",
11632 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011633 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011634 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011635 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011636 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011637 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011638 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011639 [ALC262_AUTO] = "auto",
11640};
11641
11642static struct snd_pci_quirk alc262_cfg_tbl[] = {
11643 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011644 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011645 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11646 ALC262_HP_BPC),
11647 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11648 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011649 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11650 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011651 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011652 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011653 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011654 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011655 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011656 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011657 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011658 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011659 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11660 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11661 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011662 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11663 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011664 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011665 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011666 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011667 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011668 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011669 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050011670 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010011671 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011672#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010011673 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11674 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011675#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090011676 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011677 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011678 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011679 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011680 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011681 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011682 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11683 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011684 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011685 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011686 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011687 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011688 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011689 {}
11690};
11691
11692static struct alc_config_preset alc262_presets[] = {
11693 [ALC262_BASIC] = {
11694 .mixers = { alc262_base_mixer },
11695 .init_verbs = { alc262_init_verbs },
11696 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11697 .dac_nids = alc262_dac_nids,
11698 .hp_nid = 0x03,
11699 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11700 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011701 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011702 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011703 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011704 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011705 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011706 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11707 .dac_nids = alc262_dac_nids,
11708 .hp_nid = 0x03,
11709 .dig_out_nid = ALC262_DIGOUT_NID,
11710 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11711 .channel_mode = alc262_modes,
11712 .input_mux = &alc262_capture_source,
11713 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011714 .setup = alc262_hippo_setup,
11715 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011716 },
11717 [ALC262_HIPPO_1] = {
11718 .mixers = { alc262_hippo1_mixer },
11719 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11720 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11721 .dac_nids = alc262_dac_nids,
11722 .hp_nid = 0x02,
11723 .dig_out_nid = ALC262_DIGOUT_NID,
11724 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11725 .channel_mode = alc262_modes,
11726 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011727 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011728 .setup = alc262_hippo1_setup,
11729 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011730 },
Takashi Iwai834be882006-03-01 14:16:17 +010011731 [ALC262_FUJITSU] = {
11732 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011733 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11734 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011735 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11736 .dac_nids = alc262_dac_nids,
11737 .hp_nid = 0x03,
11738 .dig_out_nid = ALC262_DIGOUT_NID,
11739 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11740 .channel_mode = alc262_modes,
11741 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011742 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011743 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011744 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011745 [ALC262_HP_BPC] = {
11746 .mixers = { alc262_HP_BPC_mixer },
11747 .init_verbs = { alc262_HP_BPC_init_verbs },
11748 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11749 .dac_nids = alc262_dac_nids,
11750 .hp_nid = 0x03,
11751 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11752 .channel_mode = alc262_modes,
11753 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011754 .unsol_event = alc262_hp_bpc_unsol_event,
11755 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011756 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011757 [ALC262_HP_BPC_D7000_WF] = {
11758 .mixers = { alc262_HP_BPC_WildWest_mixer },
11759 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11760 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11761 .dac_nids = alc262_dac_nids,
11762 .hp_nid = 0x03,
11763 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11764 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011765 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011766 .unsol_event = alc262_hp_wildwest_unsol_event,
11767 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011768 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011769 [ALC262_HP_BPC_D7000_WL] = {
11770 .mixers = { alc262_HP_BPC_WildWest_mixer,
11771 alc262_HP_BPC_WildWest_option_mixer },
11772 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11773 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11774 .dac_nids = alc262_dac_nids,
11775 .hp_nid = 0x03,
11776 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11777 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011778 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011779 .unsol_event = alc262_hp_wildwest_unsol_event,
11780 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011781 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011782 [ALC262_HP_TC_T5735] = {
11783 .mixers = { alc262_hp_t5735_mixer },
11784 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11785 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11786 .dac_nids = alc262_dac_nids,
11787 .hp_nid = 0x03,
11788 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11789 .channel_mode = alc262_modes,
11790 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011791 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011792 .setup = alc262_hp_t5735_setup,
11793 .init_hook = alc_automute_amp,
Kailang Yang8c427222008-01-10 13:03:59 +010011794 },
11795 [ALC262_HP_RP5700] = {
11796 .mixers = { alc262_hp_rp5700_mixer },
11797 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11798 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11799 .dac_nids = alc262_dac_nids,
11800 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11801 .channel_mode = alc262_modes,
11802 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011803 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011804 [ALC262_BENQ_ED8] = {
11805 .mixers = { alc262_base_mixer },
11806 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11807 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11808 .dac_nids = alc262_dac_nids,
11809 .hp_nid = 0x03,
11810 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11811 .channel_mode = alc262_modes,
11812 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011813 },
Kailang Yang272a5272007-05-14 11:00:38 +020011814 [ALC262_SONY_ASSAMD] = {
11815 .mixers = { alc262_sony_mixer },
11816 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11817 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11818 .dac_nids = alc262_dac_nids,
11819 .hp_nid = 0x02,
11820 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11821 .channel_mode = alc262_modes,
11822 .input_mux = &alc262_capture_source,
11823 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011824 .setup = alc262_hippo_setup,
11825 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020011826 },
11827 [ALC262_BENQ_T31] = {
11828 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011829 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
11830 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020011831 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11832 .dac_nids = alc262_dac_nids,
11833 .hp_nid = 0x03,
11834 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11835 .channel_mode = alc262_modes,
11836 .input_mux = &alc262_capture_source,
11837 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011838 .setup = alc262_hippo_setup,
11839 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020011840 },
Tobin Davisf651b502007-10-26 12:40:47 +020011841 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011842 .mixers = { alc262_ultra_mixer },
11843 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011844 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011845 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11846 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011847 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11848 .channel_mode = alc262_modes,
11849 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011850 .adc_nids = alc262_adc_nids, /* ADC0 */
11851 .capsrc_nids = alc262_capsrc_nids,
11852 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011853 .unsol_event = alc262_ultra_unsol_event,
11854 .init_hook = alc262_ultra_automute,
11855 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011856 [ALC262_LENOVO_3000] = {
11857 .mixers = { alc262_lenovo_3000_mixer },
11858 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050011859 alc262_lenovo_3000_unsol_verbs,
11860 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011861 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11862 .dac_nids = alc262_dac_nids,
11863 .hp_nid = 0x03,
11864 .dig_out_nid = ALC262_DIGOUT_NID,
11865 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11866 .channel_mode = alc262_modes,
11867 .input_mux = &alc262_fujitsu_capture_source,
11868 .unsol_event = alc262_lenovo_3000_unsol_event,
11869 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011870 [ALC262_NEC] = {
11871 .mixers = { alc262_nec_mixer },
11872 .init_verbs = { alc262_nec_verbs },
11873 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11874 .dac_nids = alc262_dac_nids,
11875 .hp_nid = 0x03,
11876 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11877 .channel_mode = alc262_modes,
11878 .input_mux = &alc262_capture_source,
11879 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011880 [ALC262_TOSHIBA_S06] = {
11881 .mixers = { alc262_toshiba_s06_mixer },
11882 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11883 alc262_eapd_verbs },
11884 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11885 .capsrc_nids = alc262_dmic_capsrc_nids,
11886 .dac_nids = alc262_dac_nids,
11887 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011888 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011889 .dig_out_nid = ALC262_DIGOUT_NID,
11890 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11891 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011892 .unsol_event = alc_sku_unsol_event,
11893 .setup = alc262_toshiba_s06_setup,
11894 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020011895 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011896 [ALC262_TOSHIBA_RX1] = {
11897 .mixers = { alc262_toshiba_rx1_mixer },
11898 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11899 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11900 .dac_nids = alc262_dac_nids,
11901 .hp_nid = 0x03,
11902 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11903 .channel_mode = alc262_modes,
11904 .input_mux = &alc262_capture_source,
11905 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011906 .setup = alc262_hippo_setup,
11907 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011908 },
Tony Vroonba340e82009-02-02 19:01:30 +000011909 [ALC262_TYAN] = {
11910 .mixers = { alc262_tyan_mixer },
11911 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11912 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11913 .dac_nids = alc262_dac_nids,
11914 .hp_nid = 0x02,
11915 .dig_out_nid = ALC262_DIGOUT_NID,
11916 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11917 .channel_mode = alc262_modes,
11918 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011919 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011920 .setup = alc262_tyan_setup,
11921 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000011922 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011923};
11924
11925static int patch_alc262(struct hda_codec *codec)
11926{
11927 struct alc_spec *spec;
11928 int board_config;
11929 int err;
11930
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011931 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011932 if (spec == NULL)
11933 return -ENOMEM;
11934
11935 codec->spec = spec;
11936#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011937 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11938 * under-run
11939 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011940 {
11941 int tmp;
11942 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11943 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11944 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11945 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11946 }
11947#endif
11948
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011949 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11950
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011951 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11952 alc262_models,
11953 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011954
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011955 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011956 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11957 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011958 board_config = ALC262_AUTO;
11959 }
11960
11961 if (board_config == ALC262_AUTO) {
11962 /* automatic parse from the BIOS config */
11963 err = alc262_parse_auto_config(codec);
11964 if (err < 0) {
11965 alc_free(codec);
11966 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011967 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011968 printk(KERN_INFO
11969 "hda_codec: Cannot set up configuration "
11970 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011971 board_config = ALC262_BASIC;
11972 }
11973 }
11974
Takashi Iwai07eba612009-02-19 08:06:35 +010011975 if (!spec->no_analog) {
11976 err = snd_hda_attach_beep_device(codec, 0x1);
11977 if (err < 0) {
11978 alc_free(codec);
11979 return err;
11980 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011981 }
11982
Kailang Yangdf694da2005-12-05 19:42:22 +010011983 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011984 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011985
Kailang Yangdf694da2005-12-05 19:42:22 +010011986 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11987 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011988
Kailang Yangdf694da2005-12-05 19:42:22 +010011989 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11990 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11991
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011992 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011993 int i;
11994 /* check whether the digital-mic has to be supported */
11995 for (i = 0; i < spec->input_mux->num_items; i++) {
11996 if (spec->input_mux->items[i].index >= 9)
11997 break;
11998 }
11999 if (i < spec->input_mux->num_items) {
12000 /* use only ADC0 */
12001 spec->adc_nids = alc262_dmic_adc_nids;
12002 spec->num_adc_nids = 1;
12003 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012004 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012005 /* all analog inputs */
12006 /* check whether NID 0x07 is valid */
12007 unsigned int wcap = get_wcaps(codec, 0x07);
12008
12009 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012010 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012011 if (wcap != AC_WID_AUD_IN) {
12012 spec->adc_nids = alc262_adc_nids_alt;
12013 spec->num_adc_nids =
12014 ARRAY_SIZE(alc262_adc_nids_alt);
12015 spec->capsrc_nids = alc262_capsrc_nids_alt;
12016 } else {
12017 spec->adc_nids = alc262_adc_nids;
12018 spec->num_adc_nids =
12019 ARRAY_SIZE(alc262_adc_nids);
12020 spec->capsrc_nids = alc262_capsrc_nids;
12021 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012022 }
12023 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012024 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012025 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010012026 if (!spec->no_analog)
12027 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012028
Takashi Iwai2134ea42008-01-10 16:53:55 +010012029 spec->vmaster_nid = 0x0c;
12030
Kailang Yangdf694da2005-12-05 19:42:22 +010012031 codec->patch_ops = alc_patch_ops;
12032 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012033 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012034#ifdef CONFIG_SND_HDA_POWER_SAVE
12035 if (!spec->loopback.amplist)
12036 spec->loopback.amplist = alc262_loopbacks;
12037#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010012038 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020012039
Kailang Yangdf694da2005-12-05 19:42:22 +010012040 return 0;
12041}
12042
Kailang Yangdf694da2005-12-05 19:42:22 +010012043/*
Kailang Yanga361d842007-06-05 12:30:55 +020012044 * ALC268 channel source setting (2 channel)
12045 */
12046#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12047#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012048
Kailang Yanga361d842007-06-05 12:30:55 +020012049static hda_nid_t alc268_dac_nids[2] = {
12050 /* front, hp */
12051 0x02, 0x03
12052};
12053
12054static hda_nid_t alc268_adc_nids[2] = {
12055 /* ADC0-1 */
12056 0x08, 0x07
12057};
12058
12059static hda_nid_t alc268_adc_nids_alt[1] = {
12060 /* ADC0 */
12061 0x08
12062};
12063
Takashi Iwaie1406342008-02-11 18:32:32 +010012064static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12065
Kailang Yanga361d842007-06-05 12:30:55 +020012066static struct snd_kcontrol_new alc268_base_mixer[] = {
12067 /* output mixer control */
12068 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12069 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12070 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12071 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012072 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12073 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12074 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012075 { }
12076};
12077
Takashi Iwai42171c12009-05-08 14:11:43 +020012078static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12079 /* output mixer control */
12080 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12081 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12082 ALC262_HIPPO_MASTER_SWITCH,
12083 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12084 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12085 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12086 { }
12087};
12088
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012089/* bind Beep switches of both NID 0x0f and 0x10 */
12090static struct hda_bind_ctls alc268_bind_beep_sw = {
12091 .ops = &snd_hda_bind_sw,
12092 .values = {
12093 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12094 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12095 0
12096 },
12097};
12098
12099static struct snd_kcontrol_new alc268_beep_mixer[] = {
12100 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12101 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12102 { }
12103};
12104
Kailang Yangd1a991a2007-08-15 16:21:59 +020012105static struct hda_verb alc268_eapd_verbs[] = {
12106 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12107 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12108 { }
12109};
12110
Takashi Iwaid2738092007-08-16 14:59:45 +020012111/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012112static struct hda_verb alc268_toshiba_verbs[] = {
12113 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12114 { } /* end */
12115};
12116
12117/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012118/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012119static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12120 .ops = &snd_hda_bind_vol,
12121 .values = {
12122 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12123 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12124 0
12125 },
12126};
12127
Takashi Iwai889c4392007-08-23 18:56:52 +020012128/* mute/unmute internal speaker according to the hp jack and mute state */
12129static void alc268_acer_automute(struct hda_codec *codec, int force)
12130{
12131 struct alc_spec *spec = codec->spec;
12132 unsigned int mute;
12133
12134 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012135 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012136 spec->sense_updated = 1;
12137 }
12138 if (spec->jack_present)
12139 mute = HDA_AMP_MUTE; /* mute internal speaker */
12140 else /* unmute internal speaker if necessary */
12141 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12142 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12143 HDA_AMP_MUTE, mute);
12144}
12145
12146
12147/* bind hp and internal speaker mute (with plug check) */
12148static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12149 struct snd_ctl_elem_value *ucontrol)
12150{
12151 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12152 long *valp = ucontrol->value.integer.value;
12153 int change;
12154
Takashi Iwai8de56b72009-07-24 16:51:47 +020012155 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012156 if (change)
12157 alc268_acer_automute(codec, 0);
12158 return change;
12159}
Takashi Iwaid2738092007-08-16 14:59:45 +020012160
Kailang Yang8ef355d2008-08-26 13:10:22 +020012161static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12162 /* output mixer control */
12163 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12164 {
12165 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12166 .name = "Master Playback Switch",
12167 .info = snd_hda_mixer_amp_switch_info,
12168 .get = snd_hda_mixer_amp_switch_get,
12169 .put = alc268_acer_master_sw_put,
12170 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12171 },
12172 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12173 { }
12174};
12175
Takashi Iwaid2738092007-08-16 14:59:45 +020012176static struct snd_kcontrol_new alc268_acer_mixer[] = {
12177 /* output mixer control */
12178 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12179 {
12180 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12181 .name = "Master Playback Switch",
12182 .info = snd_hda_mixer_amp_switch_info,
12183 .get = snd_hda_mixer_amp_switch_get,
12184 .put = alc268_acer_master_sw_put,
12185 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12186 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012187 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12188 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12189 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012190 { }
12191};
12192
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012193static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12194 /* output mixer control */
12195 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12196 {
12197 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12198 .name = "Master Playback Switch",
12199 .info = snd_hda_mixer_amp_switch_info,
12200 .get = snd_hda_mixer_amp_switch_get,
12201 .put = alc268_acer_master_sw_put,
12202 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12203 },
12204 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12205 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12206 { }
12207};
12208
Kailang Yang8ef355d2008-08-26 13:10:22 +020012209static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12210 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12211 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12212 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12213 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12214 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12215 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12216 { }
12217};
12218
Takashi Iwaid2738092007-08-16 14:59:45 +020012219static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012220 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12221 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012222 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12223 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012224 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12225 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012226 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12227 { }
12228};
12229
12230/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012231#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012232#define alc268_toshiba_setup alc262_hippo_setup
12233#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012234
12235static void alc268_acer_unsol_event(struct hda_codec *codec,
12236 unsigned int res)
12237{
Takashi Iwai889c4392007-08-23 18:56:52 +020012238 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012239 return;
12240 alc268_acer_automute(codec, 1);
12241}
12242
Takashi Iwai889c4392007-08-23 18:56:52 +020012243static void alc268_acer_init_hook(struct hda_codec *codec)
12244{
12245 alc268_acer_automute(codec, 1);
12246}
12247
Kailang Yang8ef355d2008-08-26 13:10:22 +020012248/* toggle speaker-output according to the hp-jack state */
12249static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12250{
12251 unsigned int present;
12252 unsigned char bits;
12253
Wu Fengguang864f92b2009-11-18 12:38:02 +080012254 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012255 bits = present ? AMP_IN_MUTE(0) : 0;
12256 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
12257 AMP_IN_MUTE(0), bits);
12258 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
12259 AMP_IN_MUTE(0), bits);
12260}
12261
Kailang Yang8ef355d2008-08-26 13:10:22 +020012262static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12263 unsigned int res)
12264{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012265 switch (res >> 26) {
12266 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012267 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012268 break;
12269 case ALC880_MIC_EVENT:
12270 alc_mic_automute(codec);
12271 break;
12272 }
12273}
12274
12275static void alc268_acer_lc_setup(struct hda_codec *codec)
12276{
12277 struct alc_spec *spec = codec->spec;
12278 spec->ext_mic.pin = 0x18;
12279 spec->ext_mic.mux_idx = 0;
12280 spec->int_mic.pin = 0x12;
12281 spec->int_mic.mux_idx = 6;
12282 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012283}
12284
12285static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12286{
12287 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012288 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012289}
12290
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012291static struct snd_kcontrol_new alc268_dell_mixer[] = {
12292 /* output mixer control */
12293 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12294 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12295 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12296 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12297 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12298 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12299 { }
12300};
12301
12302static struct hda_verb alc268_dell_verbs[] = {
12303 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12304 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12305 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012306 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012307 { }
12308};
12309
12310/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012311static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012312{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012313 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012314
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012315 spec->autocfg.hp_pins[0] = 0x15;
12316 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012317 spec->ext_mic.pin = 0x18;
12318 spec->ext_mic.mux_idx = 0;
12319 spec->int_mic.pin = 0x19;
12320 spec->int_mic.mux_idx = 1;
12321 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012322}
12323
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012324static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12325 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12326 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12327 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12328 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12329 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12330 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12331 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12332 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12333 { }
12334};
12335
12336static struct hda_verb alc267_quanta_il1_verbs[] = {
12337 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12338 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12339 { }
12340};
12341
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012342static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012343{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012344 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012345 spec->autocfg.hp_pins[0] = 0x15;
12346 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012347 spec->ext_mic.pin = 0x18;
12348 spec->ext_mic.mux_idx = 0;
12349 spec->int_mic.pin = 0x19;
12350 spec->int_mic.mux_idx = 1;
12351 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012352}
12353
Kailang Yanga361d842007-06-05 12:30:55 +020012354/*
12355 * generic initialization of ADC, input mixers and output mixers
12356 */
12357static struct hda_verb alc268_base_init_verbs[] = {
12358 /* Unmute DAC0-1 and set vol = 0 */
12359 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012360 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012361
12362 /*
12363 * Set up output mixers (0x0c - 0x0e)
12364 */
12365 /* set vol=0 to output mixers */
12366 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012367 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12368
12369 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12370 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12371
12372 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12373 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12374 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12375 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12376 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12377 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12378 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12379 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12380
12381 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12382 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12383 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12384 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012385 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012386
12387 /* set PCBEEP vol = 0, mute connections */
12388 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12389 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12390 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012391
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012392 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012393
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012394 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12395 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12396 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12397 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012398
Kailang Yanga361d842007-06-05 12:30:55 +020012399 { }
12400};
12401
12402/*
12403 * generic initialization of ADC, input mixers and output mixers
12404 */
12405static struct hda_verb alc268_volume_init_verbs[] = {
12406 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012407 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12408 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012409
12410 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12411 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12412 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12413 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12414 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12415
Kailang Yanga361d842007-06-05 12:30:55 +020012416 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012417 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12418 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12419
12420 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012421 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012422
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012423 /* set PCBEEP vol = 0, mute connections */
12424 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12425 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12426 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012427
12428 { }
12429};
12430
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012431static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12432 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12433 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12434 { } /* end */
12435};
12436
Kailang Yanga361d842007-06-05 12:30:55 +020012437static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12438 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12439 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012440 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012441 { } /* end */
12442};
12443
12444static struct snd_kcontrol_new alc268_capture_mixer[] = {
12445 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12446 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12447 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12448 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012449 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012450 { } /* end */
12451};
12452
12453static struct hda_input_mux alc268_capture_source = {
12454 .num_items = 4,
12455 .items = {
12456 { "Mic", 0x0 },
12457 { "Front Mic", 0x1 },
12458 { "Line", 0x2 },
12459 { "CD", 0x3 },
12460 },
12461};
12462
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012463static struct hda_input_mux alc268_acer_capture_source = {
12464 .num_items = 3,
12465 .items = {
12466 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012467 { "Internal Mic", 0x1 },
12468 { "Line", 0x2 },
12469 },
12470};
12471
12472static struct hda_input_mux alc268_acer_dmic_capture_source = {
12473 .num_items = 3,
12474 .items = {
12475 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012476 { "Internal Mic", 0x6 },
12477 { "Line", 0x2 },
12478 },
12479};
12480
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012481#ifdef CONFIG_SND_DEBUG
12482static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012483 /* Volume widgets */
12484 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12485 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12486 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12487 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12488 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12489 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12490 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12491 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12492 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12493 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12494 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12495 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12496 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012497 /* The below appears problematic on some hardwares */
12498 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012499 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12500 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12501 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12502 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12503
12504 /* Modes for retasking pin widgets */
12505 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12506 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12507 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12508 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12509
12510 /* Controls for GPIO pins, assuming they are configured as outputs */
12511 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12512 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12513 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12514 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12515
12516 /* Switches to allow the digital SPDIF output pin to be enabled.
12517 * The ALC268 does not have an SPDIF input.
12518 */
12519 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12520
12521 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12522 * this output to turn on an external amplifier.
12523 */
12524 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12525 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12526
12527 { } /* end */
12528};
12529#endif
12530
Kailang Yanga361d842007-06-05 12:30:55 +020012531/* create input playback/capture controls for the given pin */
12532static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12533 const char *ctlname, int idx)
12534{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012535 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012536 int err;
12537
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012538 switch (nid) {
12539 case 0x14:
12540 case 0x16:
12541 dac = 0x02;
12542 break;
12543 case 0x15:
12544 dac = 0x03;
12545 break;
12546 default:
12547 return 0;
12548 }
12549 if (spec->multiout.dac_nids[0] != dac &&
12550 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012551 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012552 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012553 HDA_OUTPUT));
12554 if (err < 0)
12555 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012556 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12557 }
12558
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012559 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012560 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020012561 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012562 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012563 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012564 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012565 if (err < 0)
12566 return err;
12567 return 0;
12568}
12569
12570/* add playback controls from the parsed DAC table */
12571static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12572 const struct auto_pin_cfg *cfg)
12573{
12574 hda_nid_t nid;
12575 int err;
12576
Kailang Yanga361d842007-06-05 12:30:55 +020012577 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012578
12579 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012580 if (nid) {
12581 const char *name;
12582 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12583 name = "Speaker";
12584 else
12585 name = "Front";
12586 err = alc268_new_analog_output(spec, nid, name, 0);
12587 if (err < 0)
12588 return err;
12589 }
Kailang Yanga361d842007-06-05 12:30:55 +020012590
12591 nid = cfg->speaker_pins[0];
12592 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012593 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020012594 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12595 if (err < 0)
12596 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012597 } else {
12598 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12599 if (err < 0)
12600 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012601 }
12602 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012603 if (nid) {
12604 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12605 if (err < 0)
12606 return err;
12607 }
Kailang Yanga361d842007-06-05 12:30:55 +020012608
12609 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12610 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012611 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012612 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012613 if (err < 0)
12614 return err;
12615 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012616 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012617}
12618
12619/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020012620static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020012621 const struct auto_pin_cfg *cfg)
12622{
Takashi Iwai05f5f472009-08-25 13:10:18 +020012623 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020012624}
12625
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012626static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12627 hda_nid_t nid, int pin_type)
12628{
12629 int idx;
12630
12631 alc_set_pin_output(codec, nid, pin_type);
12632 if (nid == 0x14 || nid == 0x16)
12633 idx = 0;
12634 else
12635 idx = 1;
12636 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12637}
12638
12639static void alc268_auto_init_multi_out(struct hda_codec *codec)
12640{
12641 struct alc_spec *spec = codec->spec;
12642 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12643 if (nid) {
12644 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12645 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12646 }
12647}
12648
12649static void alc268_auto_init_hp_out(struct hda_codec *codec)
12650{
12651 struct alc_spec *spec = codec->spec;
12652 hda_nid_t pin;
12653
12654 pin = spec->autocfg.hp_pins[0];
12655 if (pin)
12656 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12657 pin = spec->autocfg.speaker_pins[0];
12658 if (pin)
12659 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12660}
12661
Kailang Yanga361d842007-06-05 12:30:55 +020012662static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12663{
12664 struct alc_spec *spec = codec->spec;
12665 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12666 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12667 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12668 unsigned int dac_vol1, dac_vol2;
12669
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012670 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020012671 snd_hda_codec_write(codec, speaker_nid, 0,
12672 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012673 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012674 snd_hda_codec_write(codec, 0x0f, 0,
12675 AC_VERB_SET_AMP_GAIN_MUTE,
12676 AMP_IN_UNMUTE(1));
12677 snd_hda_codec_write(codec, 0x10, 0,
12678 AC_VERB_SET_AMP_GAIN_MUTE,
12679 AMP_IN_UNMUTE(1));
12680 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012681 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012682 snd_hda_codec_write(codec, 0x0f, 0,
12683 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12684 snd_hda_codec_write(codec, 0x10, 0,
12685 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12686 }
12687
12688 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012689 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012690 dac_vol2 = AMP_OUT_ZERO;
12691 else if (line_nid == 0x15)
12692 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012693 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012694 dac_vol2 = AMP_OUT_ZERO;
12695 else if (hp_nid == 0x15)
12696 dac_vol1 = AMP_OUT_ZERO;
12697 if (line_nid != 0x16 || hp_nid != 0x16 ||
12698 spec->autocfg.line_out_pins[1] != 0x16 ||
12699 spec->autocfg.line_out_pins[2] != 0x16)
12700 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12701
12702 snd_hda_codec_write(codec, 0x02, 0,
12703 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12704 snd_hda_codec_write(codec, 0x03, 0,
12705 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12706}
12707
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012708/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012709#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12710#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012711#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012712#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12713
12714/*
12715 * BIOS auto configuration
12716 */
12717static int alc268_parse_auto_config(struct hda_codec *codec)
12718{
12719 struct alc_spec *spec = codec->spec;
12720 int err;
12721 static hda_nid_t alc268_ignore[] = { 0 };
12722
12723 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12724 alc268_ignore);
12725 if (err < 0)
12726 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012727 if (!spec->autocfg.line_outs) {
12728 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12729 spec->multiout.max_channels = 2;
12730 spec->no_analog = 1;
12731 goto dig_only;
12732 }
Kailang Yanga361d842007-06-05 12:30:55 +020012733 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012734 }
Kailang Yanga361d842007-06-05 12:30:55 +020012735 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12736 if (err < 0)
12737 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012738 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020012739 if (err < 0)
12740 return err;
12741
12742 spec->multiout.max_channels = 2;
12743
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012744 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012745 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012746 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012747 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012748 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12749 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012750 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012751 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012752
Takashi Iwai892981f2009-03-02 08:04:35 +010012753 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012754 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012755
Takashi Iwaid88897e2008-10-31 15:01:37 +010012756 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012757 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012758 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012759
Takashi Iwai776e1842007-08-29 15:07:11 +020012760 err = alc_auto_add_mic_boost(codec);
12761 if (err < 0)
12762 return err;
12763
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012764 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12765
Kailang Yanga361d842007-06-05 12:30:55 +020012766 return 1;
12767}
12768
Kailang Yanga361d842007-06-05 12:30:55 +020012769#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12770
12771/* init callback for auto-configuration model -- overriding the default init */
12772static void alc268_auto_init(struct hda_codec *codec)
12773{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012774 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012775 alc268_auto_init_multi_out(codec);
12776 alc268_auto_init_hp_out(codec);
12777 alc268_auto_init_mono_speaker_out(codec);
12778 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012779 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012780 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012781}
12782
12783/*
12784 * configuration and preset
12785 */
12786static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012787 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012788 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012789 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012790 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012791 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012792 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012793 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012794 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012795#ifdef CONFIG_SND_DEBUG
12796 [ALC268_TEST] = "test",
12797#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012798 [ALC268_AUTO] = "auto",
12799};
12800
12801static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012802 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012803 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012804 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012805 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012806 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012807 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12808 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012809 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050012810 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
12811 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020012812 /* almost compatible with toshiba but with optional digital outs;
12813 * auto-probing seems working fine
12814 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012815 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020012816 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020012817 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012818 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012819 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012820 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012821 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012822 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012823 {}
12824};
12825
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012826/* Toshiba laptops have no unique PCI SSID but only codec SSID */
12827static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
12828 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
12829 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
12830 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12831 ALC268_TOSHIBA),
12832 {}
12833};
12834
Kailang Yanga361d842007-06-05 12:30:55 +020012835static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012836 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012837 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
12838 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012839 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12840 alc267_quanta_il1_verbs },
12841 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12842 .dac_nids = alc268_dac_nids,
12843 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12844 .adc_nids = alc268_adc_nids_alt,
12845 .hp_nid = 0x03,
12846 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12847 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012848 .unsol_event = alc_sku_unsol_event,
12849 .setup = alc267_quanta_il1_setup,
12850 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012851 },
Kailang Yanga361d842007-06-05 12:30:55 +020012852 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012853 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12854 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012855 .init_verbs = { alc268_base_init_verbs },
12856 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12857 .dac_nids = alc268_dac_nids,
12858 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12859 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012860 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012861 .hp_nid = 0x03,
12862 .dig_out_nid = ALC268_DIGOUT_NID,
12863 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12864 .channel_mode = alc268_modes,
12865 .input_mux = &alc268_capture_source,
12866 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012867 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012868 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012869 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012870 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12871 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012872 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12873 .dac_nids = alc268_dac_nids,
12874 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12875 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012876 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012877 .hp_nid = 0x03,
12878 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12879 .channel_mode = alc268_modes,
12880 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012881 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012882 .setup = alc268_toshiba_setup,
12883 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020012884 },
12885 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020012886 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012887 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012888 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12889 alc268_acer_verbs },
12890 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12891 .dac_nids = alc268_dac_nids,
12892 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12893 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012894 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012895 .hp_nid = 0x02,
12896 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12897 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012898 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012899 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012900 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012901 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012902 [ALC268_ACER_DMIC] = {
12903 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12904 alc268_beep_mixer },
12905 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12906 alc268_acer_verbs },
12907 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12908 .dac_nids = alc268_dac_nids,
12909 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12910 .adc_nids = alc268_adc_nids_alt,
12911 .capsrc_nids = alc268_capsrc_nids,
12912 .hp_nid = 0x02,
12913 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12914 .channel_mode = alc268_modes,
12915 .input_mux = &alc268_acer_dmic_capture_source,
12916 .unsol_event = alc268_acer_unsol_event,
12917 .init_hook = alc268_acer_init_hook,
12918 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012919 [ALC268_ACER_ASPIRE_ONE] = {
12920 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012921 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012922 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012923 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12924 alc268_acer_aspire_one_verbs },
12925 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12926 .dac_nids = alc268_dac_nids,
12927 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12928 .adc_nids = alc268_adc_nids_alt,
12929 .capsrc_nids = alc268_capsrc_nids,
12930 .hp_nid = 0x03,
12931 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12932 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012933 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012934 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012935 .init_hook = alc268_acer_lc_init_hook,
12936 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012937 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012938 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
12939 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012940 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12941 alc268_dell_verbs },
12942 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12943 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012944 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12945 .adc_nids = alc268_adc_nids_alt,
12946 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012947 .hp_nid = 0x02,
12948 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12949 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012950 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012951 .setup = alc268_dell_setup,
12952 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012953 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012954 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012955 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12956 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012957 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12958 alc268_toshiba_verbs },
12959 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12960 .dac_nids = alc268_dac_nids,
12961 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12962 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012963 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012964 .hp_nid = 0x03,
12965 .dig_out_nid = ALC268_DIGOUT_NID,
12966 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12967 .channel_mode = alc268_modes,
12968 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012969 .setup = alc268_toshiba_setup,
12970 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012971 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012972#ifdef CONFIG_SND_DEBUG
12973 [ALC268_TEST] = {
12974 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12975 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12976 alc268_volume_init_verbs },
12977 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12978 .dac_nids = alc268_dac_nids,
12979 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12980 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012981 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012982 .hp_nid = 0x03,
12983 .dig_out_nid = ALC268_DIGOUT_NID,
12984 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12985 .channel_mode = alc268_modes,
12986 .input_mux = &alc268_capture_source,
12987 },
12988#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012989};
12990
12991static int patch_alc268(struct hda_codec *codec)
12992{
12993 struct alc_spec *spec;
12994 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012995 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012996
Julia Lawallef86f582009-12-19 08:18:03 +010012997 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020012998 if (spec == NULL)
12999 return -ENOMEM;
13000
13001 codec->spec = spec;
13002
13003 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13004 alc268_models,
13005 alc268_cfg_tbl);
13006
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013007 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13008 board_config = snd_hda_check_board_codec_sid_config(codec,
13009 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
13010
Kailang Yanga361d842007-06-05 12:30:55 +020013011 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013012 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13013 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013014 board_config = ALC268_AUTO;
13015 }
13016
13017 if (board_config == ALC268_AUTO) {
13018 /* automatic parse from the BIOS config */
13019 err = alc268_parse_auto_config(codec);
13020 if (err < 0) {
13021 alc_free(codec);
13022 return err;
13023 } else if (!err) {
13024 printk(KERN_INFO
13025 "hda_codec: Cannot set up configuration "
13026 "from BIOS. Using base mode...\n");
13027 board_config = ALC268_3ST;
13028 }
13029 }
13030
13031 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013032 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013033
Kailang Yanga361d842007-06-05 12:30:55 +020013034 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13035 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013036 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013037
Kailang Yanga361d842007-06-05 12:30:55 +020013038 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13039
Takashi Iwai22971e32009-02-10 11:56:44 +010013040 has_beep = 0;
13041 for (i = 0; i < spec->num_mixers; i++) {
13042 if (spec->mixers[i] == alc268_beep_mixer) {
13043 has_beep = 1;
13044 break;
13045 }
13046 }
13047
13048 if (has_beep) {
13049 err = snd_hda_attach_beep_device(codec, 0x1);
13050 if (err < 0) {
13051 alc_free(codec);
13052 return err;
13053 }
13054 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13055 /* override the amp caps for beep generator */
13056 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013057 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13058 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13059 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13060 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013061 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013062
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013063 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013064 /* check whether NID 0x07 is valid */
13065 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013066 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013067
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013068 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013069 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013070 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013071 if (spec->auto_mic ||
13072 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013073 spec->adc_nids = alc268_adc_nids_alt;
13074 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013075 if (spec->auto_mic)
13076 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013077 if (spec->auto_mic || spec->input_mux->num_items == 1)
13078 add_mixer(spec, alc268_capture_nosrc_mixer);
13079 else
13080 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013081 } else {
13082 spec->adc_nids = alc268_adc_nids;
13083 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013084 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013085 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013086 /* set default input source */
13087 for (i = 0; i < spec->num_adc_nids; i++)
13088 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13089 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013090 i < spec->num_mux_defs ?
13091 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013092 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013093 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013094
13095 spec->vmaster_nid = 0x02;
13096
Kailang Yanga361d842007-06-05 12:30:55 +020013097 codec->patch_ops = alc_patch_ops;
13098 if (board_config == ALC268_AUTO)
13099 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013100
Takashi Iwaidaead532008-11-28 12:55:36 +010013101 codec->proc_widget_hook = print_realtek_coef;
13102
Kailang Yanga361d842007-06-05 12:30:55 +020013103 return 0;
13104}
13105
13106/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013107 * ALC269 channel source setting (2 channel)
13108 */
13109#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13110
13111#define alc269_dac_nids alc260_dac_nids
13112
13113static hda_nid_t alc269_adc_nids[1] = {
13114 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013115 0x08,
13116};
13117
Takashi Iwaie01bf502008-08-21 16:25:07 +020013118static hda_nid_t alc269_capsrc_nids[1] = {
13119 0x23,
13120};
13121
13122/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
13123 * not a mux!
13124 */
13125
Kailang Yangf6a92242007-12-13 16:52:54 +010013126#define alc269_modes alc260_modes
13127#define alc269_capture_source alc880_lg_lw_capture_source
13128
13129static struct snd_kcontrol_new alc269_base_mixer[] = {
13130 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13131 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13132 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13133 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13134 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13135 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13136 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13137 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13138 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13139 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13140 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13141 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13142 { } /* end */
13143};
13144
Kailang Yang60db6b52008-08-26 13:13:00 +020013145static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13146 /* output mixer control */
13147 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13148 {
13149 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13150 .name = "Master Playback Switch",
13151 .info = snd_hda_mixer_amp_switch_info,
13152 .get = snd_hda_mixer_amp_switch_get,
13153 .put = alc268_acer_master_sw_put,
13154 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13155 },
13156 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13157 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13158 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13159 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13160 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13161 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013162 { }
13163};
13164
Tony Vroon64154832008-11-06 15:08:49 +000013165static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13166 /* output mixer control */
13167 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13168 {
13169 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13170 .name = "Master Playback Switch",
13171 .info = snd_hda_mixer_amp_switch_info,
13172 .get = snd_hda_mixer_amp_switch_get,
13173 .put = alc268_acer_master_sw_put,
13174 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13175 },
13176 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13177 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13178 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13179 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13180 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13181 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13182 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13183 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13184 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013185 { }
13186};
13187
Kailang Yangf53281e2008-07-18 12:36:43 +020013188static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013189 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013190 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013191 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013192 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013193 { } /* end */
13194};
13195
Kailang Yangf6a92242007-12-13 16:52:54 +010013196/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020013197static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
13198 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13199 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013200 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13201 { } /* end */
13202};
13203
13204/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020013205#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013206
Kailang Yang60db6b52008-08-26 13:13:00 +020013207static struct hda_verb alc269_quanta_fl1_verbs[] = {
13208 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13209 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13210 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13211 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13212 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13213 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13214 { }
13215};
13216
Tony Vroon64154832008-11-06 15:08:49 +000013217static struct hda_verb alc269_lifebook_verbs[] = {
13218 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13219 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13220 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13221 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13222 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13223 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13224 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13225 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13226 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13227 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13228 { }
13229};
13230
Kailang Yang60db6b52008-08-26 13:13:00 +020013231/* toggle speaker-output according to the hp-jack state */
13232static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13233{
13234 unsigned int present;
13235 unsigned char bits;
13236
Wu Fengguang864f92b2009-11-18 12:38:02 +080013237 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang60db6b52008-08-26 13:13:00 +020013238 bits = present ? AMP_IN_MUTE(0) : 0;
13239 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13240 AMP_IN_MUTE(0), bits);
13241 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13242 AMP_IN_MUTE(0), bits);
13243
13244 snd_hda_codec_write(codec, 0x20, 0,
13245 AC_VERB_SET_COEF_INDEX, 0x0c);
13246 snd_hda_codec_write(codec, 0x20, 0,
13247 AC_VERB_SET_PROC_COEF, 0x680);
13248
13249 snd_hda_codec_write(codec, 0x20, 0,
13250 AC_VERB_SET_COEF_INDEX, 0x0c);
13251 snd_hda_codec_write(codec, 0x20, 0,
13252 AC_VERB_SET_PROC_COEF, 0x480);
13253}
13254
Tony Vroon64154832008-11-06 15:08:49 +000013255/* toggle speaker-output according to the hp-jacks state */
13256static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13257{
13258 unsigned int present;
13259 unsigned char bits;
13260
13261 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013262 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013263
13264 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013265 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013266
13267 bits = present ? AMP_IN_MUTE(0) : 0;
13268 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13269 AMP_IN_MUTE(0), bits);
13270 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13271 AMP_IN_MUTE(0), bits);
13272
13273 snd_hda_codec_write(codec, 0x20, 0,
13274 AC_VERB_SET_COEF_INDEX, 0x0c);
13275 snd_hda_codec_write(codec, 0x20, 0,
13276 AC_VERB_SET_PROC_COEF, 0x680);
13277
13278 snd_hda_codec_write(codec, 0x20, 0,
13279 AC_VERB_SET_COEF_INDEX, 0x0c);
13280 snd_hda_codec_write(codec, 0x20, 0,
13281 AC_VERB_SET_PROC_COEF, 0x480);
13282}
13283
Tony Vroon64154832008-11-06 15:08:49 +000013284static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13285{
13286 unsigned int present_laptop;
13287 unsigned int present_dock;
13288
Wu Fengguang864f92b2009-11-18 12:38:02 +080013289 present_laptop = snd_hda_jack_detect(codec, 0x18);
13290 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000013291
13292 /* Laptop mic port overrides dock mic port, design decision */
13293 if (present_dock)
13294 snd_hda_codec_write(codec, 0x23, 0,
13295 AC_VERB_SET_CONNECT_SEL, 0x3);
13296 if (present_laptop)
13297 snd_hda_codec_write(codec, 0x23, 0,
13298 AC_VERB_SET_CONNECT_SEL, 0x0);
13299 if (!present_dock && !present_laptop)
13300 snd_hda_codec_write(codec, 0x23, 0,
13301 AC_VERB_SET_CONNECT_SEL, 0x1);
13302}
13303
Kailang Yang60db6b52008-08-26 13:13:00 +020013304static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13305 unsigned int res)
13306{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013307 switch (res >> 26) {
13308 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013309 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013310 break;
13311 case ALC880_MIC_EVENT:
13312 alc_mic_automute(codec);
13313 break;
13314 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013315}
13316
Tony Vroon64154832008-11-06 15:08:49 +000013317static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13318 unsigned int res)
13319{
13320 if ((res >> 26) == ALC880_HP_EVENT)
13321 alc269_lifebook_speaker_automute(codec);
13322 if ((res >> 26) == ALC880_MIC_EVENT)
13323 alc269_lifebook_mic_autoswitch(codec);
13324}
13325
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013326static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13327{
13328 struct alc_spec *spec = codec->spec;
13329 spec->ext_mic.pin = 0x18;
13330 spec->ext_mic.mux_idx = 0;
13331 spec->int_mic.pin = 0x19;
13332 spec->int_mic.mux_idx = 1;
13333 spec->auto_mic = 1;
13334}
13335
Kailang Yang60db6b52008-08-26 13:13:00 +020013336static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13337{
13338 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013339 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013340}
13341
Tony Vroon64154832008-11-06 15:08:49 +000013342static void alc269_lifebook_init_hook(struct hda_codec *codec)
13343{
13344 alc269_lifebook_speaker_automute(codec);
13345 alc269_lifebook_mic_autoswitch(codec);
13346}
13347
Kailang Yang60db6b52008-08-26 13:13:00 +020013348static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
13349 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13350 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13351 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13352 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13353 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13354 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13355 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13356 {}
13357};
13358
13359static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
13360 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13361 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13362 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13363 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13364 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13365 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13366 {}
13367};
13368
13369/* toggle speaker-output according to the hp-jack state */
13370static void alc269_speaker_automute(struct hda_codec *codec)
13371{
Kailang Yangebb83ee2009-12-17 12:23:00 +010013372 struct alc_spec *spec = codec->spec;
13373 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020013374 unsigned int present;
13375 unsigned char bits;
13376
Kailang Yangebb83ee2009-12-17 12:23:00 +010013377 present = snd_hda_jack_detect(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020013378 bits = present ? AMP_IN_MUTE(0) : 0;
13379 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13380 AMP_IN_MUTE(0), bits);
13381 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13382 AMP_IN_MUTE(0), bits);
13383}
13384
Kailang Yang60db6b52008-08-26 13:13:00 +020013385/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013386static void alc269_eeepc_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013387 unsigned int res)
13388{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013389 switch (res >> 26) {
13390 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013391 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013392 break;
13393 case ALC880_MIC_EVENT:
13394 alc_mic_automute(codec);
13395 break;
13396 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013397}
13398
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013399static void alc269_eeepc_dmic_setup(struct hda_codec *codec)
13400{
13401 struct alc_spec *spec = codec->spec;
13402 spec->ext_mic.pin = 0x18;
13403 spec->ext_mic.mux_idx = 0;
13404 spec->int_mic.pin = 0x12;
13405 spec->int_mic.mux_idx = 5;
13406 spec->auto_mic = 1;
13407}
13408
13409static void alc269_eeepc_amic_setup(struct hda_codec *codec)
13410{
13411 struct alc_spec *spec = codec->spec;
13412 spec->ext_mic.pin = 0x18;
13413 spec->ext_mic.mux_idx = 0;
13414 spec->int_mic.pin = 0x19;
13415 spec->int_mic.mux_idx = 1;
13416 spec->auto_mic = 1;
13417}
13418
13419static void alc269_eeepc_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013420{
13421 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013422 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013423}
13424
Kailang Yangf6a92242007-12-13 16:52:54 +010013425/*
13426 * generic initialization of ADC, input mixers and output mixers
13427 */
13428static struct hda_verb alc269_init_verbs[] = {
13429 /*
13430 * Unmute ADC0 and set the default input to mic-in
13431 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013432 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013433
13434 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13435 * analog-loopback mixer widget
13436 * Note: PASD motherboards uses the Line In 2 as the input for
13437 * front panel mic (mic 2)
13438 */
13439 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13440 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13441 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13442 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13443 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13444 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13445
13446 /*
13447 * Set up output mixers (0x0c - 0x0e)
13448 */
13449 /* set vol=0 to output mixers */
13450 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13451 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13452
13453 /* set up input amps for analog loopback */
13454 /* Amp Indices: DAC = 0, mixer = 1 */
13455 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13456 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13457 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13458 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13459 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13460 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13461
13462 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13463 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13464 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13465 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13466 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13467 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13468 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13469
13470 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13471 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13472 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13473 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13474 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13475 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13476 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13477
13478 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13479 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13480
13481 /* FIXME: use matrix-type input source selection */
13482 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13483 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013484 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13485 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013486 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13487 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13488
13489 /* set EAPD */
13490 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13491 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13492 { }
13493};
13494
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013495#define alc269_auto_create_multi_out_ctls \
13496 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020013497#define alc269_auto_create_input_ctls \
13498 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013499
13500#ifdef CONFIG_SND_HDA_POWER_SAVE
13501#define alc269_loopbacks alc880_loopbacks
13502#endif
13503
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013504/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013505#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13506#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13507#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13508#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13509
Takashi Iwaif03d3112009-03-05 14:18:16 +010013510static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13511 .substreams = 1,
13512 .channels_min = 2,
13513 .channels_max = 8,
13514 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13515 /* NID is set in alc_build_pcms */
13516 .ops = {
13517 .open = alc880_playback_pcm_open,
13518 .prepare = alc880_playback_pcm_prepare,
13519 .cleanup = alc880_playback_pcm_cleanup
13520 },
13521};
13522
13523static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13524 .substreams = 1,
13525 .channels_min = 2,
13526 .channels_max = 2,
13527 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13528 /* NID is set in alc_build_pcms */
13529};
13530
Kailang Yangf6a92242007-12-13 16:52:54 +010013531/*
13532 * BIOS auto configuration
13533 */
13534static int alc269_parse_auto_config(struct hda_codec *codec)
13535{
13536 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013537 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013538 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13539
13540 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13541 alc269_ignore);
13542 if (err < 0)
13543 return err;
13544
13545 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13546 if (err < 0)
13547 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013548 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010013549 if (err < 0)
13550 return err;
13551
13552 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13553
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013554 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013555 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13556
Takashi Iwai603c4012008-07-30 15:01:44 +020013557 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013558 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013559
Takashi Iwaid88897e2008-10-31 15:01:37 +010013560 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013561 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013562 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013563 /* set default input source */
13564 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13565 0, AC_VERB_SET_CONNECT_SEL,
13566 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013567
13568 err = alc_auto_add_mic_boost(codec);
13569 if (err < 0)
13570 return err;
13571
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013572 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013573 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013574
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013575 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13576
Kailang Yangf6a92242007-12-13 16:52:54 +010013577 return 1;
13578}
13579
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013580#define alc269_auto_init_multi_out alc268_auto_init_multi_out
13581#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010013582#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13583
13584
13585/* init callback for auto-configuration model -- overriding the default init */
13586static void alc269_auto_init(struct hda_codec *codec)
13587{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013588 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013589 alc269_auto_init_multi_out(codec);
13590 alc269_auto_init_hp_out(codec);
13591 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013592 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013593 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013594}
13595
13596/*
13597 * configuration and preset
13598 */
13599static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013600 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013601 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013602 [ALC269_ASUS_AMIC] = "asus-amic",
13603 [ALC269_ASUS_DMIC] = "asus-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000013604 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020013605 [ALC269_LIFEBOOK] = "lifebook",
13606 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010013607};
13608
13609static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013610 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013611 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013612 ALC269_ASUS_AMIC),
13613 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_ASUS_AMIC),
13614 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80JT", ALC269_ASUS_AMIC),
13615 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_ASUS_AMIC),
13616 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_ASUS_AMIC),
13617 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_ASUS_AMIC),
13618 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_ASUS_AMIC),
13619 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_ASUS_AMIC),
13620 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_ASUS_AMIC),
13621 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_ASUS_AMIC),
13622 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_ASUS_AMIC),
13623 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_ASUS_AMIC),
13624 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_ASUS_AMIC),
13625 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_ASUS_AMIC),
13626 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_ASUS_AMIC),
13627 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_ASUS_AMIC),
13628 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_ASUS_AMIC),
13629 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_ASUS_AMIC),
13630 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_ASUS_AMIC),
13631 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_ASUS_AMIC),
13632 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_ASUS_AMIC),
13633 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_AMIC),
13634 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_ASUS_AMIC),
13635 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_AMIC),
13636 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_DMIC),
13637 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_AMIC),
13638 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_AMIC),
13639 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_AMIC),
13640 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020013641 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013642 ALC269_ASUS_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020013643 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013644 ALC269_ASUS_DMIC),
13645 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_ASUS_DMIC),
13646 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_ASUS_DMIC),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013647 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013648 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013649 {}
13650};
13651
13652static struct alc_config_preset alc269_presets[] = {
13653 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013654 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013655 .init_verbs = { alc269_init_verbs },
13656 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13657 .dac_nids = alc269_dac_nids,
13658 .hp_nid = 0x03,
13659 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13660 .channel_mode = alc269_modes,
13661 .input_mux = &alc269_capture_source,
13662 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013663 [ALC269_QUANTA_FL1] = {
13664 .mixers = { alc269_quanta_fl1_mixer },
13665 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13666 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13667 .dac_nids = alc269_dac_nids,
13668 .hp_nid = 0x03,
13669 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13670 .channel_mode = alc269_modes,
13671 .input_mux = &alc269_capture_source,
13672 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013673 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020013674 .init_hook = alc269_quanta_fl1_init_hook,
13675 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010013676 [ALC269_ASUS_AMIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013677 .mixers = { alc269_eeepc_mixer },
13678 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013679 .init_verbs = { alc269_init_verbs,
13680 alc269_eeepc_amic_init_verbs },
13681 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13682 .dac_nids = alc269_dac_nids,
13683 .hp_nid = 0x03,
13684 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13685 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013686 .unsol_event = alc269_eeepc_unsol_event,
13687 .setup = alc269_eeepc_amic_setup,
13688 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013689 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010013690 [ALC269_ASUS_DMIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013691 .mixers = { alc269_eeepc_mixer },
13692 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013693 .init_verbs = { alc269_init_verbs,
13694 alc269_eeepc_dmic_init_verbs },
13695 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13696 .dac_nids = alc269_dac_nids,
13697 .hp_nid = 0x03,
13698 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13699 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013700 .unsol_event = alc269_eeepc_unsol_event,
13701 .setup = alc269_eeepc_dmic_setup,
13702 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013703 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013704 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013705 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013706 .cap_mixer = alc269_epc_capture_mixer,
13707 .init_verbs = { alc269_init_verbs,
13708 alc269_eeepc_dmic_init_verbs },
13709 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13710 .dac_nids = alc269_dac_nids,
13711 .hp_nid = 0x03,
13712 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13713 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013714 .unsol_event = alc269_eeepc_unsol_event,
13715 .setup = alc269_eeepc_dmic_setup,
13716 .init_hook = alc269_eeepc_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010013717 },
Tony Vroon64154832008-11-06 15:08:49 +000013718 [ALC269_LIFEBOOK] = {
13719 .mixers = { alc269_lifebook_mixer },
13720 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13721 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13722 .dac_nids = alc269_dac_nids,
13723 .hp_nid = 0x03,
13724 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13725 .channel_mode = alc269_modes,
13726 .input_mux = &alc269_capture_source,
13727 .unsol_event = alc269_lifebook_unsol_event,
13728 .init_hook = alc269_lifebook_init_hook,
13729 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013730};
13731
13732static int patch_alc269(struct hda_codec *codec)
13733{
13734 struct alc_spec *spec;
13735 int board_config;
13736 int err;
13737
13738 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13739 if (spec == NULL)
13740 return -ENOMEM;
13741
13742 codec->spec = spec;
13743
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013744 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13745
Kailang Yang274693f2009-12-03 10:07:50 +010013746 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
13747 kfree(codec->chip_name);
13748 codec->chip_name = kstrdup("ALC259", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010013749 if (!codec->chip_name) {
13750 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010013751 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010013752 }
Kailang Yang274693f2009-12-03 10:07:50 +010013753 }
13754
Kailang Yangf6a92242007-12-13 16:52:54 +010013755 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13756 alc269_models,
13757 alc269_cfg_tbl);
13758
13759 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013760 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13761 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013762 board_config = ALC269_AUTO;
13763 }
13764
13765 if (board_config == ALC269_AUTO) {
13766 /* automatic parse from the BIOS config */
13767 err = alc269_parse_auto_config(codec);
13768 if (err < 0) {
13769 alc_free(codec);
13770 return err;
13771 } else if (!err) {
13772 printk(KERN_INFO
13773 "hda_codec: Cannot set up configuration "
13774 "from BIOS. Using base mode...\n");
13775 board_config = ALC269_BASIC;
13776 }
13777 }
13778
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013779 err = snd_hda_attach_beep_device(codec, 0x1);
13780 if (err < 0) {
13781 alc_free(codec);
13782 return err;
13783 }
13784
Kailang Yangf6a92242007-12-13 16:52:54 +010013785 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013786 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010013787
Takashi Iwaif03d3112009-03-05 14:18:16 +010013788 if (codec->subsystem_id == 0x17aa3bf8) {
13789 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13790 * fix the sample rate of analog I/O to 44.1kHz
13791 */
13792 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13793 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13794 } else {
13795 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13796 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13797 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013798 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13799 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13800
13801 spec->adc_nids = alc269_adc_nids;
13802 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013803 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013804 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013805 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013806 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013807
Takashi Iwai100d5eb2009-08-10 11:55:51 +020013808 spec->vmaster_nid = 0x02;
13809
Kailang Yangf6a92242007-12-13 16:52:54 +010013810 codec->patch_ops = alc_patch_ops;
13811 if (board_config == ALC269_AUTO)
13812 spec->init_hook = alc269_auto_init;
13813#ifdef CONFIG_SND_HDA_POWER_SAVE
13814 if (!spec->loopback.amplist)
13815 spec->loopback.amplist = alc269_loopbacks;
13816#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013817 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013818
13819 return 0;
13820}
13821
13822/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013823 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13824 */
13825
13826/*
13827 * set the path ways for 2 channel output
13828 * need to set the codec line out and mic 1 pin widgets to inputs
13829 */
13830static struct hda_verb alc861_threestack_ch2_init[] = {
13831 /* set pin widget 1Ah (line in) for input */
13832 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013833 /* set pin widget 18h (mic1/2) for input, for mic also enable
13834 * the vref
13835 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013836 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13837
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013838 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13839#if 0
13840 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13841 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13842#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013843 { } /* end */
13844};
13845/*
13846 * 6ch mode
13847 * need to set the codec line out and mic 1 pin widgets to outputs
13848 */
13849static struct hda_verb alc861_threestack_ch6_init[] = {
13850 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13851 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13852 /* set pin widget 18h (mic1) for output (CLFE)*/
13853 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13854
13855 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013856 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013857
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013858 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13859#if 0
13860 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13861 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13862#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013863 { } /* end */
13864};
13865
13866static struct hda_channel_mode alc861_threestack_modes[2] = {
13867 { 2, alc861_threestack_ch2_init },
13868 { 6, alc861_threestack_ch6_init },
13869};
Takashi Iwai22309c32006-08-09 16:57:28 +020013870/* Set mic1 as input and unmute the mixer */
13871static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13872 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13873 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13874 { } /* end */
13875};
13876/* Set mic1 as output and mute mixer */
13877static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13878 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13879 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13880 { } /* end */
13881};
13882
13883static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13884 { 2, alc861_uniwill_m31_ch2_init },
13885 { 4, alc861_uniwill_m31_ch4_init },
13886};
Kailang Yangdf694da2005-12-05 19:42:22 +010013887
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013888/* Set mic1 and line-in as input and unmute the mixer */
13889static struct hda_verb alc861_asus_ch2_init[] = {
13890 /* set pin widget 1Ah (line in) for input */
13891 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013892 /* set pin widget 18h (mic1/2) for input, for mic also enable
13893 * the vref
13894 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013895 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13896
13897 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13898#if 0
13899 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13900 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13901#endif
13902 { } /* end */
13903};
13904/* Set mic1 nad line-in as output and mute mixer */
13905static struct hda_verb alc861_asus_ch6_init[] = {
13906 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13907 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13908 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13909 /* set pin widget 18h (mic1) for output (CLFE)*/
13910 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13911 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13912 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13913 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13914
13915 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13916#if 0
13917 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13918 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13919#endif
13920 { } /* end */
13921};
13922
13923static struct hda_channel_mode alc861_asus_modes[2] = {
13924 { 2, alc861_asus_ch2_init },
13925 { 6, alc861_asus_ch6_init },
13926};
13927
Kailang Yangdf694da2005-12-05 19:42:22 +010013928/* patch-ALC861 */
13929
13930static struct snd_kcontrol_new alc861_base_mixer[] = {
13931 /* output mixer control */
13932 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13933 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13934 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13935 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13936 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13937
13938 /*Input mixer control */
13939 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13940 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13941 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13942 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13943 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13944 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13945 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13946 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13947 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13948 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013949
Kailang Yangdf694da2005-12-05 19:42:22 +010013950 { } /* end */
13951};
13952
13953static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13954 /* output mixer control */
13955 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13956 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13957 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13958 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13959 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13960
13961 /* Input mixer control */
13962 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13963 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13964 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13965 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13966 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13967 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13968 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13969 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13970 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13971 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013972
Kailang Yangdf694da2005-12-05 19:42:22 +010013973 {
13974 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13975 .name = "Channel Mode",
13976 .info = alc_ch_mode_info,
13977 .get = alc_ch_mode_get,
13978 .put = alc_ch_mode_put,
13979 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13980 },
13981 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013982};
13983
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013984static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013985 /* output mixer control */
13986 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13987 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13988 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013989
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013990 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013991};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013992
Takashi Iwai22309c32006-08-09 16:57:28 +020013993static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13994 /* output mixer control */
13995 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13996 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13997 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13998 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13999 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14000
14001 /* Input mixer control */
14002 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14003 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14004 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14005 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14006 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14007 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14008 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14009 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14010 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14011 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014012
Takashi Iwai22309c32006-08-09 16:57:28 +020014013 {
14014 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14015 .name = "Channel Mode",
14016 .info = alc_ch_mode_info,
14017 .get = alc_ch_mode_get,
14018 .put = alc_ch_mode_put,
14019 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
14020 },
14021 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014022};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014023
14024static struct snd_kcontrol_new alc861_asus_mixer[] = {
14025 /* output mixer control */
14026 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14027 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14028 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14029 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14030 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14031
14032 /* Input mixer control */
14033 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14034 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14035 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14036 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14037 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14038 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14039 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14040 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14041 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014042 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
14043
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014044 {
14045 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14046 .name = "Channel Mode",
14047 .info = alc_ch_mode_info,
14048 .get = alc_ch_mode_get,
14049 .put = alc_ch_mode_put,
14050 .private_value = ARRAY_SIZE(alc861_asus_modes),
14051 },
14052 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014053};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014054
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014055/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014056static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014057 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14058 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014059 { }
14060};
14061
Kailang Yangdf694da2005-12-05 19:42:22 +010014062/*
14063 * generic initialization of ADC, input mixers and output mixers
14064 */
14065static struct hda_verb alc861_base_init_verbs[] = {
14066 /*
14067 * Unmute ADC0 and set the default input to mic-in
14068 */
14069 /* port-A for surround (rear panel) */
14070 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14071 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
14072 /* port-B for mic-in (rear panel) with vref */
14073 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14074 /* port-C for line-in (rear panel) */
14075 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14076 /* port-D for Front */
14077 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14078 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14079 /* port-E for HP out (front panel) */
14080 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14081 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014082 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014083 /* port-F for mic-in (front panel) with vref */
14084 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14085 /* port-G for CLFE (rear panel) */
14086 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14087 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
14088 /* port-H for side (rear panel) */
14089 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14090 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
14091 /* CD-in */
14092 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14093 /* route front mic to ADC1*/
14094 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14095 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014096
Kailang Yangdf694da2005-12-05 19:42:22 +010014097 /* Unmute DAC0~3 & spdif out*/
14098 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14099 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14100 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14101 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14102 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014103
Kailang Yangdf694da2005-12-05 19:42:22 +010014104 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14105 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14106 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14107 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14108 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014109
Kailang Yangdf694da2005-12-05 19:42:22 +010014110 /* Unmute Stereo Mixer 15 */
14111 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14112 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14113 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014114 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014115
14116 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14117 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14118 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14119 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14120 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14121 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14122 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14123 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014124 /* hp used DAC 3 (Front) */
14125 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014126 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14127
14128 { }
14129};
14130
14131static struct hda_verb alc861_threestack_init_verbs[] = {
14132 /*
14133 * Unmute ADC0 and set the default input to mic-in
14134 */
14135 /* port-A for surround (rear panel) */
14136 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14137 /* port-B for mic-in (rear panel) with vref */
14138 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14139 /* port-C for line-in (rear panel) */
14140 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14141 /* port-D for Front */
14142 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14143 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14144 /* port-E for HP out (front panel) */
14145 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14146 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014147 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014148 /* port-F for mic-in (front panel) with vref */
14149 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14150 /* port-G for CLFE (rear panel) */
14151 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14152 /* port-H for side (rear panel) */
14153 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14154 /* CD-in */
14155 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14156 /* route front mic to ADC1*/
14157 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14158 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14159 /* Unmute DAC0~3 & spdif out*/
14160 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14161 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14162 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14163 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14164 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014165
Kailang Yangdf694da2005-12-05 19:42:22 +010014166 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14167 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14168 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14169 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14170 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014171
Kailang Yangdf694da2005-12-05 19:42:22 +010014172 /* Unmute Stereo Mixer 15 */
14173 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14174 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14175 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014176 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014177
14178 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14179 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14180 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14181 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14182 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14183 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14184 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14185 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014186 /* hp used DAC 3 (Front) */
14187 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014188 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14189 { }
14190};
Takashi Iwai22309c32006-08-09 16:57:28 +020014191
14192static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
14193 /*
14194 * Unmute ADC0 and set the default input to mic-in
14195 */
14196 /* port-A for surround (rear panel) */
14197 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14198 /* port-B for mic-in (rear panel) with vref */
14199 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14200 /* port-C for line-in (rear panel) */
14201 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14202 /* port-D for Front */
14203 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14204 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14205 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014206 /* this has to be set to VREF80 */
14207 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014208 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014209 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014210 /* port-F for mic-in (front panel) with vref */
14211 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14212 /* port-G for CLFE (rear panel) */
14213 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14214 /* port-H for side (rear panel) */
14215 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14216 /* CD-in */
14217 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14218 /* route front mic to ADC1*/
14219 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14220 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14221 /* Unmute DAC0~3 & spdif out*/
14222 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14223 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14224 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14225 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14226 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014227
Takashi Iwai22309c32006-08-09 16:57:28 +020014228 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14229 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14230 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14231 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14232 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014233
Takashi Iwai22309c32006-08-09 16:57:28 +020014234 /* Unmute Stereo Mixer 15 */
14235 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14236 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14237 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014238 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014239
14240 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14241 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14242 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14243 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14244 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14245 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14246 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14247 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014248 /* hp used DAC 3 (Front) */
14249 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014250 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14251 { }
14252};
14253
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014254static struct hda_verb alc861_asus_init_verbs[] = {
14255 /*
14256 * Unmute ADC0 and set the default input to mic-in
14257 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014258 /* port-A for surround (rear panel)
14259 * according to codec#0 this is the HP jack
14260 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014261 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14262 /* route front PCM to HP */
14263 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14264 /* port-B for mic-in (rear panel) with vref */
14265 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14266 /* port-C for line-in (rear panel) */
14267 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14268 /* port-D for Front */
14269 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14270 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14271 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014272 /* this has to be set to VREF80 */
14273 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014274 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014275 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014276 /* port-F for mic-in (front panel) with vref */
14277 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14278 /* port-G for CLFE (rear panel) */
14279 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14280 /* port-H for side (rear panel) */
14281 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14282 /* CD-in */
14283 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14284 /* route front mic to ADC1*/
14285 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14286 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14287 /* Unmute DAC0~3 & spdif out*/
14288 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14289 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14290 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14291 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14292 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14293 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14294 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14295 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14296 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14297 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014298
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014299 /* Unmute Stereo Mixer 15 */
14300 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14301 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14302 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014303 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014304
14305 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14306 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14307 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14308 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14309 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14310 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14311 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14312 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014313 /* hp used DAC 3 (Front) */
14314 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014315 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14316 { }
14317};
14318
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014319/* additional init verbs for ASUS laptops */
14320static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14321 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14322 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14323 { }
14324};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014325
Kailang Yangdf694da2005-12-05 19:42:22 +010014326/*
14327 * generic initialization of ADC, input mixers and output mixers
14328 */
14329static struct hda_verb alc861_auto_init_verbs[] = {
14330 /*
14331 * Unmute ADC0 and set the default input to mic-in
14332 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014333 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014334 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014335
Kailang Yangdf694da2005-12-05 19:42:22 +010014336 /* Unmute DAC0~3 & spdif out*/
14337 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14338 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14339 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14340 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14341 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014342
Kailang Yangdf694da2005-12-05 19:42:22 +010014343 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14344 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14345 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14346 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14347 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014348
Kailang Yangdf694da2005-12-05 19:42:22 +010014349 /* Unmute Stereo Mixer 15 */
14350 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14351 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14352 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14353 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14354
Takashi Iwai1c209302009-07-22 15:17:45 +020014355 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14356 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14357 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14358 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14359 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14360 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14361 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14362 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014363
14364 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14365 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014366 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14367 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014368 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14369 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014370 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14371 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014372
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014373 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014374
14375 { }
14376};
14377
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014378static struct hda_verb alc861_toshiba_init_verbs[] = {
14379 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014380
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014381 { }
14382};
14383
14384/* toggle speaker-output according to the hp-jack state */
14385static void alc861_toshiba_automute(struct hda_codec *codec)
14386{
Wu Fengguang864f92b2009-11-18 12:38:02 +080014387 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014388
Takashi Iwai47fd8302007-08-10 17:11:07 +020014389 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14390 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14391 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14392 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014393}
14394
14395static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14396 unsigned int res)
14397{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014398 if ((res >> 26) == ALC880_HP_EVENT)
14399 alc861_toshiba_automute(codec);
14400}
14401
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014402/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014403#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14404#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14405#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14406#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14407
14408
14409#define ALC861_DIGOUT_NID 0x07
14410
14411static struct hda_channel_mode alc861_8ch_modes[1] = {
14412 { 8, NULL }
14413};
14414
14415static hda_nid_t alc861_dac_nids[4] = {
14416 /* front, surround, clfe, side */
14417 0x03, 0x06, 0x05, 0x04
14418};
14419
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014420static hda_nid_t alc660_dac_nids[3] = {
14421 /* front, clfe, surround */
14422 0x03, 0x05, 0x06
14423};
14424
Kailang Yangdf694da2005-12-05 19:42:22 +010014425static hda_nid_t alc861_adc_nids[1] = {
14426 /* ADC0-2 */
14427 0x08,
14428};
14429
14430static struct hda_input_mux alc861_capture_source = {
14431 .num_items = 5,
14432 .items = {
14433 { "Mic", 0x0 },
14434 { "Front Mic", 0x3 },
14435 { "Line", 0x1 },
14436 { "CD", 0x4 },
14437 { "Mixer", 0x5 },
14438 },
14439};
14440
Takashi Iwai1c209302009-07-22 15:17:45 +020014441static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14442{
14443 struct alc_spec *spec = codec->spec;
14444 hda_nid_t mix, srcs[5];
14445 int i, j, num;
14446
14447 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14448 return 0;
14449 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14450 if (num < 0)
14451 return 0;
14452 for (i = 0; i < num; i++) {
14453 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014454 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014455 if (type != AC_WID_AUD_OUT)
14456 continue;
14457 for (j = 0; j < spec->multiout.num_dacs; j++)
14458 if (spec->multiout.dac_nids[j] == srcs[i])
14459 break;
14460 if (j >= spec->multiout.num_dacs)
14461 return srcs[i];
14462 }
14463 return 0;
14464}
14465
Kailang Yangdf694da2005-12-05 19:42:22 +010014466/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014467static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014468 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014469{
Takashi Iwai1c209302009-07-22 15:17:45 +020014470 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014471 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014472 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014473
14474 spec->multiout.dac_nids = spec->private_dac_nids;
14475 for (i = 0; i < cfg->line_outs; i++) {
14476 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014477 dac = alc861_look_for_dac(codec, nid);
14478 if (!dac)
14479 continue;
14480 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014481 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014482 return 0;
14483}
14484
Takashi Iwai1c209302009-07-22 15:17:45 +020014485static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14486 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014487{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020014488 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020014489 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14490}
14491
14492/* add playback controls from the parsed DAC table */
14493static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14494 const struct auto_pin_cfg *cfg)
14495{
14496 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014497 static const char *chname[4] = {
14498 "Front", "Surround", NULL /*CLFE*/, "Side"
14499 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014500 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014501 int i, err;
14502
14503 if (cfg->line_outs == 1) {
14504 const char *pfx = NULL;
14505 if (!cfg->hp_outs)
14506 pfx = "Master";
14507 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14508 pfx = "Speaker";
14509 if (pfx) {
14510 nid = spec->multiout.dac_nids[0];
14511 return alc861_create_out_sw(codec, pfx, nid, 3);
14512 }
14513 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014514
14515 for (i = 0; i < cfg->line_outs; i++) {
14516 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014517 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014518 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014519 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014520 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014521 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014522 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014523 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014524 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014525 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014526 return err;
14527 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014528 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014529 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014530 return err;
14531 }
14532 }
14533 return 0;
14534}
14535
Takashi Iwai1c209302009-07-22 15:17:45 +020014536static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014537{
Takashi Iwai1c209302009-07-22 15:17:45 +020014538 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014539 int err;
14540 hda_nid_t nid;
14541
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014542 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014543 return 0;
14544
14545 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014546 nid = alc861_look_for_dac(codec, pin);
14547 if (nid) {
14548 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14549 if (err < 0)
14550 return err;
14551 spec->multiout.hp_nid = nid;
14552 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014553 }
14554 return 0;
14555}
14556
14557/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020014558static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014559 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014560{
Takashi Iwai05f5f472009-08-25 13:10:18 +020014561 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014562}
14563
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014564static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14565 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014566 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014567{
Takashi Iwai1c209302009-07-22 15:17:45 +020014568 hda_nid_t mix, srcs[5];
14569 int i, num;
14570
Jacek Luczak564c5be2008-05-03 18:41:23 +020014571 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14572 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014573 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014574 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014575 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14576 return;
14577 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14578 if (num < 0)
14579 return;
14580 for (i = 0; i < num; i++) {
14581 unsigned int mute;
14582 if (srcs[i] == dac || srcs[i] == 0x15)
14583 mute = AMP_IN_UNMUTE(i);
14584 else
14585 mute = AMP_IN_MUTE(i);
14586 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14587 mute);
14588 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014589}
14590
14591static void alc861_auto_init_multi_out(struct hda_codec *codec)
14592{
14593 struct alc_spec *spec = codec->spec;
14594 int i;
14595
14596 for (i = 0; i < spec->autocfg.line_outs; i++) {
14597 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014598 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014599 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014600 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014601 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014602 }
14603}
14604
14605static void alc861_auto_init_hp_out(struct hda_codec *codec)
14606{
14607 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014608
Takashi Iwai15870f02009-10-05 08:25:13 +020014609 if (spec->autocfg.hp_outs)
14610 alc861_auto_set_output_and_unmute(codec,
14611 spec->autocfg.hp_pins[0],
14612 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014613 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020014614 if (spec->autocfg.speaker_outs)
14615 alc861_auto_set_output_and_unmute(codec,
14616 spec->autocfg.speaker_pins[0],
14617 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020014618 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014619}
14620
14621static void alc861_auto_init_analog_input(struct hda_codec *codec)
14622{
14623 struct alc_spec *spec = codec->spec;
14624 int i;
14625
14626 for (i = 0; i < AUTO_PIN_LAST; i++) {
14627 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014628 if (nid >= 0x0c && nid <= 0x11)
14629 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014630 }
14631}
14632
14633/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014634/* return 1 if successful, 0 if the proper config is not found,
14635 * or a negative error code
14636 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014637static int alc861_parse_auto_config(struct hda_codec *codec)
14638{
14639 struct alc_spec *spec = codec->spec;
14640 int err;
14641 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14642
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014643 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14644 alc861_ignore);
14645 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014646 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014647 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014648 return 0; /* can't find valid BIOS pin config */
14649
Takashi Iwai1c209302009-07-22 15:17:45 +020014650 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014651 if (err < 0)
14652 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014653 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014654 if (err < 0)
14655 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014656 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014657 if (err < 0)
14658 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014659 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014660 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014661 return err;
14662
14663 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14664
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014665 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014666 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14667
Takashi Iwai603c4012008-07-30 15:01:44 +020014668 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014669 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014670
Takashi Iwaid88897e2008-10-31 15:01:37 +010014671 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014672
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014673 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014674 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014675
14676 spec->adc_nids = alc861_adc_nids;
14677 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014678 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014679
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014680 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14681
Kailang Yangdf694da2005-12-05 19:42:22 +010014682 return 1;
14683}
14684
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014685/* additional initialization for auto-configuration model */
14686static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014687{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014688 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014689 alc861_auto_init_multi_out(codec);
14690 alc861_auto_init_hp_out(codec);
14691 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014692 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014693 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014694}
14695
Takashi Iwaicb53c622007-08-10 17:21:45 +020014696#ifdef CONFIG_SND_HDA_POWER_SAVE
14697static struct hda_amp_list alc861_loopbacks[] = {
14698 { 0x15, HDA_INPUT, 0 },
14699 { 0x15, HDA_INPUT, 1 },
14700 { 0x15, HDA_INPUT, 2 },
14701 { 0x15, HDA_INPUT, 3 },
14702 { } /* end */
14703};
14704#endif
14705
Kailang Yangdf694da2005-12-05 19:42:22 +010014706
14707/*
14708 * configuration and preset
14709 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014710static const char *alc861_models[ALC861_MODEL_LAST] = {
14711 [ALC861_3ST] = "3stack",
14712 [ALC660_3ST] = "3stack-660",
14713 [ALC861_3ST_DIG] = "3stack-dig",
14714 [ALC861_6ST_DIG] = "6stack-dig",
14715 [ALC861_UNIWILL_M31] = "uniwill-m31",
14716 [ALC861_TOSHIBA] = "toshiba",
14717 [ALC861_ASUS] = "asus",
14718 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14719 [ALC861_AUTO] = "auto",
14720};
14721
14722static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014723 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014724 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14725 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14726 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014727 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014728 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014729 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014730 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14731 * Any other models that need this preset?
14732 */
14733 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014734 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14735 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014736 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14737 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14738 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14739 /* FIXME: the below seems conflict */
14740 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14741 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14742 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014743 {}
14744};
14745
14746static struct alc_config_preset alc861_presets[] = {
14747 [ALC861_3ST] = {
14748 .mixers = { alc861_3ST_mixer },
14749 .init_verbs = { alc861_threestack_init_verbs },
14750 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14751 .dac_nids = alc861_dac_nids,
14752 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14753 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014754 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014755 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14756 .adc_nids = alc861_adc_nids,
14757 .input_mux = &alc861_capture_source,
14758 },
14759 [ALC861_3ST_DIG] = {
14760 .mixers = { alc861_base_mixer },
14761 .init_verbs = { alc861_threestack_init_verbs },
14762 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14763 .dac_nids = alc861_dac_nids,
14764 .dig_out_nid = ALC861_DIGOUT_NID,
14765 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14766 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014767 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014768 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14769 .adc_nids = alc861_adc_nids,
14770 .input_mux = &alc861_capture_source,
14771 },
14772 [ALC861_6ST_DIG] = {
14773 .mixers = { alc861_base_mixer },
14774 .init_verbs = { alc861_base_init_verbs },
14775 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14776 .dac_nids = alc861_dac_nids,
14777 .dig_out_nid = ALC861_DIGOUT_NID,
14778 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14779 .channel_mode = alc861_8ch_modes,
14780 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14781 .adc_nids = alc861_adc_nids,
14782 .input_mux = &alc861_capture_source,
14783 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014784 [ALC660_3ST] = {
14785 .mixers = { alc861_3ST_mixer },
14786 .init_verbs = { alc861_threestack_init_verbs },
14787 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14788 .dac_nids = alc660_dac_nids,
14789 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14790 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014791 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014792 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14793 .adc_nids = alc861_adc_nids,
14794 .input_mux = &alc861_capture_source,
14795 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014796 [ALC861_UNIWILL_M31] = {
14797 .mixers = { alc861_uniwill_m31_mixer },
14798 .init_verbs = { alc861_uniwill_m31_init_verbs },
14799 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14800 .dac_nids = alc861_dac_nids,
14801 .dig_out_nid = ALC861_DIGOUT_NID,
14802 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14803 .channel_mode = alc861_uniwill_m31_modes,
14804 .need_dac_fix = 1,
14805 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14806 .adc_nids = alc861_adc_nids,
14807 .input_mux = &alc861_capture_source,
14808 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014809 [ALC861_TOSHIBA] = {
14810 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014811 .init_verbs = { alc861_base_init_verbs,
14812 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014813 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14814 .dac_nids = alc861_dac_nids,
14815 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14816 .channel_mode = alc883_3ST_2ch_modes,
14817 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14818 .adc_nids = alc861_adc_nids,
14819 .input_mux = &alc861_capture_source,
14820 .unsol_event = alc861_toshiba_unsol_event,
14821 .init_hook = alc861_toshiba_automute,
14822 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014823 [ALC861_ASUS] = {
14824 .mixers = { alc861_asus_mixer },
14825 .init_verbs = { alc861_asus_init_verbs },
14826 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14827 .dac_nids = alc861_dac_nids,
14828 .dig_out_nid = ALC861_DIGOUT_NID,
14829 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14830 .channel_mode = alc861_asus_modes,
14831 .need_dac_fix = 1,
14832 .hp_nid = 0x06,
14833 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14834 .adc_nids = alc861_adc_nids,
14835 .input_mux = &alc861_capture_source,
14836 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014837 [ALC861_ASUS_LAPTOP] = {
14838 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14839 .init_verbs = { alc861_asus_init_verbs,
14840 alc861_asus_laptop_init_verbs },
14841 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14842 .dac_nids = alc861_dac_nids,
14843 .dig_out_nid = ALC861_DIGOUT_NID,
14844 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14845 .channel_mode = alc883_3ST_2ch_modes,
14846 .need_dac_fix = 1,
14847 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14848 .adc_nids = alc861_adc_nids,
14849 .input_mux = &alc861_capture_source,
14850 },
14851};
Kailang Yangdf694da2005-12-05 19:42:22 +010014852
Takashi Iwaicfc9b062009-12-01 12:19:37 +010014853/* Pin config fixes */
14854enum {
14855 PINFIX_FSC_AMILO_PI1505,
14856};
14857
14858static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = {
14859 { 0x0b, 0x0221101f }, /* HP */
14860 { 0x0f, 0x90170310 }, /* speaker */
14861 { }
14862};
14863
14864static const struct alc_fixup alc861_fixups[] = {
14865 [PINFIX_FSC_AMILO_PI1505] = {
14866 .pins = alc861_fsc_amilo_pi1505_pinfix
14867 },
14868};
14869
14870static struct snd_pci_quirk alc861_fixup_tbl[] = {
14871 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
14872 {}
14873};
Kailang Yangdf694da2005-12-05 19:42:22 +010014874
14875static int patch_alc861(struct hda_codec *codec)
14876{
14877 struct alc_spec *spec;
14878 int board_config;
14879 int err;
14880
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014881 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014882 if (spec == NULL)
14883 return -ENOMEM;
14884
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014885 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014886
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014887 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14888 alc861_models,
14889 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014890
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014891 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014892 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14893 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014894 board_config = ALC861_AUTO;
14895 }
14896
Takashi Iwaicfc9b062009-12-01 12:19:37 +010014897 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups);
14898
Kailang Yangdf694da2005-12-05 19:42:22 +010014899 if (board_config == ALC861_AUTO) {
14900 /* automatic parse from the BIOS config */
14901 err = alc861_parse_auto_config(codec);
14902 if (err < 0) {
14903 alc_free(codec);
14904 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014905 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014906 printk(KERN_INFO
14907 "hda_codec: Cannot set up configuration "
14908 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014909 board_config = ALC861_3ST_DIG;
14910 }
14911 }
14912
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014913 err = snd_hda_attach_beep_device(codec, 0x23);
14914 if (err < 0) {
14915 alc_free(codec);
14916 return err;
14917 }
14918
Kailang Yangdf694da2005-12-05 19:42:22 +010014919 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014920 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014921
Kailang Yangdf694da2005-12-05 19:42:22 +010014922 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14923 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14924
Kailang Yangdf694da2005-12-05 19:42:22 +010014925 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14926 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14927
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010014928 if (!spec->cap_mixer)
14929 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014930 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14931
Takashi Iwai2134ea42008-01-10 16:53:55 +010014932 spec->vmaster_nid = 0x03;
14933
Kailang Yangdf694da2005-12-05 19:42:22 +010014934 codec->patch_ops = alc_patch_ops;
14935 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014936 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014937#ifdef CONFIG_SND_HDA_POWER_SAVE
14938 if (!spec->loopback.amplist)
14939 spec->loopback.amplist = alc861_loopbacks;
14940#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014941 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014942
Kailang Yangdf694da2005-12-05 19:42:22 +010014943 return 0;
14944}
14945
14946/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014947 * ALC861-VD support
14948 *
14949 * Based on ALC882
14950 *
14951 * In addition, an independent DAC
14952 */
14953#define ALC861VD_DIGOUT_NID 0x06
14954
14955static hda_nid_t alc861vd_dac_nids[4] = {
14956 /* front, surr, clfe, side surr */
14957 0x02, 0x03, 0x04, 0x05
14958};
14959
14960/* dac_nids for ALC660vd are in a different order - according to
14961 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014962 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014963 * of ALC660vd codecs, but for now there is only 3stack mixer
14964 * - and it is the same as in 861vd.
14965 * adc_nids in ALC660vd are (is) the same as in 861vd
14966 */
14967static hda_nid_t alc660vd_dac_nids[3] = {
14968 /* front, rear, clfe, rear_surr */
14969 0x02, 0x04, 0x03
14970};
14971
14972static hda_nid_t alc861vd_adc_nids[1] = {
14973 /* ADC0 */
14974 0x09,
14975};
14976
Takashi Iwaie1406342008-02-11 18:32:32 +010014977static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14978
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014979/* input MUX */
14980/* FIXME: should be a matrix-type input source selection */
14981static struct hda_input_mux alc861vd_capture_source = {
14982 .num_items = 4,
14983 .items = {
14984 { "Mic", 0x0 },
14985 { "Front Mic", 0x1 },
14986 { "Line", 0x2 },
14987 { "CD", 0x4 },
14988 },
14989};
14990
Kailang Yang272a5272007-05-14 11:00:38 +020014991static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014992 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014993 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014994 { "Ext Mic", 0x0 },
14995 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014996 },
14997};
14998
Kailang Yangd1a991a2007-08-15 16:21:59 +020014999static struct hda_input_mux alc861vd_hp_capture_source = {
15000 .num_items = 2,
15001 .items = {
15002 { "Front Mic", 0x0 },
15003 { "ATAPI Mic", 0x1 },
15004 },
15005};
15006
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015007/*
15008 * 2ch mode
15009 */
15010static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
15011 { 2, NULL }
15012};
15013
15014/*
15015 * 6ch mode
15016 */
15017static struct hda_verb alc861vd_6stack_ch6_init[] = {
15018 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15019 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15020 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15021 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15022 { } /* end */
15023};
15024
15025/*
15026 * 8ch mode
15027 */
15028static struct hda_verb alc861vd_6stack_ch8_init[] = {
15029 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15030 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15031 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15032 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15033 { } /* end */
15034};
15035
15036static struct hda_channel_mode alc861vd_6stack_modes[2] = {
15037 { 6, alc861vd_6stack_ch6_init },
15038 { 8, alc861vd_6stack_ch8_init },
15039};
15040
15041static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
15042 {
15043 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15044 .name = "Channel Mode",
15045 .info = alc_ch_mode_info,
15046 .get = alc_ch_mode_get,
15047 .put = alc_ch_mode_put,
15048 },
15049 { } /* end */
15050};
15051
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015052/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15053 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15054 */
15055static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
15056 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15057 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15058
15059 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15060 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
15061
15062 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
15063 HDA_OUTPUT),
15064 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
15065 HDA_OUTPUT),
15066 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
15067 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
15068
15069 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
15070 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
15071
15072 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15073
15074 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15075 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15076 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15077
15078 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15079 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15080 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15081
15082 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15083 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15084
15085 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15086 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15087
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015088 { } /* end */
15089};
15090
15091static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
15092 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15093 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15094
15095 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15096
15097 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15098 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15099 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15100
15101 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15102 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15103 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15104
15105 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15106 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15107
15108 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15109 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15110
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015111 { } /* end */
15112};
15113
Kailang Yangbdd148a2007-05-08 15:19:08 +020015114static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
15115 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15116 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
15117 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15118
15119 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15120
15121 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15122 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15123 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15124
15125 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15126 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15127 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15128
15129 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15130 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15131
15132 { } /* end */
15133};
15134
Tobin Davisb419f342008-03-07 11:57:51 +010015135/* Pin assignment: Speaker=0x14, HP = 0x15,
15136 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020015137 */
15138static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010015139 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15140 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015141 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15142 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010015143 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
15144 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15145 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15146 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
15147 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15148 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015149 { } /* end */
15150};
15151
Kailang Yangd1a991a2007-08-15 16:21:59 +020015152/* Pin assignment: Speaker=0x14, Line-out = 0x15,
15153 * Front Mic=0x18, ATAPI Mic = 0x19,
15154 */
15155static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
15156 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15157 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15158 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15159 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
15160 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15161 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15162 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15163 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015164
Kailang Yangd1a991a2007-08-15 16:21:59 +020015165 { } /* end */
15166};
15167
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015168/*
15169 * generic initialization of ADC, input mixers and output mixers
15170 */
15171static struct hda_verb alc861vd_volume_init_verbs[] = {
15172 /*
15173 * Unmute ADC0 and set the default input to mic-in
15174 */
15175 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15176 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15177
15178 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
15179 * the analog-loopback mixer widget
15180 */
15181 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015182 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15183 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15184 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15185 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15186 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015187
15188 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020015189 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15190 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15191 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015192 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015193
15194 /*
15195 * Set up output mixers (0x02 - 0x05)
15196 */
15197 /* set vol=0 to output mixers */
15198 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15199 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15200 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15201 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15202
15203 /* set up input amps for analog loopback */
15204 /* Amp Indices: DAC = 0, mixer = 1 */
15205 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15206 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15207 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15208 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15209 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15210 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15211 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15212 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15213
15214 { }
15215};
15216
15217/*
15218 * 3-stack pin configuration:
15219 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
15220 */
15221static struct hda_verb alc861vd_3stack_init_verbs[] = {
15222 /*
15223 * Set pin mode and muting
15224 */
15225 /* set front pin widgets 0x14 for output */
15226 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15227 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15228 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15229
15230 /* Mic (rear) pin: input vref at 80% */
15231 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15232 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15233 /* Front Mic pin: input vref at 80% */
15234 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15235 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15236 /* Line In pin: input */
15237 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15238 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15239 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15240 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15241 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15242 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15243 /* CD pin widget for input */
15244 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15245
15246 { }
15247};
15248
15249/*
15250 * 6-stack pin configuration:
15251 */
15252static struct hda_verb alc861vd_6stack_init_verbs[] = {
15253 /*
15254 * Set pin mode and muting
15255 */
15256 /* set front pin widgets 0x14 for output */
15257 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15258 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15259 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15260
15261 /* Rear Pin: output 1 (0x0d) */
15262 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15263 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15264 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15265 /* CLFE Pin: output 2 (0x0e) */
15266 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15267 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15268 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15269 /* Side Pin: output 3 (0x0f) */
15270 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15271 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15272 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15273
15274 /* Mic (rear) pin: input vref at 80% */
15275 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15276 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15277 /* Front Mic pin: input vref at 80% */
15278 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15279 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15280 /* Line In pin: input */
15281 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15282 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15283 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15284 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15285 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15286 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15287 /* CD pin widget for input */
15288 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15289
15290 { }
15291};
15292
Kailang Yangbdd148a2007-05-08 15:19:08 +020015293static struct hda_verb alc861vd_eapd_verbs[] = {
15294 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15295 { }
15296};
15297
Kailang Yangf9423e72008-05-27 12:32:25 +020015298static struct hda_verb alc660vd_eapd_verbs[] = {
15299 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15300 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15301 { }
15302};
15303
Kailang Yangbdd148a2007-05-08 15:19:08 +020015304static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15305 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15306 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15307 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15308 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015309 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015310 {}
15311};
15312
Kailang Yangbdd148a2007-05-08 15:19:08 +020015313static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15314{
15315 unsigned int present;
15316 unsigned char bits;
15317
Wu Fengguang864f92b2009-11-18 12:38:02 +080015318 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020015319 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080015320
Takashi Iwai47fd8302007-08-10 17:11:07 +020015321 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15322 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015323}
15324
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015325static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015326{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015327 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015328 spec->autocfg.hp_pins[0] = 0x1b;
15329 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015330}
15331
15332static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15333{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015334 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015335 alc861vd_lenovo_mic_automute(codec);
15336}
15337
15338static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15339 unsigned int res)
15340{
15341 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015342 case ALC880_MIC_EVENT:
15343 alc861vd_lenovo_mic_automute(codec);
15344 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015345 default:
15346 alc_automute_amp_unsol_event(codec, res);
15347 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015348 }
15349}
15350
Kailang Yang272a5272007-05-14 11:00:38 +020015351static struct hda_verb alc861vd_dallas_verbs[] = {
15352 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15353 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15354 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15355 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15356
15357 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15358 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15359 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15360 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15361 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15362 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15363 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15364 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015365
Kailang Yang272a5272007-05-14 11:00:38 +020015366 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15367 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15368 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15369 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15370 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15371 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15372 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15373 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15374
15375 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15376 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15377 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15378 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15379 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15380 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15381 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15382 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15383
15384 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15385 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15386 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15387 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15388
15389 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015390 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015391 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15392
15393 { } /* end */
15394};
15395
15396/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015397static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015398{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015399 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015400
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015401 spec->autocfg.hp_pins[0] = 0x15;
15402 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020015403}
15404
Takashi Iwaicb53c622007-08-10 17:21:45 +020015405#ifdef CONFIG_SND_HDA_POWER_SAVE
15406#define alc861vd_loopbacks alc880_loopbacks
15407#endif
15408
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015409/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015410#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15411#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15412#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15413#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15414
15415/*
15416 * configuration and preset
15417 */
15418static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15419 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015420 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015421 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015422 [ALC861VD_3ST] = "3stack",
15423 [ALC861VD_3ST_DIG] = "3stack-digout",
15424 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015425 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015426 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015427 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015428 [ALC861VD_AUTO] = "auto",
15429};
15430
15431static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015432 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15433 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015434 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015435 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010015436 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015437 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015438 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015439 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015440 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015441 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015442 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015443 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015444 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015445 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015446 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015447 {}
15448};
15449
15450static struct alc_config_preset alc861vd_presets[] = {
15451 [ALC660VD_3ST] = {
15452 .mixers = { alc861vd_3st_mixer },
15453 .init_verbs = { alc861vd_volume_init_verbs,
15454 alc861vd_3stack_init_verbs },
15455 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15456 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015457 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15458 .channel_mode = alc861vd_3stack_2ch_modes,
15459 .input_mux = &alc861vd_capture_source,
15460 },
Mike Crash6963f842007-06-25 12:12:51 +020015461 [ALC660VD_3ST_DIG] = {
15462 .mixers = { alc861vd_3st_mixer },
15463 .init_verbs = { alc861vd_volume_init_verbs,
15464 alc861vd_3stack_init_verbs },
15465 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15466 .dac_nids = alc660vd_dac_nids,
15467 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015468 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15469 .channel_mode = alc861vd_3stack_2ch_modes,
15470 .input_mux = &alc861vd_capture_source,
15471 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015472 [ALC861VD_3ST] = {
15473 .mixers = { alc861vd_3st_mixer },
15474 .init_verbs = { alc861vd_volume_init_verbs,
15475 alc861vd_3stack_init_verbs },
15476 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15477 .dac_nids = alc861vd_dac_nids,
15478 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15479 .channel_mode = alc861vd_3stack_2ch_modes,
15480 .input_mux = &alc861vd_capture_source,
15481 },
15482 [ALC861VD_3ST_DIG] = {
15483 .mixers = { alc861vd_3st_mixer },
15484 .init_verbs = { alc861vd_volume_init_verbs,
15485 alc861vd_3stack_init_verbs },
15486 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15487 .dac_nids = alc861vd_dac_nids,
15488 .dig_out_nid = ALC861VD_DIGOUT_NID,
15489 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15490 .channel_mode = alc861vd_3stack_2ch_modes,
15491 .input_mux = &alc861vd_capture_source,
15492 },
15493 [ALC861VD_6ST_DIG] = {
15494 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15495 .init_verbs = { alc861vd_volume_init_verbs,
15496 alc861vd_6stack_init_verbs },
15497 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15498 .dac_nids = alc861vd_dac_nids,
15499 .dig_out_nid = ALC861VD_DIGOUT_NID,
15500 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15501 .channel_mode = alc861vd_6stack_modes,
15502 .input_mux = &alc861vd_capture_source,
15503 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015504 [ALC861VD_LENOVO] = {
15505 .mixers = { alc861vd_lenovo_mixer },
15506 .init_verbs = { alc861vd_volume_init_verbs,
15507 alc861vd_3stack_init_verbs,
15508 alc861vd_eapd_verbs,
15509 alc861vd_lenovo_unsol_verbs },
15510 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15511 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015512 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15513 .channel_mode = alc861vd_3stack_2ch_modes,
15514 .input_mux = &alc861vd_capture_source,
15515 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015516 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015517 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015518 },
Kailang Yang272a5272007-05-14 11:00:38 +020015519 [ALC861VD_DALLAS] = {
15520 .mixers = { alc861vd_dallas_mixer },
15521 .init_verbs = { alc861vd_dallas_verbs },
15522 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15523 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015524 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15525 .channel_mode = alc861vd_3stack_2ch_modes,
15526 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015527 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015528 .setup = alc861vd_dallas_setup,
15529 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015530 },
15531 [ALC861VD_HP] = {
15532 .mixers = { alc861vd_hp_mixer },
15533 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15534 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15535 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015536 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015537 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15538 .channel_mode = alc861vd_3stack_2ch_modes,
15539 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015540 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015541 .setup = alc861vd_dallas_setup,
15542 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020015543 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015544 [ALC660VD_ASUS_V1S] = {
15545 .mixers = { alc861vd_lenovo_mixer },
15546 .init_verbs = { alc861vd_volume_init_verbs,
15547 alc861vd_3stack_init_verbs,
15548 alc861vd_eapd_verbs,
15549 alc861vd_lenovo_unsol_verbs },
15550 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15551 .dac_nids = alc660vd_dac_nids,
15552 .dig_out_nid = ALC861VD_DIGOUT_NID,
15553 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15554 .channel_mode = alc861vd_3stack_2ch_modes,
15555 .input_mux = &alc861vd_capture_source,
15556 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015557 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015558 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015559 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015560};
15561
15562/*
15563 * BIOS auto configuration
15564 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015565static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15566 const struct auto_pin_cfg *cfg)
15567{
Takashi Iwai9c0afc82010-01-12 14:00:11 +010015568 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x22, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020015569}
15570
15571
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015572static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15573 hda_nid_t nid, int pin_type, int dac_idx)
15574{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015575 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015576}
15577
15578static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15579{
15580 struct alc_spec *spec = codec->spec;
15581 int i;
15582
15583 for (i = 0; i <= HDA_SIDE; i++) {
15584 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015585 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015586 if (nid)
15587 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015588 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015589 }
15590}
15591
15592
15593static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15594{
15595 struct alc_spec *spec = codec->spec;
15596 hda_nid_t pin;
15597
15598 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015599 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015600 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015601 pin = spec->autocfg.speaker_pins[0];
15602 if (pin)
15603 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015604}
15605
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015606#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15607
15608static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15609{
15610 struct alc_spec *spec = codec->spec;
15611 int i;
15612
15613 for (i = 0; i < AUTO_PIN_LAST; i++) {
15614 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020015615 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015616 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015617 if (nid != ALC861VD_PIN_CD_NID &&
15618 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015619 snd_hda_codec_write(codec, nid, 0,
15620 AC_VERB_SET_AMP_GAIN_MUTE,
15621 AMP_OUT_MUTE);
15622 }
15623 }
15624}
15625
Takashi Iwaif511b012008-08-15 16:46:42 +020015626#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15627
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015628#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15629#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15630
15631/* add playback controls from the parsed DAC table */
15632/* Based on ALC880 version. But ALC861VD has separate,
15633 * different NIDs for mute/unmute switch and volume control */
15634static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15635 const struct auto_pin_cfg *cfg)
15636{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015637 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15638 hda_nid_t nid_v, nid_s;
15639 int i, err;
15640
15641 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015642 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015643 continue;
15644 nid_v = alc861vd_idx_to_mixer_vol(
15645 alc880_dac_to_idx(
15646 spec->multiout.dac_nids[i]));
15647 nid_s = alc861vd_idx_to_mixer_switch(
15648 alc880_dac_to_idx(
15649 spec->multiout.dac_nids[i]));
15650
15651 if (i == 2) {
15652 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015653 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
15654 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015655 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15656 HDA_OUTPUT));
15657 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015658 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015659 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
15660 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015661 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15662 HDA_OUTPUT));
15663 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015664 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015665 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
15666 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015667 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15668 HDA_INPUT));
15669 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015670 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015671 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
15672 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015673 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15674 HDA_INPUT));
15675 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015676 return err;
15677 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015678 const char *pfx;
15679 if (cfg->line_outs == 1 &&
15680 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
15681 if (!cfg->hp_pins)
15682 pfx = "Speaker";
15683 else
15684 pfx = "PCM";
15685 } else
15686 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015687 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015688 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15689 HDA_OUTPUT));
15690 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015691 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015692 if (cfg->line_outs == 1 &&
15693 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15694 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015695 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015696 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015697 HDA_INPUT));
15698 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015699 return err;
15700 }
15701 }
15702 return 0;
15703}
15704
15705/* add playback controls for speaker and HP outputs */
15706/* Based on ALC880 version. But ALC861VD has separate,
15707 * different NIDs for mute/unmute switch and volume control */
15708static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15709 hda_nid_t pin, const char *pfx)
15710{
15711 hda_nid_t nid_v, nid_s;
15712 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015713
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015714 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015715 return 0;
15716
15717 if (alc880_is_fixed_pin(pin)) {
15718 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15719 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015720 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015721 spec->multiout.hp_nid = nid_v;
15722 else
15723 spec->multiout.extra_out_nid[0] = nid_v;
15724 /* control HP volume/switch on the output mixer amp */
15725 nid_v = alc861vd_idx_to_mixer_vol(
15726 alc880_fixed_pin_idx(pin));
15727 nid_s = alc861vd_idx_to_mixer_switch(
15728 alc880_fixed_pin_idx(pin));
15729
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015730 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015731 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15732 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015733 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015734 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015735 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15736 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015737 return err;
15738 } else if (alc880_is_multi_pin(pin)) {
15739 /* set manual connection */
15740 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015741 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015742 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15743 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015744 return err;
15745 }
15746 return 0;
15747}
15748
15749/* parse the BIOS configuration and set up the alc_spec
15750 * return 1 if successful, 0 if the proper config is not found,
15751 * or a negative error code
15752 * Based on ALC880 version - had to change it to override
15753 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15754static int alc861vd_parse_auto_config(struct hda_codec *codec)
15755{
15756 struct alc_spec *spec = codec->spec;
15757 int err;
15758 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15759
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015760 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15761 alc861vd_ignore);
15762 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015763 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015764 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015765 return 0; /* can't find valid BIOS pin config */
15766
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015767 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15768 if (err < 0)
15769 return err;
15770 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15771 if (err < 0)
15772 return err;
15773 err = alc861vd_auto_create_extra_out(spec,
15774 spec->autocfg.speaker_pins[0],
15775 "Speaker");
15776 if (err < 0)
15777 return err;
15778 err = alc861vd_auto_create_extra_out(spec,
15779 spec->autocfg.hp_pins[0],
15780 "Headphone");
15781 if (err < 0)
15782 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015783 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015784 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015785 return err;
15786
15787 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15788
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015789 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015790 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15791
Takashi Iwai603c4012008-07-30 15:01:44 +020015792 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015793 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015794
Takashi Iwaid88897e2008-10-31 15:01:37 +010015795 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015796
15797 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015798 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015799
Takashi Iwai776e1842007-08-29 15:07:11 +020015800 err = alc_auto_add_mic_boost(codec);
15801 if (err < 0)
15802 return err;
15803
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015804 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15805
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015806 return 1;
15807}
15808
15809/* additional initialization for auto-configuration model */
15810static void alc861vd_auto_init(struct hda_codec *codec)
15811{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015812 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015813 alc861vd_auto_init_multi_out(codec);
15814 alc861vd_auto_init_hp_out(codec);
15815 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015816 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015817 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015818 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015819}
15820
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015821enum {
15822 ALC660VD_FIX_ASUS_GPIO1
15823};
15824
15825/* reset GPIO1 */
15826static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
15827 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
15828 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
15829 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
15830 { }
15831};
15832
15833static const struct alc_fixup alc861vd_fixups[] = {
15834 [ALC660VD_FIX_ASUS_GPIO1] = {
15835 .verbs = alc660vd_fix_asus_gpio1_verbs,
15836 },
15837};
15838
15839static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
15840 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
15841 {}
15842};
15843
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015844static int patch_alc861vd(struct hda_codec *codec)
15845{
15846 struct alc_spec *spec;
15847 int err, board_config;
15848
15849 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15850 if (spec == NULL)
15851 return -ENOMEM;
15852
15853 codec->spec = spec;
15854
15855 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15856 alc861vd_models,
15857 alc861vd_cfg_tbl);
15858
15859 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015860 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15861 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015862 board_config = ALC861VD_AUTO;
15863 }
15864
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015865 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups);
15866
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015867 if (board_config == ALC861VD_AUTO) {
15868 /* automatic parse from the BIOS config */
15869 err = alc861vd_parse_auto_config(codec);
15870 if (err < 0) {
15871 alc_free(codec);
15872 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015873 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015874 printk(KERN_INFO
15875 "hda_codec: Cannot set up configuration "
15876 "from BIOS. Using base mode...\n");
15877 board_config = ALC861VD_3ST;
15878 }
15879 }
15880
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015881 err = snd_hda_attach_beep_device(codec, 0x23);
15882 if (err < 0) {
15883 alc_free(codec);
15884 return err;
15885 }
15886
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015887 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015888 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015889
Kailang Yang2f893282008-05-27 12:14:47 +020015890 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015891 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015892 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015893 }
15894
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015895 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15896 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15897
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015898 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15899 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15900
Takashi Iwaidd704692009-08-11 08:45:11 +020015901 if (!spec->adc_nids) {
15902 spec->adc_nids = alc861vd_adc_nids;
15903 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15904 }
15905 if (!spec->capsrc_nids)
15906 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015907
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015908 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015909 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015910
Takashi Iwai2134ea42008-01-10 16:53:55 +010015911 spec->vmaster_nid = 0x02;
15912
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015913 codec->patch_ops = alc_patch_ops;
15914
15915 if (board_config == ALC861VD_AUTO)
15916 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015917#ifdef CONFIG_SND_HDA_POWER_SAVE
15918 if (!spec->loopback.amplist)
15919 spec->loopback.amplist = alc861vd_loopbacks;
15920#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015921 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015922
15923 return 0;
15924}
15925
15926/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015927 * ALC662 support
15928 *
15929 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15930 * configuration. Each pin widget can choose any input DACs and a mixer.
15931 * Each ADC is connected from a mixer of all inputs. This makes possible
15932 * 6-channel independent captures.
15933 *
15934 * In addition, an independent DAC for the multi-playback (not used in this
15935 * driver yet).
15936 */
15937#define ALC662_DIGOUT_NID 0x06
15938#define ALC662_DIGIN_NID 0x0a
15939
15940static hda_nid_t alc662_dac_nids[4] = {
15941 /* front, rear, clfe, rear_surr */
15942 0x02, 0x03, 0x04
15943};
15944
Kailang Yang622e84c2009-04-21 07:39:04 +020015945static hda_nid_t alc272_dac_nids[2] = {
15946 0x02, 0x03
15947};
15948
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015949static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015950 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015951 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015952};
Takashi Iwaie1406342008-02-11 18:32:32 +010015953
Kailang Yang622e84c2009-04-21 07:39:04 +020015954static hda_nid_t alc272_adc_nids[1] = {
15955 /* ADC1-2 */
15956 0x08,
15957};
15958
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015959static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015960static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15961
Takashi Iwaie1406342008-02-11 18:32:32 +010015962
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015963/* input MUX */
15964/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015965static struct hda_input_mux alc662_capture_source = {
15966 .num_items = 4,
15967 .items = {
15968 { "Mic", 0x0 },
15969 { "Front Mic", 0x1 },
15970 { "Line", 0x2 },
15971 { "CD", 0x4 },
15972 },
15973};
15974
15975static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15976 .num_items = 2,
15977 .items = {
15978 { "Mic", 0x1 },
15979 { "Line", 0x2 },
15980 },
15981};
Kailang Yang291702f2007-10-16 14:28:03 +020015982
Kailang Yang6dda9f42008-05-27 12:05:31 +020015983static struct hda_input_mux alc663_capture_source = {
15984 .num_items = 3,
15985 .items = {
15986 { "Mic", 0x0 },
15987 { "Front Mic", 0x1 },
15988 { "Line", 0x2 },
15989 },
15990};
15991
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015992#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020015993static struct hda_input_mux alc272_nc10_capture_source = {
15994 .num_items = 16,
15995 .items = {
15996 { "Autoselect Mic", 0x0 },
15997 { "Internal Mic", 0x1 },
15998 { "In-0x02", 0x2 },
15999 { "In-0x03", 0x3 },
16000 { "In-0x04", 0x4 },
16001 { "In-0x05", 0x5 },
16002 { "In-0x06", 0x6 },
16003 { "In-0x07", 0x7 },
16004 { "In-0x08", 0x8 },
16005 { "In-0x09", 0x9 },
16006 { "In-0x0a", 0x0a },
16007 { "In-0x0b", 0x0b },
16008 { "In-0x0c", 0x0c },
16009 { "In-0x0d", 0x0d },
16010 { "In-0x0e", 0x0e },
16011 { "In-0x0f", 0x0f },
16012 },
16013};
16014#endif
16015
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016016/*
16017 * 2ch mode
16018 */
16019static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
16020 { 2, NULL }
16021};
16022
16023/*
16024 * 2ch mode
16025 */
16026static struct hda_verb alc662_3ST_ch2_init[] = {
16027 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
16028 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16029 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
16030 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16031 { } /* end */
16032};
16033
16034/*
16035 * 6ch mode
16036 */
16037static struct hda_verb alc662_3ST_ch6_init[] = {
16038 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16039 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16040 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
16041 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16042 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16043 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
16044 { } /* end */
16045};
16046
16047static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
16048 { 2, alc662_3ST_ch2_init },
16049 { 6, alc662_3ST_ch6_init },
16050};
16051
16052/*
16053 * 2ch mode
16054 */
16055static struct hda_verb alc662_sixstack_ch6_init[] = {
16056 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16057 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16058 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16059 { } /* end */
16060};
16061
16062/*
16063 * 6ch mode
16064 */
16065static struct hda_verb alc662_sixstack_ch8_init[] = {
16066 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16067 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16068 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16069 { } /* end */
16070};
16071
16072static struct hda_channel_mode alc662_5stack_modes[2] = {
16073 { 2, alc662_sixstack_ch6_init },
16074 { 6, alc662_sixstack_ch8_init },
16075};
16076
16077/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16078 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16079 */
16080
16081static struct snd_kcontrol_new alc662_base_mixer[] = {
16082 /* output mixer control */
16083 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016084 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016085 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016086 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016087 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16088 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016089 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16090 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016091 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16092
16093 /*Input mixer control */
16094 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
16095 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
16096 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
16097 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
16098 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
16099 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
16100 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
16101 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016102 { } /* end */
16103};
16104
16105static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
16106 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016107 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016108 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16109 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16110 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16111 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16112 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16113 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16114 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16115 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16116 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016117 { } /* end */
16118};
16119
16120static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
16121 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016122 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016123 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016124 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016125 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16126 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016127 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16128 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016129 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16130 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16131 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16132 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16133 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16134 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16135 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16136 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16137 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016138 { } /* end */
16139};
16140
16141static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
16142 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16143 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010016144 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16145 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016146 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16147 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16148 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16149 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16150 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016151 { } /* end */
16152};
16153
Kailang Yang291702f2007-10-16 14:28:03 +020016154static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016155 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16156 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020016157
16158 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
16159 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16160 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16161
16162 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16163 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16164 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16165 { } /* end */
16166};
16167
Kailang Yang8c427222008-01-10 13:03:59 +010016168static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016169 ALC262_HIPPO_MASTER_SWITCH,
16170 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016171 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016172 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16173 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016174 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
16175 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16176 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16177 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16178 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16179 { } /* end */
16180};
16181
Kailang Yangf1d4e282008-08-26 14:03:29 +020016182static struct hda_bind_ctls alc663_asus_bind_master_vol = {
16183 .ops = &snd_hda_bind_vol,
16184 .values = {
16185 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16186 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
16187 0
16188 },
16189};
16190
16191static struct hda_bind_ctls alc663_asus_one_bind_switch = {
16192 .ops = &snd_hda_bind_sw,
16193 .values = {
16194 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16195 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16196 0
16197 },
16198};
16199
Kailang Yang6dda9f42008-05-27 12:05:31 +020016200static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016201 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16202 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
16203 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16204 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16205 { } /* end */
16206};
16207
16208static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
16209 .ops = &snd_hda_bind_sw,
16210 .values = {
16211 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16212 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16213 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16214 0
16215 },
16216};
16217
16218static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
16219 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16220 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
16221 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16222 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16223 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16224 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16225
16226 { } /* end */
16227};
16228
16229static struct hda_bind_ctls alc663_asus_four_bind_switch = {
16230 .ops = &snd_hda_bind_sw,
16231 .values = {
16232 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16233 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16234 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16235 0
16236 },
16237};
16238
16239static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
16240 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16241 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
16242 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16243 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16244 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16245 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16246 { } /* end */
16247};
16248
16249static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016250 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16251 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016252 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16253 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16254 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16255 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16256 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16257 { } /* end */
16258};
16259
16260static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
16261 .ops = &snd_hda_bind_vol,
16262 .values = {
16263 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16264 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16265 0
16266 },
16267};
16268
16269static struct hda_bind_ctls alc663_asus_two_bind_switch = {
16270 .ops = &snd_hda_bind_sw,
16271 .values = {
16272 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16273 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
16274 0
16275 },
16276};
16277
16278static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16279 HDA_BIND_VOL("Master Playback Volume",
16280 &alc663_asus_two_bind_master_vol),
16281 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16282 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016283 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16284 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16285 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016286 { } /* end */
16287};
16288
16289static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16290 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16291 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16292 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16293 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16294 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16295 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016296 { } /* end */
16297};
16298
16299static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16300 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16301 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16302 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16303 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16304 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16305
16306 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16307 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16308 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16309 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16310 { } /* end */
16311};
16312
16313static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16314 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16315 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16316 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16317
16318 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16319 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16320 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16321 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16322 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16323 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16324 { } /* end */
16325};
16326
Kailang Yangebb83ee2009-12-17 12:23:00 +010016327static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
16328 .ops = &snd_hda_bind_sw,
16329 .values = {
16330 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16331 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16332 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16333 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16334 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16335 0
16336 },
16337};
16338
16339static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
16340 .ops = &snd_hda_bind_sw,
16341 .values = {
16342 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16343 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16344 0
16345 },
16346};
16347
16348static struct snd_kcontrol_new alc663_mode7_mixer[] = {
16349 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16350 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16351 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16352 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16353 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16354 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16355 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16356 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16357 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16358 { } /* end */
16359};
16360
16361static struct snd_kcontrol_new alc663_mode8_mixer[] = {
16362 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16363 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16364 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16365 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16366 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16367 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16368 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16369 { } /* end */
16370};
16371
16372
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016373static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16374 {
16375 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16376 .name = "Channel Mode",
16377 .info = alc_ch_mode_info,
16378 .get = alc_ch_mode_get,
16379 .put = alc_ch_mode_put,
16380 },
16381 { } /* end */
16382};
16383
16384static struct hda_verb alc662_init_verbs[] = {
16385 /* ADC: mute amp left and right */
16386 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16387 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16388 /* Front mixer: unmute input/output amp left and right (volume = 0) */
16389
Takashi Iwaicb53c622007-08-10 17:21:45 +020016390 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16391 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16392 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16393 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16394 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016395
Kailang Yangb60dd392007-09-20 12:50:29 +020016396 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16397 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16398 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16399 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16400 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16401 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016402
16403 /* Front Pin: output 0 (0x0c) */
16404 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16405 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16406
16407 /* Rear Pin: output 1 (0x0d) */
16408 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16409 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16410
16411 /* CLFE Pin: output 2 (0x0e) */
16412 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16413 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16414
16415 /* Mic (rear) pin: input vref at 80% */
16416 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16417 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16418 /* Front Mic pin: input vref at 80% */
16419 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16420 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16421 /* Line In pin: input */
16422 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16423 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16424 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16425 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16426 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16427 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16428 /* CD pin widget for input */
16429 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16430
16431 /* FIXME: use matrix-type input source selection */
16432 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16433 /* Input mixer */
16434 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016435 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016436
16437 /* always trun on EAPD */
16438 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16439 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16440
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016441 { }
16442};
16443
16444static struct hda_verb alc662_sue_init_verbs[] = {
16445 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16446 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016447 {}
16448};
16449
16450static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16451 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16452 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16453 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016454};
16455
Kailang Yang8c427222008-01-10 13:03:59 +010016456/* Set Unsolicited Event*/
16457static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16458 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16459 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16460 {}
16461};
16462
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016463/*
16464 * generic initialization of ADC, input mixers and output mixers
16465 */
16466static struct hda_verb alc662_auto_init_verbs[] = {
16467 /*
16468 * Unmute ADC and set the default input to mic-in
16469 */
16470 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16471 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16472
16473 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16474 * mixer widget
16475 * Note: PASD motherboards uses the Line In 2 as the input for front
16476 * panel mic (mic 2)
16477 */
16478 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016479 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16480 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16481 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16482 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16483 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016484
16485 /*
16486 * Set up output mixers (0x0c - 0x0f)
16487 */
16488 /* set vol=0 to output mixers */
16489 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16490 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16491 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16492
16493 /* set up input amps for analog loopback */
16494 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020016495 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16496 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16497 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16498 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16499 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16500 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016501
16502
16503 /* FIXME: use matrix-type input source selection */
16504 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16505 /* Input mixer */
16506 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016507 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016508 { }
16509};
16510
Takashi Iwai24fb9172008-09-02 14:48:20 +020016511/* additional verbs for ALC663 */
16512static struct hda_verb alc663_auto_init_verbs[] = {
16513 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16514 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16515 { }
16516};
16517
Kailang Yang6dda9f42008-05-27 12:05:31 +020016518static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016519 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16520 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016521 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16522 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016523 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16524 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16525 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016526 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16527 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16528 {}
16529};
16530
Kailang Yangf1d4e282008-08-26 14:03:29 +020016531static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16532 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16533 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16534 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16535 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16536 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16537 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16538 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16539 {}
16540};
16541
16542static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16543 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16544 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16545 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16546 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16547 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16548 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16549 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16550 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16551 {}
16552};
16553
16554static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16555 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16556 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16557 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16558 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16559 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16560 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16561 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16562 {}
16563};
16564
16565static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16566 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16567 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16568 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16569 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16570 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16571 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16572 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16573 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16574 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16575 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16576 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16577 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16578 {}
16579};
16580
16581static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16582 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16583 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16584 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16585 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16586 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16587 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16588 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16589 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16590 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16591 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16592 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16593 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16594 {}
16595};
16596
Kailang Yang6dda9f42008-05-27 12:05:31 +020016597static struct hda_verb alc663_g71v_init_verbs[] = {
16598 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16599 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16600 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16601
16602 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16603 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16604 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16605
16606 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16607 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16608 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16609 {}
16610};
16611
16612static struct hda_verb alc663_g50v_init_verbs[] = {
16613 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16614 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16615 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16616
16617 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16618 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16619 {}
16620};
16621
Kailang Yangf1d4e282008-08-26 14:03:29 +020016622static struct hda_verb alc662_ecs_init_verbs[] = {
16623 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16624 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16625 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16626 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16627 {}
16628};
16629
Kailang Yang622e84c2009-04-21 07:39:04 +020016630static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16631 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16632 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16633 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16634 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16635 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16636 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16637 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16638 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16639 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16640 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16641 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16642 {}
16643};
16644
16645static struct hda_verb alc272_dell_init_verbs[] = {
16646 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16647 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16648 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16649 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16650 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16651 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16652 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16653 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16654 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16655 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16656 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16657 {}
16658};
16659
Kailang Yangebb83ee2009-12-17 12:23:00 +010016660static struct hda_verb alc663_mode7_init_verbs[] = {
16661 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16662 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16663 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16664 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16665 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16666 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16667 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
16668 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16669 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16670 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16671 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16672 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16673 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16674 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16675 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16676 {}
16677};
16678
16679static struct hda_verb alc663_mode8_init_verbs[] = {
16680 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16681 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16682 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16683 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16684 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16685 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16686 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16687 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16688 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16689 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16690 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16691 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16692 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16693 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16694 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16695 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16696 {}
16697};
16698
Kailang Yangf1d4e282008-08-26 14:03:29 +020016699static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16700 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16701 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16702 { } /* end */
16703};
16704
Kailang Yang622e84c2009-04-21 07:39:04 +020016705static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16706 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16707 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16708 { } /* end */
16709};
16710
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016711static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16712{
16713 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016714 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016715
Wu Fengguang864f92b2009-11-18 12:38:02 +080016716 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016717 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016718
Takashi Iwai47fd8302007-08-10 17:11:07 +020016719 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16720 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016721}
16722
16723static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16724{
16725 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016726 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016727
Wu Fengguang864f92b2009-11-18 12:38:02 +080016728 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016729 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016730
Takashi Iwai47fd8302007-08-10 17:11:07 +020016731 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16732 HDA_AMP_MUTE, bits);
16733 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16734 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016735}
16736
16737static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16738 unsigned int res)
16739{
16740 if ((res >> 26) == ALC880_HP_EVENT)
16741 alc662_lenovo_101e_all_automute(codec);
16742 if ((res >> 26) == ALC880_FRONT_EVENT)
16743 alc662_lenovo_101e_ispeaker_automute(codec);
16744}
16745
Kailang Yang291702f2007-10-16 14:28:03 +020016746/* unsolicited event for HP jack sensing */
16747static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16748 unsigned int res)
16749{
Kailang Yang291702f2007-10-16 14:28:03 +020016750 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016751 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016752 else
16753 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016754}
16755
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016756static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020016757{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016758 struct alc_spec *spec = codec->spec;
16759
16760 alc262_hippo1_setup(codec);
16761 spec->ext_mic.pin = 0x18;
16762 spec->ext_mic.mux_idx = 0;
16763 spec->int_mic.pin = 0x19;
16764 spec->int_mic.mux_idx = 1;
16765 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020016766}
16767
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016768static void alc662_eeepc_inithook(struct hda_codec *codec)
16769{
16770 alc262_hippo_automute(codec);
16771 alc_mic_automute(codec);
16772}
16773
16774static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010016775{
Takashi Iwai42171c12009-05-08 14:11:43 +020016776 struct alc_spec *spec = codec->spec;
16777
16778 spec->autocfg.hp_pins[0] = 0x14;
16779 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010016780}
16781
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016782#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
16783
Kailang Yang6dda9f42008-05-27 12:05:31 +020016784static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16785{
16786 unsigned int present;
16787 unsigned char bits;
16788
Wu Fengguang864f92b2009-11-18 12:38:02 +080016789 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016790 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016791 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16792 AMP_IN_MUTE(0), bits);
16793 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16794 AMP_IN_MUTE(0), bits);
16795}
16796
16797static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16798{
16799 unsigned int present;
16800 unsigned char bits;
16801
Wu Fengguang864f92b2009-11-18 12:38:02 +080016802 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016803 bits = present ? HDA_AMP_MUTE : 0;
16804 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16805 AMP_IN_MUTE(0), bits);
16806 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16807 AMP_IN_MUTE(0), bits);
16808 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16809 AMP_IN_MUTE(0), bits);
16810 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16811 AMP_IN_MUTE(0), bits);
16812}
16813
16814static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16815{
16816 unsigned int present;
16817 unsigned char bits;
16818
Wu Fengguang864f92b2009-11-18 12:38:02 +080016819 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016820 bits = present ? HDA_AMP_MUTE : 0;
16821 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16822 AMP_IN_MUTE(0), bits);
16823 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16824 AMP_IN_MUTE(0), bits);
16825 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16826 AMP_IN_MUTE(0), bits);
16827 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16828 AMP_IN_MUTE(0), bits);
16829}
16830
16831static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16832{
16833 unsigned int present;
16834 unsigned char bits;
16835
Wu Fengguang864f92b2009-11-18 12:38:02 +080016836 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016837 bits = present ? 0 : PIN_OUT;
16838 snd_hda_codec_write(codec, 0x14, 0,
16839 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16840}
16841
16842static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16843{
16844 unsigned int present1, present2;
16845
Wu Fengguang864f92b2009-11-18 12:38:02 +080016846 present1 = snd_hda_jack_detect(codec, 0x21);
16847 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016848
16849 if (present1 || present2) {
16850 snd_hda_codec_write_cache(codec, 0x14, 0,
16851 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16852 } else {
16853 snd_hda_codec_write_cache(codec, 0x14, 0,
16854 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16855 }
16856}
16857
16858static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16859{
16860 unsigned int present1, present2;
16861
Wu Fengguang864f92b2009-11-18 12:38:02 +080016862 present1 = snd_hda_jack_detect(codec, 0x1b);
16863 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016864
16865 if (present1 || present2) {
16866 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16867 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16868 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16869 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16870 } else {
16871 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16872 AMP_IN_MUTE(0), 0);
16873 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16874 AMP_IN_MUTE(0), 0);
16875 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016876}
16877
Kailang Yangebb83ee2009-12-17 12:23:00 +010016878static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
16879{
16880 unsigned int present1, present2;
16881
16882 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16883 AC_VERB_GET_PIN_SENSE, 0)
16884 & AC_PINSENSE_PRESENCE;
16885 present2 = snd_hda_codec_read(codec, 0x21, 0,
16886 AC_VERB_GET_PIN_SENSE, 0)
16887 & AC_PINSENSE_PRESENCE;
16888
16889 if (present1 || present2) {
16890 snd_hda_codec_write_cache(codec, 0x14, 0,
16891 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16892 snd_hda_codec_write_cache(codec, 0x17, 0,
16893 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16894 } else {
16895 snd_hda_codec_write_cache(codec, 0x14, 0,
16896 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16897 snd_hda_codec_write_cache(codec, 0x17, 0,
16898 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16899 }
16900}
16901
16902static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
16903{
16904 unsigned int present1, present2;
16905
16906 present1 = snd_hda_codec_read(codec, 0x21, 0,
16907 AC_VERB_GET_PIN_SENSE, 0)
16908 & AC_PINSENSE_PRESENCE;
16909 present2 = snd_hda_codec_read(codec, 0x15, 0,
16910 AC_VERB_GET_PIN_SENSE, 0)
16911 & AC_PINSENSE_PRESENCE;
16912
16913 if (present1 || present2) {
16914 snd_hda_codec_write_cache(codec, 0x14, 0,
16915 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16916 snd_hda_codec_write_cache(codec, 0x17, 0,
16917 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16918 } else {
16919 snd_hda_codec_write_cache(codec, 0x14, 0,
16920 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16921 snd_hda_codec_write_cache(codec, 0x17, 0,
16922 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16923 }
16924}
16925
Kailang Yang6dda9f42008-05-27 12:05:31 +020016926static void alc663_m51va_unsol_event(struct hda_codec *codec,
16927 unsigned int res)
16928{
16929 switch (res >> 26) {
16930 case ALC880_HP_EVENT:
16931 alc663_m51va_speaker_automute(codec);
16932 break;
16933 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016934 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016935 break;
16936 }
16937}
16938
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016939static void alc663_m51va_setup(struct hda_codec *codec)
16940{
16941 struct alc_spec *spec = codec->spec;
16942 spec->ext_mic.pin = 0x18;
16943 spec->ext_mic.mux_idx = 0;
16944 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010016945 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016946 spec->auto_mic = 1;
16947}
16948
Kailang Yang6dda9f42008-05-27 12:05:31 +020016949static void alc663_m51va_inithook(struct hda_codec *codec)
16950{
16951 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016952 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016953}
16954
Kailang Yangf1d4e282008-08-26 14:03:29 +020016955/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016956#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010016957
16958static void alc663_mode1_setup(struct hda_codec *codec)
16959{
16960 struct alc_spec *spec = codec->spec;
16961 spec->ext_mic.pin = 0x18;
16962 spec->ext_mic.mux_idx = 0;
16963 spec->int_mic.pin = 0x19;
16964 spec->int_mic.mux_idx = 1;
16965 spec->auto_mic = 1;
16966}
16967
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016968#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020016969
Kailang Yangf1d4e282008-08-26 14:03:29 +020016970/* ***************** Mode2 ******************************/
16971static void alc662_mode2_unsol_event(struct hda_codec *codec,
16972 unsigned int res)
16973{
16974 switch (res >> 26) {
16975 case ALC880_HP_EVENT:
16976 alc662_f5z_speaker_automute(codec);
16977 break;
16978 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016979 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016980 break;
16981 }
16982}
16983
Kailang Yangebb83ee2009-12-17 12:23:00 +010016984#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016985
Kailang Yangf1d4e282008-08-26 14:03:29 +020016986static void alc662_mode2_inithook(struct hda_codec *codec)
16987{
16988 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016989 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016990}
16991/* ***************** Mode3 ******************************/
16992static void alc663_mode3_unsol_event(struct hda_codec *codec,
16993 unsigned int res)
16994{
16995 switch (res >> 26) {
16996 case ALC880_HP_EVENT:
16997 alc663_two_hp_m1_speaker_automute(codec);
16998 break;
16999 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017000 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017001 break;
17002 }
17003}
17004
Kailang Yangebb83ee2009-12-17 12:23:00 +010017005#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017006
Kailang Yangf1d4e282008-08-26 14:03:29 +020017007static void alc663_mode3_inithook(struct hda_codec *codec)
17008{
17009 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017010 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017011}
17012/* ***************** Mode4 ******************************/
17013static void alc663_mode4_unsol_event(struct hda_codec *codec,
17014 unsigned int res)
17015{
17016 switch (res >> 26) {
17017 case ALC880_HP_EVENT:
17018 alc663_21jd_two_speaker_automute(codec);
17019 break;
17020 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017021 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017022 break;
17023 }
17024}
17025
Kailang Yangebb83ee2009-12-17 12:23:00 +010017026#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017027
Kailang Yangf1d4e282008-08-26 14:03:29 +020017028static void alc663_mode4_inithook(struct hda_codec *codec)
17029{
17030 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017031 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017032}
17033/* ***************** Mode5 ******************************/
17034static void alc663_mode5_unsol_event(struct hda_codec *codec,
17035 unsigned int res)
17036{
17037 switch (res >> 26) {
17038 case ALC880_HP_EVENT:
17039 alc663_15jd_two_speaker_automute(codec);
17040 break;
17041 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017042 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017043 break;
17044 }
17045}
17046
Kailang Yangebb83ee2009-12-17 12:23:00 +010017047#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017048
Kailang Yangf1d4e282008-08-26 14:03:29 +020017049static void alc663_mode5_inithook(struct hda_codec *codec)
17050{
17051 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017052 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017053}
17054/* ***************** Mode6 ******************************/
17055static void alc663_mode6_unsol_event(struct hda_codec *codec,
17056 unsigned int res)
17057{
17058 switch (res >> 26) {
17059 case ALC880_HP_EVENT:
17060 alc663_two_hp_m2_speaker_automute(codec);
17061 break;
17062 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017063 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017064 break;
17065 }
17066}
17067
Kailang Yangebb83ee2009-12-17 12:23:00 +010017068#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017069
Kailang Yangf1d4e282008-08-26 14:03:29 +020017070static void alc663_mode6_inithook(struct hda_codec *codec)
17071{
17072 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017073 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017074}
17075
Kailang Yangebb83ee2009-12-17 12:23:00 +010017076/* ***************** Mode7 ******************************/
17077static void alc663_mode7_unsol_event(struct hda_codec *codec,
17078 unsigned int res)
17079{
17080 switch (res >> 26) {
17081 case ALC880_HP_EVENT:
17082 alc663_two_hp_m7_speaker_automute(codec);
17083 break;
17084 case ALC880_MIC_EVENT:
17085 alc_mic_automute(codec);
17086 break;
17087 }
17088}
17089
17090#define alc663_mode7_setup alc663_mode1_setup
17091
17092static void alc663_mode7_inithook(struct hda_codec *codec)
17093{
17094 alc663_two_hp_m7_speaker_automute(codec);
17095 alc_mic_automute(codec);
17096}
17097
17098/* ***************** Mode8 ******************************/
17099static void alc663_mode8_unsol_event(struct hda_codec *codec,
17100 unsigned int res)
17101{
17102 switch (res >> 26) {
17103 case ALC880_HP_EVENT:
17104 alc663_two_hp_m8_speaker_automute(codec);
17105 break;
17106 case ALC880_MIC_EVENT:
17107 alc_mic_automute(codec);
17108 break;
17109 }
17110}
17111
17112#define alc663_mode8_setup alc663_m51va_setup
17113
17114static void alc663_mode8_inithook(struct hda_codec *codec)
17115{
17116 alc663_two_hp_m8_speaker_automute(codec);
17117 alc_mic_automute(codec);
17118}
17119
Kailang Yang6dda9f42008-05-27 12:05:31 +020017120static void alc663_g71v_hp_automute(struct hda_codec *codec)
17121{
17122 unsigned int present;
17123 unsigned char bits;
17124
Wu Fengguang864f92b2009-11-18 12:38:02 +080017125 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017126 bits = present ? HDA_AMP_MUTE : 0;
17127 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17128 HDA_AMP_MUTE, bits);
17129 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17130 HDA_AMP_MUTE, bits);
17131}
17132
17133static void alc663_g71v_front_automute(struct hda_codec *codec)
17134{
17135 unsigned int present;
17136 unsigned char bits;
17137
Wu Fengguang864f92b2009-11-18 12:38:02 +080017138 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017139 bits = present ? HDA_AMP_MUTE : 0;
17140 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17141 HDA_AMP_MUTE, bits);
17142}
17143
17144static void alc663_g71v_unsol_event(struct hda_codec *codec,
17145 unsigned int res)
17146{
17147 switch (res >> 26) {
17148 case ALC880_HP_EVENT:
17149 alc663_g71v_hp_automute(codec);
17150 break;
17151 case ALC880_FRONT_EVENT:
17152 alc663_g71v_front_automute(codec);
17153 break;
17154 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017155 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017156 break;
17157 }
17158}
17159
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017160#define alc663_g71v_setup alc663_m51va_setup
17161
Kailang Yang6dda9f42008-05-27 12:05:31 +020017162static void alc663_g71v_inithook(struct hda_codec *codec)
17163{
17164 alc663_g71v_front_automute(codec);
17165 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017166 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017167}
17168
17169static void alc663_g50v_unsol_event(struct hda_codec *codec,
17170 unsigned int res)
17171{
17172 switch (res >> 26) {
17173 case ALC880_HP_EVENT:
17174 alc663_m51va_speaker_automute(codec);
17175 break;
17176 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017177 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017178 break;
17179 }
17180}
17181
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017182#define alc663_g50v_setup alc663_m51va_setup
17183
Kailang Yang6dda9f42008-05-27 12:05:31 +020017184static void alc663_g50v_inithook(struct hda_codec *codec)
17185{
17186 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017187 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017188}
17189
Kailang Yangf1d4e282008-08-26 14:03:29 +020017190static struct snd_kcontrol_new alc662_ecs_mixer[] = {
17191 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020017192 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017193
17194 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
17195 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
17196 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
17197
17198 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17199 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17200 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17201 { } /* end */
17202};
17203
Chris Pockelé9541ba12009-05-12 08:08:53 +020017204static struct snd_kcontrol_new alc272_nc10_mixer[] = {
17205 /* Master Playback automatically created from Speaker and Headphone */
17206 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17207 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17208 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17209 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17210
17211 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17212 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17213 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
17214
17215 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17216 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17217 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
17218 { } /* end */
17219};
17220
Takashi Iwaicb53c622007-08-10 17:21:45 +020017221#ifdef CONFIG_SND_HDA_POWER_SAVE
17222#define alc662_loopbacks alc880_loopbacks
17223#endif
17224
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017225
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017226/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017227#define alc662_pcm_analog_playback alc880_pcm_analog_playback
17228#define alc662_pcm_analog_capture alc880_pcm_analog_capture
17229#define alc662_pcm_digital_playback alc880_pcm_digital_playback
17230#define alc662_pcm_digital_capture alc880_pcm_digital_capture
17231
17232/*
17233 * configuration and preset
17234 */
17235static const char *alc662_models[ALC662_MODEL_LAST] = {
17236 [ALC662_3ST_2ch_DIG] = "3stack-dig",
17237 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
17238 [ALC662_3ST_6ch] = "3stack-6ch",
17239 [ALC662_5ST_DIG] = "6stack-dig",
17240 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020017241 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010017242 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017243 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020017244 [ALC663_ASUS_M51VA] = "m51va",
17245 [ALC663_ASUS_G71V] = "g71v",
17246 [ALC663_ASUS_H13] = "h13",
17247 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017248 [ALC663_ASUS_MODE1] = "asus-mode1",
17249 [ALC662_ASUS_MODE2] = "asus-mode2",
17250 [ALC663_ASUS_MODE3] = "asus-mode3",
17251 [ALC663_ASUS_MODE4] = "asus-mode4",
17252 [ALC663_ASUS_MODE5] = "asus-mode5",
17253 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010017254 [ALC663_ASUS_MODE7] = "asus-mode7",
17255 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020017256 [ALC272_DELL] = "dell",
17257 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020017258 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017259 [ALC662_AUTO] = "auto",
17260};
17261
17262static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010017263 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020017264 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
17265 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017266 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
17267 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
17268 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
17269 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
17270 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
17271 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017272 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
17273 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017274 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017275 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
17276 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
17277 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
17278 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
17279 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017280 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017281 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
17282 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017283 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
17284 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
17285 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
17286 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017287 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017288 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
17289 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
17290 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017291 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
17292 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
17293 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
17294 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017295 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017296 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
17297 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017298 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017299 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
17300 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
17301 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017302 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
17303 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
17304 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017305 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
17306 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
17307 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017308 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017309 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
17310 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017311 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017312 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020017313 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017314 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
17315 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
17316 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017317 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017318 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
17319 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010017320 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020017321 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010017322 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017323 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030017324 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
17325 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010017326 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020017327 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030017328 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
17329 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020017330 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020017331 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017332 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020017333 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020017334 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017335 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
17336 ALC663_ASUS_H13),
David Santinoli7aee6742009-12-09 12:34:26 +010017337 SND_PCI_QUIRK(0x8086, 0xd604, "Intel mobo", ALC662_3ST_2ch_DIG),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017338 {}
17339};
17340
17341static struct alc_config_preset alc662_presets[] = {
17342 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017343 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017344 .init_verbs = { alc662_init_verbs },
17345 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17346 .dac_nids = alc662_dac_nids,
17347 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017348 .dig_in_nid = ALC662_DIGIN_NID,
17349 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17350 .channel_mode = alc662_3ST_2ch_modes,
17351 .input_mux = &alc662_capture_source,
17352 },
17353 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017354 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017355 .init_verbs = { alc662_init_verbs },
17356 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17357 .dac_nids = alc662_dac_nids,
17358 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017359 .dig_in_nid = ALC662_DIGIN_NID,
17360 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17361 .channel_mode = alc662_3ST_6ch_modes,
17362 .need_dac_fix = 1,
17363 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017364 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017365 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017366 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017367 .init_verbs = { alc662_init_verbs },
17368 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17369 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017370 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17371 .channel_mode = alc662_3ST_6ch_modes,
17372 .need_dac_fix = 1,
17373 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017374 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017375 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017376 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017377 .init_verbs = { alc662_init_verbs },
17378 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17379 .dac_nids = alc662_dac_nids,
17380 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017381 .dig_in_nid = ALC662_DIGIN_NID,
17382 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
17383 .channel_mode = alc662_5stack_modes,
17384 .input_mux = &alc662_capture_source,
17385 },
17386 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017387 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017388 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
17389 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17390 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017391 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17392 .channel_mode = alc662_3ST_2ch_modes,
17393 .input_mux = &alc662_lenovo_101e_capture_source,
17394 .unsol_event = alc662_lenovo_101e_unsol_event,
17395 .init_hook = alc662_lenovo_101e_all_automute,
17396 },
Kailang Yang291702f2007-10-16 14:28:03 +020017397 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017398 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020017399 .init_verbs = { alc662_init_verbs,
17400 alc662_eeepc_sue_init_verbs },
17401 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17402 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020017403 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17404 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020017405 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017406 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020017407 .init_hook = alc662_eeepc_inithook,
17408 },
Kailang Yang8c427222008-01-10 13:03:59 +010017409 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017410 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010017411 alc662_chmode_mixer },
17412 .init_verbs = { alc662_init_verbs,
17413 alc662_eeepc_ep20_sue_init_verbs },
17414 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17415 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010017416 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17417 .channel_mode = alc662_3ST_6ch_modes,
17418 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020017419 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017420 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010017421 .init_hook = alc662_eeepc_ep20_inithook,
17422 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017423 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017424 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017425 .init_verbs = { alc662_init_verbs,
17426 alc662_ecs_init_verbs },
17427 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17428 .dac_nids = alc662_dac_nids,
17429 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17430 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017431 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017432 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017433 .init_hook = alc662_eeepc_inithook,
17434 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017435 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017436 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017437 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17438 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17439 .dac_nids = alc662_dac_nids,
17440 .dig_out_nid = ALC662_DIGOUT_NID,
17441 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17442 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017443 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017444 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017445 .init_hook = alc663_m51va_inithook,
17446 },
17447 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017448 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017449 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
17450 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17451 .dac_nids = alc662_dac_nids,
17452 .dig_out_nid = ALC662_DIGOUT_NID,
17453 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17454 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017455 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017456 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017457 .init_hook = alc663_g71v_inithook,
17458 },
17459 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017460 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017461 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17462 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17463 .dac_nids = alc662_dac_nids,
17464 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17465 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017466 .unsol_event = alc663_m51va_unsol_event,
17467 .init_hook = alc663_m51va_inithook,
17468 },
17469 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017470 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017471 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17472 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17473 .dac_nids = alc662_dac_nids,
17474 .dig_out_nid = ALC662_DIGOUT_NID,
17475 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17476 .channel_mode = alc662_3ST_6ch_modes,
17477 .input_mux = &alc663_capture_source,
17478 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017479 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017480 .init_hook = alc663_g50v_inithook,
17481 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017482 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017483 .mixers = { alc663_m51va_mixer },
17484 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017485 .init_verbs = { alc662_init_verbs,
17486 alc663_21jd_amic_init_verbs },
17487 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17488 .hp_nid = 0x03,
17489 .dac_nids = alc662_dac_nids,
17490 .dig_out_nid = ALC662_DIGOUT_NID,
17491 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17492 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017493 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017494 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017495 .init_hook = alc663_mode1_inithook,
17496 },
17497 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017498 .mixers = { alc662_1bjd_mixer },
17499 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017500 .init_verbs = { alc662_init_verbs,
17501 alc662_1bjd_amic_init_verbs },
17502 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17503 .dac_nids = alc662_dac_nids,
17504 .dig_out_nid = ALC662_DIGOUT_NID,
17505 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17506 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017507 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017508 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017509 .init_hook = alc662_mode2_inithook,
17510 },
17511 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017512 .mixers = { alc663_two_hp_m1_mixer },
17513 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017514 .init_verbs = { alc662_init_verbs,
17515 alc663_two_hp_amic_m1_init_verbs },
17516 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17517 .hp_nid = 0x03,
17518 .dac_nids = alc662_dac_nids,
17519 .dig_out_nid = ALC662_DIGOUT_NID,
17520 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17521 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017522 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017523 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017524 .init_hook = alc663_mode3_inithook,
17525 },
17526 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017527 .mixers = { alc663_asus_21jd_clfe_mixer },
17528 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017529 .init_verbs = { alc662_init_verbs,
17530 alc663_21jd_amic_init_verbs},
17531 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17532 .hp_nid = 0x03,
17533 .dac_nids = alc662_dac_nids,
17534 .dig_out_nid = ALC662_DIGOUT_NID,
17535 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17536 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017537 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017538 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017539 .init_hook = alc663_mode4_inithook,
17540 },
17541 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017542 .mixers = { alc663_asus_15jd_clfe_mixer },
17543 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017544 .init_verbs = { alc662_init_verbs,
17545 alc663_15jd_amic_init_verbs },
17546 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17547 .hp_nid = 0x03,
17548 .dac_nids = alc662_dac_nids,
17549 .dig_out_nid = ALC662_DIGOUT_NID,
17550 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17551 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017552 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017553 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017554 .init_hook = alc663_mode5_inithook,
17555 },
17556 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017557 .mixers = { alc663_two_hp_m2_mixer },
17558 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017559 .init_verbs = { alc662_init_verbs,
17560 alc663_two_hp_amic_m2_init_verbs },
17561 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17562 .hp_nid = 0x03,
17563 .dac_nids = alc662_dac_nids,
17564 .dig_out_nid = ALC662_DIGOUT_NID,
17565 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17566 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017567 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017568 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017569 .init_hook = alc663_mode6_inithook,
17570 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010017571 [ALC663_ASUS_MODE7] = {
17572 .mixers = { alc663_mode7_mixer },
17573 .cap_mixer = alc662_auto_capture_mixer,
17574 .init_verbs = { alc662_init_verbs,
17575 alc663_mode7_init_verbs },
17576 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17577 .hp_nid = 0x03,
17578 .dac_nids = alc662_dac_nids,
17579 .dig_out_nid = ALC662_DIGOUT_NID,
17580 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17581 .channel_mode = alc662_3ST_2ch_modes,
17582 .unsol_event = alc663_mode7_unsol_event,
17583 .setup = alc663_mode7_setup,
17584 .init_hook = alc663_mode7_inithook,
17585 },
17586 [ALC663_ASUS_MODE8] = {
17587 .mixers = { alc663_mode8_mixer },
17588 .cap_mixer = alc662_auto_capture_mixer,
17589 .init_verbs = { alc662_init_verbs,
17590 alc663_mode8_init_verbs },
17591 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17592 .hp_nid = 0x03,
17593 .dac_nids = alc662_dac_nids,
17594 .dig_out_nid = ALC662_DIGOUT_NID,
17595 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17596 .channel_mode = alc662_3ST_2ch_modes,
17597 .unsol_event = alc663_mode8_unsol_event,
17598 .setup = alc663_mode8_setup,
17599 .init_hook = alc663_mode8_inithook,
17600 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017601 [ALC272_DELL] = {
17602 .mixers = { alc663_m51va_mixer },
17603 .cap_mixer = alc272_auto_capture_mixer,
17604 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17605 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17606 .dac_nids = alc662_dac_nids,
17607 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17608 .adc_nids = alc272_adc_nids,
17609 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17610 .capsrc_nids = alc272_capsrc_nids,
17611 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017612 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017613 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017614 .init_hook = alc663_m51va_inithook,
17615 },
17616 [ALC272_DELL_ZM1] = {
17617 .mixers = { alc663_m51va_mixer },
17618 .cap_mixer = alc662_auto_capture_mixer,
17619 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17620 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17621 .dac_nids = alc662_dac_nids,
17622 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17623 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017624 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020017625 .capsrc_nids = alc662_capsrc_nids,
17626 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017627 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017628 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017629 .init_hook = alc663_m51va_inithook,
17630 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017631 [ALC272_SAMSUNG_NC10] = {
17632 .mixers = { alc272_nc10_mixer },
17633 .init_verbs = { alc662_init_verbs,
17634 alc663_21jd_amic_init_verbs },
17635 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17636 .dac_nids = alc272_dac_nids,
17637 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17638 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017639 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020017640 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017641 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020017642 .init_hook = alc663_mode4_inithook,
17643 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017644};
17645
17646
17647/*
17648 * BIOS auto configuration
17649 */
17650
Takashi Iwai7085ec12009-10-02 09:03:58 +020017651/* convert from MIX nid to DAC */
17652static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
17653{
17654 if (nid == 0x0f)
17655 return 0x02;
17656 else if (nid >= 0x0c && nid <= 0x0e)
17657 return nid - 0x0c + 0x02;
17658 else
17659 return 0;
17660}
17661
17662/* get MIX nid connected to the given pin targeted to DAC */
17663static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
17664 hda_nid_t dac)
17665{
17666 hda_nid_t mix[4];
17667 int i, num;
17668
17669 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
17670 for (i = 0; i < num; i++) {
17671 if (alc662_mix_to_dac(mix[i]) == dac)
17672 return mix[i];
17673 }
17674 return 0;
17675}
17676
17677/* look for an empty DAC slot */
17678static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
17679{
17680 struct alc_spec *spec = codec->spec;
17681 hda_nid_t srcs[5];
17682 int i, j, num;
17683
17684 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
17685 if (num < 0)
17686 return 0;
17687 for (i = 0; i < num; i++) {
17688 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
17689 if (!nid)
17690 continue;
17691 for (j = 0; j < spec->multiout.num_dacs; j++)
17692 if (spec->multiout.dac_nids[j] == nid)
17693 break;
17694 if (j >= spec->multiout.num_dacs)
17695 return nid;
17696 }
17697 return 0;
17698}
17699
17700/* fill in the dac_nids table from the parsed pin configuration */
17701static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
17702 const struct auto_pin_cfg *cfg)
17703{
17704 struct alc_spec *spec = codec->spec;
17705 int i;
17706 hda_nid_t dac;
17707
17708 spec->multiout.dac_nids = spec->private_dac_nids;
17709 for (i = 0; i < cfg->line_outs; i++) {
17710 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
17711 if (!dac)
17712 continue;
17713 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
17714 }
17715 return 0;
17716}
17717
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017718static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017719 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017720{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017721 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017722 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
17723}
17724
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017725static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017726 hda_nid_t nid, unsigned int chs)
17727{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017728 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017729 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
17730}
17731
17732#define alc662_add_stereo_vol(spec, pfx, nid) \
17733 alc662_add_vol_ctl(spec, pfx, nid, 3)
17734#define alc662_add_stereo_sw(spec, pfx, nid) \
17735 alc662_add_sw_ctl(spec, pfx, nid, 3)
17736
17737/* add playback controls from the parsed DAC table */
17738static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
17739 const struct auto_pin_cfg *cfg)
17740{
17741 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017742 static const char *chname[4] = {
17743 "Front", "Surround", NULL /*CLFE*/, "Side"
17744 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020017745 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017746 int i, err;
17747
17748 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017749 nid = spec->multiout.dac_nids[i];
17750 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017751 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017752 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
17753 if (!mix)
17754 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017755 if (i == 2) {
17756 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017757 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017758 if (err < 0)
17759 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017760 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017761 if (err < 0)
17762 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017763 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017764 if (err < 0)
17765 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017766 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017767 if (err < 0)
17768 return err;
17769 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017770 const char *pfx;
17771 if (cfg->line_outs == 1 &&
17772 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017773 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017774 pfx = "Speaker";
17775 else
17776 pfx = "PCM";
17777 } else
17778 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017779 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017780 if (err < 0)
17781 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017782 if (cfg->line_outs == 1 &&
17783 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
17784 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020017785 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017786 if (err < 0)
17787 return err;
17788 }
17789 }
17790 return 0;
17791}
17792
17793/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017794/* return DAC nid if any new DAC is assigned */
17795static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017796 const char *pfx)
17797{
Takashi Iwai7085ec12009-10-02 09:03:58 +020017798 struct alc_spec *spec = codec->spec;
17799 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017800 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017801
17802 if (!pin)
17803 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017804 nid = alc662_look_for_dac(codec, pin);
17805 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017806 /* the corresponding DAC is already occupied */
17807 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
17808 return 0; /* no way */
17809 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017810 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017811 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17812 }
17813
17814 mix = alc662_dac_to_mix(codec, pin, nid);
17815 if (!mix)
17816 return 0;
17817 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
17818 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020017819 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017820 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
17821 if (err < 0)
17822 return err;
17823 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017824}
17825
17826/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017827#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020017828 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017829
17830static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17831 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017832 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017833{
Takashi Iwai7085ec12009-10-02 09:03:58 +020017834 int i, num;
17835 hda_nid_t srcs[4];
17836
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017837 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017838 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017839 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
17840 if (num <= 1)
17841 return;
17842 for (i = 0; i < num; i++) {
17843 if (alc662_mix_to_dac(srcs[i]) != dac)
17844 continue;
17845 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
17846 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017847 }
17848}
17849
17850static void alc662_auto_init_multi_out(struct hda_codec *codec)
17851{
17852 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017853 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017854 int i;
17855
17856 for (i = 0; i <= HDA_SIDE; i++) {
17857 hda_nid_t nid = spec->autocfg.line_out_pins[i];
17858 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017859 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017860 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017861 }
17862}
17863
17864static void alc662_auto_init_hp_out(struct hda_codec *codec)
17865{
17866 struct alc_spec *spec = codec->spec;
17867 hda_nid_t pin;
17868
17869 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017870 if (pin)
17871 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
17872 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017873 pin = spec->autocfg.speaker_pins[0];
17874 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020017875 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
17876 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017877}
17878
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017879#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17880
17881static void alc662_auto_init_analog_input(struct hda_codec *codec)
17882{
17883 struct alc_spec *spec = codec->spec;
17884 int i;
17885
17886 for (i = 0; i < AUTO_PIN_LAST; i++) {
17887 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020017888 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017889 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017890 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017891 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017892 snd_hda_codec_write(codec, nid, 0,
17893 AC_VERB_SET_AMP_GAIN_MUTE,
17894 AMP_OUT_MUTE);
17895 }
17896 }
17897}
17898
Takashi Iwaif511b012008-08-15 16:46:42 +020017899#define alc662_auto_init_input_src alc882_auto_init_input_src
17900
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017901static int alc662_parse_auto_config(struct hda_codec *codec)
17902{
17903 struct alc_spec *spec = codec->spec;
17904 int err;
17905 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17906
17907 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17908 alc662_ignore);
17909 if (err < 0)
17910 return err;
17911 if (!spec->autocfg.line_outs)
17912 return 0; /* can't find valid BIOS pin config */
17913
Takashi Iwai7085ec12009-10-02 09:03:58 +020017914 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017915 if (err < 0)
17916 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017917 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017918 if (err < 0)
17919 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017920 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017921 spec->autocfg.speaker_pins[0],
17922 "Speaker");
17923 if (err < 0)
17924 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017925 if (err)
17926 spec->multiout.extra_out_nid[0] = err;
17927 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017928 "Headphone");
17929 if (err < 0)
17930 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017931 if (err)
17932 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017933 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017934 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017935 return err;
17936
17937 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17938
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017939 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017940 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17941
Takashi Iwai603c4012008-07-30 15:01:44 +020017942 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017943 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017944
17945 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017946 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017947
Takashi Iwaid88897e2008-10-31 15:01:37 +010017948 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017949 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017950 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017951
17952 err = alc_auto_add_mic_boost(codec);
17953 if (err < 0)
17954 return err;
17955
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017956 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17957
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017958 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017959}
17960
17961/* additional initialization for auto-configuration model */
17962static void alc662_auto_init(struct hda_codec *codec)
17963{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017964 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017965 alc662_auto_init_multi_out(codec);
17966 alc662_auto_init_hp_out(codec);
17967 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017968 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017969 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017970 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017971}
17972
17973static int patch_alc662(struct hda_codec *codec)
17974{
17975 struct alc_spec *spec;
17976 int err, board_config;
17977
17978 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17979 if (!spec)
17980 return -ENOMEM;
17981
17982 codec->spec = spec;
17983
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017984 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17985
Kailang Yang274693f2009-12-03 10:07:50 +010017986 if (alc_read_coef_idx(codec, 0)==0x8020){
17987 kfree(codec->chip_name);
17988 codec->chip_name = kstrdup("ALC661", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017989 if (!codec->chip_name) {
17990 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010017991 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017992 }
Kailang Yang274693f2009-12-03 10:07:50 +010017993 }
17994
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017995 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17996 alc662_models,
17997 alc662_cfg_tbl);
17998 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017999 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
18000 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018001 board_config = ALC662_AUTO;
18002 }
18003
18004 if (board_config == ALC662_AUTO) {
18005 /* automatic parse from the BIOS config */
18006 err = alc662_parse_auto_config(codec);
18007 if (err < 0) {
18008 alc_free(codec);
18009 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018010 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018011 printk(KERN_INFO
18012 "hda_codec: Cannot set up configuration "
18013 "from BIOS. Using base mode...\n");
18014 board_config = ALC662_3ST_2ch_DIG;
18015 }
18016 }
18017
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090018018 err = snd_hda_attach_beep_device(codec, 0x1);
18019 if (err < 0) {
18020 alc_free(codec);
18021 return err;
18022 }
18023
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018024 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020018025 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018026
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018027 spec->stream_analog_playback = &alc662_pcm_analog_playback;
18028 spec->stream_analog_capture = &alc662_pcm_analog_capture;
18029
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018030 spec->stream_digital_playback = &alc662_pcm_digital_playback;
18031 spec->stream_digital_capture = &alc662_pcm_digital_capture;
18032
Takashi Iwaidd704692009-08-11 08:45:11 +020018033 if (!spec->adc_nids) {
18034 spec->adc_nids = alc662_adc_nids;
18035 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
18036 }
18037 if (!spec->capsrc_nids)
18038 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018039
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018040 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018041 set_capture_mixer(codec);
Takashi Iwaib9591442009-03-16 15:25:00 +010018042 if (codec->vendor_id == 0x10ec0662)
18043 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
18044 else
18045 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018046
Takashi Iwai2134ea42008-01-10 16:53:55 +010018047 spec->vmaster_nid = 0x02;
18048
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018049 codec->patch_ops = alc_patch_ops;
18050 if (board_config == ALC662_AUTO)
18051 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020018052#ifdef CONFIG_SND_HDA_POWER_SAVE
18053 if (!spec->loopback.amplist)
18054 spec->loopback.amplist = alc662_loopbacks;
18055#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010018056 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018057
18058 return 0;
18059}
18060
Kailang Yang274693f2009-12-03 10:07:50 +010018061static int patch_alc888(struct hda_codec *codec)
18062{
18063 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
18064 kfree(codec->chip_name);
18065 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018066 if (!codec->chip_name) {
18067 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018068 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018069 }
18070 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018071 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018072 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018073}
18074
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018075/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070018076 * patch entries
18077 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018078static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070018079 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018080 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018081 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020018082 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018083 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018084 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020018085 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018086 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018087 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018088 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018089 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
18090 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
18091 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018092 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018093 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018094 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
18095 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018096 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018097 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018098 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018099 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020018100 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018101 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020018102 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018103 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018104 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018105 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020018106 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018107 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018108 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018109 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018110 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018111 {} /* terminator */
18112};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018113
18114MODULE_ALIAS("snd-hda-codec-id:10ec*");
18115
18116MODULE_LICENSE("GPL");
18117MODULE_DESCRIPTION("Realtek HD-audio codec");
18118
18119static struct hda_codec_preset_list realtek_list = {
18120 .preset = snd_hda_preset_realtek,
18121 .owner = THIS_MODULE,
18122};
18123
18124static int __init patch_realtek_init(void)
18125{
18126 return snd_hda_add_codec_preset(&realtek_list);
18127}
18128
18129static void __exit patch_realtek_exit(void)
18130{
18131 snd_hda_delete_codec_preset(&realtek_list);
18132}
18133
18134module_init(patch_realtek_init)
18135module_exit(patch_realtek_exit)