blob: 40ebf2746bb15f7d52cd4c96f55e12db1e9accaa [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
Daniel T Chenc97259d2009-12-27 18:52:08 -0500341 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100342#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;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500394 void (*power_hook)(struct hda_codec *codec);
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, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100636 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100637 .info = alc_pin_mode_info, \
638 .get = alc_pin_mode_get, \
639 .put = alc_pin_mode_put, \
640 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100641
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100642/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
643 * together using a mask with more than one bit set. This control is
644 * currently used only by the ALC260 test model. At this stage they are not
645 * needed for any "production" models.
646 */
647#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200648#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200649
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200650static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
651 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100652{
653 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
654 hda_nid_t nid = kcontrol->private_value & 0xffff;
655 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
656 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200657 unsigned int val = snd_hda_codec_read(codec, nid, 0,
658 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100659
660 *valp = (val & mask) != 0;
661 return 0;
662}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200663static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
664 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100665{
666 signed int change;
667 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
668 hda_nid_t nid = kcontrol->private_value & 0xffff;
669 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
670 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200671 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
672 AC_VERB_GET_GPIO_DATA,
673 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100674
675 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200676 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
677 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100678 gpio_data &= ~mask;
679 else
680 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200681 snd_hda_codec_write_cache(codec, nid, 0,
682 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100683
684 return change;
685}
686#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
687 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100688 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100689 .info = alc_gpio_data_info, \
690 .get = alc_gpio_data_get, \
691 .put = alc_gpio_data_put, \
692 .private_value = nid | (mask<<16) }
693#endif /* CONFIG_SND_DEBUG */
694
Jonathan Woithe92621f12006-02-28 11:47:47 +0100695/* A switch control to allow the enabling of the digital IO pins on the
696 * ALC260. This is incredibly simplistic; the intention of this control is
697 * to provide something in the test model allowing digital outputs to be
698 * identified if present. If models are found which can utilise these
699 * outputs a more complete mixer control can be devised for those models if
700 * necessary.
701 */
702#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200703#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200704
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200705static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
706 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100707{
708 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
709 hda_nid_t nid = kcontrol->private_value & 0xffff;
710 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
711 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200712 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100713 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100714
715 *valp = (val & mask) != 0;
716 return 0;
717}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200718static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
719 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100720{
721 signed int change;
722 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
723 hda_nid_t nid = kcontrol->private_value & 0xffff;
724 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
725 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200726 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100727 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200728 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100729
730 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200731 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100732 if (val==0)
733 ctrl_data &= ~mask;
734 else
735 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200736 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
737 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100738
739 return change;
740}
741#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
742 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100743 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100744 .info = alc_spdif_ctrl_info, \
745 .get = alc_spdif_ctrl_get, \
746 .put = alc_spdif_ctrl_put, \
747 .private_value = nid | (mask<<16) }
748#endif /* CONFIG_SND_DEBUG */
749
Jonathan Woithef8225f62008-01-08 12:16:54 +0100750/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
751 * Again, this is only used in the ALC26x test models to help identify when
752 * the EAPD line must be asserted for features to work.
753 */
754#ifdef CONFIG_SND_DEBUG
755#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
756
757static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
758 struct snd_ctl_elem_value *ucontrol)
759{
760 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
761 hda_nid_t nid = kcontrol->private_value & 0xffff;
762 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
763 long *valp = ucontrol->value.integer.value;
764 unsigned int val = snd_hda_codec_read(codec, nid, 0,
765 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
766
767 *valp = (val & mask) != 0;
768 return 0;
769}
770
771static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
772 struct snd_ctl_elem_value *ucontrol)
773{
774 int change;
775 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
776 hda_nid_t nid = kcontrol->private_value & 0xffff;
777 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
778 long val = *ucontrol->value.integer.value;
779 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
780 AC_VERB_GET_EAPD_BTLENABLE,
781 0x00);
782
783 /* Set/unset the masked control bit(s) as needed */
784 change = (!val ? 0 : mask) != (ctrl_data & mask);
785 if (!val)
786 ctrl_data &= ~mask;
787 else
788 ctrl_data |= mask;
789 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
790 ctrl_data);
791
792 return change;
793}
794
795#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
796 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100797 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100798 .info = alc_eapd_ctrl_info, \
799 .get = alc_eapd_ctrl_get, \
800 .put = alc_eapd_ctrl_put, \
801 .private_value = nid | (mask<<16) }
802#endif /* CONFIG_SND_DEBUG */
803
Kailang Yangdf694da2005-12-05 19:42:22 +0100804/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100805 * set up the input pin config (depending on the given auto-pin type)
806 */
807static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
808 int auto_pin_type)
809{
810 unsigned int val = PIN_IN;
811
812 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
813 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100814 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100815 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
816 if (pincap & AC_PINCAP_VREF_80)
817 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200818 else if (pincap & AC_PINCAP_VREF_50)
819 val = PIN_VREF50;
820 else if (pincap & AC_PINCAP_VREF_100)
821 val = PIN_VREF100;
822 else if (pincap & AC_PINCAP_VREF_GRD)
823 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100824 }
825 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
826}
827
828/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100829 */
830static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
831{
832 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
833 return;
834 spec->mixers[spec->num_mixers++] = mix;
835}
836
837static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
838{
839 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
840 return;
841 spec->init_verbs[spec->num_init_verbs++] = verb;
842}
843
844/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100845 * set up from the preset table
846 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200847static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200848 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100849{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200850 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100851 int i;
852
853 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100854 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100855 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200856 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
857 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100858 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200859
Kailang Yangdf694da2005-12-05 19:42:22 +0100860 spec->channel_mode = preset->channel_mode;
861 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200862 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200863 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100864
Hector Martin3b315d72009-06-02 10:54:19 +0200865 if (preset->const_channel_count)
866 spec->multiout.max_channels = preset->const_channel_count;
867 else
868 spec->multiout.max_channels = spec->channel_mode[0].channels;
869 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100870
871 spec->multiout.num_dacs = preset->num_dacs;
872 spec->multiout.dac_nids = preset->dac_nids;
873 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800874 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100875 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200876
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200877 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200878 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200879 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100880 spec->input_mux = preset->input_mux;
881
882 spec->num_adc_nids = preset->num_adc_nids;
883 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100884 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100885 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100886
887 spec->unsol_event = preset->unsol_event;
888 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200889#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100890 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200891 spec->loopback.amplist = preset->loopbacks;
892#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200893
894 if (preset->setup)
895 preset->setup(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100896}
897
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200898/* Enable GPIO mask and set output */
899static struct hda_verb alc_gpio1_init_verbs[] = {
900 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
901 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
902 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
903 { }
904};
905
906static struct hda_verb alc_gpio2_init_verbs[] = {
907 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
908 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
909 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
910 { }
911};
912
Kailang Yangbdd148a2007-05-08 15:19:08 +0200913static struct hda_verb alc_gpio3_init_verbs[] = {
914 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
915 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
916 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
917 { }
918};
919
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200920/*
921 * Fix hardware PLL issue
922 * On some codecs, the analog PLL gating control must be off while
923 * the default value is 1.
924 */
925static void alc_fix_pll(struct hda_codec *codec)
926{
927 struct alc_spec *spec = codec->spec;
928 unsigned int val;
929
930 if (!spec->pll_nid)
931 return;
932 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
933 spec->pll_coef_idx);
934 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
935 AC_VERB_GET_PROC_COEF, 0);
936 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
937 spec->pll_coef_idx);
938 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
939 val & ~(1 << spec->pll_coef_bit));
940}
941
942static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
943 unsigned int coef_idx, unsigned int coef_bit)
944{
945 struct alc_spec *spec = codec->spec;
946 spec->pll_nid = nid;
947 spec->pll_coef_idx = coef_idx;
948 spec->pll_coef_bit = coef_bit;
949 alc_fix_pll(codec);
950}
951
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200952static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200953{
954 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200955 unsigned int nid = spec->autocfg.hp_pins[0];
956 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200957
Takashi Iwaiad87c642009-11-02 14:23:15 +0100958 if (!nid)
959 return;
Wu Fengguang864f92b2009-11-18 12:38:02 +0800960 spec->jack_present = snd_hda_jack_detect(codec, nid);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200961 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
962 nid = spec->autocfg.speaker_pins[i];
963 if (!nid)
964 break;
965 snd_hda_codec_write(codec, nid, 0,
966 AC_VERB_SET_PIN_WIDGET_CONTROL,
967 spec->jack_present ? 0 : PIN_OUT);
968 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200969}
970
Takashi Iwai6c819492009-08-10 18:47:44 +0200971static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
972 hda_nid_t nid)
973{
974 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
975 int i, nums;
976
977 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
978 for (i = 0; i < nums; i++)
979 if (conn[i] == nid)
980 return i;
981 return -1;
982}
983
Kailang Yang7fb0d782008-10-15 11:12:35 +0200984static void alc_mic_automute(struct hda_codec *codec)
985{
986 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +0200987 struct alc_mic_route *dead, *alive;
988 unsigned int present, type;
989 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +0200990
Takashi Iwaib59bdf32009-08-11 09:47:30 +0200991 if (!spec->auto_mic)
992 return;
Takashi Iwai6c819492009-08-10 18:47:44 +0200993 if (!spec->int_mic.pin || !spec->ext_mic.pin)
994 return;
995 if (snd_BUG_ON(!spec->adc_nids))
996 return;
997
998 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
999
Wu Fengguang864f92b2009-11-18 12:38:02 +08001000 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001001 if (present) {
1002 alive = &spec->ext_mic;
1003 dead = &spec->int_mic;
1004 } else {
1005 alive = &spec->int_mic;
1006 dead = &spec->ext_mic;
1007 }
1008
Takashi Iwai6c819492009-08-10 18:47:44 +02001009 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1010 if (type == AC_WID_AUD_MIX) {
1011 /* Matrix-mixer style (e.g. ALC882) */
1012 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1013 alive->mux_idx,
1014 HDA_AMP_MUTE, 0);
1015 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1016 dead->mux_idx,
1017 HDA_AMP_MUTE, HDA_AMP_MUTE);
1018 } else {
1019 /* MUX style (e.g. ALC880) */
1020 snd_hda_codec_write_cache(codec, cap_nid, 0,
1021 AC_VERB_SET_CONNECT_SEL,
1022 alive->mux_idx);
1023 }
1024
1025 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001026}
1027
Kailang Yangc9b58002007-10-16 14:30:01 +02001028/* unsolicited event for HP jack sensing */
1029static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1030{
1031 if (codec->vendor_id == 0x10ec0880)
1032 res >>= 28;
1033 else
1034 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001035 switch (res) {
1036 case ALC880_HP_EVENT:
1037 alc_automute_pin(codec);
1038 break;
1039 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001040 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001041 break;
1042 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001043}
1044
1045static void alc_inithook(struct hda_codec *codec)
1046{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001047 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001048 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001049}
1050
Kailang Yangf9423e72008-05-27 12:32:25 +02001051/* additional initialization for ALC888 variants */
1052static void alc888_coef_init(struct hda_codec *codec)
1053{
1054 unsigned int tmp;
1055
1056 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1057 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1058 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001059 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001060 /* alc888S-VC */
1061 snd_hda_codec_read(codec, 0x20, 0,
1062 AC_VERB_SET_PROC_COEF, 0x830);
1063 else
1064 /* alc888-VB */
1065 snd_hda_codec_read(codec, 0x20, 0,
1066 AC_VERB_SET_PROC_COEF, 0x3030);
1067}
1068
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001069static void alc889_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, 7);
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);
1076 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1077}
1078
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001079/* turn on/off EAPD control (only if available) */
1080static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1081{
1082 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1083 return;
1084 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1085 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1086 on ? 2 : 0);
1087}
1088
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001089static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001090{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001091 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001092
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001093 switch (type) {
1094 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001095 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1096 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001097 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001098 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1099 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001100 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001101 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1102 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001103 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001104 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001105 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001106 set_eapd(codec, 0x0f, 1);
1107 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001108 break;
1109 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001110 case 0x10ec0267:
1111 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001112 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001113 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001114 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001115 case 0x10ec0660:
1116 case 0x10ec0662:
1117 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001118 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001119 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001120 set_eapd(codec, 0x14, 1);
1121 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001122 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001123 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001124 switch (codec->vendor_id) {
1125 case 0x10ec0260:
1126 snd_hda_codec_write(codec, 0x1a, 0,
1127 AC_VERB_SET_COEF_INDEX, 7);
1128 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1129 AC_VERB_GET_PROC_COEF, 0);
1130 snd_hda_codec_write(codec, 0x1a, 0,
1131 AC_VERB_SET_COEF_INDEX, 7);
1132 snd_hda_codec_write(codec, 0x1a, 0,
1133 AC_VERB_SET_PROC_COEF,
1134 tmp | 0x2010);
1135 break;
1136 case 0x10ec0262:
1137 case 0x10ec0880:
1138 case 0x10ec0882:
1139 case 0x10ec0883:
1140 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001141 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001142 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001143 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001144 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001145 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001146 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001147 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001148#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001149 case 0x10ec0267:
1150 case 0x10ec0268:
1151 snd_hda_codec_write(codec, 0x20, 0,
1152 AC_VERB_SET_COEF_INDEX, 7);
1153 tmp = snd_hda_codec_read(codec, 0x20, 0,
1154 AC_VERB_GET_PROC_COEF, 0);
1155 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001156 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001157 snd_hda_codec_write(codec, 0x20, 0,
1158 AC_VERB_SET_PROC_COEF,
1159 tmp | 0x3000);
1160 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001161#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001162 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001163 break;
1164 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001165}
Kailang Yangea1fb292008-08-26 12:58:38 +02001166
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001167static void alc_init_auto_hp(struct hda_codec *codec)
1168{
1169 struct alc_spec *spec = codec->spec;
1170
1171 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001172 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001173
Kailang Yangc9b58002007-10-16 14:30:01 +02001174 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001175 if (spec->autocfg.line_out_pins[0] &&
1176 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001177 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001178 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001179 else
1180 return;
1181 }
1182
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001183 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1184 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001185 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1186 AC_VERB_SET_UNSOLICITED_ENABLE,
1187 AC_USRSP_EN | ALC880_HP_EVENT);
1188 spec->unsol_event = alc_sku_unsol_event;
1189}
1190
Takashi Iwai6c819492009-08-10 18:47:44 +02001191static void alc_init_auto_mic(struct hda_codec *codec)
1192{
1193 struct alc_spec *spec = codec->spec;
1194 struct auto_pin_cfg *cfg = &spec->autocfg;
1195 hda_nid_t fixed, ext;
1196 int i;
1197
1198 /* there must be only two mic inputs exclusively */
1199 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1200 if (cfg->input_pins[i])
1201 return;
1202
1203 fixed = ext = 0;
1204 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1205 hda_nid_t nid = cfg->input_pins[i];
1206 unsigned int defcfg;
1207 if (!nid)
1208 return;
1209 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1210 switch (get_defcfg_connect(defcfg)) {
1211 case AC_JACK_PORT_FIXED:
1212 if (fixed)
1213 return; /* already occupied */
1214 fixed = nid;
1215 break;
1216 case AC_JACK_PORT_COMPLEX:
1217 if (ext)
1218 return; /* already occupied */
1219 ext = nid;
1220 break;
1221 default:
1222 return; /* invalid entry */
1223 }
1224 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001225 if (!ext || !fixed)
1226 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001227 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1228 return; /* no unsol support */
1229 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1230 ext, fixed);
1231 spec->ext_mic.pin = ext;
1232 spec->int_mic.pin = fixed;
1233 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1234 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1235 spec->auto_mic = 1;
1236 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1237 AC_VERB_SET_UNSOLICITED_ENABLE,
1238 AC_USRSP_EN | ALC880_MIC_EVENT);
1239 spec->unsol_event = alc_sku_unsol_event;
1240}
1241
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001242/* check subsystem ID and set up device-specific initialization;
1243 * return 1 if initialized, 0 if invalid SSID
1244 */
1245/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1246 * 31 ~ 16 : Manufacture ID
1247 * 15 ~ 8 : SKU ID
1248 * 7 ~ 0 : Assembly ID
1249 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1250 */
1251static int alc_subsystem_id(struct hda_codec *codec,
1252 hda_nid_t porta, hda_nid_t porte,
1253 hda_nid_t portd)
1254{
1255 unsigned int ass, tmp, i;
1256 unsigned nid;
1257 struct alc_spec *spec = codec->spec;
1258
1259 ass = codec->subsystem_id & 0xffff;
1260 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1261 goto do_sku;
1262
1263 /* invalid SSID, check the special NID pin defcfg instead */
1264 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001265 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001266 * 29~21 : reserve
1267 * 20 : PCBEEP input
1268 * 19~16 : Check sum (15:1)
1269 * 15~1 : Custom
1270 * 0 : override
1271 */
1272 nid = 0x1d;
1273 if (codec->vendor_id == 0x10ec0260)
1274 nid = 0x17;
1275 ass = snd_hda_codec_get_pincfg(codec, nid);
1276 snd_printd("realtek: No valid SSID, "
1277 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001278 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001279 if (!(ass & 1) && !(ass & 0x100000))
1280 return 0;
1281 if ((ass >> 30) != 1) /* no physical connection */
1282 return 0;
1283
1284 /* check sum */
1285 tmp = 0;
1286 for (i = 1; i < 16; i++) {
1287 if ((ass >> i) & 1)
1288 tmp++;
1289 }
1290 if (((ass >> 16) & 0xf) != tmp)
1291 return 0;
1292do_sku:
1293 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1294 ass & 0xffff, codec->vendor_id);
1295 /*
1296 * 0 : override
1297 * 1 : Swap Jack
1298 * 2 : 0 --> Desktop, 1 --> Laptop
1299 * 3~5 : External Amplifier control
1300 * 7~6 : Reserved
1301 */
1302 tmp = (ass & 0x38) >> 3; /* external Amp control */
1303 switch (tmp) {
1304 case 1:
1305 spec->init_amp = ALC_INIT_GPIO1;
1306 break;
1307 case 3:
1308 spec->init_amp = ALC_INIT_GPIO2;
1309 break;
1310 case 7:
1311 spec->init_amp = ALC_INIT_GPIO3;
1312 break;
1313 case 5:
1314 spec->init_amp = ALC_INIT_DEFAULT;
1315 break;
1316 }
1317
1318 /* is laptop or Desktop and enable the function "Mute internal speaker
1319 * when the external headphone out jack is plugged"
1320 */
1321 if (!(ass & 0x8000))
1322 return 1;
1323 /*
1324 * 10~8 : Jack location
1325 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1326 * 14~13: Resvered
1327 * 15 : 1 --> enable the function "Mute internal speaker
1328 * when the external headphone out jack is plugged"
1329 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001330 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001331 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001332 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1333 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001334 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001335 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001336 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001337 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001338 nid = portd;
Kailang Yangc9b58002007-10-16 14:30:01 +02001339 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001340 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001341 for (i = 0; i < spec->autocfg.line_outs; i++)
1342 if (spec->autocfg.line_out_pins[i] == nid)
1343 return 1;
1344 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001345 }
1346
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001347 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001348 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001349 return 1;
1350}
Kailang Yangea1fb292008-08-26 12:58:38 +02001351
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001352static void alc_ssid_check(struct hda_codec *codec,
1353 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1354{
1355 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1356 struct alc_spec *spec = codec->spec;
1357 snd_printd("realtek: "
1358 "Enable default setup for auto mode as fallback\n");
1359 spec->init_amp = ALC_INIT_DEFAULT;
1360 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001361 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001362 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001363}
1364
Takashi Iwai41e41f12005-06-08 14:48:49 +02001365/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001366 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001367 */
1368
1369struct alc_pincfg {
1370 hda_nid_t nid;
1371 u32 val;
1372};
1373
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001374struct alc_fixup {
1375 const struct alc_pincfg *pins;
1376 const struct hda_verb *verbs;
1377};
1378
1379static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001380 const struct snd_pci_quirk *quirk,
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001381 const struct alc_fixup *fix)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001382{
1383 const struct alc_pincfg *cfg;
1384
1385 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1386 if (!quirk)
1387 return;
1388
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001389 fix += quirk->value;
1390 cfg = fix->pins;
1391 if (cfg) {
1392 for (; cfg->nid; cfg++)
1393 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1394 }
1395 if (fix->verbs)
1396 add_verb(codec->spec, fix->verbs);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001397}
1398
Kailang Yang274693f2009-12-03 10:07:50 +01001399static int alc_read_coef_idx(struct hda_codec *codec,
1400 unsigned int coef_idx)
1401{
1402 unsigned int val;
1403 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1404 coef_idx);
1405 val = snd_hda_codec_read(codec, 0x20, 0,
1406 AC_VERB_GET_PROC_COEF, 0);
1407 return val;
1408}
1409
Takashi Iwaif95474e2007-07-10 00:47:43 +02001410/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001411 * ALC888
1412 */
1413
1414/*
1415 * 2ch mode
1416 */
1417static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1418/* Mic-in jack as mic in */
1419 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1420 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1421/* Line-in jack as Line in */
1422 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1423 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1424/* Line-Out as Front */
1425 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1426 { } /* end */
1427};
1428
1429/*
1430 * 4ch mode
1431 */
1432static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1433/* Mic-in jack as mic in */
1434 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1435 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1436/* Line-in jack as Surround */
1437 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1438 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1439/* Line-Out as Front */
1440 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1441 { } /* end */
1442};
1443
1444/*
1445 * 6ch mode
1446 */
1447static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1448/* Mic-in jack as CLFE */
1449 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1450 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1451/* Line-in jack as Surround */
1452 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1453 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1454/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1455 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1456 { } /* end */
1457};
1458
1459/*
1460 * 8ch mode
1461 */
1462static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1463/* Mic-in jack as CLFE */
1464 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1465 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1466/* Line-in jack as Surround */
1467 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1468 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1469/* Line-Out as Side */
1470 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1471 { } /* end */
1472};
1473
1474static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1475 { 2, alc888_4ST_ch2_intel_init },
1476 { 4, alc888_4ST_ch4_intel_init },
1477 { 6, alc888_4ST_ch6_intel_init },
1478 { 8, alc888_4ST_ch8_intel_init },
1479};
1480
1481/*
1482 * ALC888 Fujitsu Siemens Amillo xa3530
1483 */
1484
1485static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1486/* Front Mic: set to PIN_IN (empty by default) */
1487 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1488/* Connect Internal HP to Front */
1489 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1490 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1491 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1492/* Connect Bass HP to Front */
1493 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1494 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1495 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1496/* Connect Line-Out side jack (SPDIF) to Side */
1497 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1498 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1499 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1500/* Connect Mic jack to CLFE */
1501 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1502 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1503 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1504/* Connect Line-in jack to Surround */
1505 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1506 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1507 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1508/* Connect HP out jack to Front */
1509 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1510 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1511 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1512/* Enable unsolicited event for HP jack and Line-out jack */
1513 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1514 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1515 {}
1516};
1517
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001518static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001519{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001520 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001521 unsigned int mute;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001522 hda_nid_t nid;
1523 int i;
1524
1525 spec->jack_present = 0;
1526 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1527 nid = spec->autocfg.hp_pins[i];
1528 if (!nid)
1529 break;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001530 if (snd_hda_jack_detect(codec, nid)) {
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001531 spec->jack_present = 1;
1532 break;
1533 }
1534 }
1535
1536 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001537 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001538 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1539 nid = spec->autocfg.speaker_pins[i];
1540 if (!nid)
1541 break;
1542 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1543 HDA_AMP_MUTE, mute);
1544 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001545}
1546
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001547static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1548 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001549{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001550 if (codec->vendor_id == 0x10ec0880)
1551 res >>= 28;
1552 else
1553 res >>= 26;
1554 if (res == ALC880_HP_EVENT)
1555 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001556}
1557
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001558static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001559{
1560 struct alc_spec *spec = codec->spec;
1561
1562 spec->autocfg.hp_pins[0] = 0x15;
1563 spec->autocfg.speaker_pins[0] = 0x14;
1564 spec->autocfg.speaker_pins[1] = 0x16;
1565 spec->autocfg.speaker_pins[2] = 0x17;
1566 spec->autocfg.speaker_pins[3] = 0x19;
1567 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001568}
1569
1570static void alc889_intel_init_hook(struct hda_codec *codec)
1571{
1572 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001573 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001574}
1575
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001576static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001577{
1578 struct alc_spec *spec = codec->spec;
1579
1580 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1581 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1582 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1583 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001584}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001585
1586/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001587 * ALC888 Acer Aspire 4930G model
1588 */
1589
1590static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1591/* Front Mic: set to PIN_IN (empty by default) */
1592 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1593/* Unselect Front Mic by default in input mixer 3 */
1594 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001595/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001596 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1597/* Connect Internal HP to front */
1598 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1599 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1600 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1601/* Connect HP out to front */
1602 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1603 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1604 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1605 { }
1606};
1607
Hector Martin3b315d72009-06-02 10:54:19 +02001608/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001609 * ALC888 Acer Aspire 6530G model
1610 */
1611
1612static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1613/* Bias voltage on for external mic port */
1614 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001615/* Front Mic: set to PIN_IN (empty by default) */
1616 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1617/* Unselect Front Mic by default in input mixer 3 */
1618 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001619/* Enable unsolicited event for HP jack */
1620 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1621/* Enable speaker output */
1622 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1623 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1624/* Enable headphone output */
1625 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1626 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1627 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1628 { }
1629};
1630
1631/*
Hector Martin018df412009-06-04 00:13:40 +02001632 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001633 */
1634
Hector Martin018df412009-06-04 00:13:40 +02001635static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001636/* Front Mic: set to PIN_IN (empty by default) */
1637 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1638/* Unselect Front Mic by default in input mixer 3 */
1639 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1640/* Enable unsolicited event for HP jack */
1641 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1642/* Connect Internal Front to Front */
1643 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1644 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1645 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1646/* Connect Internal Rear to Rear */
1647 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1648 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1649 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1650/* Connect Internal CLFE to CLFE */
1651 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1652 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1653 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1654/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001655 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001656 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1657 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1658/* Enable all DACs */
1659/* DAC DISABLE/MUTE 1? */
1660/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1661 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1662 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1663/* DAC DISABLE/MUTE 2? */
1664/* some bit here disables the other DACs. Init=0x4900 */
1665 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1666 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02001667/* DMIC fix
1668 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1669 * which makes the stereo useless. However, either the mic or the ALC889
1670 * makes the signal become a difference/sum signal instead of standard
1671 * stereo, which is annoying. So instead we flip this bit which makes the
1672 * codec replicate the sum signal to both channels, turning it into a
1673 * normal mono mic.
1674 */
1675/* DMIC_CONTROL? Init value = 0x0001 */
1676 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1677 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001678 { }
1679};
1680
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001681static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001682 /* Front mic only available on one ADC */
1683 {
1684 .num_items = 4,
1685 .items = {
1686 { "Mic", 0x0 },
1687 { "Line", 0x2 },
1688 { "CD", 0x4 },
1689 { "Front Mic", 0xb },
1690 },
1691 },
1692 {
1693 .num_items = 3,
1694 .items = {
1695 { "Mic", 0x0 },
1696 { "Line", 0x2 },
1697 { "CD", 0x4 },
1698 },
1699 }
1700};
1701
Tony Vroond2fd4b02009-06-21 00:40:10 +01001702static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1703 /* Interal mic only available on one ADC */
1704 {
Tony Vroon684a8842009-06-26 09:27:50 +01001705 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001706 .items = {
1707 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001708 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001709 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001710 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001711 { "Int Mic", 0xb },
1712 },
1713 },
1714 {
Tony Vroon684a8842009-06-26 09:27:50 +01001715 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001716 .items = {
1717 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001718 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001719 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001720 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001721 },
1722 }
1723};
1724
Hector Martin018df412009-06-04 00:13:40 +02001725static struct hda_input_mux alc889_capture_sources[3] = {
1726 /* Digital mic only available on first "ADC" */
1727 {
1728 .num_items = 5,
1729 .items = {
1730 { "Mic", 0x0 },
1731 { "Line", 0x2 },
1732 { "CD", 0x4 },
1733 { "Front Mic", 0xb },
1734 { "Input Mix", 0xa },
1735 },
1736 },
1737 {
1738 .num_items = 4,
1739 .items = {
1740 { "Mic", 0x0 },
1741 { "Line", 0x2 },
1742 { "CD", 0x4 },
1743 { "Input Mix", 0xa },
1744 },
1745 },
1746 {
1747 .num_items = 4,
1748 .items = {
1749 { "Mic", 0x0 },
1750 { "Line", 0x2 },
1751 { "CD", 0x4 },
1752 { "Input Mix", 0xa },
1753 },
1754 }
1755};
1756
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001757static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001758 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1759 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1760 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1761 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1762 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1763 HDA_OUTPUT),
1764 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1765 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1766 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1767 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1768 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1769 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1770 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1771 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1772 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1773 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1774 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1775 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001776 { } /* end */
1777};
1778
Hector Martin556eea92009-12-20 22:51:23 +01001779static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
1780 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1781 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1782 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1783 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1784 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1785 HDA_OUTPUT),
1786 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1787 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1788 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1789 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1790 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1791 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1792 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1793 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1794 { } /* end */
1795};
1796
1797
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001798static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001799{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001800 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001801
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001802 spec->autocfg.hp_pins[0] = 0x15;
1803 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01001804 spec->autocfg.speaker_pins[1] = 0x16;
1805 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001806}
1807
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001808static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001809{
1810 struct alc_spec *spec = codec->spec;
1811
1812 spec->autocfg.hp_pins[0] = 0x15;
1813 spec->autocfg.speaker_pins[0] = 0x14;
1814 spec->autocfg.speaker_pins[1] = 0x16;
1815 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001816}
1817
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001818static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001819{
1820 struct alc_spec *spec = codec->spec;
1821
1822 spec->autocfg.hp_pins[0] = 0x15;
1823 spec->autocfg.speaker_pins[0] = 0x14;
1824 spec->autocfg.speaker_pins[1] = 0x16;
1825 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001826}
1827
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001828/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001829 * ALC880 3-stack model
1830 *
1831 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001832 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1833 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001834 */
1835
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001836static hda_nid_t alc880_dac_nids[4] = {
1837 /* front, rear, clfe, rear_surr */
1838 0x02, 0x05, 0x04, 0x03
1839};
1840
1841static hda_nid_t alc880_adc_nids[3] = {
1842 /* ADC0-2 */
1843 0x07, 0x08, 0x09,
1844};
1845
1846/* The datasheet says the node 0x07 is connected from inputs,
1847 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001848 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001849 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001850static hda_nid_t alc880_adc_nids_alt[2] = {
1851 /* ADC1-2 */
1852 0x08, 0x09,
1853};
1854
1855#define ALC880_DIGOUT_NID 0x06
1856#define ALC880_DIGIN_NID 0x0a
1857
1858static struct hda_input_mux alc880_capture_source = {
1859 .num_items = 4,
1860 .items = {
1861 { "Mic", 0x0 },
1862 { "Front Mic", 0x3 },
1863 { "Line", 0x2 },
1864 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001865 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001866};
1867
1868/* channel source setting (2/6 channel selection for 3-stack) */
1869/* 2ch mode */
1870static struct hda_verb alc880_threestack_ch2_init[] = {
1871 /* set line-in to input, mute it */
1872 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1873 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1874 /* set mic-in to input vref 80%, mute it */
1875 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1876 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001877 { } /* end */
1878};
1879
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001880/* 6ch mode */
1881static struct hda_verb alc880_threestack_ch6_init[] = {
1882 /* set line-in to output, unmute it */
1883 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1884 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1885 /* set mic-in to output, unmute it */
1886 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1887 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1888 { } /* end */
1889};
1890
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001891static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001892 { 2, alc880_threestack_ch2_init },
1893 { 6, alc880_threestack_ch6_init },
1894};
1895
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001896static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001897 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001898 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001899 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001900 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001901 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1902 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001903 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1904 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001905 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1906 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1907 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1908 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1909 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1910 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1911 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1912 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001913 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001914 {
1915 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1916 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001917 .info = alc_ch_mode_info,
1918 .get = alc_ch_mode_get,
1919 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001920 },
1921 { } /* end */
1922};
1923
1924/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001925static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1926 struct snd_ctl_elem_info *uinfo)
1927{
1928 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1929 struct alc_spec *spec = codec->spec;
1930 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001931
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001932 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001933 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1934 HDA_INPUT);
1935 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001936 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001937 return err;
1938}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001939
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001940static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1941 unsigned int size, unsigned int __user *tlv)
1942{
1943 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1944 struct alc_spec *spec = codec->spec;
1945 int err;
1946
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001947 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001948 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1949 HDA_INPUT);
1950 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001951 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001952 return err;
1953}
1954
1955typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1956 struct snd_ctl_elem_value *ucontrol);
1957
1958static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1959 struct snd_ctl_elem_value *ucontrol,
1960 getput_call_t func)
1961{
1962 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1963 struct alc_spec *spec = codec->spec;
1964 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1965 int err;
1966
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001967 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001968 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1969 3, 0, HDA_INPUT);
1970 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001971 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001972 return err;
1973}
1974
1975static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1976 struct snd_ctl_elem_value *ucontrol)
1977{
1978 return alc_cap_getput_caller(kcontrol, ucontrol,
1979 snd_hda_mixer_amp_volume_get);
1980}
1981
1982static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1983 struct snd_ctl_elem_value *ucontrol)
1984{
1985 return alc_cap_getput_caller(kcontrol, ucontrol,
1986 snd_hda_mixer_amp_volume_put);
1987}
1988
1989/* capture mixer elements */
1990#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1991
1992static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1993 struct snd_ctl_elem_value *ucontrol)
1994{
1995 return alc_cap_getput_caller(kcontrol, ucontrol,
1996 snd_hda_mixer_amp_switch_get);
1997}
1998
1999static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2000 struct snd_ctl_elem_value *ucontrol)
2001{
2002 return alc_cap_getput_caller(kcontrol, ucontrol,
2003 snd_hda_mixer_amp_switch_put);
2004}
2005
Takashi Iwaia23b6882009-03-23 15:21:36 +01002006#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002007 { \
2008 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2009 .name = "Capture Switch", \
2010 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2011 .count = num, \
2012 .info = alc_cap_sw_info, \
2013 .get = alc_cap_sw_get, \
2014 .put = alc_cap_sw_put, \
2015 }, \
2016 { \
2017 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2018 .name = "Capture Volume", \
2019 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2020 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2021 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2022 .count = num, \
2023 .info = alc_cap_vol_info, \
2024 .get = alc_cap_vol_get, \
2025 .put = alc_cap_vol_put, \
2026 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002027 }
2028
2029#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002030 { \
2031 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2032 /* .name = "Capture Source", */ \
2033 .name = "Input Source", \
2034 .count = num, \
2035 .info = alc_mux_enum_info, \
2036 .get = alc_mux_enum_get, \
2037 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002038 }
2039
2040#define DEFINE_CAPMIX(num) \
2041static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2042 _DEFINE_CAPMIX(num), \
2043 _DEFINE_CAPSRC(num), \
2044 { } /* end */ \
2045}
2046
2047#define DEFINE_CAPMIX_NOSRC(num) \
2048static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2049 _DEFINE_CAPMIX(num), \
2050 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002051}
2052
2053/* up to three ADCs */
2054DEFINE_CAPMIX(1);
2055DEFINE_CAPMIX(2);
2056DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002057DEFINE_CAPMIX_NOSRC(1);
2058DEFINE_CAPMIX_NOSRC(2);
2059DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002060
2061/*
2062 * ALC880 5-stack model
2063 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002064 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2065 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002066 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2067 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2068 */
2069
2070/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002071static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002072 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002073 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002074 { } /* end */
2075};
2076
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002077/* channel source setting (6/8 channel selection for 5-stack) */
2078/* 6ch mode */
2079static struct hda_verb alc880_fivestack_ch6_init[] = {
2080 /* set line-in to input, mute it */
2081 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2082 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002083 { } /* end */
2084};
2085
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002086/* 8ch mode */
2087static struct hda_verb alc880_fivestack_ch8_init[] = {
2088 /* set line-in to output, unmute it */
2089 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2090 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2091 { } /* end */
2092};
2093
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002094static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002095 { 6, alc880_fivestack_ch6_init },
2096 { 8, alc880_fivestack_ch8_init },
2097};
2098
2099
2100/*
2101 * ALC880 6-stack model
2102 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002103 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2104 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002105 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2106 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2107 */
2108
2109static hda_nid_t alc880_6st_dac_nids[4] = {
2110 /* front, rear, clfe, rear_surr */
2111 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002112};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002113
2114static struct hda_input_mux alc880_6stack_capture_source = {
2115 .num_items = 4,
2116 .items = {
2117 { "Mic", 0x0 },
2118 { "Front Mic", 0x1 },
2119 { "Line", 0x2 },
2120 { "CD", 0x4 },
2121 },
2122};
2123
2124/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002125static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002126 { 8, NULL },
2127};
2128
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002129static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002130 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002131 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002132 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002133 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002134 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2135 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002136 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2137 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002138 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002139 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002140 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2141 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2142 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2143 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2144 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2145 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2146 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2147 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002148 {
2149 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2150 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002151 .info = alc_ch_mode_info,
2152 .get = alc_ch_mode_get,
2153 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002154 },
2155 { } /* end */
2156};
2157
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002158
2159/*
2160 * ALC880 W810 model
2161 *
2162 * W810 has rear IO for:
2163 * Front (DAC 02)
2164 * Surround (DAC 03)
2165 * Center/LFE (DAC 04)
2166 * Digital out (06)
2167 *
2168 * The system also has a pair of internal speakers, and a headphone jack.
2169 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002170 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002171 * There is a variable resistor to control the speaker or headphone
2172 * volume. This is a hardware-only device without a software API.
2173 *
2174 * Plugging headphones in will disable the internal speakers. This is
2175 * implemented in hardware, not via the driver using jack sense. In
2176 * a similar fashion, plugging into the rear socket marked "front" will
2177 * disable both the speakers and headphones.
2178 *
2179 * For input, there's a microphone jack, and an "audio in" jack.
2180 * These may not do anything useful with this driver yet, because I
2181 * haven't setup any initialization verbs for these yet...
2182 */
2183
2184static hda_nid_t alc880_w810_dac_nids[3] = {
2185 /* front, rear/surround, clfe */
2186 0x02, 0x03, 0x04
2187};
2188
2189/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002190static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002191 { 6, NULL }
2192};
2193
2194/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002195static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002196 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002197 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002198 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002199 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002200 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2201 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002202 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2203 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002204 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2205 { } /* end */
2206};
2207
2208
2209/*
2210 * Z710V model
2211 *
2212 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002213 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2214 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002215 */
2216
2217static hda_nid_t alc880_z71v_dac_nids[1] = {
2218 0x02
2219};
2220#define ALC880_Z71V_HP_DAC 0x03
2221
2222/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002223static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002224 { 2, NULL }
2225};
2226
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002227static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002228 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002229 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002230 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002231 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002232 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2233 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2234 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2235 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2236 { } /* end */
2237};
2238
2239
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002240/*
2241 * ALC880 F1734 model
2242 *
2243 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2244 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2245 */
2246
2247static hda_nid_t alc880_f1734_dac_nids[1] = {
2248 0x03
2249};
2250#define ALC880_F1734_HP_DAC 0x02
2251
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002252static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002253 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002254 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002255 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2256 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002257 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2258 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002259 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2260 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002261 { } /* end */
2262};
2263
Takashi Iwai937b4162008-02-11 14:52:36 +01002264static struct hda_input_mux alc880_f1734_capture_source = {
2265 .num_items = 2,
2266 .items = {
2267 { "Mic", 0x1 },
2268 { "CD", 0x4 },
2269 },
2270};
2271
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002272
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002273/*
2274 * ALC880 ASUS model
2275 *
2276 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2277 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2278 * Mic = 0x18, Line = 0x1a
2279 */
2280
2281#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2282#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2283
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002284static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002285 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002286 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002287 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002288 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002289 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2290 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002291 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2292 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002293 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2294 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2295 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2296 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2297 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2298 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002299 {
2300 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2301 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002302 .info = alc_ch_mode_info,
2303 .get = alc_ch_mode_get,
2304 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002305 },
2306 { } /* end */
2307};
2308
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002309/*
2310 * ALC880 ASUS W1V model
2311 *
2312 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2313 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2314 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2315 */
2316
2317/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002318static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002319 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2320 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002321 { } /* end */
2322};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002323
Kailang Yangdf694da2005-12-05 19:42:22 +01002324/* TCL S700 */
2325static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2326 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2327 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2328 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2329 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2330 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2331 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2332 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2333 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2334 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002335 { } /* end */
2336};
2337
Kailang Yangccc656c2006-10-17 12:32:26 +02002338/* Uniwill */
2339static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002340 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2341 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2342 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2343 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002344 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2345 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2346 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2347 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2348 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2349 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2350 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2351 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2352 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2353 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2354 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2355 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002356 {
2357 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2358 .name = "Channel Mode",
2359 .info = alc_ch_mode_info,
2360 .get = alc_ch_mode_get,
2361 .put = alc_ch_mode_put,
2362 },
2363 { } /* end */
2364};
2365
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002366static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2367 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2368 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2369 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2370 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2371 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2372 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2373 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2374 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2375 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2376 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2377 { } /* end */
2378};
2379
Kailang Yangccc656c2006-10-17 12:32:26 +02002380static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002381 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2382 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2383 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2384 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002385 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2386 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2387 { } /* end */
2388};
2389
Linus Torvalds1da177e2005-04-16 15:20:36 -07002390/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002391 * virtual master controls
2392 */
2393
2394/*
2395 * slave controls for virtual master
2396 */
2397static const char *alc_slave_vols[] = {
2398 "Front Playback Volume",
2399 "Surround Playback Volume",
2400 "Center Playback Volume",
2401 "LFE Playback Volume",
2402 "Side Playback Volume",
2403 "Headphone Playback Volume",
2404 "Speaker Playback Volume",
2405 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002406 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002407 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002408 NULL,
2409};
2410
2411static const char *alc_slave_sws[] = {
2412 "Front Playback Switch",
2413 "Surround Playback Switch",
2414 "Center Playback Switch",
2415 "LFE Playback Switch",
2416 "Side Playback Switch",
2417 "Headphone Playback Switch",
2418 "Speaker Playback Switch",
2419 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002420 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002421 "Line-Out Playback Switch",
2422 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002423 NULL,
2424};
2425
2426/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002427 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002428 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002429
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002430#define NID_MAPPING (-1)
2431
2432#define SUBDEV_SPEAKER_ (0 << 6)
2433#define SUBDEV_HP_ (1 << 6)
2434#define SUBDEV_LINE_ (2 << 6)
2435#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2436#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2437#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2438
Takashi Iwai603c4012008-07-30 15:01:44 +02002439static void alc_free_kctls(struct hda_codec *codec);
2440
Takashi Iwai67d634c2009-11-16 15:35:59 +01002441#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002442/* additional beep mixers; the actual parameters are overwritten at build */
2443static struct snd_kcontrol_new alc_beep_mixer[] = {
2444 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002445 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002446 { } /* end */
2447};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002448#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002449
Linus Torvalds1da177e2005-04-16 15:20:36 -07002450static int alc_build_controls(struct hda_codec *codec)
2451{
2452 struct alc_spec *spec = codec->spec;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002453 struct snd_kcontrol *kctl;
2454 struct snd_kcontrol_new *knew;
2455 int i, j, err;
2456 unsigned int u;
2457 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002458
2459 for (i = 0; i < spec->num_mixers; i++) {
2460 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2461 if (err < 0)
2462 return err;
2463 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002464 if (spec->cap_mixer) {
2465 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2466 if (err < 0)
2467 return err;
2468 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002469 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002470 err = snd_hda_create_spdif_out_ctls(codec,
2471 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002472 if (err < 0)
2473 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002474 if (!spec->no_analog) {
2475 err = snd_hda_create_spdif_share_sw(codec,
2476 &spec->multiout);
2477 if (err < 0)
2478 return err;
2479 spec->multiout.share_spdif = 1;
2480 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002481 }
2482 if (spec->dig_in_nid) {
2483 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2484 if (err < 0)
2485 return err;
2486 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002487
Takashi Iwai67d634c2009-11-16 15:35:59 +01002488#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002489 /* create beep controls if needed */
2490 if (spec->beep_amp) {
2491 struct snd_kcontrol_new *knew;
2492 for (knew = alc_beep_mixer; knew->name; knew++) {
2493 struct snd_kcontrol *kctl;
2494 kctl = snd_ctl_new1(knew, codec);
2495 if (!kctl)
2496 return -ENOMEM;
2497 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002498 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002499 if (err < 0)
2500 return err;
2501 }
2502 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002503#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002504
Takashi Iwai2134ea42008-01-10 16:53:55 +01002505 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002506 if (!spec->no_analog &&
2507 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002508 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002509 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002510 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002511 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002512 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002513 if (err < 0)
2514 return err;
2515 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002516 if (!spec->no_analog &&
2517 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002518 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2519 NULL, alc_slave_sws);
2520 if (err < 0)
2521 return err;
2522 }
2523
Takashi Iwai603c4012008-07-30 15:01:44 +02002524 alc_free_kctls(codec); /* no longer needed */
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002525
2526 /* assign Capture Source enums to NID */
2527 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2528 if (!kctl)
2529 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2530 for (i = 0; kctl && i < kctl->count; i++) {
Takashi Iwaid1409ae2009-12-17 15:01:31 +01002531 hda_nid_t *nids = spec->capsrc_nids;
2532 if (!nids)
2533 nids = spec->adc_nids;
Takashi Iwai21949f02009-12-23 08:31:59 +01002534 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002535 if (err < 0)
2536 return err;
2537 }
2538 if (spec->cap_mixer) {
2539 const char *kname = kctl ? kctl->id.name : NULL;
2540 for (knew = spec->cap_mixer; knew->name; knew++) {
2541 if (kname && strcmp(knew->name, kname) == 0)
2542 continue;
2543 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2544 for (i = 0; kctl && i < kctl->count; i++) {
2545 err = snd_hda_add_nid(codec, kctl, i,
2546 spec->adc_nids[i]);
2547 if (err < 0)
2548 return err;
2549 }
2550 }
2551 }
2552
2553 /* other nid->control mapping */
2554 for (i = 0; i < spec->num_mixers; i++) {
2555 for (knew = spec->mixers[i]; knew->name; knew++) {
2556 if (knew->iface != NID_MAPPING)
2557 continue;
2558 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2559 if (kctl == NULL)
2560 continue;
2561 u = knew->subdevice;
2562 for (j = 0; j < 4; j++, u >>= 8) {
2563 nid = u & 0x3f;
2564 if (nid == 0)
2565 continue;
2566 switch (u & 0xc0) {
2567 case SUBDEV_SPEAKER_:
2568 nid = spec->autocfg.speaker_pins[nid];
2569 break;
2570 case SUBDEV_LINE_:
2571 nid = spec->autocfg.line_out_pins[nid];
2572 break;
2573 case SUBDEV_HP_:
2574 nid = spec->autocfg.hp_pins[nid];
2575 break;
2576 default:
2577 continue;
2578 }
2579 err = snd_hda_add_nid(codec, kctl, 0, nid);
2580 if (err < 0)
2581 return err;
2582 }
2583 u = knew->private_value;
2584 for (j = 0; j < 4; j++, u >>= 8) {
2585 nid = u & 0xff;
2586 if (nid == 0)
2587 continue;
2588 err = snd_hda_add_nid(codec, kctl, 0, nid);
2589 if (err < 0)
2590 return err;
2591 }
2592 }
2593 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002594 return 0;
2595}
2596
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002597
Linus Torvalds1da177e2005-04-16 15:20:36 -07002598/*
2599 * initialize the codec volumes, etc
2600 */
2601
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002602/*
2603 * generic initialization of ADC, input mixers and output mixers
2604 */
2605static struct hda_verb alc880_volume_init_verbs[] = {
2606 /*
2607 * Unmute ADC0-2 and set the default input to mic-in
2608 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002609 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002610 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002611 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002612 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002613 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002614 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002615
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002616 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2617 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002618 * Note: PASD motherboards uses the Line In 2 as the input for front
2619 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002620 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002621 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002622 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2623 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2624 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2625 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2626 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2627 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2628 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002629
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002630 /*
2631 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002632 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002633 /* set vol=0 to output mixers */
2634 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2635 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2636 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2637 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2638 /* set up input amps for analog loopback */
2639 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002640 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2641 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002642 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2643 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002644 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2645 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002646 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2647 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002648
2649 { }
2650};
2651
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002652/*
2653 * 3-stack pin configuration:
2654 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2655 */
2656static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2657 /*
2658 * preset connection lists of input pins
2659 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2660 */
2661 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2662 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2663 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2664
2665 /*
2666 * Set pin mode and muting
2667 */
2668 /* set front pin widgets 0x14 for output */
2669 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2670 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2671 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2672 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2673 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2674 /* Mic2 (as headphone out) for HP output */
2675 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2676 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2677 /* Line In pin widget for input */
2678 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2679 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2680 /* Line2 (as front mic) pin widget for input and vref at 80% */
2681 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2682 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2683 /* CD pin widget for input */
2684 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2685
2686 { }
2687};
2688
2689/*
2690 * 5-stack pin configuration:
2691 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2692 * line-in/side = 0x1a, f-mic = 0x1b
2693 */
2694static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2695 /*
2696 * preset connection lists of input pins
2697 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2698 */
2699 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2700 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2701
2702 /*
2703 * Set pin mode and muting
2704 */
2705 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002706 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2707 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2708 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2709 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002710 /* unmute pins for output (no gain on this amp) */
2711 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2712 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2713 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2714 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2715
Linus Torvalds1da177e2005-04-16 15:20:36 -07002716 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002717 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002718 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2719 /* Mic2 (as headphone out) for HP output */
2720 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002721 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002722 /* Line In pin widget for input */
2723 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2724 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2725 /* Line2 (as front mic) pin widget for input and vref at 80% */
2726 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2727 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2728 /* CD pin widget for input */
2729 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002730
2731 { }
2732};
2733
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002734/*
2735 * W810 pin configuration:
2736 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2737 */
2738static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002739 /* hphone/speaker input selector: front DAC */
2740 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2741
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002742 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2743 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2744 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2745 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2746 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2747 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2748
2749 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002750 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002751
Linus Torvalds1da177e2005-04-16 15:20:36 -07002752 { }
2753};
2754
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002755/*
2756 * Z71V pin configuration:
2757 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2758 */
2759static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002760 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002761 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002762 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002763 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002764
Takashi Iwai16ded522005-06-10 19:58:24 +02002765 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002766 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002767 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002768 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002769
2770 { }
2771};
2772
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002773/*
2774 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002775 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2776 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002777 */
2778static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2779 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2780
Takashi Iwai16ded522005-06-10 19:58:24 +02002781 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002782 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002783 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002784 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002785 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002786 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002787 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002788 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2789
Takashi Iwai16ded522005-06-10 19:58:24 +02002790 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002791 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002792 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002793 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002794 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002795 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002796 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002797 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002798 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002799
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002800 { }
2801};
Takashi Iwai16ded522005-06-10 19:58:24 +02002802
Kailang Yangccc656c2006-10-17 12:32:26 +02002803/*
2804 * Uniwill pin configuration:
2805 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2806 * line = 0x1a
2807 */
2808static struct hda_verb alc880_uniwill_init_verbs[] = {
2809 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2810
2811 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2812 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2813 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2814 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2815 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2816 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2817 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2818 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2819 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2820 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2821 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2822 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2823 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2824 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2825
2826 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2827 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2828 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2829 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2830 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2831 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2832 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2833 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2834 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2835
2836 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2837 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2838
2839 { }
2840};
2841
2842/*
2843* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002844* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002845 */
2846static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2847 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2848
2849 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2850 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2851 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2852 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2853 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2854 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2855 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2856 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2857 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2858 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2859 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2860 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2861
2862 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2863 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2864 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2865 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2866 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2867 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2868
2869 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2870 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2871
2872 { }
2873};
2874
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002875static struct hda_verb alc880_beep_init_verbs[] = {
2876 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2877 { }
2878};
2879
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002880/* auto-toggle front mic */
2881static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2882{
2883 unsigned int present;
2884 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002885
Wu Fengguang864f92b2009-11-18 12:38:02 +08002886 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002887 bits = present ? HDA_AMP_MUTE : 0;
2888 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002889}
2890
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002891static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002892{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002893 struct alc_spec *spec = codec->spec;
2894
2895 spec->autocfg.hp_pins[0] = 0x14;
2896 spec->autocfg.speaker_pins[0] = 0x15;
2897 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002898}
2899
2900static void alc880_uniwill_init_hook(struct hda_codec *codec)
2901{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002902 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002903 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002904}
2905
2906static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2907 unsigned int res)
2908{
2909 /* Looks like the unsol event is incompatible with the standard
2910 * definition. 4bit tag is placed at 28 bit!
2911 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002912 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002913 case ALC880_MIC_EVENT:
2914 alc880_uniwill_mic_automute(codec);
2915 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002916 default:
2917 alc_automute_amp_unsol_event(codec, res);
2918 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002919 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002920}
2921
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002922static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002923{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002924 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002925
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002926 spec->autocfg.hp_pins[0] = 0x14;
2927 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02002928}
2929
2930static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2931{
2932 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002933
Kailang Yangccc656c2006-10-17 12:32:26 +02002934 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002935 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2936 present &= HDA_AMP_VOLMASK;
2937 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2938 HDA_AMP_VOLMASK, present);
2939 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2940 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002941}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002942
Kailang Yangccc656c2006-10-17 12:32:26 +02002943static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2944 unsigned int res)
2945{
2946 /* Looks like the unsol event is incompatible with the standard
2947 * definition. 4bit tag is placed at 28 bit!
2948 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002949 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002950 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002951 else
2952 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002953}
2954
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002955/*
2956 * F1734 pin configuration:
2957 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2958 */
2959static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002960 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002961 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2962 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2963 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2964 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2965
2966 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2967 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2968 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2969 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2970
2971 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2972 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002973 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002974 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2975 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2976 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2977 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2978 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2979 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002980
Takashi Iwai937b4162008-02-11 14:52:36 +01002981 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2982 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2983
Takashi Iwai16ded522005-06-10 19:58:24 +02002984 { }
2985};
2986
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002987/*
2988 * ASUS pin configuration:
2989 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2990 */
2991static struct hda_verb alc880_pin_asus_init_verbs[] = {
2992 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2993 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2994 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2995 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2996
2997 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2998 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2999 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3000 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3001 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3002 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3003 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3004 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3005
3006 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3007 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3008 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3009 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3010 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3011 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3012 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3013 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3014 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003015
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003016 { }
3017};
3018
3019/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003020#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3021#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003022#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003023
Kailang Yangdf694da2005-12-05 19:42:22 +01003024/* Clevo m520g init */
3025static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3026 /* headphone output */
3027 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3028 /* line-out */
3029 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3030 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3031 /* Line-in */
3032 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3033 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3034 /* CD */
3035 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3036 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3037 /* Mic1 (rear panel) */
3038 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3039 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3040 /* Mic2 (front panel) */
3041 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3042 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3043 /* headphone */
3044 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3045 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3046 /* change to EAPD mode */
3047 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3048 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3049
3050 { }
3051};
3052
3053static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003054 /* change to EAPD mode */
3055 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3056 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3057
Kailang Yangdf694da2005-12-05 19:42:22 +01003058 /* Headphone output */
3059 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3060 /* Front output*/
3061 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3062 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3063
3064 /* Line In pin widget for input */
3065 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3066 /* CD pin widget for input */
3067 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3068 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3069 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3070
3071 /* change to EAPD mode */
3072 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3073 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3074
3075 { }
3076};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003077
3078/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003079 * LG m1 express dual
3080 *
3081 * Pin assignment:
3082 * Rear Line-In/Out (blue): 0x14
3083 * Build-in Mic-In: 0x15
3084 * Speaker-out: 0x17
3085 * HP-Out (green): 0x1b
3086 * Mic-In/Out (red): 0x19
3087 * SPDIF-Out: 0x1e
3088 */
3089
3090/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3091static hda_nid_t alc880_lg_dac_nids[3] = {
3092 0x05, 0x02, 0x03
3093};
3094
3095/* seems analog CD is not working */
3096static struct hda_input_mux alc880_lg_capture_source = {
3097 .num_items = 3,
3098 .items = {
3099 { "Mic", 0x1 },
3100 { "Line", 0x5 },
3101 { "Internal Mic", 0x6 },
3102 },
3103};
3104
3105/* 2,4,6 channel modes */
3106static struct hda_verb alc880_lg_ch2_init[] = {
3107 /* set line-in and mic-in to input */
3108 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3109 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3110 { }
3111};
3112
3113static struct hda_verb alc880_lg_ch4_init[] = {
3114 /* set line-in to out and mic-in to input */
3115 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3116 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3117 { }
3118};
3119
3120static struct hda_verb alc880_lg_ch6_init[] = {
3121 /* set line-in and mic-in to output */
3122 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3123 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3124 { }
3125};
3126
3127static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3128 { 2, alc880_lg_ch2_init },
3129 { 4, alc880_lg_ch4_init },
3130 { 6, alc880_lg_ch6_init },
3131};
3132
3133static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003134 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3135 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003136 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3137 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3138 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3139 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3140 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3141 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3142 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3143 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3144 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3145 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3146 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3147 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3148 {
3149 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3150 .name = "Channel Mode",
3151 .info = alc_ch_mode_info,
3152 .get = alc_ch_mode_get,
3153 .put = alc_ch_mode_put,
3154 },
3155 { } /* end */
3156};
3157
3158static struct hda_verb alc880_lg_init_verbs[] = {
3159 /* set capture source to mic-in */
3160 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3161 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3162 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3163 /* mute all amp mixer inputs */
3164 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003165 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3166 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003167 /* line-in to input */
3168 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3169 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3170 /* built-in mic */
3171 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3172 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3173 /* speaker-out */
3174 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3175 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3176 /* mic-in to input */
3177 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3178 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3179 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3180 /* HP-out */
3181 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3182 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3183 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3184 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003185 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003186 { }
3187};
3188
3189/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003190static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003191{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003192 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003193
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003194 spec->autocfg.hp_pins[0] = 0x1b;
3195 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003196}
3197
3198/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003199 * LG LW20
3200 *
3201 * Pin assignment:
3202 * Speaker-out: 0x14
3203 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003204 * Built-in Mic-In: 0x19
3205 * Line-In: 0x1b
3206 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003207 * SPDIF-Out: 0x1e
3208 */
3209
Takashi Iwaid6815182006-03-23 16:06:23 +01003210static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003211 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003212 .items = {
3213 { "Mic", 0x0 },
3214 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003215 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003216 },
3217};
3218
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003219#define alc880_lg_lw_modes alc880_threestack_modes
3220
Takashi Iwaid6815182006-03-23 16:06:23 +01003221static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003222 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3223 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3224 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3225 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3226 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3227 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3228 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3229 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3230 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3231 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003232 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3233 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3234 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3235 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003236 {
3237 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3238 .name = "Channel Mode",
3239 .info = alc_ch_mode_info,
3240 .get = alc_ch_mode_get,
3241 .put = alc_ch_mode_put,
3242 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003243 { } /* end */
3244};
3245
3246static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003247 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3248 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3249 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3250
Takashi Iwaid6815182006-03-23 16:06:23 +01003251 /* set capture source to mic-in */
3252 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3253 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3254 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003255 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003256 /* speaker-out */
3257 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3258 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3259 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003260 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3261 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3262 /* mic-in to input */
3263 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3264 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3265 /* built-in mic */
3266 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3267 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3268 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003269 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003270 { }
3271};
3272
3273/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003274static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003275{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003276 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003277
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003278 spec->autocfg.hp_pins[0] = 0x1b;
3279 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003280}
3281
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003282static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3283 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3284 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3285 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3286 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3287 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3288 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3289 { } /* end */
3290};
3291
3292static struct hda_input_mux alc880_medion_rim_capture_source = {
3293 .num_items = 2,
3294 .items = {
3295 { "Mic", 0x0 },
3296 { "Internal Mic", 0x1 },
3297 },
3298};
3299
3300static struct hda_verb alc880_medion_rim_init_verbs[] = {
3301 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3302
3303 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3304 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3305
3306 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3307 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3308 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3309 /* Mic2 (as headphone out) for HP output */
3310 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3311 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3312 /* Internal Speaker */
3313 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3314 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3315
3316 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3317 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3318
3319 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3320 { }
3321};
3322
3323/* toggle speaker-output according to the hp-jack state */
3324static void alc880_medion_rim_automute(struct hda_codec *codec)
3325{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003326 struct alc_spec *spec = codec->spec;
3327 alc_automute_amp(codec);
3328 /* toggle EAPD */
3329 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003330 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3331 else
3332 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3333}
3334
3335static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3336 unsigned int res)
3337{
3338 /* Looks like the unsol event is incompatible with the standard
3339 * definition. 4bit tag is placed at 28 bit!
3340 */
3341 if ((res >> 28) == ALC880_HP_EVENT)
3342 alc880_medion_rim_automute(codec);
3343}
3344
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003345static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003346{
3347 struct alc_spec *spec = codec->spec;
3348
3349 spec->autocfg.hp_pins[0] = 0x14;
3350 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003351}
3352
Takashi Iwaicb53c622007-08-10 17:21:45 +02003353#ifdef CONFIG_SND_HDA_POWER_SAVE
3354static struct hda_amp_list alc880_loopbacks[] = {
3355 { 0x0b, HDA_INPUT, 0 },
3356 { 0x0b, HDA_INPUT, 1 },
3357 { 0x0b, HDA_INPUT, 2 },
3358 { 0x0b, HDA_INPUT, 3 },
3359 { 0x0b, HDA_INPUT, 4 },
3360 { } /* end */
3361};
3362
3363static struct hda_amp_list alc880_lg_loopbacks[] = {
3364 { 0x0b, HDA_INPUT, 1 },
3365 { 0x0b, HDA_INPUT, 6 },
3366 { 0x0b, HDA_INPUT, 7 },
3367 { } /* end */
3368};
3369#endif
3370
Takashi Iwaid6815182006-03-23 16:06:23 +01003371/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003372 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003373 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003374
Linus Torvalds1da177e2005-04-16 15:20:36 -07003375static int alc_init(struct hda_codec *codec)
3376{
3377 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003378 unsigned int i;
3379
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003380 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003381 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003382
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003383 for (i = 0; i < spec->num_init_verbs; i++)
3384 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003385
3386 if (spec->init_hook)
3387 spec->init_hook(codec);
3388
Linus Torvalds1da177e2005-04-16 15:20:36 -07003389 return 0;
3390}
3391
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003392static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3393{
3394 struct alc_spec *spec = codec->spec;
3395
3396 if (spec->unsol_event)
3397 spec->unsol_event(codec, res);
3398}
3399
Takashi Iwaicb53c622007-08-10 17:21:45 +02003400#ifdef CONFIG_SND_HDA_POWER_SAVE
3401static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3402{
3403 struct alc_spec *spec = codec->spec;
3404 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3405}
3406#endif
3407
Linus Torvalds1da177e2005-04-16 15:20:36 -07003408/*
3409 * Analog playback callbacks
3410 */
3411static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3412 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003413 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003414{
3415 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003416 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3417 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003418}
3419
3420static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3421 struct hda_codec *codec,
3422 unsigned int stream_tag,
3423 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003424 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003425{
3426 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003427 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3428 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003429}
3430
3431static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3432 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 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3437}
3438
3439/*
3440 * Digital out
3441 */
3442static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3443 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003444 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003445{
3446 struct alc_spec *spec = codec->spec;
3447 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3448}
3449
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003450static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3451 struct hda_codec *codec,
3452 unsigned int stream_tag,
3453 unsigned int format,
3454 struct snd_pcm_substream *substream)
3455{
3456 struct alc_spec *spec = codec->spec;
3457 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3458 stream_tag, format, substream);
3459}
3460
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003461static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3462 struct hda_codec *codec,
3463 struct snd_pcm_substream *substream)
3464{
3465 struct alc_spec *spec = codec->spec;
3466 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3467}
3468
Linus Torvalds1da177e2005-04-16 15:20:36 -07003469static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3470 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003471 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003472{
3473 struct alc_spec *spec = codec->spec;
3474 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3475}
3476
3477/*
3478 * Analog capture
3479 */
Takashi Iwai63300792008-01-24 15:31:36 +01003480static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003481 struct hda_codec *codec,
3482 unsigned int stream_tag,
3483 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003484 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003485{
3486 struct alc_spec *spec = codec->spec;
3487
Takashi Iwai63300792008-01-24 15:31:36 +01003488 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003489 stream_tag, 0, format);
3490 return 0;
3491}
3492
Takashi Iwai63300792008-01-24 15:31:36 +01003493static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003494 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003495 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003496{
3497 struct alc_spec *spec = codec->spec;
3498
Takashi Iwai888afa12008-03-18 09:57:50 +01003499 snd_hda_codec_cleanup_stream(codec,
3500 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003501 return 0;
3502}
3503
3504
3505/*
3506 */
3507static struct hda_pcm_stream alc880_pcm_analog_playback = {
3508 .substreams = 1,
3509 .channels_min = 2,
3510 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003511 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003512 .ops = {
3513 .open = alc880_playback_pcm_open,
3514 .prepare = alc880_playback_pcm_prepare,
3515 .cleanup = alc880_playback_pcm_cleanup
3516 },
3517};
3518
3519static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003520 .substreams = 1,
3521 .channels_min = 2,
3522 .channels_max = 2,
3523 /* NID is set in alc_build_pcms */
3524};
3525
3526static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3527 .substreams = 1,
3528 .channels_min = 2,
3529 .channels_max = 2,
3530 /* NID is set in alc_build_pcms */
3531};
3532
3533static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3534 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003535 .channels_min = 2,
3536 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003537 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003538 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003539 .prepare = alc880_alt_capture_pcm_prepare,
3540 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003541 },
3542};
3543
3544static struct hda_pcm_stream alc880_pcm_digital_playback = {
3545 .substreams = 1,
3546 .channels_min = 2,
3547 .channels_max = 2,
3548 /* NID is set in alc_build_pcms */
3549 .ops = {
3550 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003551 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003552 .prepare = alc880_dig_playback_pcm_prepare,
3553 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003554 },
3555};
3556
3557static struct hda_pcm_stream alc880_pcm_digital_capture = {
3558 .substreams = 1,
3559 .channels_min = 2,
3560 .channels_max = 2,
3561 /* NID is set in alc_build_pcms */
3562};
3563
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003564/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003565static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003566 .substreams = 0,
3567 .channels_min = 0,
3568 .channels_max = 0,
3569};
3570
Linus Torvalds1da177e2005-04-16 15:20:36 -07003571static int alc_build_pcms(struct hda_codec *codec)
3572{
3573 struct alc_spec *spec = codec->spec;
3574 struct hda_pcm *info = spec->pcm_rec;
3575 int i;
3576
3577 codec->num_pcms = 1;
3578 codec->pcm_info = info;
3579
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003580 if (spec->no_analog)
3581 goto skip_analog;
3582
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003583 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3584 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003585 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003586
Takashi Iwai4a471b72005-12-07 13:56:29 +01003587 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003588 if (snd_BUG_ON(!spec->multiout.dac_nids))
3589 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003590 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3591 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3592 }
3593 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003594 if (snd_BUG_ON(!spec->adc_nids))
3595 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003596 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3597 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3598 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003599
Takashi Iwai4a471b72005-12-07 13:56:29 +01003600 if (spec->channel_mode) {
3601 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3602 for (i = 0; i < spec->num_channel_mode; i++) {
3603 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3604 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3605 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003606 }
3607 }
3608
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003609 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003610 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003611 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003612 snprintf(spec->stream_name_digital,
3613 sizeof(spec->stream_name_digital),
3614 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003615 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003616 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003617 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003618 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003619 if (spec->dig_out_type)
3620 info->pcm_type = spec->dig_out_type;
3621 else
3622 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003623 if (spec->multiout.dig_out_nid &&
3624 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003625 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3626 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3627 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003628 if (spec->dig_in_nid &&
3629 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003630 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3631 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3632 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003633 /* FIXME: do we need this for all Realtek codec models? */
3634 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003635 }
3636
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003637 if (spec->no_analog)
3638 return 0;
3639
Takashi Iwaie08a0072006-09-07 17:52:14 +02003640 /* If the use of more than one ADC is requested for the current
3641 * model, configure a second analog capture-only PCM.
3642 */
3643 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003644 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3645 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003646 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003647 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003648 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003649 if (spec->alt_dac_nid) {
3650 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3651 *spec->stream_analog_alt_playback;
3652 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3653 spec->alt_dac_nid;
3654 } else {
3655 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3656 alc_pcm_null_stream;
3657 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3658 }
3659 if (spec->num_adc_nids > 1) {
3660 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3661 *spec->stream_analog_alt_capture;
3662 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3663 spec->adc_nids[1];
3664 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3665 spec->num_adc_nids - 1;
3666 } else {
3667 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3668 alc_pcm_null_stream;
3669 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003670 }
3671 }
3672
Linus Torvalds1da177e2005-04-16 15:20:36 -07003673 return 0;
3674}
3675
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003676static inline void alc_shutup(struct hda_codec *codec)
3677{
3678 snd_hda_shutup_pins(codec);
3679}
3680
Takashi Iwai603c4012008-07-30 15:01:44 +02003681static void alc_free_kctls(struct hda_codec *codec)
3682{
3683 struct alc_spec *spec = codec->spec;
3684
3685 if (spec->kctls.list) {
3686 struct snd_kcontrol_new *kctl = spec->kctls.list;
3687 int i;
3688 for (i = 0; i < spec->kctls.used; i++)
3689 kfree(kctl[i].name);
3690 }
3691 snd_array_free(&spec->kctls);
3692}
3693
Linus Torvalds1da177e2005-04-16 15:20:36 -07003694static void alc_free(struct hda_codec *codec)
3695{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003696 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003697
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003698 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003699 return;
3700
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003701 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02003702 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003703 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003704 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003705}
3706
Hector Martinf5de24b2009-12-20 22:51:31 +01003707#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05003708static void alc_power_eapd(struct hda_codec *codec)
3709{
3710 /* We currently only handle front, HP */
3711 switch (codec->vendor_id) {
3712 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003713 set_eapd(codec, 0x0f, 0);
3714 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003715 break;
3716 case 0x10ec0262:
3717 case 0x10ec0267:
3718 case 0x10ec0268:
3719 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003720 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05003721 case 0x10ec0272:
3722 case 0x10ec0660:
3723 case 0x10ec0662:
3724 case 0x10ec0663:
3725 case 0x10ec0862:
3726 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003727 set_eapd(codec, 0x14, 0);
3728 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003729 break;
3730 }
3731}
3732
Hector Martinf5de24b2009-12-20 22:51:31 +01003733static int alc_suspend(struct hda_codec *codec, pm_message_t state)
3734{
3735 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003736 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003737 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05003738 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003739 return 0;
3740}
3741#endif
3742
Takashi Iwaie044c392008-10-27 16:56:24 +01003743#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003744static int alc_resume(struct hda_codec *codec)
3745{
Takashi Iwaie044c392008-10-27 16:56:24 +01003746 codec->patch_ops.init(codec);
3747 snd_hda_codec_resume_amp(codec);
3748 snd_hda_codec_resume_cache(codec);
3749 return 0;
3750}
Takashi Iwaie044c392008-10-27 16:56:24 +01003751#endif
3752
Linus Torvalds1da177e2005-04-16 15:20:36 -07003753/*
3754 */
3755static struct hda_codec_ops alc_patch_ops = {
3756 .build_controls = alc_build_controls,
3757 .build_pcms = alc_build_pcms,
3758 .init = alc_init,
3759 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003760 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003761#ifdef SND_HDA_NEEDS_RESUME
3762 .resume = alc_resume,
3763#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003764#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01003765 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003766 .check_power_status = alc_check_power_status,
3767#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05003768 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003769};
3770
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003771
3772/*
3773 * Test configuration for debugging
3774 *
3775 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3776 * enum controls.
3777 */
3778#ifdef CONFIG_SND_DEBUG
3779static hda_nid_t alc880_test_dac_nids[4] = {
3780 0x02, 0x03, 0x04, 0x05
3781};
3782
3783static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003784 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003785 .items = {
3786 { "In-1", 0x0 },
3787 { "In-2", 0x1 },
3788 { "In-3", 0x2 },
3789 { "In-4", 0x3 },
3790 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003791 { "Front", 0x5 },
3792 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003793 },
3794};
3795
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003796static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003797 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003798 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003799 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003800 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003801};
3802
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003803static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3804 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003805{
3806 static char *texts[] = {
3807 "N/A", "Line Out", "HP Out",
3808 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3809 };
3810 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3811 uinfo->count = 1;
3812 uinfo->value.enumerated.items = 8;
3813 if (uinfo->value.enumerated.item >= 8)
3814 uinfo->value.enumerated.item = 7;
3815 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3816 return 0;
3817}
3818
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003819static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3820 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003821{
3822 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3823 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3824 unsigned int pin_ctl, item = 0;
3825
3826 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3827 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3828 if (pin_ctl & AC_PINCTL_OUT_EN) {
3829 if (pin_ctl & AC_PINCTL_HP_EN)
3830 item = 2;
3831 else
3832 item = 1;
3833 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3834 switch (pin_ctl & AC_PINCTL_VREFEN) {
3835 case AC_PINCTL_VREF_HIZ: item = 3; break;
3836 case AC_PINCTL_VREF_50: item = 4; break;
3837 case AC_PINCTL_VREF_GRD: item = 5; break;
3838 case AC_PINCTL_VREF_80: item = 6; break;
3839 case AC_PINCTL_VREF_100: item = 7; break;
3840 }
3841 }
3842 ucontrol->value.enumerated.item[0] = item;
3843 return 0;
3844}
3845
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003846static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3847 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003848{
3849 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3850 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3851 static unsigned int ctls[] = {
3852 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3853 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3854 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3855 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3856 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3857 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3858 };
3859 unsigned int old_ctl, new_ctl;
3860
3861 old_ctl = snd_hda_codec_read(codec, nid, 0,
3862 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3863 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3864 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003865 int val;
3866 snd_hda_codec_write_cache(codec, nid, 0,
3867 AC_VERB_SET_PIN_WIDGET_CONTROL,
3868 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003869 val = ucontrol->value.enumerated.item[0] >= 3 ?
3870 HDA_AMP_MUTE : 0;
3871 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3872 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003873 return 1;
3874 }
3875 return 0;
3876}
3877
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003878static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3879 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003880{
3881 static char *texts[] = {
3882 "Front", "Surround", "CLFE", "Side"
3883 };
3884 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3885 uinfo->count = 1;
3886 uinfo->value.enumerated.items = 4;
3887 if (uinfo->value.enumerated.item >= 4)
3888 uinfo->value.enumerated.item = 3;
3889 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3890 return 0;
3891}
3892
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003893static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3894 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003895{
3896 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3897 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3898 unsigned int sel;
3899
3900 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3901 ucontrol->value.enumerated.item[0] = sel & 3;
3902 return 0;
3903}
3904
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003905static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3906 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003907{
3908 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3909 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3910 unsigned int sel;
3911
3912 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3913 if (ucontrol->value.enumerated.item[0] != sel) {
3914 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003915 snd_hda_codec_write_cache(codec, nid, 0,
3916 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003917 return 1;
3918 }
3919 return 0;
3920}
3921
3922#define PIN_CTL_TEST(xname,nid) { \
3923 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3924 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003925 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003926 .info = alc_test_pin_ctl_info, \
3927 .get = alc_test_pin_ctl_get, \
3928 .put = alc_test_pin_ctl_put, \
3929 .private_value = nid \
3930 }
3931
3932#define PIN_SRC_TEST(xname,nid) { \
3933 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3934 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003935 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003936 .info = alc_test_pin_src_info, \
3937 .get = alc_test_pin_src_get, \
3938 .put = alc_test_pin_src_put, \
3939 .private_value = nid \
3940 }
3941
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003942static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003943 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3944 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3945 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3946 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003947 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3948 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3949 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3950 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003951 PIN_CTL_TEST("Front Pin Mode", 0x14),
3952 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3953 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3954 PIN_CTL_TEST("Side Pin Mode", 0x17),
3955 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3956 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3957 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3958 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3959 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3960 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3961 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3962 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3963 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3964 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3965 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3966 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3967 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3968 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3969 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3970 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3971 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3972 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003973 {
3974 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3975 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003976 .info = alc_ch_mode_info,
3977 .get = alc_ch_mode_get,
3978 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003979 },
3980 { } /* end */
3981};
3982
3983static struct hda_verb alc880_test_init_verbs[] = {
3984 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003985 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3986 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3987 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3988 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3989 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3990 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3991 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3992 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003993 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003994 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3995 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3996 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3997 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003998 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003999 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4000 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4001 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4002 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004003 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004004 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4005 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4006 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4007 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004008 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004009 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4010 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004011 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4012 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4013 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004014 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004015 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4016 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4017 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4018 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004019 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004020 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004021 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004022 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004023 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004024 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004025 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004026 /* Analog input/passthru */
4027 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4028 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4029 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4030 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4031 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004032 { }
4033};
4034#endif
4035
Linus Torvalds1da177e2005-04-16 15:20:36 -07004036/*
4037 */
4038
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004039static const char *alc880_models[ALC880_MODEL_LAST] = {
4040 [ALC880_3ST] = "3stack",
4041 [ALC880_TCL_S700] = "tcl",
4042 [ALC880_3ST_DIG] = "3stack-digout",
4043 [ALC880_CLEVO] = "clevo",
4044 [ALC880_5ST] = "5stack",
4045 [ALC880_5ST_DIG] = "5stack-digout",
4046 [ALC880_W810] = "w810",
4047 [ALC880_Z71V] = "z71v",
4048 [ALC880_6ST] = "6stack",
4049 [ALC880_6ST_DIG] = "6stack-digout",
4050 [ALC880_ASUS] = "asus",
4051 [ALC880_ASUS_W1V] = "asus-w1v",
4052 [ALC880_ASUS_DIG] = "asus-dig",
4053 [ALC880_ASUS_DIG2] = "asus-dig2",
4054 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004055 [ALC880_UNIWILL_P53] = "uniwill-p53",
4056 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004057 [ALC880_F1734] = "F1734",
4058 [ALC880_LG] = "lg",
4059 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004060 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004061#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004062 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004063#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004064 [ALC880_AUTO] = "auto",
4065};
4066
4067static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004068 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004069 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4070 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4071 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4072 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4073 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4074 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4075 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4076 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004077 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4078 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004079 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4080 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4081 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4082 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4083 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4084 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4085 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4086 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4087 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4088 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004089 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004090 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4091 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4092 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004093 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004094 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004095 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4096 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004097 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4098 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004099 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4100 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4101 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4102 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004103 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4104 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004105 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004106 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004107 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004108 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004109 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4110 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004111 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004112 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004113 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004114 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004115 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004116 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004117 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004118 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004119 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004120 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4121 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004122 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004123 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4124 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4125 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4126 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004127 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4128 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004129 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004130 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004131 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4132 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004133 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4134 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4135 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004136 /* default Intel */
4137 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004138 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4139 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004140 {}
4141};
4142
Takashi Iwai16ded522005-06-10 19:58:24 +02004143/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004144 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004145 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004146static struct alc_config_preset alc880_presets[] = {
4147 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004148 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004149 .init_verbs = { alc880_volume_init_verbs,
4150 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004151 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004152 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004153 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4154 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004155 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004156 .input_mux = &alc880_capture_source,
4157 },
4158 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004159 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004160 .init_verbs = { alc880_volume_init_verbs,
4161 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004162 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004163 .dac_nids = alc880_dac_nids,
4164 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004165 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4166 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004167 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004168 .input_mux = &alc880_capture_source,
4169 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004170 [ALC880_TCL_S700] = {
4171 .mixers = { alc880_tcl_s700_mixer },
4172 .init_verbs = { alc880_volume_init_verbs,
4173 alc880_pin_tcl_S700_init_verbs,
4174 alc880_gpio2_init_verbs },
4175 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4176 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004177 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4178 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004179 .hp_nid = 0x03,
4180 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4181 .channel_mode = alc880_2_jack_modes,
4182 .input_mux = &alc880_capture_source,
4183 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004184 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004185 .mixers = { alc880_three_stack_mixer,
4186 alc880_five_stack_mixer},
4187 .init_verbs = { alc880_volume_init_verbs,
4188 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004189 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4190 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004191 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4192 .channel_mode = alc880_fivestack_modes,
4193 .input_mux = &alc880_capture_source,
4194 },
4195 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004196 .mixers = { alc880_three_stack_mixer,
4197 alc880_five_stack_mixer },
4198 .init_verbs = { alc880_volume_init_verbs,
4199 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004200 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4201 .dac_nids = alc880_dac_nids,
4202 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004203 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4204 .channel_mode = alc880_fivestack_modes,
4205 .input_mux = &alc880_capture_source,
4206 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004207 [ALC880_6ST] = {
4208 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004209 .init_verbs = { alc880_volume_init_verbs,
4210 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004211 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4212 .dac_nids = alc880_6st_dac_nids,
4213 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4214 .channel_mode = alc880_sixstack_modes,
4215 .input_mux = &alc880_6stack_capture_source,
4216 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004217 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004218 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004219 .init_verbs = { alc880_volume_init_verbs,
4220 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004221 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4222 .dac_nids = alc880_6st_dac_nids,
4223 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004224 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4225 .channel_mode = alc880_sixstack_modes,
4226 .input_mux = &alc880_6stack_capture_source,
4227 },
4228 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004229 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004230 .init_verbs = { alc880_volume_init_verbs,
4231 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004232 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004233 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4234 .dac_nids = alc880_w810_dac_nids,
4235 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004236 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4237 .channel_mode = alc880_w810_modes,
4238 .input_mux = &alc880_capture_source,
4239 },
4240 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004241 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004242 .init_verbs = { alc880_volume_init_verbs,
4243 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004244 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4245 .dac_nids = alc880_z71v_dac_nids,
4246 .dig_out_nid = ALC880_DIGOUT_NID,
4247 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004248 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4249 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004250 .input_mux = &alc880_capture_source,
4251 },
4252 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004253 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004254 .init_verbs = { alc880_volume_init_verbs,
4255 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004256 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4257 .dac_nids = alc880_f1734_dac_nids,
4258 .hp_nid = 0x02,
4259 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4260 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004261 .input_mux = &alc880_f1734_capture_source,
4262 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004263 .setup = alc880_uniwill_p53_setup,
4264 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004265 },
4266 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004267 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004268 .init_verbs = { alc880_volume_init_verbs,
4269 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004270 alc880_gpio1_init_verbs },
4271 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4272 .dac_nids = alc880_asus_dac_nids,
4273 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4274 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004275 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004276 .input_mux = &alc880_capture_source,
4277 },
4278 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004279 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004280 .init_verbs = { alc880_volume_init_verbs,
4281 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004282 alc880_gpio1_init_verbs },
4283 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4284 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004285 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004286 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4287 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004288 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004289 .input_mux = &alc880_capture_source,
4290 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004291 [ALC880_ASUS_DIG2] = {
4292 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004293 .init_verbs = { alc880_volume_init_verbs,
4294 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004295 alc880_gpio2_init_verbs }, /* use GPIO2 */
4296 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4297 .dac_nids = alc880_asus_dac_nids,
4298 .dig_out_nid = ALC880_DIGOUT_NID,
4299 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4300 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004301 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004302 .input_mux = &alc880_capture_source,
4303 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004304 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004305 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004306 .init_verbs = { alc880_volume_init_verbs,
4307 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004308 alc880_gpio1_init_verbs },
4309 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4310 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004311 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004312 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4313 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004314 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004315 .input_mux = &alc880_capture_source,
4316 },
4317 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004318 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004319 .init_verbs = { alc880_volume_init_verbs,
4320 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004321 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4322 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004323 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004324 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4325 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004326 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004327 .input_mux = &alc880_capture_source,
4328 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004329 [ALC880_UNIWILL] = {
4330 .mixers = { alc880_uniwill_mixer },
4331 .init_verbs = { alc880_volume_init_verbs,
4332 alc880_uniwill_init_verbs },
4333 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4334 .dac_nids = alc880_asus_dac_nids,
4335 .dig_out_nid = ALC880_DIGOUT_NID,
4336 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4337 .channel_mode = alc880_threestack_modes,
4338 .need_dac_fix = 1,
4339 .input_mux = &alc880_capture_source,
4340 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004341 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004342 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004343 },
4344 [ALC880_UNIWILL_P53] = {
4345 .mixers = { alc880_uniwill_p53_mixer },
4346 .init_verbs = { alc880_volume_init_verbs,
4347 alc880_uniwill_p53_init_verbs },
4348 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4349 .dac_nids = alc880_asus_dac_nids,
4350 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004351 .channel_mode = alc880_threestack_modes,
4352 .input_mux = &alc880_capture_source,
4353 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004354 .setup = alc880_uniwill_p53_setup,
4355 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004356 },
4357 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004358 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004359 .init_verbs = { alc880_volume_init_verbs,
4360 alc880_uniwill_p53_init_verbs,
4361 alc880_beep_init_verbs },
4362 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4363 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004364 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004365 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4366 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004367 .input_mux = &alc880_capture_source,
4368 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004369 .setup = alc880_uniwill_p53_setup,
4370 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004371 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004372 [ALC880_CLEVO] = {
4373 .mixers = { alc880_three_stack_mixer },
4374 .init_verbs = { alc880_volume_init_verbs,
4375 alc880_pin_clevo_init_verbs },
4376 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4377 .dac_nids = alc880_dac_nids,
4378 .hp_nid = 0x03,
4379 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4380 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004381 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004382 .input_mux = &alc880_capture_source,
4383 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004384 [ALC880_LG] = {
4385 .mixers = { alc880_lg_mixer },
4386 .init_verbs = { alc880_volume_init_verbs,
4387 alc880_lg_init_verbs },
4388 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4389 .dac_nids = alc880_lg_dac_nids,
4390 .dig_out_nid = ALC880_DIGOUT_NID,
4391 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4392 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004393 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004394 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004395 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004396 .setup = alc880_lg_setup,
4397 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004398#ifdef CONFIG_SND_HDA_POWER_SAVE
4399 .loopbacks = alc880_lg_loopbacks,
4400#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004401 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004402 [ALC880_LG_LW] = {
4403 .mixers = { alc880_lg_lw_mixer },
4404 .init_verbs = { alc880_volume_init_verbs,
4405 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004406 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004407 .dac_nids = alc880_dac_nids,
4408 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004409 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4410 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004411 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004412 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004413 .setup = alc880_lg_lw_setup,
4414 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004415 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004416 [ALC880_MEDION_RIM] = {
4417 .mixers = { alc880_medion_rim_mixer },
4418 .init_verbs = { alc880_volume_init_verbs,
4419 alc880_medion_rim_init_verbs,
4420 alc_gpio2_init_verbs },
4421 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4422 .dac_nids = alc880_dac_nids,
4423 .dig_out_nid = ALC880_DIGOUT_NID,
4424 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4425 .channel_mode = alc880_2_jack_modes,
4426 .input_mux = &alc880_medion_rim_capture_source,
4427 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004428 .setup = alc880_medion_rim_setup,
4429 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004430 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004431#ifdef CONFIG_SND_DEBUG
4432 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004433 .mixers = { alc880_test_mixer },
4434 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004435 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4436 .dac_nids = alc880_test_dac_nids,
4437 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004438 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4439 .channel_mode = alc880_test_modes,
4440 .input_mux = &alc880_test_capture_source,
4441 },
4442#endif
4443};
4444
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004445/*
4446 * Automatic parse of I/O pins from the BIOS configuration
4447 */
4448
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004449enum {
4450 ALC_CTL_WIDGET_VOL,
4451 ALC_CTL_WIDGET_MUTE,
4452 ALC_CTL_BIND_MUTE,
4453};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004454static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004455 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4456 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004457 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004458};
4459
4460/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004461static int add_control(struct alc_spec *spec, int type, const char *name,
4462 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004463{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004464 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004465
Takashi Iwai603c4012008-07-30 15:01:44 +02004466 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4467 knew = snd_array_new(&spec->kctls);
4468 if (!knew)
4469 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004470 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004471 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004472 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004473 return -ENOMEM;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004474 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004475 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004476 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004477 return 0;
4478}
4479
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004480static int add_control_with_pfx(struct alc_spec *spec, int type,
4481 const char *pfx, const char *dir,
4482 const char *sfx, unsigned long val)
4483{
4484 char name[32];
4485 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
4486 return add_control(spec, type, name, val);
4487}
4488
4489#define add_pb_vol_ctrl(spec, type, pfx, val) \
4490 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val)
4491#define add_pb_sw_ctrl(spec, type, pfx, val) \
4492 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val)
4493
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004494#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4495#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4496#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4497#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004498#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4499#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4500#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4501#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4502#define ALC880_PIN_CD_NID 0x1c
4503
4504/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004505static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4506 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004507{
4508 hda_nid_t nid;
4509 int assigned[4];
4510 int i, j;
4511
4512 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004513 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004514
4515 /* check the pins hardwired to audio widget */
4516 for (i = 0; i < cfg->line_outs; i++) {
4517 nid = cfg->line_out_pins[i];
4518 if (alc880_is_fixed_pin(nid)) {
4519 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004520 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004521 assigned[idx] = 1;
4522 }
4523 }
4524 /* left pins can be connect to any audio widget */
4525 for (i = 0; i < cfg->line_outs; i++) {
4526 nid = cfg->line_out_pins[i];
4527 if (alc880_is_fixed_pin(nid))
4528 continue;
4529 /* search for an empty channel */
4530 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004531 if (!assigned[j]) {
4532 spec->multiout.dac_nids[i] =
4533 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004534 assigned[j] = 1;
4535 break;
4536 }
4537 }
4538 }
4539 spec->multiout.num_dacs = cfg->line_outs;
4540 return 0;
4541}
4542
4543/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004544static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4545 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004546{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004547 static const char *chname[4] = {
4548 "Front", "Surround", NULL /*CLFE*/, "Side"
4549 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004550 hda_nid_t nid;
4551 int i, err;
4552
4553 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004554 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004555 continue;
4556 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4557 if (i == 2) {
4558 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004559 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4560 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004561 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4562 HDA_OUTPUT));
4563 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004564 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004565 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4566 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004567 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4568 HDA_OUTPUT));
4569 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004570 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004571 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4572 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004573 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4574 HDA_INPUT));
4575 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004576 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004577 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4578 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004579 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4580 HDA_INPUT));
4581 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004582 return err;
4583 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004584 const char *pfx;
4585 if (cfg->line_outs == 1 &&
4586 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4587 pfx = "Speaker";
4588 else
4589 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004590 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004591 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4592 HDA_OUTPUT));
4593 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004594 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004595 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004596 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4597 HDA_INPUT));
4598 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004599 return err;
4600 }
4601 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004602 return 0;
4603}
4604
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004605/* add playback controls for speaker and HP outputs */
4606static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4607 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004608{
4609 hda_nid_t nid;
4610 int err;
4611
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004612 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004613 return 0;
4614
4615 if (alc880_is_fixed_pin(pin)) {
4616 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004617 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004618 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004619 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004620 else
4621 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004622 /* control HP volume/switch on the output mixer amp */
4623 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004624 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004625 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4626 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004627 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004628 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004629 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4630 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004631 return err;
4632 } else if (alc880_is_multi_pin(pin)) {
4633 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004634 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004635 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004636 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4637 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004638 return err;
4639 }
4640 return 0;
4641}
4642
4643/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004644static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4645 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004646 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004647{
Kailang Yangdf694da2005-12-05 19:42:22 +01004648 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004649
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004650 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004651 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4652 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004653 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004654 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004655 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4656 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004657 return err;
4658 return 0;
4659}
4660
Takashi Iwai05f5f472009-08-25 13:10:18 +02004661static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004662{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004663 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4664 return (pincap & AC_PINCAP_IN) != 0;
4665}
4666
4667/* create playback/capture controls for input pins */
4668static int alc_auto_create_input_ctls(struct hda_codec *codec,
4669 const struct auto_pin_cfg *cfg,
4670 hda_nid_t mixer,
4671 hda_nid_t cap1, hda_nid_t cap2)
4672{
4673 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004674 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004675 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004676
4677 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004678 hda_nid_t pin;
4679
4680 pin = cfg->input_pins[i];
4681 if (!alc_is_input_pin(codec, pin))
4682 continue;
4683
4684 if (mixer) {
4685 idx = get_connection_index(codec, mixer, pin);
4686 if (idx >= 0) {
4687 err = new_analog_input(spec, pin,
4688 auto_pin_cfg_labels[i],
4689 idx, mixer);
4690 if (err < 0)
4691 return err;
4692 }
4693 }
4694
4695 if (!cap1)
4696 continue;
4697 idx = get_connection_index(codec, cap1, pin);
4698 if (idx < 0 && cap2)
4699 idx = get_connection_index(codec, cap2, pin);
4700 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004701 imux->items[imux->num_items].label =
4702 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004703 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004704 imux->num_items++;
4705 }
4706 }
4707 return 0;
4708}
4709
Takashi Iwai05f5f472009-08-25 13:10:18 +02004710static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4711 const struct auto_pin_cfg *cfg)
4712{
4713 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4714}
4715
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004716static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4717 unsigned int pin_type)
4718{
4719 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4720 pin_type);
4721 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004722 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4723 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004724}
4725
Kailang Yangdf694da2005-12-05 19:42:22 +01004726static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4727 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004728 int dac_idx)
4729{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004730 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004731 /* need the manual connection? */
4732 if (alc880_is_multi_pin(nid)) {
4733 struct alc_spec *spec = codec->spec;
4734 int idx = alc880_multi_pin_idx(nid);
4735 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4736 AC_VERB_SET_CONNECT_SEL,
4737 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4738 }
4739}
4740
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004741static int get_pin_type(int line_out_type)
4742{
4743 if (line_out_type == AUTO_PIN_HP_OUT)
4744 return PIN_HP;
4745 else
4746 return PIN_OUT;
4747}
4748
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004749static void alc880_auto_init_multi_out(struct hda_codec *codec)
4750{
4751 struct alc_spec *spec = codec->spec;
4752 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004753
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004754 for (i = 0; i < spec->autocfg.line_outs; i++) {
4755 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004756 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4757 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004758 }
4759}
4760
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004761static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004762{
4763 struct alc_spec *spec = codec->spec;
4764 hda_nid_t pin;
4765
Takashi Iwai82bc9552006-03-21 11:24:42 +01004766 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004767 if (pin) /* connect to front */
4768 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004769 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004770 if (pin) /* connect to front */
4771 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4772}
4773
4774static void alc880_auto_init_analog_input(struct hda_codec *codec)
4775{
4776 struct alc_spec *spec = codec->spec;
4777 int i;
4778
4779 for (i = 0; i < AUTO_PIN_LAST; i++) {
4780 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004781 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004782 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004783 if (nid != ALC880_PIN_CD_NID &&
4784 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004785 snd_hda_codec_write(codec, nid, 0,
4786 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004787 AMP_OUT_MUTE);
4788 }
4789 }
4790}
4791
4792/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004793/* return 1 if successful, 0 if the proper config is not found,
4794 * or a negative error code
4795 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004796static int alc880_parse_auto_config(struct hda_codec *codec)
4797{
4798 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004799 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004800 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004801
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004802 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4803 alc880_ignore);
4804 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004805 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004806 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004807 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004808
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004809 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4810 if (err < 0)
4811 return err;
4812 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4813 if (err < 0)
4814 return err;
4815 err = alc880_auto_create_extra_out(spec,
4816 spec->autocfg.speaker_pins[0],
4817 "Speaker");
4818 if (err < 0)
4819 return err;
4820 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4821 "Headphone");
4822 if (err < 0)
4823 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004824 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004825 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004826 return err;
4827
4828 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4829
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004830 /* check multiple SPDIF-out (for recent codecs) */
4831 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4832 hda_nid_t dig_nid;
4833 err = snd_hda_get_connections(codec,
4834 spec->autocfg.dig_out_pins[i],
4835 &dig_nid, 1);
4836 if (err < 0)
4837 continue;
4838 if (!i)
4839 spec->multiout.dig_out_nid = dig_nid;
4840 else {
4841 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004842 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004843 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004844 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004845 }
4846 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004847 if (spec->autocfg.dig_in_pin)
4848 spec->dig_in_nid = ALC880_DIGIN_NID;
4849
Takashi Iwai603c4012008-07-30 15:01:44 +02004850 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004851 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004852
Takashi Iwaid88897e2008-10-31 15:01:37 +01004853 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004854
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004855 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004856 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004857
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004858 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4859
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004860 return 1;
4861}
4862
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004863/* additional initialization for auto-configuration model */
4864static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004865{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004866 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004867 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004868 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004869 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004870 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004871 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004872}
4873
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004874/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4875 * one of two digital mic pins, e.g. on ALC272
4876 */
4877static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004878{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004879 struct alc_spec *spec = codec->spec;
4880 int i;
4881
4882 for (i = 0; i < spec->num_adc_nids; i++) {
4883 hda_nid_t cap = spec->capsrc_nids ?
4884 spec->capsrc_nids[i] : spec->adc_nids[i];
4885 int iidx, eidx;
4886
4887 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4888 if (iidx < 0)
4889 continue;
4890 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4891 if (eidx < 0)
4892 continue;
4893 spec->int_mic.mux_idx = iidx;
4894 spec->ext_mic.mux_idx = eidx;
4895 if (spec->capsrc_nids)
4896 spec->capsrc_nids += i;
4897 spec->adc_nids += i;
4898 spec->num_adc_nids = 1;
4899 return;
4900 }
4901 snd_printd(KERN_INFO "hda_codec: %s: "
4902 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4903 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4904 spec->auto_mic = 0; /* disable auto-mic to be sure */
4905}
4906
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004907/* choose the ADC/MUX containing the input pin and initialize the setup */
4908static void fixup_single_adc(struct hda_codec *codec)
4909{
4910 struct alc_spec *spec = codec->spec;
4911 hda_nid_t pin;
4912 int i;
4913
4914 /* search for the input pin; there must be only one */
4915 for (i = 0; i < AUTO_PIN_LAST; i++) {
4916 if (spec->autocfg.input_pins[i]) {
4917 pin = spec->autocfg.input_pins[i];
4918 break;
4919 }
4920 }
4921 if (!pin)
4922 return;
4923
4924 /* set the default connection to that pin */
4925 for (i = 0; i < spec->num_adc_nids; i++) {
4926 hda_nid_t cap = spec->capsrc_nids ?
4927 spec->capsrc_nids[i] : spec->adc_nids[i];
4928 int idx;
4929
4930 idx = get_connection_index(codec, cap, pin);
4931 if (idx < 0)
4932 continue;
4933 /* use only this ADC */
4934 if (spec->capsrc_nids)
4935 spec->capsrc_nids += i;
4936 spec->adc_nids += i;
4937 spec->num_adc_nids = 1;
4938 /* select or unmute this route */
4939 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
4940 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
4941 HDA_AMP_MUTE, 0);
4942 } else {
4943 snd_hda_codec_write_cache(codec, cap, 0,
4944 AC_VERB_SET_CONNECT_SEL, idx);
4945 }
4946 return;
4947 }
4948}
4949
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004950static void set_capture_mixer(struct hda_codec *codec)
4951{
4952 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01004953 static struct snd_kcontrol_new *caps[2][3] = {
4954 { alc_capture_mixer_nosrc1,
4955 alc_capture_mixer_nosrc2,
4956 alc_capture_mixer_nosrc3 },
4957 { alc_capture_mixer1,
4958 alc_capture_mixer2,
4959 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004960 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004961 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004962 int mux = 0;
4963 if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004964 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004965 else if (spec->input_mux) {
4966 if (spec->input_mux->num_items > 1)
4967 mux = 1;
4968 else if (spec->input_mux->num_items == 1)
4969 fixup_single_adc(codec);
4970 }
Takashi Iwaia23b6882009-03-23 15:21:36 +01004971 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4972 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004973}
4974
Takashi Iwai67d634c2009-11-16 15:35:59 +01004975#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004976#define set_beep_amp(spec, nid, idx, dir) \
4977 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwai67d634c2009-11-16 15:35:59 +01004978#else
4979#define set_beep_amp(spec, nid, idx, dir) /* NOP */
4980#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004981
4982/*
4983 * OK, here we have finally the patch for ALC880
4984 */
4985
Linus Torvalds1da177e2005-04-16 15:20:36 -07004986static int patch_alc880(struct hda_codec *codec)
4987{
4988 struct alc_spec *spec;
4989 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004990 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004991
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004992 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004993 if (spec == NULL)
4994 return -ENOMEM;
4995
4996 codec->spec = spec;
4997
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004998 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4999 alc880_models,
5000 alc880_cfg_tbl);
5001 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005002 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5003 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005004 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005005 }
5006
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005007 if (board_config == ALC880_AUTO) {
5008 /* automatic parse from the BIOS config */
5009 err = alc880_parse_auto_config(codec);
5010 if (err < 0) {
5011 alc_free(codec);
5012 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005013 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005014 printk(KERN_INFO
5015 "hda_codec: Cannot set up configuration "
5016 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005017 board_config = ALC880_3ST;
5018 }
5019 }
5020
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005021 err = snd_hda_attach_beep_device(codec, 0x1);
5022 if (err < 0) {
5023 alc_free(codec);
5024 return err;
5025 }
5026
Kailang Yangdf694da2005-12-05 19:42:22 +01005027 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005028 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005029
Linus Torvalds1da177e2005-04-16 15:20:36 -07005030 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5031 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005032 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005033
Linus Torvalds1da177e2005-04-16 15:20:36 -07005034 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5035 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5036
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005037 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005038 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005039 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005040 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005041 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005042 if (wcap != AC_WID_AUD_IN) {
5043 spec->adc_nids = alc880_adc_nids_alt;
5044 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005045 } else {
5046 spec->adc_nids = alc880_adc_nids;
5047 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005048 }
5049 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005050 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005051 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005052
Takashi Iwai2134ea42008-01-10 16:53:55 +01005053 spec->vmaster_nid = 0x0c;
5054
Linus Torvalds1da177e2005-04-16 15:20:36 -07005055 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005056 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005057 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005058#ifdef CONFIG_SND_HDA_POWER_SAVE
5059 if (!spec->loopback.amplist)
5060 spec->loopback.amplist = alc880_loopbacks;
5061#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005062
5063 return 0;
5064}
5065
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005066
Linus Torvalds1da177e2005-04-16 15:20:36 -07005067/*
5068 * ALC260 support
5069 */
5070
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005071static hda_nid_t alc260_dac_nids[1] = {
5072 /* front */
5073 0x02,
5074};
5075
5076static hda_nid_t alc260_adc_nids[1] = {
5077 /* ADC0 */
5078 0x04,
5079};
5080
Kailang Yangdf694da2005-12-05 19:42:22 +01005081static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005082 /* ADC1 */
5083 0x05,
5084};
5085
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005086/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5087 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5088 */
5089static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005090 /* ADC0, ADC1 */
5091 0x04, 0x05
5092};
5093
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005094#define ALC260_DIGOUT_NID 0x03
5095#define ALC260_DIGIN_NID 0x06
5096
5097static struct hda_input_mux alc260_capture_source = {
5098 .num_items = 4,
5099 .items = {
5100 { "Mic", 0x0 },
5101 { "Front Mic", 0x1 },
5102 { "Line", 0x2 },
5103 { "CD", 0x4 },
5104 },
5105};
5106
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005107/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005108 * headphone jack and the internal CD lines since these are the only pins at
5109 * which audio can appear. For flexibility, also allow the option of
5110 * recording the mixer output on the second ADC (ADC0 doesn't have a
5111 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005112 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005113static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5114 {
5115 .num_items = 3,
5116 .items = {
5117 { "Mic/Line", 0x0 },
5118 { "CD", 0x4 },
5119 { "Headphone", 0x2 },
5120 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005121 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005122 {
5123 .num_items = 4,
5124 .items = {
5125 { "Mic/Line", 0x0 },
5126 { "CD", 0x4 },
5127 { "Headphone", 0x2 },
5128 { "Mixer", 0x5 },
5129 },
5130 },
5131
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005132};
5133
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005134/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5135 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005136 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005137static struct hda_input_mux alc260_acer_capture_sources[2] = {
5138 {
5139 .num_items = 4,
5140 .items = {
5141 { "Mic", 0x0 },
5142 { "Line", 0x2 },
5143 { "CD", 0x4 },
5144 { "Headphone", 0x5 },
5145 },
5146 },
5147 {
5148 .num_items = 5,
5149 .items = {
5150 { "Mic", 0x0 },
5151 { "Line", 0x2 },
5152 { "CD", 0x4 },
5153 { "Headphone", 0x6 },
5154 { "Mixer", 0x5 },
5155 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005156 },
5157};
Michael Schwingencc959482009-02-22 18:58:45 +01005158
5159/* Maxdata Favorit 100XS */
5160static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5161 {
5162 .num_items = 2,
5163 .items = {
5164 { "Line/Mic", 0x0 },
5165 { "CD", 0x4 },
5166 },
5167 },
5168 {
5169 .num_items = 3,
5170 .items = {
5171 { "Line/Mic", 0x0 },
5172 { "CD", 0x4 },
5173 { "Mixer", 0x5 },
5174 },
5175 },
5176};
5177
Linus Torvalds1da177e2005-04-16 15:20:36 -07005178/*
5179 * This is just place-holder, so there's something for alc_build_pcms to look
5180 * at when it calculates the maximum number of channels. ALC260 has no mixer
5181 * element which allows changing the channel mode, so the verb list is
5182 * never used.
5183 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005184static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005185 { 2, NULL },
5186};
5187
Kailang Yangdf694da2005-12-05 19:42:22 +01005188
5189/* Mixer combinations
5190 *
5191 * basic: base_output + input + pc_beep + capture
5192 * HP: base_output + input + capture_alt
5193 * HP_3013: hp_3013 + input + capture
5194 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005195 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005196 */
5197
5198static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005199 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005200 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005201 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5202 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5203 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5204 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5205 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005206};
Kailang Yangdf694da2005-12-05 19:42:22 +01005207
5208static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005209 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5210 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5211 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5212 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5213 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5214 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5215 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5216 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005217 { } /* end */
5218};
5219
Takashi Iwaibec15c32008-01-28 18:16:30 +01005220/* update HP, line and mono out pins according to the master switch */
5221static void alc260_hp_master_update(struct hda_codec *codec,
5222 hda_nid_t hp, hda_nid_t line,
5223 hda_nid_t mono)
5224{
5225 struct alc_spec *spec = codec->spec;
5226 unsigned int val = spec->master_sw ? PIN_HP : 0;
5227 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005228 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005229 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005230 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005231 val);
5232 /* mono (speaker) depending on the HP jack sense */
5233 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005234 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005235 val);
5236}
5237
5238static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5239 struct snd_ctl_elem_value *ucontrol)
5240{
5241 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5242 struct alc_spec *spec = codec->spec;
5243 *ucontrol->value.integer.value = spec->master_sw;
5244 return 0;
5245}
5246
5247static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5248 struct snd_ctl_elem_value *ucontrol)
5249{
5250 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5251 struct alc_spec *spec = codec->spec;
5252 int val = !!*ucontrol->value.integer.value;
5253 hda_nid_t hp, line, mono;
5254
5255 if (val == spec->master_sw)
5256 return 0;
5257 spec->master_sw = val;
5258 hp = (kcontrol->private_value >> 16) & 0xff;
5259 line = (kcontrol->private_value >> 8) & 0xff;
5260 mono = kcontrol->private_value & 0xff;
5261 alc260_hp_master_update(codec, hp, line, mono);
5262 return 1;
5263}
5264
5265static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5266 {
5267 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5268 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005269 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005270 .info = snd_ctl_boolean_mono_info,
5271 .get = alc260_hp_master_sw_get,
5272 .put = alc260_hp_master_sw_put,
5273 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5274 },
5275 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5276 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5277 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5278 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5279 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5280 HDA_OUTPUT),
5281 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5282 { } /* end */
5283};
5284
5285static struct hda_verb alc260_hp_unsol_verbs[] = {
5286 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5287 {},
5288};
5289
5290static void alc260_hp_automute(struct hda_codec *codec)
5291{
5292 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005293
Wu Fengguang864f92b2009-11-18 12:38:02 +08005294 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005295 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5296}
5297
5298static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5299{
5300 if ((res >> 26) == ALC880_HP_EVENT)
5301 alc260_hp_automute(codec);
5302}
5303
Kailang Yangdf694da2005-12-05 19:42:22 +01005304static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005305 {
5306 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5307 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005308 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005309 .info = snd_ctl_boolean_mono_info,
5310 .get = alc260_hp_master_sw_get,
5311 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005312 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005313 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005314 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5315 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5316 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5317 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5318 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5319 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005320 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5321 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005322 { } /* end */
5323};
5324
Kailang Yang3f878302008-08-26 13:02:23 +02005325static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5326 .ops = &snd_hda_bind_vol,
5327 .values = {
5328 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5329 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5330 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5331 0
5332 },
5333};
5334
5335static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5336 .ops = &snd_hda_bind_sw,
5337 .values = {
5338 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5339 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5340 0
5341 },
5342};
5343
5344static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5345 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5346 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5347 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5348 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5349 { } /* end */
5350};
5351
Takashi Iwaibec15c32008-01-28 18:16:30 +01005352static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5353 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5354 {},
5355};
5356
5357static void alc260_hp_3013_automute(struct hda_codec *codec)
5358{
5359 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005360
Wu Fengguang864f92b2009-11-18 12:38:02 +08005361 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005362 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005363}
5364
5365static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5366 unsigned int res)
5367{
5368 if ((res >> 26) == ALC880_HP_EVENT)
5369 alc260_hp_3013_automute(codec);
5370}
5371
Kailang Yang3f878302008-08-26 13:02:23 +02005372static void alc260_hp_3012_automute(struct hda_codec *codec)
5373{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005374 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005375
Kailang Yang3f878302008-08-26 13:02:23 +02005376 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5377 bits);
5378 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5379 bits);
5380 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5381 bits);
5382}
5383
5384static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5385 unsigned int res)
5386{
5387 if ((res >> 26) == ALC880_HP_EVENT)
5388 alc260_hp_3012_automute(codec);
5389}
5390
5391/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005392 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5393 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005394static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005395 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005396 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005397 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005398 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5399 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5400 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5401 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005402 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005403 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5404 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005405 { } /* end */
5406};
5407
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005408/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5409 * versions of the ALC260 don't act on requests to enable mic bias from NID
5410 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5411 * datasheet doesn't mention this restriction. At this stage it's not clear
5412 * whether this behaviour is intentional or is a hardware bug in chip
5413 * revisions available in early 2006. Therefore for now allow the
5414 * "Headphone Jack Mode" control to span all choices, but if it turns out
5415 * that the lack of mic bias for this NID is intentional we could change the
5416 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5417 *
5418 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5419 * don't appear to make the mic bias available from the "line" jack, even
5420 * though the NID used for this jack (0x14) can supply it. The theory is
5421 * that perhaps Acer have included blocking capacitors between the ALC260
5422 * and the output jack. If this turns out to be the case for all such
5423 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5424 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005425 *
5426 * The C20x Tablet series have a mono internal speaker which is controlled
5427 * via the chip's Mono sum widget and pin complex, so include the necessary
5428 * controls for such models. On models without a "mono speaker" the control
5429 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005430 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005431static struct snd_kcontrol_new alc260_acer_mixer[] = {
5432 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5433 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005434 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005435 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005436 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005437 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005438 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005439 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5440 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5441 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5442 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5443 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5444 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5445 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5446 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005447 { } /* end */
5448};
5449
Michael Schwingencc959482009-02-22 18:58:45 +01005450/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5451 */
5452static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5453 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5454 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5455 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5456 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5457 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5458 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5459 { } /* end */
5460};
5461
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005462/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5463 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5464 */
5465static struct snd_kcontrol_new alc260_will_mixer[] = {
5466 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5467 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5468 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5469 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5470 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5471 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5472 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5473 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5474 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5475 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005476 { } /* end */
5477};
5478
5479/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5480 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5481 */
5482static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5483 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5484 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5485 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5486 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5487 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5488 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5489 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5490 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5491 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5492 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5493 { } /* end */
5494};
5495
Kailang Yangdf694da2005-12-05 19:42:22 +01005496/*
5497 * initialization verbs
5498 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005499static struct hda_verb alc260_init_verbs[] = {
5500 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005501 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005502 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005503 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005504 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005505 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005506 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005507 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005508 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005509 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005510 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005511 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005512 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005513 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005514 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005515 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005516 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005517 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5518 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005519 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005520 /* set connection select to line in (default select for this ADC) */
5521 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005522 /* mute capture amp left and right */
5523 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5524 /* set connection select to line in (default select for this ADC) */
5525 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005526 /* set vol=0 Line-Out mixer amp left and right */
5527 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5528 /* unmute pin widget amp left and right (no gain on this amp) */
5529 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5530 /* set vol=0 HP mixer amp left and right */
5531 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5532 /* unmute pin widget amp left and right (no gain on this amp) */
5533 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5534 /* set vol=0 Mono mixer amp left and right */
5535 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5536 /* unmute pin widget amp left and right (no gain on this amp) */
5537 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5538 /* unmute LINE-2 out pin */
5539 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005540 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5541 * Line In 2 = 0x03
5542 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005543 /* mute analog inputs */
5544 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5545 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5546 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5547 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5548 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005549 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005550 /* mute Front out path */
5551 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5552 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5553 /* mute Headphone out path */
5554 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5555 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5556 /* mute Mono out path */
5557 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5558 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005559 { }
5560};
5561
Takashi Iwai474167d2006-05-17 17:17:43 +02005562#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005563static struct hda_verb alc260_hp_init_verbs[] = {
5564 /* Headphone and output */
5565 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5566 /* mono output */
5567 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5568 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5569 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5570 /* Mic2 (front panel) pin widget for input and vref at 80% */
5571 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5572 /* Line In pin widget for input */
5573 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5574 /* Line-2 pin widget for output */
5575 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5576 /* CD pin widget for input */
5577 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5578 /* unmute amp left and right */
5579 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5580 /* set connection select to line in (default select for this ADC) */
5581 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5582 /* unmute Line-Out mixer amp left and right (volume = 0) */
5583 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5584 /* mute pin widget amp left and right (no gain on this amp) */
5585 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5586 /* unmute HP mixer amp left and right (volume = 0) */
5587 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5588 /* mute pin widget amp left and right (no gain on this amp) */
5589 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005590 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5591 * Line In 2 = 0x03
5592 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005593 /* mute analog inputs */
5594 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5595 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5596 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5597 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5598 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005599 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5600 /* Unmute Front out path */
5601 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5602 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5603 /* Unmute Headphone out path */
5604 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5605 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5606 /* Unmute Mono out path */
5607 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5608 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5609 { }
5610};
Takashi Iwai474167d2006-05-17 17:17:43 +02005611#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005612
5613static struct hda_verb alc260_hp_3013_init_verbs[] = {
5614 /* Line out and output */
5615 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5616 /* mono output */
5617 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5618 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5619 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5620 /* Mic2 (front panel) pin widget for input and vref at 80% */
5621 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5622 /* Line In pin widget for input */
5623 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5624 /* Headphone pin widget for output */
5625 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5626 /* CD pin widget for input */
5627 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5628 /* unmute amp left and right */
5629 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5630 /* set connection select to line in (default select for this ADC) */
5631 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5632 /* unmute Line-Out mixer amp left and right (volume = 0) */
5633 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5634 /* mute pin widget amp left and right (no gain on this amp) */
5635 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5636 /* unmute HP mixer amp left and right (volume = 0) */
5637 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5638 /* mute pin widget amp left and right (no gain on this amp) */
5639 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005640 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5641 * Line In 2 = 0x03
5642 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005643 /* mute analog inputs */
5644 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5645 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5646 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5647 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5648 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005649 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5650 /* Unmute Front out path */
5651 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5652 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5653 /* Unmute Headphone out path */
5654 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5655 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5656 /* Unmute Mono out path */
5657 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5658 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5659 { }
5660};
5661
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005662/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005663 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5664 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005665 */
5666static struct hda_verb alc260_fujitsu_init_verbs[] = {
5667 /* Disable all GPIOs */
5668 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5669 /* Internal speaker is connected to headphone pin */
5670 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5671 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5672 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005673 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5674 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5675 /* Ensure all other unused pins are disabled and muted. */
5676 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5677 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005678 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005679 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005680 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005681 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5682 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5683 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005684
Jonathan Woithef7ace402006-02-28 11:46:14 +01005685 /* Disable digital (SPDIF) pins */
5686 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5687 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005688
Kailang Yangea1fb292008-08-26 12:58:38 +02005689 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005690 * when acting as an output.
5691 */
5692 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5693
5694 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005695 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5696 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5697 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5698 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5699 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5700 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5701 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5702 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5703 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005704
Jonathan Woithef7ace402006-02-28 11:46:14 +01005705 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5706 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5707 /* Unmute Line1 pin widget output buffer since it starts as an output.
5708 * If the pin mode is changed by the user the pin mode control will
5709 * 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.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005712 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005713 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005714 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005715 * mixer ctrl)
5716 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005717 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005718
Jonathan Woithef7ace402006-02-28 11:46:14 +01005719 /* Mute capture amp left and right */
5720 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005721 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005722 * in (on mic1 pin)
5723 */
5724 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005725
Jonathan Woithef7ace402006-02-28 11:46:14 +01005726 /* Do the same for the second ADC: mute capture input amp and
5727 * set ADC connection to line in (on mic1 pin)
5728 */
5729 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5730 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005731
Jonathan Woithef7ace402006-02-28 11:46:14 +01005732 /* Mute all inputs to mixer widget (even unconnected ones) */
5733 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5734 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5735 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5736 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5737 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5738 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5739 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5740 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005741
5742 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005743};
5744
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005745/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5746 * similar laptops (adapted from Fujitsu init verbs).
5747 */
5748static struct hda_verb alc260_acer_init_verbs[] = {
5749 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5750 * the headphone jack. Turn this on and rely on the standard mute
5751 * methods whenever the user wants to turn these outputs off.
5752 */
5753 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5754 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5755 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5756 /* Internal speaker/Headphone jack is connected to Line-out pin */
5757 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5758 /* Internal microphone/Mic jack is connected to Mic1 pin */
5759 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5760 /* Line In jack is connected to Line1 pin */
5761 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005762 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5763 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005764 /* Ensure all other unused pins are disabled and muted. */
5765 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5766 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005767 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5768 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5769 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5770 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5771 /* Disable digital (SPDIF) pins */
5772 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5773 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5774
Kailang Yangea1fb292008-08-26 12:58:38 +02005775 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005776 * bus when acting as outputs.
5777 */
5778 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5779 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5780
5781 /* Start with output sum widgets muted and their output gains at min */
5782 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5783 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5784 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5785 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5786 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5787 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5788 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5789 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5790 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5791
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005792 /* Unmute Line-out pin widget amp left and right
5793 * (no equiv mixer ctrl)
5794 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005795 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005796 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5797 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005798 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5799 * inputs. If the pin mode is changed by the user the pin mode control
5800 * will take care of enabling the pin's input/output buffers as needed.
5801 * Therefore there's no need to enable the input buffer at this
5802 * stage.
5803 */
5804 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5805 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5806
5807 /* Mute capture amp left and right */
5808 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5809 /* Set ADC connection select to match default mixer setting - mic
5810 * (on mic1 pin)
5811 */
5812 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5813
5814 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005815 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005816 */
5817 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005818 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005819
5820 /* Mute all inputs to mixer widget (even unconnected ones) */
5821 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5822 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5823 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5824 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5825 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5826 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5827 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5828 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5829
5830 { }
5831};
5832
Michael Schwingencc959482009-02-22 18:58:45 +01005833/* Initialisation sequence for Maxdata Favorit 100XS
5834 * (adapted from Acer init verbs).
5835 */
5836static struct hda_verb alc260_favorit100_init_verbs[] = {
5837 /* GPIO 0 enables the output jack.
5838 * Turn this on and rely on the standard mute
5839 * methods whenever the user wants to turn these outputs off.
5840 */
5841 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5842 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5843 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5844 /* Line/Mic input jack is connected to Mic1 pin */
5845 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5846 /* Ensure all other unused pins are disabled and muted. */
5847 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5848 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5849 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5850 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5851 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5852 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5853 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5854 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5855 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5856 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5857 /* Disable digital (SPDIF) pins */
5858 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5859 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5860
5861 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5862 * bus when acting as outputs.
5863 */
5864 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5865 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5866
5867 /* Start with output sum widgets muted and their output gains at min */
5868 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5869 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5870 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5871 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5872 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5873 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5874 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5875 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5876 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5877
5878 /* Unmute Line-out pin widget amp left and right
5879 * (no equiv mixer ctrl)
5880 */
5881 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5882 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5883 * inputs. If the pin mode is changed by the user the pin mode control
5884 * will take care of enabling the pin's input/output buffers as needed.
5885 * Therefore there's no need to enable the input buffer at this
5886 * stage.
5887 */
5888 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5889
5890 /* Mute capture amp left and right */
5891 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5892 /* Set ADC connection select to match default mixer setting - mic
5893 * (on mic1 pin)
5894 */
5895 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5896
5897 /* Do similar with the second ADC: mute capture input amp and
5898 * set ADC connection to mic to match ALSA's default state.
5899 */
5900 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5901 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5902
5903 /* Mute all inputs to mixer widget (even unconnected ones) */
5904 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5905 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5906 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5907 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5908 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5909 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5910 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5911 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5912
5913 { }
5914};
5915
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005916static struct hda_verb alc260_will_verbs[] = {
5917 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5918 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5919 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5920 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5921 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5922 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5923 {}
5924};
5925
5926static struct hda_verb alc260_replacer_672v_verbs[] = {
5927 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5928 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5929 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5930
5931 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5932 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5933 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5934
5935 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5936 {}
5937};
5938
5939/* toggle speaker-output according to the hp-jack state */
5940static void alc260_replacer_672v_automute(struct hda_codec *codec)
5941{
5942 unsigned int present;
5943
5944 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08005945 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005946 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005947 snd_hda_codec_write_cache(codec, 0x01, 0,
5948 AC_VERB_SET_GPIO_DATA, 1);
5949 snd_hda_codec_write_cache(codec, 0x0f, 0,
5950 AC_VERB_SET_PIN_WIDGET_CONTROL,
5951 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005952 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005953 snd_hda_codec_write_cache(codec, 0x01, 0,
5954 AC_VERB_SET_GPIO_DATA, 0);
5955 snd_hda_codec_write_cache(codec, 0x0f, 0,
5956 AC_VERB_SET_PIN_WIDGET_CONTROL,
5957 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005958 }
5959}
5960
5961static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5962 unsigned int res)
5963{
5964 if ((res >> 26) == ALC880_HP_EVENT)
5965 alc260_replacer_672v_automute(codec);
5966}
5967
Kailang Yang3f878302008-08-26 13:02:23 +02005968static struct hda_verb alc260_hp_dc7600_verbs[] = {
5969 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5970 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5971 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5972 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5973 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5974 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5975 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5976 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5977 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5978 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5979 {}
5980};
5981
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005982/* Test configuration for debugging, modelled after the ALC880 test
5983 * configuration.
5984 */
5985#ifdef CONFIG_SND_DEBUG
5986static hda_nid_t alc260_test_dac_nids[1] = {
5987 0x02,
5988};
5989static hda_nid_t alc260_test_adc_nids[2] = {
5990 0x04, 0x05,
5991};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005992/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005993 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005994 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005995 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005996static struct hda_input_mux alc260_test_capture_sources[2] = {
5997 {
5998 .num_items = 7,
5999 .items = {
6000 { "MIC1 pin", 0x0 },
6001 { "MIC2 pin", 0x1 },
6002 { "LINE1 pin", 0x2 },
6003 { "LINE2 pin", 0x3 },
6004 { "CD pin", 0x4 },
6005 { "LINE-OUT pin", 0x5 },
6006 { "HP-OUT pin", 0x6 },
6007 },
6008 },
6009 {
6010 .num_items = 8,
6011 .items = {
6012 { "MIC1 pin", 0x0 },
6013 { "MIC2 pin", 0x1 },
6014 { "LINE1 pin", 0x2 },
6015 { "LINE2 pin", 0x3 },
6016 { "CD pin", 0x4 },
6017 { "Mixer", 0x5 },
6018 { "LINE-OUT pin", 0x6 },
6019 { "HP-OUT pin", 0x7 },
6020 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006021 },
6022};
6023static struct snd_kcontrol_new alc260_test_mixer[] = {
6024 /* Output driver widgets */
6025 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6026 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6027 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6028 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6029 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6030 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6031
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006032 /* Modes for retasking pin widgets
6033 * Note: the ALC260 doesn't seem to act on requests to enable mic
6034 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6035 * mention this restriction. At this stage it's not clear whether
6036 * this behaviour is intentional or is a hardware bug in chip
6037 * revisions available at least up until early 2006. Therefore for
6038 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6039 * choices, but if it turns out that the lack of mic bias for these
6040 * NIDs is intentional we could change their modes from
6041 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6042 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006043 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6044 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6045 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6046 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6047 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6048 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6049
6050 /* Loopback mixer controls */
6051 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6052 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6053 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6054 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6055 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6056 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6057 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6058 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6059 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6060 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006061 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6062 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6063 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6064 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006065
6066 /* Controls for GPIO pins, assuming they are configured as outputs */
6067 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6068 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6069 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6070 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6071
Jonathan Woithe92621f12006-02-28 11:47:47 +01006072 /* Switches to allow the digital IO pins to be enabled. The datasheet
6073 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006074 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006075 */
6076 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6077 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6078
Jonathan Woithef8225f62008-01-08 12:16:54 +01006079 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6080 * this output to turn on an external amplifier.
6081 */
6082 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6083 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6084
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006085 { } /* end */
6086};
6087static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006088 /* Enable all GPIOs as outputs with an initial value of 0 */
6089 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6090 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6091 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6092
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006093 /* Enable retasking pins as output, initially without power amp */
6094 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6095 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6096 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6097 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6098 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6099 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6100
Jonathan Woithe92621f12006-02-28 11:47:47 +01006101 /* Disable digital (SPDIF) pins initially, but users can enable
6102 * them via a mixer switch. In the case of SPDIF-out, this initverb
6103 * payload also sets the generation to 0, output to be in "consumer"
6104 * PCM format, copyright asserted, no pre-emphasis and no validity
6105 * control.
6106 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006107 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6108 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6109
Kailang Yangea1fb292008-08-26 12:58:38 +02006110 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006111 * OUT1 sum bus when acting as an output.
6112 */
6113 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6114 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6115 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6116 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6117
6118 /* Start with output sum widgets muted and their output gains at min */
6119 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6120 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6121 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6122 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6123 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6124 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6125 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6126 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6127 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6128
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006129 /* Unmute retasking pin widget output buffers since the default
6130 * state appears to be output. As the pin mode is changed by the
6131 * user the pin mode control will take care of enabling the pin's
6132 * input/output buffers as needed.
6133 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006134 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6135 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6136 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6137 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6138 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6139 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6140 /* Also unmute the mono-out pin widget */
6141 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6142
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006143 /* Mute capture amp left and right */
6144 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006145 /* Set ADC connection select to match default mixer setting (mic1
6146 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006147 */
6148 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6149
6150 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006151 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006152 */
6153 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6154 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6155
6156 /* Mute all inputs to mixer widget (even unconnected ones) */
6157 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6158 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6159 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6160 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6161 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6162 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6163 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6164 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6165
6166 { }
6167};
6168#endif
6169
Takashi Iwai63300792008-01-24 15:31:36 +01006170#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6171#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006172
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006173#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6174#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6175
Kailang Yangdf694da2005-12-05 19:42:22 +01006176/*
6177 * for BIOS auto-configuration
6178 */
6179
6180static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006181 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006182{
6183 hda_nid_t nid_vol;
6184 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006185 int err;
6186
6187 if (nid >= 0x0f && nid < 0x11) {
6188 nid_vol = nid - 0x7;
6189 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6190 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6191 } else if (nid == 0x11) {
6192 nid_vol = nid - 0x7;
6193 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6194 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6195 } else if (nid >= 0x12 && nid <= 0x15) {
6196 nid_vol = 0x08;
6197 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6198 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6199 } else
6200 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006201
Takashi Iwai863b4512008-10-21 17:01:47 +02006202 if (!(*vol_bits & (1 << nid_vol))) {
6203 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006204 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006205 if (err < 0)
6206 return err;
6207 *vol_bits |= (1 << nid_vol);
6208 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006209 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006210 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006211 return err;
6212 return 1;
6213}
6214
6215/* add playback controls from the parsed DAC table */
6216static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6217 const struct auto_pin_cfg *cfg)
6218{
6219 hda_nid_t nid;
6220 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006221 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006222
6223 spec->multiout.num_dacs = 1;
6224 spec->multiout.dac_nids = spec->private_dac_nids;
6225 spec->multiout.dac_nids[0] = 0x02;
6226
6227 nid = cfg->line_out_pins[0];
6228 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006229 const char *pfx;
6230 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6231 pfx = "Master";
6232 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6233 pfx = "Speaker";
6234 else
6235 pfx = "Front";
6236 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006237 if (err < 0)
6238 return err;
6239 }
6240
Takashi Iwai82bc9552006-03-21 11:24:42 +01006241 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006242 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006243 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006244 if (err < 0)
6245 return err;
6246 }
6247
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006248 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006249 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006250 err = alc260_add_playback_controls(spec, nid, "Headphone",
6251 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006252 if (err < 0)
6253 return err;
6254 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006255 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006256}
6257
6258/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006259static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006260 const struct auto_pin_cfg *cfg)
6261{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006262 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006263}
6264
6265static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6266 hda_nid_t nid, int pin_type,
6267 int sel_idx)
6268{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006269 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006270 /* need the manual connection? */
6271 if (nid >= 0x12) {
6272 int idx = nid - 0x12;
6273 snd_hda_codec_write(codec, idx + 0x0b, 0,
6274 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006275 }
6276}
6277
6278static void alc260_auto_init_multi_out(struct hda_codec *codec)
6279{
6280 struct alc_spec *spec = codec->spec;
6281 hda_nid_t nid;
6282
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006283 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006284 if (nid) {
6285 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6286 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6287 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006288
Takashi Iwai82bc9552006-03-21 11:24:42 +01006289 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006290 if (nid)
6291 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6292
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006293 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006294 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006295 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006296}
Kailang Yangdf694da2005-12-05 19:42:22 +01006297
6298#define ALC260_PIN_CD_NID 0x16
6299static void alc260_auto_init_analog_input(struct hda_codec *codec)
6300{
6301 struct alc_spec *spec = codec->spec;
6302 int i;
6303
6304 for (i = 0; i < AUTO_PIN_LAST; i++) {
6305 hda_nid_t nid = spec->autocfg.input_pins[i];
6306 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006307 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006308 if (nid != ALC260_PIN_CD_NID &&
6309 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006310 snd_hda_codec_write(codec, nid, 0,
6311 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006312 AMP_OUT_MUTE);
6313 }
6314 }
6315}
6316
6317/*
6318 * generic initialization of ADC, input mixers and output mixers
6319 */
6320static struct hda_verb alc260_volume_init_verbs[] = {
6321 /*
6322 * Unmute ADC0-1 and set the default input to mic-in
6323 */
6324 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6325 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6326 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6327 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006328
Kailang Yangdf694da2005-12-05 19:42:22 +01006329 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6330 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006331 * Note: PASD motherboards uses the Line In 2 as the input for
6332 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006333 */
6334 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006335 /* mute analog inputs */
6336 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6337 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6338 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6339 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6340 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006341
6342 /*
6343 * Set up output mixers (0x08 - 0x0a)
6344 */
6345 /* set vol=0 to output mixers */
6346 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6347 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6348 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6349 /* set up input amps for analog loopback */
6350 /* Amp Indices: DAC = 0, mixer = 1 */
6351 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6352 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6353 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6354 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6355 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6356 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006357
Kailang Yangdf694da2005-12-05 19:42:22 +01006358 { }
6359};
6360
6361static int alc260_parse_auto_config(struct hda_codec *codec)
6362{
6363 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006364 int err;
6365 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6366
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006367 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6368 alc260_ignore);
6369 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006370 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006371 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6372 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006373 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006374 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006375 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006376 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006377 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006378 return err;
6379
6380 spec->multiout.max_channels = 2;
6381
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006382 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006383 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006384 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006385 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006386
Takashi Iwaid88897e2008-10-31 15:01:37 +01006387 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006388
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006389 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006390 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006391
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006392 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6393
Kailang Yangdf694da2005-12-05 19:42:22 +01006394 return 1;
6395}
6396
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006397/* additional initialization for auto-configuration model */
6398static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006399{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006400 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006401 alc260_auto_init_multi_out(codec);
6402 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006403 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006404 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006405}
6406
Takashi Iwaicb53c622007-08-10 17:21:45 +02006407#ifdef CONFIG_SND_HDA_POWER_SAVE
6408static struct hda_amp_list alc260_loopbacks[] = {
6409 { 0x07, HDA_INPUT, 0 },
6410 { 0x07, HDA_INPUT, 1 },
6411 { 0x07, HDA_INPUT, 2 },
6412 { 0x07, HDA_INPUT, 3 },
6413 { 0x07, HDA_INPUT, 4 },
6414 { } /* end */
6415};
6416#endif
6417
Kailang Yangdf694da2005-12-05 19:42:22 +01006418/*
6419 * ALC260 configurations
6420 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006421static const char *alc260_models[ALC260_MODEL_LAST] = {
6422 [ALC260_BASIC] = "basic",
6423 [ALC260_HP] = "hp",
6424 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006425 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006426 [ALC260_FUJITSU_S702X] = "fujitsu",
6427 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006428 [ALC260_WILL] = "will",
6429 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006430 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006431#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006432 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006433#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006434 [ALC260_AUTO] = "auto",
6435};
6436
6437static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006438 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006439 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006440 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006441 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006442 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006443 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006444 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006445 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006446 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006447 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6448 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6449 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6450 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6451 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6452 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6453 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6454 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6455 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006456 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006457 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006458 {}
6459};
6460
Kailang Yangdf694da2005-12-05 19:42:22 +01006461static struct alc_config_preset alc260_presets[] = {
6462 [ALC260_BASIC] = {
6463 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006464 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006465 .init_verbs = { alc260_init_verbs },
6466 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6467 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006468 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006469 .adc_nids = alc260_adc_nids,
6470 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6471 .channel_mode = alc260_modes,
6472 .input_mux = &alc260_capture_source,
6473 },
6474 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006475 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006476 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006477 .init_verbs = { alc260_init_verbs,
6478 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006479 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6480 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006481 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6482 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006483 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6484 .channel_mode = alc260_modes,
6485 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006486 .unsol_event = alc260_hp_unsol_event,
6487 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006488 },
Kailang Yang3f878302008-08-26 13:02:23 +02006489 [ALC260_HP_DC7600] = {
6490 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006491 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006492 .init_verbs = { alc260_init_verbs,
6493 alc260_hp_dc7600_verbs },
6494 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6495 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006496 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6497 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006498 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6499 .channel_mode = alc260_modes,
6500 .input_mux = &alc260_capture_source,
6501 .unsol_event = alc260_hp_3012_unsol_event,
6502 .init_hook = alc260_hp_3012_automute,
6503 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006504 [ALC260_HP_3013] = {
6505 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006506 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006507 .init_verbs = { alc260_hp_3013_init_verbs,
6508 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006509 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6510 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006511 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6512 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006513 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6514 .channel_mode = alc260_modes,
6515 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006516 .unsol_event = alc260_hp_3013_unsol_event,
6517 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006518 },
6519 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006520 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006521 .init_verbs = { alc260_fujitsu_init_verbs },
6522 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6523 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006524 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6525 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006526 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6527 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006528 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6529 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006530 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006531 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006532 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006533 .init_verbs = { alc260_acer_init_verbs },
6534 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6535 .dac_nids = alc260_dac_nids,
6536 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6537 .adc_nids = alc260_dual_adc_nids,
6538 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6539 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006540 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6541 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006542 },
Michael Schwingencc959482009-02-22 18:58:45 +01006543 [ALC260_FAVORIT100] = {
6544 .mixers = { alc260_favorit100_mixer },
6545 .init_verbs = { alc260_favorit100_init_verbs },
6546 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6547 .dac_nids = alc260_dac_nids,
6548 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6549 .adc_nids = alc260_dual_adc_nids,
6550 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6551 .channel_mode = alc260_modes,
6552 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6553 .input_mux = alc260_favorit100_capture_sources,
6554 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006555 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006556 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006557 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6558 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6559 .dac_nids = alc260_dac_nids,
6560 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6561 .adc_nids = alc260_adc_nids,
6562 .dig_out_nid = ALC260_DIGOUT_NID,
6563 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6564 .channel_mode = alc260_modes,
6565 .input_mux = &alc260_capture_source,
6566 },
6567 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006568 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006569 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6570 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6571 .dac_nids = alc260_dac_nids,
6572 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6573 .adc_nids = alc260_adc_nids,
6574 .dig_out_nid = ALC260_DIGOUT_NID,
6575 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6576 .channel_mode = alc260_modes,
6577 .input_mux = &alc260_capture_source,
6578 .unsol_event = alc260_replacer_672v_unsol_event,
6579 .init_hook = alc260_replacer_672v_automute,
6580 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006581#ifdef CONFIG_SND_DEBUG
6582 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006583 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006584 .init_verbs = { alc260_test_init_verbs },
6585 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6586 .dac_nids = alc260_test_dac_nids,
6587 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6588 .adc_nids = alc260_test_adc_nids,
6589 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6590 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006591 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6592 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006593 },
6594#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006595};
6596
Linus Torvalds1da177e2005-04-16 15:20:36 -07006597static int patch_alc260(struct hda_codec *codec)
6598{
6599 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006600 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006601
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006602 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006603 if (spec == NULL)
6604 return -ENOMEM;
6605
6606 codec->spec = spec;
6607
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006608 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6609 alc260_models,
6610 alc260_cfg_tbl);
6611 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006612 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006613 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006614 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006615 }
6616
Kailang Yangdf694da2005-12-05 19:42:22 +01006617 if (board_config == ALC260_AUTO) {
6618 /* automatic parse from the BIOS config */
6619 err = alc260_parse_auto_config(codec);
6620 if (err < 0) {
6621 alc_free(codec);
6622 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006623 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006624 printk(KERN_INFO
6625 "hda_codec: Cannot set up configuration "
6626 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006627 board_config = ALC260_BASIC;
6628 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006629 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006630
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006631 err = snd_hda_attach_beep_device(codec, 0x1);
6632 if (err < 0) {
6633 alc_free(codec);
6634 return err;
6635 }
6636
Kailang Yangdf694da2005-12-05 19:42:22 +01006637 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006638 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006639
Linus Torvalds1da177e2005-04-16 15:20:36 -07006640 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6641 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6642
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006643 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6644 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6645
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006646 if (!spec->adc_nids && spec->input_mux) {
6647 /* check whether NID 0x04 is valid */
6648 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006649 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006650 /* get type */
6651 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6652 spec->adc_nids = alc260_adc_nids_alt;
6653 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6654 } else {
6655 spec->adc_nids = alc260_adc_nids;
6656 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6657 }
6658 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006659 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006660 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006661
Takashi Iwai2134ea42008-01-10 16:53:55 +01006662 spec->vmaster_nid = 0x08;
6663
Linus Torvalds1da177e2005-04-16 15:20:36 -07006664 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006665 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006666 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006667#ifdef CONFIG_SND_HDA_POWER_SAVE
6668 if (!spec->loopback.amplist)
6669 spec->loopback.amplist = alc260_loopbacks;
6670#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006671
6672 return 0;
6673}
6674
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006675
Linus Torvalds1da177e2005-04-16 15:20:36 -07006676/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006677 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006678 *
6679 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6680 * configuration. Each pin widget can choose any input DACs and a mixer.
6681 * Each ADC is connected from a mixer of all inputs. This makes possible
6682 * 6-channel independent captures.
6683 *
6684 * In addition, an independent DAC for the multi-playback (not used in this
6685 * driver yet).
6686 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006687#define ALC882_DIGOUT_NID 0x06
6688#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006689#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6690#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6691#define ALC1200_DIGOUT_NID 0x10
6692
Linus Torvalds1da177e2005-04-16 15:20:36 -07006693
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006694static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006695 { 8, NULL }
6696};
6697
Takashi Iwai4953550a2009-06-30 15:28:30 +02006698/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006699static hda_nid_t alc882_dac_nids[4] = {
6700 /* front, rear, clfe, rear_surr */
6701 0x02, 0x03, 0x04, 0x05
6702};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006703#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006704
Takashi Iwai4953550a2009-06-30 15:28:30 +02006705/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006706#define alc882_adc_nids alc880_adc_nids
6707#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006708#define alc883_adc_nids alc882_adc_nids_alt
6709static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6710static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6711#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006712
Takashi Iwaie1406342008-02-11 18:32:32 +01006713static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6714static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006715#define alc883_capsrc_nids alc882_capsrc_nids_alt
6716static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6717#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006718
Linus Torvalds1da177e2005-04-16 15:20:36 -07006719/* input MUX */
6720/* FIXME: should be a matrix-type input source selection */
6721
6722static struct hda_input_mux alc882_capture_source = {
6723 .num_items = 4,
6724 .items = {
6725 { "Mic", 0x0 },
6726 { "Front Mic", 0x1 },
6727 { "Line", 0x2 },
6728 { "CD", 0x4 },
6729 },
6730};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006731
Takashi Iwai4953550a2009-06-30 15:28:30 +02006732#define alc883_capture_source alc882_capture_source
6733
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006734static struct hda_input_mux alc889_capture_source = {
6735 .num_items = 3,
6736 .items = {
6737 { "Front Mic", 0x0 },
6738 { "Mic", 0x3 },
6739 { "Line", 0x2 },
6740 },
6741};
6742
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006743static struct hda_input_mux mb5_capture_source = {
6744 .num_items = 3,
6745 .items = {
6746 { "Mic", 0x1 },
6747 { "Line", 0x2 },
6748 { "CD", 0x4 },
6749 },
6750};
6751
Takashi Iwai4953550a2009-06-30 15:28:30 +02006752static struct hda_input_mux alc883_3stack_6ch_intel = {
6753 .num_items = 4,
6754 .items = {
6755 { "Mic", 0x1 },
6756 { "Front Mic", 0x0 },
6757 { "Line", 0x2 },
6758 { "CD", 0x4 },
6759 },
6760};
6761
6762static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6763 .num_items = 2,
6764 .items = {
6765 { "Mic", 0x1 },
6766 { "Line", 0x2 },
6767 },
6768};
6769
6770static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6771 .num_items = 4,
6772 .items = {
6773 { "Mic", 0x0 },
6774 { "iMic", 0x1 },
6775 { "Line", 0x2 },
6776 { "CD", 0x4 },
6777 },
6778};
6779
6780static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6781 .num_items = 2,
6782 .items = {
6783 { "Mic", 0x0 },
6784 { "Int Mic", 0x1 },
6785 },
6786};
6787
6788static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6789 .num_items = 3,
6790 .items = {
6791 { "Mic", 0x0 },
6792 { "Front Mic", 0x1 },
6793 { "Line", 0x4 },
6794 },
6795};
6796
6797static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6798 .num_items = 2,
6799 .items = {
6800 { "Mic", 0x0 },
6801 { "Line", 0x2 },
6802 },
6803};
6804
6805static struct hda_input_mux alc889A_mb31_capture_source = {
6806 .num_items = 2,
6807 .items = {
6808 { "Mic", 0x0 },
6809 /* Front Mic (0x01) unused */
6810 { "Line", 0x2 },
6811 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02006812 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006813 },
6814};
6815
6816/*
6817 * 2ch mode
6818 */
6819static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6820 { 2, NULL }
6821};
6822
Kailang Yangdf694da2005-12-05 19:42:22 +01006823/*
Kailang Yang272a5272007-05-14 11:00:38 +02006824 * 2ch mode
6825 */
6826static struct hda_verb alc882_3ST_ch2_init[] = {
6827 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6828 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6829 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6830 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6831 { } /* end */
6832};
6833
6834/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006835 * 4ch mode
6836 */
6837static struct hda_verb alc882_3ST_ch4_init[] = {
6838 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6839 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6840 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6841 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6842 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6843 { } /* end */
6844};
6845
6846/*
Kailang Yang272a5272007-05-14 11:00:38 +02006847 * 6ch mode
6848 */
6849static struct hda_verb alc882_3ST_ch6_init[] = {
6850 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6851 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6852 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6853 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6854 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6855 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6856 { } /* end */
6857};
6858
Takashi Iwai4953550a2009-06-30 15:28:30 +02006859static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006860 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006861 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006862 { 6, alc882_3ST_ch6_init },
6863};
6864
Takashi Iwai4953550a2009-06-30 15:28:30 +02006865#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6866
Kailang Yang272a5272007-05-14 11:00:38 +02006867/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04306868 * 2ch mode
6869 */
6870static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6871 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6872 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6873 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6874 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6875 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6876 { } /* end */
6877};
6878
6879/*
6880 * 4ch mode
6881 */
6882static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
6883 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6884 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6885 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6886 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6887 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6888 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6889 { } /* end */
6890};
6891
6892/*
6893 * 6ch mode
6894 */
6895static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
6896 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6897 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6898 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6899 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6900 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6901 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6902 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6903 { } /* end */
6904};
6905
6906static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
6907 { 2, alc883_3ST_ch2_clevo_init },
6908 { 4, alc883_3ST_ch4_clevo_init },
6909 { 6, alc883_3ST_ch6_clevo_init },
6910};
6911
6912
6913/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006914 * 6ch mode
6915 */
6916static struct hda_verb alc882_sixstack_ch6_init[] = {
6917 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6918 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6919 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6920 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6921 { } /* end */
6922};
6923
6924/*
6925 * 8ch mode
6926 */
6927static struct hda_verb alc882_sixstack_ch8_init[] = {
6928 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6929 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6930 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6931 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6932 { } /* end */
6933};
6934
6935static struct hda_channel_mode alc882_sixstack_modes[2] = {
6936 { 6, alc882_sixstack_ch6_init },
6937 { 8, alc882_sixstack_ch8_init },
6938};
6939
Takashi Iwai87350ad2007-08-16 18:19:38 +02006940/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006941 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006942 */
6943
6944/*
6945 * 2ch mode
6946 */
6947static struct hda_verb alc885_mbp_ch2_init[] = {
6948 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6949 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6950 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6951 { } /* end */
6952};
6953
6954/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006955 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02006956 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006957static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006958 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6959 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6960 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6961 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6962 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6963 { } /* end */
6964};
6965
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006966static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006967 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006968 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006969};
6970
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006971/*
6972 * 2ch
6973 * Speakers/Woofer/HP = Front
6974 * LineIn = Input
6975 */
6976static struct hda_verb alc885_mb5_ch2_init[] = {
6977 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6978 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6979 { } /* end */
6980};
6981
6982/*
6983 * 6ch mode
6984 * Speakers/HP = Front
6985 * Woofer = LFE
6986 * LineIn = Surround
6987 */
6988static struct hda_verb alc885_mb5_ch6_init[] = {
6989 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6990 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6991 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6992 { } /* end */
6993};
6994
6995static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6996 { 2, alc885_mb5_ch2_init },
6997 { 6, alc885_mb5_ch6_init },
6998};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006999
Takashi Iwai4953550a2009-06-30 15:28:30 +02007000
7001/*
7002 * 2ch mode
7003 */
7004static struct hda_verb alc883_4ST_ch2_init[] = {
7005 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7006 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7007 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7008 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7009 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7010 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7011 { } /* end */
7012};
7013
7014/*
7015 * 4ch mode
7016 */
7017static struct hda_verb alc883_4ST_ch4_init[] = {
7018 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7019 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7020 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7021 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7022 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7023 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7024 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7025 { } /* end */
7026};
7027
7028/*
7029 * 6ch mode
7030 */
7031static struct hda_verb alc883_4ST_ch6_init[] = {
7032 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7033 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7034 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7035 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7036 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7037 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7038 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7039 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7040 { } /* end */
7041};
7042
7043/*
7044 * 8ch mode
7045 */
7046static struct hda_verb alc883_4ST_ch8_init[] = {
7047 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7048 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7049 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7050 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7051 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7052 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7053 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7054 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7055 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7056 { } /* end */
7057};
7058
7059static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7060 { 2, alc883_4ST_ch2_init },
7061 { 4, alc883_4ST_ch4_init },
7062 { 6, alc883_4ST_ch6_init },
7063 { 8, alc883_4ST_ch8_init },
7064};
7065
7066
7067/*
7068 * 2ch mode
7069 */
7070static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7071 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7072 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7073 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7074 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7075 { } /* end */
7076};
7077
7078/*
7079 * 4ch mode
7080 */
7081static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7082 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7083 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7084 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7085 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7086 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7087 { } /* end */
7088};
7089
7090/*
7091 * 6ch mode
7092 */
7093static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7094 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7095 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7096 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7097 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7098 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7099 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7100 { } /* end */
7101};
7102
7103static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7104 { 2, alc883_3ST_ch2_intel_init },
7105 { 4, alc883_3ST_ch4_intel_init },
7106 { 6, alc883_3ST_ch6_intel_init },
7107};
7108
7109/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007110 * 2ch mode
7111 */
7112static struct hda_verb alc889_ch2_intel_init[] = {
7113 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7114 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7115 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7116 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7117 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7118 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7119 { } /* end */
7120};
7121
7122/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007123 * 6ch mode
7124 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007125static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007126 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7127 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7128 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7129 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7130 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007131 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7132 { } /* end */
7133};
7134
7135/*
7136 * 8ch mode
7137 */
7138static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007139 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7140 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7141 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7142 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7143 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007144 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7145 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007146 { } /* end */
7147};
7148
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007149static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7150 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007151 { 6, alc889_ch6_intel_init },
7152 { 8, alc889_ch8_intel_init },
7153};
7154
7155/*
7156 * 6ch mode
7157 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007158static struct hda_verb alc883_sixstack_ch6_init[] = {
7159 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7160 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7161 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7162 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7163 { } /* end */
7164};
7165
7166/*
7167 * 8ch mode
7168 */
7169static struct hda_verb alc883_sixstack_ch8_init[] = {
7170 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7171 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7172 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7173 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7174 { } /* end */
7175};
7176
7177static struct hda_channel_mode alc883_sixstack_modes[2] = {
7178 { 6, alc883_sixstack_ch6_init },
7179 { 8, alc883_sixstack_ch8_init },
7180};
7181
7182
Linus Torvalds1da177e2005-04-16 15:20:36 -07007183/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7184 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7185 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007186static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007187 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007188 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007189 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007190 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007191 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7192 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007193 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7194 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007195 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007196 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007197 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7198 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7199 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7200 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7201 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7202 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007203 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007204 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7205 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007206 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007207 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007208 { } /* end */
7209};
7210
Takashi Iwai87350ad2007-08-16 18:19:38 +02007211static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007212 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7213 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7214 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7215 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7216 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007217 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7218 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007219 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7220 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007221 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007222 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7223 { } /* end */
7224};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007225
7226static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007227 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7228 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7229 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7230 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7231 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7232 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307233 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7234 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007235 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7236 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7237 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7238 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7239 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7240 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7241 { } /* end */
7242};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007243
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007244static struct snd_kcontrol_new alc885_imac91_mixer[] = {
7245 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7246 HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
7247 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
7248 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7249 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7250 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7251 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7252 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7253 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7254 { } /* end */
7255};
7256
7257
Kailang Yangbdd148a2007-05-08 15:19:08 +02007258static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7259 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7260 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7261 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7262 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7263 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7264 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7265 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7266 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7267 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007268 { } /* end */
7269};
7270
Kailang Yang272a5272007-05-14 11:00:38 +02007271static struct snd_kcontrol_new alc882_targa_mixer[] = {
7272 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7273 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7274 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7275 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7276 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7277 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7278 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7279 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7280 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007281 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007282 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7283 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007284 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007285 { } /* end */
7286};
7287
7288/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7289 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7290 */
7291static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7292 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7293 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7294 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7295 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7296 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7297 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7298 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7299 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7300 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7301 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7302 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7303 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007304 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007305 { } /* end */
7306};
7307
Takashi Iwai914759b2007-09-06 14:52:04 +02007308static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7309 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7310 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7311 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7312 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7313 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7314 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7315 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7316 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7317 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7318 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007319 { } /* end */
7320};
7321
Kailang Yangdf694da2005-12-05 19:42:22 +01007322static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7323 {
7324 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7325 .name = "Channel Mode",
7326 .info = alc_ch_mode_info,
7327 .get = alc_ch_mode_get,
7328 .put = alc_ch_mode_put,
7329 },
7330 { } /* end */
7331};
7332
Takashi Iwai4953550a2009-06-30 15:28:30 +02007333static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007334 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007335 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7336 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007337 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007338 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7339 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007340 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007341 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7342 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007343 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007344 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7345 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007346
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007347 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007348 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007349 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007350 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007351 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007352 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007353 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007354 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007355 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007356 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007357 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007358 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007359 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007360 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007361 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007362 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007363 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007364 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007365 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7366 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007367 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007368 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7369 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007370 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007371 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7372 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7373 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7374 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7375 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007376 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007377 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007378
7379 /* FIXME: use matrix-type input source selection */
7380 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007381 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007382 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007383 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007384 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007385 /* ADC2: mute amp left and right */
7386 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007387 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007388 /* ADC3: mute amp left and right */
7389 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007390 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007391
7392 { }
7393};
7394
Takashi Iwai4953550a2009-06-30 15:28:30 +02007395static struct hda_verb alc882_adc1_init_verbs[] = {
7396 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7397 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7398 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7399 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7400 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7401 /* ADC1: mute amp left and right */
7402 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7403 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7404 { }
7405};
7406
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007407static struct hda_verb alc882_eapd_verbs[] = {
7408 /* change to EAPD mode */
7409 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007410 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007411 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007412};
7413
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007414static struct hda_verb alc889_eapd_verbs[] = {
7415 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7416 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7417 { }
7418};
7419
Wu Fengguang6732bd02009-07-30 09:19:14 +02007420static struct hda_verb alc_hp15_unsol_verbs[] = {
7421 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7422 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7423 {}
7424};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007425
7426static struct hda_verb alc885_init_verbs[] = {
7427 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01007428 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7429 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007430 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007431 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7432 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007433 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007434 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7435 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007436 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007437 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7438 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007439
7440 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007441 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007442 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7443 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7444 /* Front Pin: output 0 (0x0c) */
7445 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7446 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7447 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7448 /* Rear Pin: output 1 (0x0d) */
7449 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7450 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7451 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7452 /* CLFE Pin: output 2 (0x0e) */
7453 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7454 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7455 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7456 /* Side Pin: output 3 (0x0f) */
7457 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7458 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7459 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7460 /* Mic (rear) pin: input vref at 80% */
7461 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7462 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7463 /* Front Mic pin: input vref at 80% */
7464 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7465 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7466 /* Line In pin: input */
7467 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7468 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7469
7470 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7471 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01007472 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007473 /* Input mixer2 */
7474 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007475 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01007476 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007477 /* ADC2: mute amp left and right */
7478 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7479 /* ADC3: mute amp left and right */
7480 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7481
7482 { }
7483};
7484
7485static struct hda_verb alc885_init_input_verbs[] = {
7486 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7487 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7488 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7489 { }
7490};
7491
7492
7493/* Unmute Selector 24h and set the default input to front mic */
7494static struct hda_verb alc889_init_input_verbs[] = {
7495 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7496 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7497 { }
7498};
7499
7500
Takashi Iwai4953550a2009-06-30 15:28:30 +02007501#define alc883_init_verbs alc882_base_init_verbs
7502
Tobin Davis9102cd12006-12-15 10:02:12 +01007503/* Mac Pro test */
7504static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7505 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7506 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7507 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7508 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7509 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007510 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007511 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7512 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007513 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007514 { } /* end */
7515};
7516
7517static struct hda_verb alc882_macpro_init_verbs[] = {
7518 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7519 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7520 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7521 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7522 /* Front Pin: output 0 (0x0c) */
7523 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7524 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7525 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7526 /* Front Mic pin: input vref at 80% */
7527 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7528 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7529 /* Speaker: output */
7530 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7531 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7532 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7533 /* Headphone output (output 0 - 0x0c) */
7534 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7535 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7536 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7537
7538 /* FIXME: use matrix-type input source selection */
7539 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7540 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7541 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7542 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7543 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7544 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7545 /* Input mixer2 */
7546 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7547 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7548 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7549 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7550 /* Input mixer3 */
7551 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7552 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7553 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7554 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7555 /* ADC1: mute amp left and right */
7556 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7557 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7558 /* ADC2: mute amp left and right */
7559 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7560 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7561 /* ADC3: mute amp left and right */
7562 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7563 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7564
7565 { }
7566};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007567
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007568/* Macbook 5,1 */
7569static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007570 /* DACs */
7571 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7572 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7573 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7574 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007575 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007576 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7577 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7578 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007579 /* Surround mixer */
7580 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7581 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7582 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7583 /* LFE mixer */
7584 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7585 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7586 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7587 /* HP mixer */
7588 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7589 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7590 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7591 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007592 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7593 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007594 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7595 /* LFE Pin (0x0e) */
7596 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7597 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7598 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7599 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007600 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7601 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007602 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10307603 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007604 /* Front Mic pin: input vref at 80% */
7605 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7606 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7607 /* Line In pin */
7608 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7609 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7610
7611 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7612 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7613 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7614 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7615 { }
7616};
7617
Takashi Iwai87350ad2007-08-16 18:19:38 +02007618/* Macbook Pro rev3 */
7619static struct hda_verb alc885_mbp3_init_verbs[] = {
7620 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7621 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7622 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7623 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7624 /* Rear mixer */
7625 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7626 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7627 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007628 /* HP mixer */
7629 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7630 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7631 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007632 /* Front Pin: output 0 (0x0c) */
7633 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7634 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7635 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007636 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007637 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007638 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7639 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007640 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7641 /* Mic (rear) pin: input vref at 80% */
7642 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7643 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7644 /* Front Mic pin: input vref at 80% */
7645 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7646 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7647 /* Line In pin: use output 1 when in LineOut mode */
7648 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7649 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7650 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7651
7652 /* FIXME: use matrix-type input source selection */
7653 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7654 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7655 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7656 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7657 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7658 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7659 /* Input mixer2 */
7660 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7661 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7662 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7663 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7664 /* Input mixer3 */
7665 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7666 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7667 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7668 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7669 /* ADC1: mute amp left and right */
7670 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7671 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7672 /* ADC2: mute amp left and right */
7673 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7674 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7675 /* ADC3: mute amp left and right */
7676 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7677 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7678
7679 { }
7680};
7681
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007682/* iMac 9,1 */
7683static struct hda_verb alc885_imac91_init_verbs[] = {
7684 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
7685 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7686 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7687 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7688 /* Rear mixer */
7689 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7690 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7691 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7692 /* HP Pin: output 0 (0x0c) */
7693 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7694 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7695 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7696 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7697 /* Internal Speakers: output 0 (0x0d) */
7698 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7699 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7700 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7701 /* Mic (rear) pin: input vref at 80% */
7702 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7703 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7704 /* Front Mic pin: input vref at 80% */
7705 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7706 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7707 /* Line In pin: use output 1 when in LineOut mode */
7708 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7709 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7710 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7711
7712 /* FIXME: use matrix-type input source selection */
7713 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7714 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7715 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7716 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7717 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7718 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7719 /* Input mixer2 */
7720 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7721 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7722 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7723 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7724 /* Input mixer3 */
7725 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7726 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7727 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7728 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7729 /* ADC1: mute amp left and right */
7730 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7731 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7732 /* ADC2: mute amp left and right */
7733 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7734 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7735 /* ADC3: mute amp left and right */
7736 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7737 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7738
7739 { }
7740};
7741
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007742/* iMac 24 mixer. */
7743static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7744 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7745 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7746 { } /* end */
7747};
7748
7749/* iMac 24 init verbs. */
7750static struct hda_verb alc885_imac24_init_verbs[] = {
7751 /* Internal speakers: output 0 (0x0c) */
7752 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7753 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7754 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7755 /* Internal speakers: output 0 (0x0c) */
7756 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7757 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7758 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7759 /* Headphone: output 0 (0x0c) */
7760 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7761 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7762 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7763 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7764 /* Front Mic: input vref at 80% */
7765 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7766 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7767 { }
7768};
7769
7770/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007771static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007772{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007773 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007774
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007775 spec->autocfg.hp_pins[0] = 0x14;
7776 spec->autocfg.speaker_pins[0] = 0x18;
7777 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007778}
7779
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007780static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007781{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007782 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007783
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007784 spec->autocfg.hp_pins[0] = 0x15;
7785 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02007786}
7787
Alex Murraya76221d2010-01-13 23:15:03 +10307788static void alc885_mb5_automute(struct hda_codec *codec)
7789{
7790 unsigned int present;
7791
7792 present = snd_hda_codec_read(codec, 0x14, 0,
7793 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7794 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
7795 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7796 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
7797 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7798
7799}
7800
7801static void alc885_mb5_unsol_event(struct hda_codec *codec,
7802 unsigned int res)
7803{
7804 /* Headphone insertion or removal. */
7805 if ((res >> 26) == ALC880_HP_EVENT)
7806 alc885_mb5_automute(codec);
7807}
7808
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007809static void alc885_imac91_automute(struct hda_codec *codec)
7810{
7811 unsigned int present;
7812
7813 present = snd_hda_codec_read(codec, 0x14, 0,
7814 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7815 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7816 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7817 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
7818 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7819
7820}
7821
7822static void alc885_imac91_unsol_event(struct hda_codec *codec,
7823 unsigned int res)
7824{
7825 /* Headphone insertion or removal. */
7826 if ((res >> 26) == ALC880_HP_EVENT)
7827 alc885_imac91_automute(codec);
7828}
Takashi Iwai87350ad2007-08-16 18:19:38 +02007829
Kailang Yang272a5272007-05-14 11:00:38 +02007830static struct hda_verb alc882_targa_verbs[] = {
7831 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7832 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7833
7834 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7835 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007836
Kailang Yang272a5272007-05-14 11:00:38 +02007837 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7838 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7839 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7840
7841 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007842 { } /* end */
7843};
7844
7845/* toggle speaker-output according to the hp-jack state */
7846static void alc882_targa_automute(struct hda_codec *codec)
7847{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007848 struct alc_spec *spec = codec->spec;
7849 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007850 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007851 spec->jack_present ? 1 : 3);
7852}
7853
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007854static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007855{
7856 struct alc_spec *spec = codec->spec;
7857
7858 spec->autocfg.hp_pins[0] = 0x14;
7859 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02007860}
7861
7862static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7863{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007864 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007865 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007866}
7867
7868static struct hda_verb alc882_asus_a7j_verbs[] = {
7869 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7870 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7871
7872 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7873 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7874 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007875
Kailang Yang272a5272007-05-14 11:00:38 +02007876 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7877 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7878 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7879
7880 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7881 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7882 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7883 { } /* end */
7884};
7885
Takashi Iwai914759b2007-09-06 14:52:04 +02007886static struct hda_verb alc882_asus_a7m_verbs[] = {
7887 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7889
7890 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7891 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7892 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007893
Takashi Iwai914759b2007-09-06 14:52:04 +02007894 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7895 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7896 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7897
7898 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7899 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7900 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7901 { } /* end */
7902};
7903
Tobin Davis9102cd12006-12-15 10:02:12 +01007904static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7905{
7906 unsigned int gpiostate, gpiomask, gpiodir;
7907
7908 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7909 AC_VERB_GET_GPIO_DATA, 0);
7910
7911 if (!muted)
7912 gpiostate |= (1 << pin);
7913 else
7914 gpiostate &= ~(1 << pin);
7915
7916 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7917 AC_VERB_GET_GPIO_MASK, 0);
7918 gpiomask |= (1 << pin);
7919
7920 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7921 AC_VERB_GET_GPIO_DIRECTION, 0);
7922 gpiodir |= (1 << pin);
7923
7924
7925 snd_hda_codec_write(codec, codec->afg, 0,
7926 AC_VERB_SET_GPIO_MASK, gpiomask);
7927 snd_hda_codec_write(codec, codec->afg, 0,
7928 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7929
7930 msleep(1);
7931
7932 snd_hda_codec_write(codec, codec->afg, 0,
7933 AC_VERB_SET_GPIO_DATA, gpiostate);
7934}
7935
Takashi Iwai7debbe52007-08-16 15:01:03 +02007936/* set up GPIO at initialization */
7937static void alc885_macpro_init_hook(struct hda_codec *codec)
7938{
7939 alc882_gpio_mute(codec, 0, 0);
7940 alc882_gpio_mute(codec, 1, 0);
7941}
7942
7943/* set up GPIO and update auto-muting at initialization */
7944static void alc885_imac24_init_hook(struct hda_codec *codec)
7945{
7946 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007947 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007948}
7949
Kailang Yangdf694da2005-12-05 19:42:22 +01007950/*
7951 * generic initialization of ADC, input mixers and output mixers
7952 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007953static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007954 /*
7955 * Unmute ADC0-2 and set the default input to mic-in
7956 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007957 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7958 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7959 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7960 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7961
Kailang Yangdf694da2005-12-05 19:42:22 +01007962 /*
7963 * Set up output mixers (0x0c - 0x0f)
7964 */
7965 /* set vol=0 to output mixers */
7966 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7967 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7968 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7969 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7970 /* set up input amps for analog loopback */
7971 /* Amp Indices: DAC = 0, mixer = 1 */
7972 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7973 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7974 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7975 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7976 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7977 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7978 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7979 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7980 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7981 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7982
7983 /* FIXME: use matrix-type input source selection */
7984 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01007985 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01007986 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007987 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01007988 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007989 { }
7990};
7991
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007992/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7993static struct hda_verb alc889A_mb31_ch2_init[] = {
7994 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7995 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7996 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7997 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7998 { } /* end */
7999};
8000
8001/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8002static struct hda_verb alc889A_mb31_ch4_init[] = {
8003 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8004 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8005 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8006 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8007 { } /* end */
8008};
8009
8010/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8011static struct hda_verb alc889A_mb31_ch5_init[] = {
8012 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8013 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8014 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8015 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8016 { } /* end */
8017};
8018
8019/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8020static struct hda_verb alc889A_mb31_ch6_init[] = {
8021 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8022 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8023 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8024 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8025 { } /* end */
8026};
8027
8028static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8029 { 2, alc889A_mb31_ch2_init },
8030 { 4, alc889A_mb31_ch4_init },
8031 { 5, alc889A_mb31_ch5_init },
8032 { 6, alc889A_mb31_ch6_init },
8033};
8034
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008035static struct hda_verb alc883_medion_eapd_verbs[] = {
8036 /* eanable EAPD on medion laptop */
8037 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8038 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8039 { }
8040};
8041
Takashi Iwai4953550a2009-06-30 15:28:30 +02008042#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008043
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008044static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8045 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8046 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8047 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8048 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8049 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8050 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8051 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8052 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8053 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8054 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8055 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8056 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8057 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008058 { } /* end */
8059};
8060
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008061static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008062 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8063 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8064 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8065 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8066 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8067 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8068 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8069 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8070 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8071 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008072 { } /* end */
8073};
8074
Jiang zhefb97dc62008-03-06 11:07:11 +01008075static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8076 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8077 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8078 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8079 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8080 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8081 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8082 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8083 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8084 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8085 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008086 { } /* end */
8087};
8088
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008089static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8090 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8091 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8092 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8093 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8094 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8095 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8096 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8097 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008098 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008099 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8100 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008101 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008102 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008103 { } /* end */
8104};
8105
8106static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8107 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8108 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8109 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8110 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8111 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8112 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8113 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8114 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8115 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8116 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8117 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8118 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8119 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8120 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008121 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008122 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8123 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008124 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008125 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008126 { } /* end */
8127};
8128
Jiang zhe17bba1b2008-06-04 12:11:07 +02008129static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8130 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8131 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8132 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8133 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8134 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8135 HDA_OUTPUT),
8136 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8137 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8138 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8139 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8140 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8141 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8142 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8143 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8144 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8145 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8146 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8147 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8148 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8149 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008150 { } /* end */
8151};
8152
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008153static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8154 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8155 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8156 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8157 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8158 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8159 HDA_OUTPUT),
8160 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8161 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8162 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8163 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8164 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8165 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8166 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8167 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8168 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8169 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8170 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8171 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8172 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8173 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8174 { } /* end */
8175};
8176
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008177static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008178 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008179 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008180 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008181 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008182 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8183 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008184 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8185 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008186 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8187 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("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8190 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8191 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008192 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008193 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8194 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008195 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008196 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008197 { } /* end */
8198};
8199
Sasha Alexandrc2592492009-06-16 14:52:54 -04008200static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008201 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008202 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008203 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008204 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008205 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8206 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8207 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8208 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8209 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8210 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8211 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8212 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8213 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8214 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8215 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008216 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008217 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008218 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008219};
Kailang Yangccc656c2006-10-17 12:32:26 +02008220
Sasha Alexandrc2592492009-06-16 14:52:54 -04008221static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008222 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008223 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008224 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008225 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008226 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8227 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8228 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008229 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008230 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008231 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8232 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8233 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008234 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008235};
Kailang Yangccc656c2006-10-17 12:32:26 +02008236
Takashi Iwaib99dba32009-09-17 18:23:00 +02008237static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8238 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8239 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8240 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8241 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8242 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8243 { } /* end */
8244};
8245
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008246static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8247 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8248 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008249 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8250 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008251 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8252 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8253 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8254 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008255 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008256};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008257
Kailang Yang272a5272007-05-14 11:00:38 +02008258static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8259 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8260 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8261 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8262 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8263 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8264 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8265 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8266 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8267 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008268 { } /* end */
8269};
8270
8271static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8272 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8273 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8274 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8275 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8276 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8277 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8278 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8279 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8280 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008281 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008282};
Kailang Yang272a5272007-05-14 11:00:38 +02008283
Tobin Davis2880a862007-08-07 11:50:26 +02008284static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008285 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8286 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008287 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008288 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8289 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008290 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8291 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8292 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008293 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008294};
Tobin Davis2880a862007-08-07 11:50:26 +02008295
Tony Vroond2fd4b02009-06-21 00:40:10 +01008296static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8297 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8298 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8299 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8300 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008301 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8302 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008303 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8304 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8305 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8306 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8307 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8308 { } /* end */
8309};
8310
Kailang Yange2757d52008-08-26 13:17:46 +02008311static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8312 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8313 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8314 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8315 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8316 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8317 0x0d, 1, 0x0, HDA_OUTPUT),
8318 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8319 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8320 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8321 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8322 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008323 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8324 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8325 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8326 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8327 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8328 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8329 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8330 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8331 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8332 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008333 { } /* end */
8334};
8335
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008336static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8337 /* Output mixers */
8338 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8339 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8340 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8341 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8342 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8343 HDA_OUTPUT),
8344 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8345 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8346 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8347 /* Output switches */
8348 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8349 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8350 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8351 /* Boost mixers */
8352 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8353 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8354 /* Input mixers */
8355 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8356 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8357 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8358 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8359 { } /* end */
8360};
8361
Guido Günther3e1647c2009-06-05 00:47:26 +02008362static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8363 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8364 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8365 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8366 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8367 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8368 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8369 { } /* end */
8370};
8371
Kailang Yange2757d52008-08-26 13:17:46 +02008372static struct hda_bind_ctls alc883_bind_cap_vol = {
8373 .ops = &snd_hda_bind_vol,
8374 .values = {
8375 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8376 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8377 0
8378 },
8379};
8380
8381static struct hda_bind_ctls alc883_bind_cap_switch = {
8382 .ops = &snd_hda_bind_sw,
8383 .values = {
8384 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8385 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8386 0
8387 },
8388};
8389
8390static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8391 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8392 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8393 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8394 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8395 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8396 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8397 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8398 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008399 { } /* end */
8400};
8401
8402static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008403 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8404 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8405 {
8406 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8407 /* .name = "Capture Source", */
8408 .name = "Input Source",
8409 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008410 .info = alc_mux_enum_info,
8411 .get = alc_mux_enum_get,
8412 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008413 },
8414 { } /* end */
8415};
8416
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008417static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8418 {
8419 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8420 .name = "Channel Mode",
8421 .info = alc_ch_mode_info,
8422 .get = alc_ch_mode_get,
8423 .put = alc_ch_mode_put,
8424 },
8425 { } /* end */
8426};
8427
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008428/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008429static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008430{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008431 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008432
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008433 spec->autocfg.hp_pins[0] = 0x15;
8434 spec->autocfg.speaker_pins[0] = 0x14;
8435 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008436}
8437
8438/* auto-toggle front mic */
8439/*
8440static void alc883_mitac_mic_automute(struct hda_codec *codec)
8441{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008442 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008443
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008444 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8445}
8446*/
8447
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008448static struct hda_verb alc883_mitac_verbs[] = {
8449 /* HP */
8450 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8451 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8452 /* Subwoofer */
8453 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8454 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8455
8456 /* enable unsolicited event */
8457 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8458 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8459
8460 { } /* end */
8461};
8462
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308463static struct hda_verb alc883_clevo_m540r_verbs[] = {
8464 /* HP */
8465 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8466 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8467 /* Int speaker */
8468 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8469
8470 /* enable unsolicited event */
8471 /*
8472 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8473 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8474 */
8475
8476 { } /* end */
8477};
8478
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008479static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008480 /* HP */
8481 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8482 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8483 /* Int speaker */
8484 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8485 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8486
8487 /* enable unsolicited event */
8488 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008489 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008490
8491 { } /* end */
8492};
8493
Jiang zhefb97dc62008-03-06 11:07:11 +01008494static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8495 /* HP */
8496 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8497 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8498 /* Subwoofer */
8499 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8500 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8501
8502 /* enable unsolicited event */
8503 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8504
8505 { } /* end */
8506};
8507
Sasha Alexandrc2592492009-06-16 14:52:54 -04008508static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008509 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8510 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8511
8512 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8513 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008514
David Heidelberger64a8be72009-06-08 16:15:18 +02008515/* Connect Line-Out side jack (SPDIF) to Side */
8516 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8517 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8518 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8519/* Connect Mic jack to CLFE */
8520 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8521 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8522 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8523/* Connect Line-in jack to Surround */
8524 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8525 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8526 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8527/* Connect HP out jack to Front */
8528 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8529 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8530 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008531
8532 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008533
8534 { } /* end */
8535};
8536
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008537static struct hda_verb alc883_lenovo_101e_verbs[] = {
8538 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8539 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8540 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8541 { } /* end */
8542};
8543
Kailang Yang272a5272007-05-14 11:00:38 +02008544static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8545 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8546 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8547 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8548 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8549 { } /* end */
8550};
8551
8552static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8553 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8554 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8555 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8556 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8557 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8558 { } /* end */
8559};
8560
Kailang Yang189609a2007-08-20 11:31:23 +02008561static struct hda_verb alc883_haier_w66_verbs[] = {
8562 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8563 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8564
8565 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8566
8567 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8568 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8569 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8570 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8571 { } /* end */
8572};
8573
Kailang Yange2757d52008-08-26 13:17:46 +02008574static struct hda_verb alc888_lenovo_sky_verbs[] = {
8575 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8576 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8577 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8578 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8579 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8580 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8581 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8582 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8583 { } /* end */
8584};
8585
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008586static struct hda_verb alc888_6st_dell_verbs[] = {
8587 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8588 { }
8589};
8590
Guido Günther3e1647c2009-06-05 00:47:26 +02008591static struct hda_verb alc883_vaiott_verbs[] = {
8592 /* HP */
8593 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8594 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8595
8596 /* enable unsolicited event */
8597 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8598
8599 { } /* end */
8600};
8601
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008602static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008603{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008604 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008605
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008606 spec->autocfg.hp_pins[0] = 0x1b;
8607 spec->autocfg.speaker_pins[0] = 0x14;
8608 spec->autocfg.speaker_pins[1] = 0x16;
8609 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008610}
8611
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008612static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008613 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008614 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8615 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008616 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008617 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008618};
8619
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008620/*
8621 * 2ch mode
8622 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008623static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008624 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8625 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8626 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8627 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008628 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008629};
8630
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008631/*
8632 * 4ch mode
8633 */
8634static struct hda_verb alc888_3st_hp_4ch_init[] = {
8635 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8636 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8637 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8638 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8639 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8640 { } /* end */
8641};
8642
8643/*
8644 * 6ch mode
8645 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008646static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008647 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8648 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008649 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008650 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8651 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008652 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8653 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008654};
8655
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008656static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008657 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008658 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008659 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008660};
8661
Kailang Yang272a5272007-05-14 11:00:38 +02008662/* toggle front-jack and RCA according to the hp-jack state */
8663static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8664{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008665 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02008666
Takashi Iwai47fd8302007-08-10 17:11:07 +02008667 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8668 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8669 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8670 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008671}
8672
8673/* toggle RCA according to the front-jack state */
8674static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8675{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008676 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02008677
Takashi Iwai47fd8302007-08-10 17:11:07 +02008678 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8679 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008680}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008681
Kailang Yang272a5272007-05-14 11:00:38 +02008682static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8683 unsigned int res)
8684{
8685 if ((res >> 26) == ALC880_HP_EVENT)
8686 alc888_lenovo_ms7195_front_automute(codec);
8687 if ((res >> 26) == ALC880_FRONT_EVENT)
8688 alc888_lenovo_ms7195_rca_automute(codec);
8689}
8690
8691static struct hda_verb alc883_medion_md2_verbs[] = {
8692 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8693 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8694
8695 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8696
8697 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8698 { } /* end */
8699};
8700
8701/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008702static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008703{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008704 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008705
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008706 spec->autocfg.hp_pins[0] = 0x14;
8707 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008708}
8709
Kailang Yangccc656c2006-10-17 12:32:26 +02008710/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008711#define alc883_targa_init_hook alc882_targa_init_hook
8712#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008713
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008714static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8715{
8716 unsigned int present;
8717
Takashi Iwaid56757a2009-11-18 08:00:14 +01008718 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008719 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8720 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8721}
8722
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008723static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008724{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008725 struct alc_spec *spec = codec->spec;
8726
8727 spec->autocfg.hp_pins[0] = 0x15;
8728 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008729}
8730
8731static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8732{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008733 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008734 alc883_clevo_m720_mic_automute(codec);
8735}
8736
8737static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008738 unsigned int res)
8739{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008740 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008741 case ALC880_MIC_EVENT:
8742 alc883_clevo_m720_mic_automute(codec);
8743 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008744 default:
8745 alc_automute_amp_unsol_event(codec, res);
8746 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008747 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008748}
8749
Jiang zhefb97dc62008-03-06 11:07:11 +01008750/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008751static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008752{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008753 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008754
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008755 spec->autocfg.hp_pins[0] = 0x14;
8756 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01008757}
8758
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008759static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008760{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008761 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008762
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008763 spec->autocfg.hp_pins[0] = 0x1b;
8764 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02008765}
8766
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008767static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8768{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008769 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008770
Takashi Iwai47fd8302007-08-10 17:11:07 +02008771 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8772 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008773}
8774
8775static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8776{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008777 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008778
Takashi Iwai47fd8302007-08-10 17:11:07 +02008779 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8780 HDA_AMP_MUTE, bits);
8781 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8782 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008783}
8784
8785static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8786 unsigned int res)
8787{
8788 if ((res >> 26) == ALC880_HP_EVENT)
8789 alc883_lenovo_101e_all_automute(codec);
8790 if ((res >> 26) == ALC880_FRONT_EVENT)
8791 alc883_lenovo_101e_ispeaker_automute(codec);
8792}
8793
Takashi Iwai676a9b52007-08-16 15:23:35 +02008794/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008795static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008796{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008797 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008798
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008799 spec->autocfg.hp_pins[0] = 0x14;
8800 spec->autocfg.speaker_pins[0] = 0x15;
8801 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02008802}
8803
Kailang Yangd1a991a2007-08-15 16:21:59 +02008804static struct hda_verb alc883_acer_eapd_verbs[] = {
8805 /* HP Pin: output 0 (0x0c) */
8806 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8807 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8808 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8809 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008810 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8811 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008812 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008813 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8814 /* eanable EAPD on medion laptop */
8815 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8816 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008817 /* enable unsolicited event */
8818 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008819 { }
8820};
8821
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008822static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8823 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8824 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8825 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8826 { } /* end */
8827};
8828
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008829static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008830{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008831 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008832
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008833 spec->autocfg.hp_pins[0] = 0x1b;
8834 spec->autocfg.speaker_pins[0] = 0x14;
8835 spec->autocfg.speaker_pins[1] = 0x15;
8836 spec->autocfg.speaker_pins[2] = 0x16;
8837 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008838}
8839
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008840static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008841{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008842 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008843
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008844 spec->autocfg.hp_pins[0] = 0x1b;
8845 spec->autocfg.speaker_pins[0] = 0x14;
8846 spec->autocfg.speaker_pins[1] = 0x15;
8847 spec->autocfg.speaker_pins[2] = 0x16;
8848 spec->autocfg.speaker_pins[3] = 0x17;
8849 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02008850}
8851
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008852static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02008853{
8854 struct alc_spec *spec = codec->spec;
8855
8856 spec->autocfg.hp_pins[0] = 0x15;
8857 spec->autocfg.speaker_pins[0] = 0x14;
8858 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02008859}
8860
Kailang Yange2757d52008-08-26 13:17:46 +02008861static struct hda_verb alc888_asus_m90v_verbs[] = {
8862 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8863 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8864 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8865 /* enable unsolicited event */
8866 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8867 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8868 { } /* end */
8869};
8870
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008871static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008872{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008873 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008874
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008875 spec->autocfg.hp_pins[0] = 0x1b;
8876 spec->autocfg.speaker_pins[0] = 0x14;
8877 spec->autocfg.speaker_pins[1] = 0x15;
8878 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008879 spec->ext_mic.pin = 0x18;
8880 spec->int_mic.pin = 0x19;
8881 spec->ext_mic.mux_idx = 0;
8882 spec->int_mic.mux_idx = 1;
8883 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02008884}
8885
8886static struct hda_verb alc888_asus_eee1601_verbs[] = {
8887 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8888 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8889 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8890 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8891 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8892 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8893 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8894 /* enable unsolicited event */
8895 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8896 { } /* end */
8897};
8898
Kailang Yange2757d52008-08-26 13:17:46 +02008899static void alc883_eee1601_inithook(struct hda_codec *codec)
8900{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008901 struct alc_spec *spec = codec->spec;
8902
8903 spec->autocfg.hp_pins[0] = 0x14;
8904 spec->autocfg.speaker_pins[0] = 0x1b;
8905 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008906}
8907
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008908static struct hda_verb alc889A_mb31_verbs[] = {
8909 /* Init rear pin (used as headphone output) */
8910 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8911 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8912 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8913 /* Init line pin (used as output in 4ch and 6ch mode) */
8914 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8915 /* Init line 2 pin (used as headphone out by default) */
8916 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8917 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8918 { } /* end */
8919};
8920
8921/* Mute speakers according to the headphone jack state */
8922static void alc889A_mb31_automute(struct hda_codec *codec)
8923{
8924 unsigned int present;
8925
8926 /* Mute only in 2ch or 4ch mode */
8927 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8928 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08008929 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008930 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8931 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8932 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8933 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8934 }
8935}
8936
8937static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8938{
8939 if ((res >> 26) == ALC880_HP_EVENT)
8940 alc889A_mb31_automute(codec);
8941}
8942
Takashi Iwai4953550a2009-06-30 15:28:30 +02008943
Takashi Iwaicb53c622007-08-10 17:21:45 +02008944#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02008945#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02008946#endif
8947
Sasha Alexandrdef319f2009-06-16 16:00:15 -04008948/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008949#define alc882_pcm_analog_playback alc880_pcm_analog_playback
8950#define alc882_pcm_analog_capture alc880_pcm_analog_capture
8951#define alc882_pcm_digital_playback alc880_pcm_digital_playback
8952#define alc882_pcm_digital_capture alc880_pcm_digital_capture
8953
8954static hda_nid_t alc883_slave_dig_outs[] = {
8955 ALC1200_DIGOUT_NID, 0,
8956};
8957
8958static hda_nid_t alc1200_slave_dig_outs[] = {
8959 ALC883_DIGOUT_NID, 0,
8960};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008961
8962/*
8963 * configuration and preset
8964 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008965static const char *alc882_models[ALC882_MODEL_LAST] = {
8966 [ALC882_3ST_DIG] = "3stack-dig",
8967 [ALC882_6ST_DIG] = "6stack-dig",
8968 [ALC882_ARIMA] = "arima",
8969 [ALC882_W2JC] = "w2jc",
8970 [ALC882_TARGA] = "targa",
8971 [ALC882_ASUS_A7J] = "asus-a7j",
8972 [ALC882_ASUS_A7M] = "asus-a7m",
8973 [ALC885_MACPRO] = "macpro",
8974 [ALC885_MB5] = "mb5",
8975 [ALC885_MBP3] = "mbp3",
8976 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008977 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008978 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008979 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8980 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008981 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008982 [ALC883_TARGA_DIG] = "targa-dig",
8983 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02008984 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008985 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008986 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008987 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02008988 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02008989 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008990 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008991 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008992 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008993 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008994 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008995 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8996 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008997 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008998 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008999 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009000 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009001 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309002 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009003 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009004 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009005 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009006 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009007 [ALC889A_INTEL] = "intel-alc889a",
9008 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009009 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009010 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009011 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009012 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009013};
9014
Takashi Iwai4953550a2009-06-30 15:28:30 +02009015static struct snd_pci_quirk alc882_cfg_tbl[] = {
9016 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9017
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009018 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009019 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009020 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009021 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9022 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009023 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009024 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9025 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009026 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009027 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009028 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9029 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009030 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9031 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009032 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9033 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009034 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009035 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009036 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009037 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009038 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9039 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009040 /* default Acer -- disabled as it causes more problems.
9041 * model=auto should work fine now
9042 */
9043 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009044
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009045 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009046
Tobin Davisfebe3372007-06-12 11:27:46 +02009047 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009048 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9049 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009050 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009051 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009052 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009053
9054 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9055 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9056 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009057 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009058 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9059 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9060 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009061 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009062 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009063 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009064 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009065
9066 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009067 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009068 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009069 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009070 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9071 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009072 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009073 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009074 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9075
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009076 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9077 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9078 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009079 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009080 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009081 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009082 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009083 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009084 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9085 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9086 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9087 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9088 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9089 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009090 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009091 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9092 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9093 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009094 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009095 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9096 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009097 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009098 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009099 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009100 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009101 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009102 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009103 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009104 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009105
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009106 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009107 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9108 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309109 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009110 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009111 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009112 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009113 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009114 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009115 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009116 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009117 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009118 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009119 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009120 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9121 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009122 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009123 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009124 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009125 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009126 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009127
Jiang zhe17bba1b2008-06-04 12:11:07 +02009128 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9129 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009130 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009131 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9132 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9133 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009134 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009135
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009136 {}
9137};
9138
Takashi Iwai4953550a2009-06-30 15:28:30 +02009139/* codec SSID table for Intel Mac */
9140static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9141 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9142 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9143 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9144 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9145 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9146 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9147 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
9148 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9149 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9150 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009151 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009152 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009153 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9154 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009155 */
9156 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009157 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009158 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009159};
9160
Takashi Iwai4953550a2009-06-30 15:28:30 +02009161static struct alc_config_preset alc882_presets[] = {
9162 [ALC882_3ST_DIG] = {
9163 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009164 .init_verbs = { alc882_base_init_verbs,
9165 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009166 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9167 .dac_nids = alc882_dac_nids,
9168 .dig_out_nid = ALC882_DIGOUT_NID,
9169 .dig_in_nid = ALC882_DIGIN_NID,
9170 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9171 .channel_mode = alc882_ch_modes,
9172 .need_dac_fix = 1,
9173 .input_mux = &alc882_capture_source,
9174 },
9175 [ALC882_6ST_DIG] = {
9176 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009177 .init_verbs = { alc882_base_init_verbs,
9178 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009179 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9180 .dac_nids = alc882_dac_nids,
9181 .dig_out_nid = ALC882_DIGOUT_NID,
9182 .dig_in_nid = ALC882_DIGIN_NID,
9183 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9184 .channel_mode = alc882_sixstack_modes,
9185 .input_mux = &alc882_capture_source,
9186 },
9187 [ALC882_ARIMA] = {
9188 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009189 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9190 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009191 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9192 .dac_nids = alc882_dac_nids,
9193 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9194 .channel_mode = alc882_sixstack_modes,
9195 .input_mux = &alc882_capture_source,
9196 },
9197 [ALC882_W2JC] = {
9198 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009199 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9200 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009201 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9202 .dac_nids = alc882_dac_nids,
9203 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9204 .channel_mode = alc880_threestack_modes,
9205 .need_dac_fix = 1,
9206 .input_mux = &alc882_capture_source,
9207 .dig_out_nid = ALC882_DIGOUT_NID,
9208 },
9209 [ALC885_MBP3] = {
9210 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9211 .init_verbs = { alc885_mbp3_init_verbs,
9212 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009213 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009214 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009215 .hp_nid = 0x04,
9216 .channel_mode = alc885_mbp_4ch_modes,
9217 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009218 .input_mux = &alc882_capture_source,
9219 .dig_out_nid = ALC882_DIGOUT_NID,
9220 .dig_in_nid = ALC882_DIGIN_NID,
9221 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009222 .setup = alc885_mbp3_setup,
9223 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009224 },
9225 [ALC885_MB5] = {
9226 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9227 .init_verbs = { alc885_mb5_init_verbs,
9228 alc880_gpio1_init_verbs },
9229 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9230 .dac_nids = alc882_dac_nids,
9231 .channel_mode = alc885_mb5_6ch_modes,
9232 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9233 .input_mux = &mb5_capture_source,
9234 .dig_out_nid = ALC882_DIGOUT_NID,
9235 .dig_in_nid = ALC882_DIGIN_NID,
Alex Murraya76221d2010-01-13 23:15:03 +10309236 .unsol_event = alc885_mb5_unsol_event,
9237 .init_hook = alc885_mb5_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009238 },
9239 [ALC885_MACPRO] = {
9240 .mixers = { alc882_macpro_mixer },
9241 .init_verbs = { alc882_macpro_init_verbs },
9242 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9243 .dac_nids = alc882_dac_nids,
9244 .dig_out_nid = ALC882_DIGOUT_NID,
9245 .dig_in_nid = ALC882_DIGIN_NID,
9246 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9247 .channel_mode = alc882_ch_modes,
9248 .input_mux = &alc882_capture_source,
9249 .init_hook = alc885_macpro_init_hook,
9250 },
9251 [ALC885_IMAC24] = {
9252 .mixers = { alc885_imac24_mixer },
9253 .init_verbs = { alc885_imac24_init_verbs },
9254 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9255 .dac_nids = alc882_dac_nids,
9256 .dig_out_nid = ALC882_DIGOUT_NID,
9257 .dig_in_nid = ALC882_DIGIN_NID,
9258 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9259 .channel_mode = alc882_ch_modes,
9260 .input_mux = &alc882_capture_source,
9261 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009262 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009263 .init_hook = alc885_imac24_init_hook,
9264 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009265 [ALC885_IMAC91] = {
9266 .mixers = { alc885_imac91_mixer, alc882_chmode_mixer },
9267 .init_verbs = { alc885_imac91_init_verbs,
9268 alc880_gpio1_init_verbs },
9269 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9270 .dac_nids = alc882_dac_nids,
9271 .channel_mode = alc885_mbp_4ch_modes,
9272 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
9273 .input_mux = &alc882_capture_source,
9274 .dig_out_nid = ALC882_DIGOUT_NID,
9275 .dig_in_nid = ALC882_DIGIN_NID,
9276 .unsol_event = alc885_imac91_unsol_event,
9277 .init_hook = alc885_imac91_automute,
9278 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009279 [ALC882_TARGA] = {
9280 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009281 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009282 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009283 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9284 .dac_nids = alc882_dac_nids,
9285 .dig_out_nid = ALC882_DIGOUT_NID,
9286 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9287 .adc_nids = alc882_adc_nids,
9288 .capsrc_nids = alc882_capsrc_nids,
9289 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9290 .channel_mode = alc882_3ST_6ch_modes,
9291 .need_dac_fix = 1,
9292 .input_mux = &alc882_capture_source,
9293 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009294 .setup = alc882_targa_setup,
9295 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009296 },
9297 [ALC882_ASUS_A7J] = {
9298 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009299 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9300 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009301 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9302 .dac_nids = alc882_dac_nids,
9303 .dig_out_nid = ALC882_DIGOUT_NID,
9304 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9305 .adc_nids = alc882_adc_nids,
9306 .capsrc_nids = alc882_capsrc_nids,
9307 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9308 .channel_mode = alc882_3ST_6ch_modes,
9309 .need_dac_fix = 1,
9310 .input_mux = &alc882_capture_source,
9311 },
9312 [ALC882_ASUS_A7M] = {
9313 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009314 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9315 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009316 alc882_asus_a7m_verbs },
9317 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9318 .dac_nids = alc882_dac_nids,
9319 .dig_out_nid = ALC882_DIGOUT_NID,
9320 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9321 .channel_mode = alc880_threestack_modes,
9322 .need_dac_fix = 1,
9323 .input_mux = &alc882_capture_source,
9324 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009325 [ALC883_3ST_2ch_DIG] = {
9326 .mixers = { alc883_3ST_2ch_mixer },
9327 .init_verbs = { alc883_init_verbs },
9328 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9329 .dac_nids = alc883_dac_nids,
9330 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009331 .dig_in_nid = ALC883_DIGIN_NID,
9332 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9333 .channel_mode = alc883_3ST_2ch_modes,
9334 .input_mux = &alc883_capture_source,
9335 },
9336 [ALC883_3ST_6ch_DIG] = {
9337 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9338 .init_verbs = { alc883_init_verbs },
9339 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9340 .dac_nids = alc883_dac_nids,
9341 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009342 .dig_in_nid = ALC883_DIGIN_NID,
9343 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9344 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009345 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009346 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009347 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009348 [ALC883_3ST_6ch] = {
9349 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9350 .init_verbs = { alc883_init_verbs },
9351 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9352 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009353 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9354 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009355 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009356 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009357 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009358 [ALC883_3ST_6ch_INTEL] = {
9359 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9360 .init_verbs = { alc883_init_verbs },
9361 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9362 .dac_nids = alc883_dac_nids,
9363 .dig_out_nid = ALC883_DIGOUT_NID,
9364 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009365 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009366 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9367 .channel_mode = alc883_3ST_6ch_intel_modes,
9368 .need_dac_fix = 1,
9369 .input_mux = &alc883_3stack_6ch_intel,
9370 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009371 [ALC889A_INTEL] = {
9372 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009373 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9374 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009375 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9376 .dac_nids = alc883_dac_nids,
9377 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9378 .adc_nids = alc889_adc_nids,
9379 .dig_out_nid = ALC883_DIGOUT_NID,
9380 .dig_in_nid = ALC883_DIGIN_NID,
9381 .slave_dig_outs = alc883_slave_dig_outs,
9382 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9383 .channel_mode = alc889_8ch_intel_modes,
9384 .capsrc_nids = alc889_capsrc_nids,
9385 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009386 .setup = alc889_automute_setup,
9387 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009388 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009389 .need_dac_fix = 1,
9390 },
9391 [ALC889_INTEL] = {
9392 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9393 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009394 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009395 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9396 .dac_nids = alc883_dac_nids,
9397 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9398 .adc_nids = alc889_adc_nids,
9399 .dig_out_nid = ALC883_DIGOUT_NID,
9400 .dig_in_nid = ALC883_DIGIN_NID,
9401 .slave_dig_outs = alc883_slave_dig_outs,
9402 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9403 .channel_mode = alc889_8ch_intel_modes,
9404 .capsrc_nids = alc889_capsrc_nids,
9405 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009406 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009407 .init_hook = alc889_intel_init_hook,
9408 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009409 .need_dac_fix = 1,
9410 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009411 [ALC883_6ST_DIG] = {
9412 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9413 .init_verbs = { alc883_init_verbs },
9414 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9415 .dac_nids = alc883_dac_nids,
9416 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009417 .dig_in_nid = ALC883_DIGIN_NID,
9418 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9419 .channel_mode = alc883_sixstack_modes,
9420 .input_mux = &alc883_capture_source,
9421 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009422 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009423 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009424 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9425 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009426 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9427 .dac_nids = alc883_dac_nids,
9428 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009429 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9430 .channel_mode = alc883_3ST_6ch_modes,
9431 .need_dac_fix = 1,
9432 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009433 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009434 .setup = alc882_targa_setup,
9435 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009436 },
9437 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009438 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009439 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9440 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009441 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9442 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009443 .adc_nids = alc883_adc_nids_alt,
9444 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009445 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +02009446 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009447 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9448 .channel_mode = alc883_3ST_2ch_modes,
9449 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009450 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009451 .setup = alc882_targa_setup,
9452 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009453 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009454 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009455 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9456 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +02009457 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009458 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009459 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9460 .dac_nids = alc883_dac_nids,
9461 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9462 .adc_nids = alc883_adc_nids_rev,
9463 .capsrc_nids = alc883_capsrc_nids_rev,
9464 .dig_out_nid = ALC883_DIGOUT_NID,
9465 .dig_in_nid = ALC883_DIGIN_NID,
9466 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9467 .channel_mode = alc883_4ST_8ch_modes,
9468 .need_dac_fix = 1,
9469 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009470 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009471 .setup = alc882_targa_setup,
9472 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009473 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009474 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009475 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009476 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9477 * and the headphone jack. Turn this on and rely on the
9478 * standard mute methods whenever the user wants to turn
9479 * these outputs off.
9480 */
9481 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9482 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9483 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009484 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9485 .channel_mode = alc883_3ST_2ch_modes,
9486 .input_mux = &alc883_capture_source,
9487 },
Tobin Davis2880a862007-08-07 11:50:26 +02009488 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009489 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009490 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009491 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9492 .dac_nids = alc883_dac_nids,
9493 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009494 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9495 .channel_mode = alc883_3ST_2ch_modes,
9496 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009497 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009498 .setup = alc883_acer_aspire_setup,
9499 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009500 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009501 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009502 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009503 alc883_chmode_mixer },
9504 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9505 alc888_acer_aspire_4930g_verbs },
9506 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9507 .dac_nids = alc883_dac_nids,
9508 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9509 .adc_nids = alc883_adc_nids_rev,
9510 .capsrc_nids = alc883_capsrc_nids_rev,
9511 .dig_out_nid = ALC883_DIGOUT_NID,
9512 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9513 .channel_mode = alc883_3ST_6ch_modes,
9514 .need_dac_fix = 1,
9515 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009516 ARRAY_SIZE(alc888_2_capture_sources),
9517 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009518 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009519 .setup = alc888_acer_aspire_4930g_setup,
9520 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009521 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009522 [ALC888_ACER_ASPIRE_6530G] = {
9523 .mixers = { alc888_acer_aspire_6530_mixer },
9524 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9525 alc888_acer_aspire_6530g_verbs },
9526 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9527 .dac_nids = alc883_dac_nids,
9528 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9529 .adc_nids = alc883_adc_nids_rev,
9530 .capsrc_nids = alc883_capsrc_nids_rev,
9531 .dig_out_nid = ALC883_DIGOUT_NID,
9532 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9533 .channel_mode = alc883_3ST_2ch_modes,
9534 .num_mux_defs =
9535 ARRAY_SIZE(alc888_2_capture_sources),
9536 .input_mux = alc888_acer_aspire_6530_sources,
9537 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009538 .setup = alc888_acer_aspire_6530g_setup,
9539 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009540 },
Hector Martin3b315d72009-06-02 10:54:19 +02009541 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +01009542 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +02009543 alc883_chmode_mixer },
9544 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +01009545 alc889_acer_aspire_8930g_verbs,
9546 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +02009547 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9548 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009549 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9550 .adc_nids = alc889_adc_nids,
9551 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009552 .dig_out_nid = ALC883_DIGOUT_NID,
9553 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9554 .channel_mode = alc883_3ST_6ch_modes,
9555 .need_dac_fix = 1,
9556 .const_channel_count = 6,
9557 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009558 ARRAY_SIZE(alc889_capture_sources),
9559 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009560 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009561 .setup = alc889_acer_aspire_8930g_setup,
9562 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +01009563#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05009564 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +01009565#endif
Hector Martin3b315d72009-06-02 10:54:19 +02009566 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009567 [ALC888_ACER_ASPIRE_7730G] = {
9568 .mixers = { alc883_3ST_6ch_mixer,
9569 alc883_chmode_mixer },
9570 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9571 alc888_acer_aspire_7730G_verbs },
9572 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9573 .dac_nids = alc883_dac_nids,
9574 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9575 .adc_nids = alc883_adc_nids_rev,
9576 .capsrc_nids = alc883_capsrc_nids_rev,
9577 .dig_out_nid = ALC883_DIGOUT_NID,
9578 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9579 .channel_mode = alc883_3ST_6ch_modes,
9580 .need_dac_fix = 1,
9581 .const_channel_count = 6,
9582 .input_mux = &alc883_capture_source,
9583 .unsol_event = alc_automute_amp_unsol_event,
9584 .setup = alc888_acer_aspire_6530g_setup,
9585 .init_hook = alc_automute_amp,
9586 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009587 [ALC883_MEDION] = {
9588 .mixers = { alc883_fivestack_mixer,
9589 alc883_chmode_mixer },
9590 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009591 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009592 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9593 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009594 .adc_nids = alc883_adc_nids_alt,
9595 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009596 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02009597 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9598 .channel_mode = alc883_sixstack_modes,
9599 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009600 },
Kailang Yang272a5272007-05-14 11:00:38 +02009601 [ALC883_MEDION_MD2] = {
9602 .mixers = { alc883_medion_md2_mixer},
9603 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9604 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9605 .dac_nids = alc883_dac_nids,
9606 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009607 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9608 .channel_mode = alc883_3ST_2ch_modes,
9609 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009610 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009611 .setup = alc883_medion_md2_setup,
9612 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009613 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009614 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009615 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009616 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9617 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9618 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009619 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9620 .channel_mode = alc883_3ST_2ch_modes,
9621 .input_mux = &alc883_capture_source,
9622 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309623 [ALC883_CLEVO_M540R] = {
9624 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9625 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9626 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9627 .dac_nids = alc883_dac_nids,
9628 .dig_out_nid = ALC883_DIGOUT_NID,
9629 .dig_in_nid = ALC883_DIGIN_NID,
9630 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9631 .channel_mode = alc883_3ST_6ch_clevo_modes,
9632 .need_dac_fix = 1,
9633 .input_mux = &alc883_capture_source,
9634 /* This machine has the hardware HP auto-muting, thus
9635 * we need no software mute via unsol event
9636 */
9637 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009638 [ALC883_CLEVO_M720] = {
9639 .mixers = { alc883_clevo_m720_mixer },
9640 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009641 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9642 .dac_nids = alc883_dac_nids,
9643 .dig_out_nid = ALC883_DIGOUT_NID,
9644 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9645 .channel_mode = alc883_3ST_2ch_modes,
9646 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009647 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009648 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009649 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009650 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009651 [ALC883_LENOVO_101E_2ch] = {
9652 .mixers = { alc883_lenovo_101e_2ch_mixer},
9653 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9654 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9655 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009656 .adc_nids = alc883_adc_nids_alt,
9657 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009658 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009659 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9660 .channel_mode = alc883_3ST_2ch_modes,
9661 .input_mux = &alc883_lenovo_101e_capture_source,
9662 .unsol_event = alc883_lenovo_101e_unsol_event,
9663 .init_hook = alc883_lenovo_101e_all_automute,
9664 },
Kailang Yang272a5272007-05-14 11:00:38 +02009665 [ALC883_LENOVO_NB0763] = {
9666 .mixers = { alc883_lenovo_nb0763_mixer },
9667 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9668 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9669 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009670 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9671 .channel_mode = alc883_3ST_2ch_modes,
9672 .need_dac_fix = 1,
9673 .input_mux = &alc883_lenovo_nb0763_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 = alc883_medion_md2_setup,
9676 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009677 },
9678 [ALC888_LENOVO_MS7195_DIG] = {
9679 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9680 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9681 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9682 .dac_nids = alc883_dac_nids,
9683 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009684 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9685 .channel_mode = alc883_3ST_6ch_modes,
9686 .need_dac_fix = 1,
9687 .input_mux = &alc883_capture_source,
9688 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9689 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009690 },
9691 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009692 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009693 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9694 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9695 .dac_nids = alc883_dac_nids,
9696 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009697 .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_haier_w66_setup,
9702 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009703 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009704 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009705 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009706 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009707 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9708 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009709 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9710 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009711 .need_dac_fix = 1,
9712 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009713 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009714 .setup = alc888_3st_hp_setup,
9715 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009716 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009717 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009718 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009719 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9720 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9721 .dac_nids = alc883_dac_nids,
9722 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009723 .dig_in_nid = ALC883_DIGIN_NID,
9724 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9725 .channel_mode = alc883_sixstack_modes,
9726 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009727 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009728 .setup = alc888_6st_dell_setup,
9729 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009730 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009731 [ALC883_MITAC] = {
9732 .mixers = { alc883_mitac_mixer },
9733 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9734 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9735 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009736 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9737 .channel_mode = alc883_3ST_2ch_modes,
9738 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009739 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009740 .setup = alc883_mitac_setup,
9741 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009742 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009743 [ALC883_FUJITSU_PI2515] = {
9744 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9745 .init_verbs = { alc883_init_verbs,
9746 alc883_2ch_fujitsu_pi2515_verbs},
9747 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9748 .dac_nids = alc883_dac_nids,
9749 .dig_out_nid = ALC883_DIGOUT_NID,
9750 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9751 .channel_mode = alc883_3ST_2ch_modes,
9752 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009753 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009754 .setup = alc883_2ch_fujitsu_pi2515_setup,
9755 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +01009756 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009757 [ALC888_FUJITSU_XA3530] = {
9758 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9759 .init_verbs = { alc883_init_verbs,
9760 alc888_fujitsu_xa3530_verbs },
9761 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9762 .dac_nids = alc883_dac_nids,
9763 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9764 .adc_nids = alc883_adc_nids_rev,
9765 .capsrc_nids = alc883_capsrc_nids_rev,
9766 .dig_out_nid = ALC883_DIGOUT_NID,
9767 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9768 .channel_mode = alc888_4ST_8ch_intel_modes,
9769 .num_mux_defs =
9770 ARRAY_SIZE(alc888_2_capture_sources),
9771 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009772 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009773 .setup = alc888_fujitsu_xa3530_setup,
9774 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009775 },
Kailang Yange2757d52008-08-26 13:17:46 +02009776 [ALC888_LENOVO_SKY] = {
9777 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9778 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9779 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9780 .dac_nids = alc883_dac_nids,
9781 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009782 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9783 .channel_mode = alc883_sixstack_modes,
9784 .need_dac_fix = 1,
9785 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009786 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009787 .setup = alc888_lenovo_sky_setup,
9788 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +02009789 },
9790 [ALC888_ASUS_M90V] = {
9791 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9792 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9793 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9794 .dac_nids = alc883_dac_nids,
9795 .dig_out_nid = ALC883_DIGOUT_NID,
9796 .dig_in_nid = ALC883_DIGIN_NID,
9797 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9798 .channel_mode = alc883_3ST_6ch_modes,
9799 .need_dac_fix = 1,
9800 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009801 .unsol_event = alc_sku_unsol_event,
9802 .setup = alc883_mode2_setup,
9803 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +02009804 },
9805 [ALC888_ASUS_EEE1601] = {
9806 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009807 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009808 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9809 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9810 .dac_nids = alc883_dac_nids,
9811 .dig_out_nid = ALC883_DIGOUT_NID,
9812 .dig_in_nid = ALC883_DIGIN_NID,
9813 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9814 .channel_mode = alc883_3ST_2ch_modes,
9815 .need_dac_fix = 1,
9816 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009817 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009818 .init_hook = alc883_eee1601_inithook,
9819 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009820 [ALC1200_ASUS_P5Q] = {
9821 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9822 .init_verbs = { alc883_init_verbs },
9823 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9824 .dac_nids = alc883_dac_nids,
9825 .dig_out_nid = ALC1200_DIGOUT_NID,
9826 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009827 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009828 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9829 .channel_mode = alc883_sixstack_modes,
9830 .input_mux = &alc883_capture_source,
9831 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009832 [ALC889A_MB31] = {
9833 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9834 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9835 alc880_gpio1_init_verbs },
9836 .adc_nids = alc883_adc_nids,
9837 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009838 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009839 .dac_nids = alc883_dac_nids,
9840 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9841 .channel_mode = alc889A_mb31_6ch_modes,
9842 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9843 .input_mux = &alc889A_mb31_capture_source,
9844 .dig_out_nid = ALC883_DIGOUT_NID,
9845 .unsol_event = alc889A_mb31_unsol_event,
9846 .init_hook = alc889A_mb31_automute,
9847 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009848 [ALC883_SONY_VAIO_TT] = {
9849 .mixers = { alc883_vaiott_mixer },
9850 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9851 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9852 .dac_nids = alc883_dac_nids,
9853 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9854 .channel_mode = alc883_3ST_2ch_modes,
9855 .input_mux = &alc883_capture_source,
9856 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009857 .setup = alc883_vaiott_setup,
9858 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +02009859 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009860};
9861
9862
9863/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02009864 * Pin config fixes
9865 */
9866enum {
9867 PINFIX_ABIT_AW9D_MAX
9868};
9869
9870static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9871 { 0x15, 0x01080104 }, /* side */
9872 { 0x16, 0x01011012 }, /* rear */
9873 { 0x17, 0x01016011 }, /* clfe */
9874 { }
9875};
9876
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009877static const struct alc_fixup alc882_fixups[] = {
9878 [PINFIX_ABIT_AW9D_MAX] = {
9879 .pins = alc882_abit_aw9d_pinfix
9880 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009881};
9882
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009883static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009884 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9885 {}
9886};
9887
9888/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009889 * BIOS auto configuration
9890 */
Takashi Iwai05f5f472009-08-25 13:10:18 +02009891static int alc882_auto_create_input_ctls(struct hda_codec *codec,
9892 const struct auto_pin_cfg *cfg)
9893{
9894 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
9895}
9896
Takashi Iwai4953550a2009-06-30 15:28:30 +02009897static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009898 hda_nid_t nid, int pin_type,
9899 int dac_idx)
9900{
9901 /* set as output */
9902 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009903 int idx;
9904
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009905 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009906 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9907 idx = 4;
9908 else
9909 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009910 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9911
9912}
9913
Takashi Iwai4953550a2009-06-30 15:28:30 +02009914static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009915{
9916 struct alc_spec *spec = codec->spec;
9917 int i;
9918
9919 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009920 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009921 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009922 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009923 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009924 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009925 }
9926}
9927
Takashi Iwai4953550a2009-06-30 15:28:30 +02009928static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009929{
9930 struct alc_spec *spec = codec->spec;
9931 hda_nid_t pin;
9932
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009933 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009934 if (pin) /* connect to front */
9935 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009936 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009937 pin = spec->autocfg.speaker_pins[0];
9938 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009939 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009940}
9941
Takashi Iwai4953550a2009-06-30 15:28:30 +02009942static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009943{
9944 struct alc_spec *spec = codec->spec;
9945 int i;
9946
9947 for (i = 0; i < AUTO_PIN_LAST; i++) {
9948 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +02009949 if (!nid)
9950 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +02009951 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009952 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9953 snd_hda_codec_write(codec, nid, 0,
9954 AC_VERB_SET_AMP_GAIN_MUTE,
9955 AMP_OUT_MUTE);
9956 }
9957}
9958
9959static void alc882_auto_init_input_src(struct hda_codec *codec)
9960{
9961 struct alc_spec *spec = codec->spec;
9962 int c;
9963
9964 for (c = 0; c < spec->num_adc_nids; c++) {
9965 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9966 hda_nid_t nid = spec->capsrc_nids[c];
9967 unsigned int mux_idx;
9968 const struct hda_input_mux *imux;
9969 int conns, mute, idx, item;
9970
9971 conns = snd_hda_get_connections(codec, nid, conn_list,
9972 ARRAY_SIZE(conn_list));
9973 if (conns < 0)
9974 continue;
9975 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9976 imux = &spec->input_mux[mux_idx];
9977 for (idx = 0; idx < conns; idx++) {
9978 /* if the current connection is the selected one,
9979 * unmute it as default - otherwise mute it
9980 */
9981 mute = AMP_IN_MUTE(idx);
9982 for (item = 0; item < imux->num_items; item++) {
9983 if (imux->items[item].index == idx) {
9984 if (spec->cur_mux[c] == item)
9985 mute = AMP_IN_UNMUTE(idx);
9986 break;
9987 }
9988 }
9989 /* check if we have a selector or mixer
9990 * we could check for the widget type instead, but
9991 * just check for Amp-In presence (in case of mixer
9992 * without amp-in there is something wrong, this
9993 * function shouldn't be used or capsrc nid is wrong)
9994 */
9995 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009996 snd_hda_codec_write(codec, nid, 0,
9997 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009998 mute);
9999 else if (mute != AMP_IN_MUTE(idx))
10000 snd_hda_codec_write(codec, nid, 0,
10001 AC_VERB_SET_CONNECT_SEL,
10002 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010003 }
10004 }
10005}
10006
Takashi Iwai4953550a2009-06-30 15:28:30 +020010007/* add mic boosts if needed */
10008static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010009{
10010 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010011 int err;
10012 hda_nid_t nid;
10013
10014 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
10015 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10016 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10017 "Mic Boost",
10018 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10019 if (err < 0)
10020 return err;
10021 }
10022 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
10023 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10024 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10025 "Front Mic Boost",
10026 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10027 if (err < 0)
10028 return err;
10029 }
10030 return 0;
10031}
10032
10033/* almost identical with ALC880 parser... */
10034static int alc882_parse_auto_config(struct hda_codec *codec)
10035{
10036 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010037 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
10038 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010039
Takashi Iwai05f5f472009-08-25 13:10:18 +020010040 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10041 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010042 if (err < 0)
10043 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010044 if (!spec->autocfg.line_outs)
10045 return 0; /* can't find valid BIOS pin config */
10046
10047 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10048 if (err < 0)
10049 return err;
10050 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10051 if (err < 0)
10052 return err;
10053 err = alc880_auto_create_extra_out(spec,
10054 spec->autocfg.speaker_pins[0],
10055 "Speaker");
10056 if (err < 0)
10057 return err;
10058 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10059 "Headphone");
10060 if (err < 0)
10061 return err;
10062 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10063 if (err < 0)
10064 return err;
10065
10066 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10067
10068 /* check multiple SPDIF-out (for recent codecs) */
10069 for (i = 0; i < spec->autocfg.dig_outs; i++) {
10070 hda_nid_t dig_nid;
10071 err = snd_hda_get_connections(codec,
10072 spec->autocfg.dig_out_pins[i],
10073 &dig_nid, 1);
10074 if (err < 0)
10075 continue;
10076 if (!i)
10077 spec->multiout.dig_out_nid = dig_nid;
10078 else {
10079 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010080 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai05f5f472009-08-25 13:10:18 +020010081 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010082 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010083 }
10084 }
10085 if (spec->autocfg.dig_in_pin)
10086 spec->dig_in_nid = ALC880_DIGIN_NID;
10087
10088 if (spec->kctls.list)
10089 add_mixer(spec, spec->kctls.list);
10090
10091 add_verb(spec, alc883_auto_init_verbs);
10092 /* if ADC 0x07 is available, initialize it, too */
10093 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10094 add_verb(spec, alc882_adc1_init_verbs);
10095
10096 spec->num_mux_defs = 1;
10097 spec->input_mux = &spec->private_imux[0];
10098
10099 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
Takashi Iwai776e1842007-08-29 15:07:11 +020010100
10101 err = alc_auto_add_mic_boost(codec);
10102 if (err < 0)
10103 return err;
10104
Takashi Iwai776e1842007-08-29 15:07:11 +020010105 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010106}
10107
10108/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010109static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010110{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010111 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010112 alc882_auto_init_multi_out(codec);
10113 alc882_auto_init_hp_out(codec);
10114 alc882_auto_init_analog_input(codec);
10115 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010116 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010117 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010118}
10119
Takashi Iwai4953550a2009-06-30 15:28:30 +020010120static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010121{
10122 struct alc_spec *spec;
10123 int err, board_config;
10124
10125 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10126 if (spec == NULL)
10127 return -ENOMEM;
10128
10129 codec->spec = spec;
10130
Takashi Iwai4953550a2009-06-30 15:28:30 +020010131 switch (codec->vendor_id) {
10132 case 0x10ec0882:
10133 case 0x10ec0885:
10134 break;
10135 default:
10136 /* ALC883 and variants */
10137 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10138 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010139 }
10140
Takashi Iwai4953550a2009-06-30 15:28:30 +020010141 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10142 alc882_models,
10143 alc882_cfg_tbl);
10144
10145 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10146 board_config = snd_hda_check_board_codec_sid_config(codec,
10147 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10148
10149 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010150 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010151 codec->chip_name);
10152 board_config = ALC882_AUTO;
10153 }
10154
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010155 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010156
10157 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010158 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010159 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010160 if (err < 0) {
10161 alc_free(codec);
10162 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010163 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010164 printk(KERN_INFO
10165 "hda_codec: Cannot set up configuration "
10166 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010167 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010168 }
10169 }
10170
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010171 err = snd_hda_attach_beep_device(codec, 0x1);
10172 if (err < 0) {
10173 alc_free(codec);
10174 return err;
10175 }
10176
Takashi Iwai4953550a2009-06-30 15:28:30 +020010177 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010178 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010179
Takashi Iwai4953550a2009-06-30 15:28:30 +020010180 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10181 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10182 /* FIXME: setup DAC5 */
10183 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10184 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10185
10186 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10187 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10188
10189 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010190 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010191
10192 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010193 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010194 spec->num_adc_nids = 0;
10195 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010196 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010197 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010198 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010199 hda_nid_t nid = alc882_adc_nids[i];
10200 unsigned int wcap = get_wcaps(codec, nid);
10201 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010202 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010203 if (wcap != AC_WID_AUD_IN)
10204 continue;
10205 spec->private_adc_nids[spec->num_adc_nids] = nid;
10206 err = snd_hda_get_connections(codec, nid, &cap, 1);
10207 if (err < 0)
10208 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010209 err = snd_hda_get_connections(codec, cap, items,
10210 ARRAY_SIZE(items));
10211 if (err < 0)
10212 continue;
10213 for (j = 0; j < imux->num_items; j++)
10214 if (imux->items[j].index >= err)
10215 break;
10216 if (j < imux->num_items)
10217 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010218 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10219 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010220 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010221 spec->adc_nids = spec->private_adc_nids;
10222 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010223 }
10224
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010225 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010010226 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010227
Takashi Iwai2134ea42008-01-10 16:53:55 +010010228 spec->vmaster_nid = 0x0c;
10229
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010230 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010231 if (board_config == ALC882_AUTO)
10232 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010233#ifdef CONFIG_SND_HDA_POWER_SAVE
10234 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010235 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010236#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010237
10238 return 0;
10239}
10240
Takashi Iwai4953550a2009-06-30 15:28:30 +020010241
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010242/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010243 * ALC262 support
10244 */
10245
10246#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10247#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10248
10249#define alc262_dac_nids alc260_dac_nids
10250#define alc262_adc_nids alc882_adc_nids
10251#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010252#define alc262_capsrc_nids alc882_capsrc_nids
10253#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010254
10255#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010256#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010257
Kailang Yang4e555fe2008-08-26 13:05:55 +020010258static hda_nid_t alc262_dmic_adc_nids[1] = {
10259 /* ADC0 */
10260 0x09
10261};
10262
10263static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10264
Kailang Yangdf694da2005-12-05 19:42:22 +010010265static struct snd_kcontrol_new alc262_base_mixer[] = {
10266 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10267 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10268 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10269 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10270 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10271 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10272 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10273 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010274 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010275 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10276 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010277 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010278 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10279 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10280 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10281 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010282 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010283};
10284
Takashi Iwaice875f02008-01-28 18:17:43 +010010285/* update HP, line and mono-out pins according to the master switch */
10286static void alc262_hp_master_update(struct hda_codec *codec)
10287{
10288 struct alc_spec *spec = codec->spec;
10289 int val = spec->master_sw;
10290
10291 /* HP & line-out */
10292 snd_hda_codec_write_cache(codec, 0x1b, 0,
10293 AC_VERB_SET_PIN_WIDGET_CONTROL,
10294 val ? PIN_HP : 0);
10295 snd_hda_codec_write_cache(codec, 0x15, 0,
10296 AC_VERB_SET_PIN_WIDGET_CONTROL,
10297 val ? PIN_HP : 0);
10298 /* mono (speaker) depending on the HP jack sense */
10299 val = val && !spec->jack_present;
10300 snd_hda_codec_write_cache(codec, 0x16, 0,
10301 AC_VERB_SET_PIN_WIDGET_CONTROL,
10302 val ? PIN_OUT : 0);
10303}
10304
10305static void alc262_hp_bpc_automute(struct hda_codec *codec)
10306{
10307 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010308
10309 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010310 alc262_hp_master_update(codec);
10311}
10312
10313static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10314{
10315 if ((res >> 26) != ALC880_HP_EVENT)
10316 return;
10317 alc262_hp_bpc_automute(codec);
10318}
10319
10320static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10321{
10322 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010323
10324 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010325 alc262_hp_master_update(codec);
10326}
10327
10328static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10329 unsigned int res)
10330{
10331 if ((res >> 26) != ALC880_HP_EVENT)
10332 return;
10333 alc262_hp_wildwest_automute(codec);
10334}
10335
Takashi Iwaib72519b2009-05-08 14:31:55 +020010336#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010337
10338static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10339 struct snd_ctl_elem_value *ucontrol)
10340{
10341 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10342 struct alc_spec *spec = codec->spec;
10343 int val = !!*ucontrol->value.integer.value;
10344
10345 if (val == spec->master_sw)
10346 return 0;
10347 spec->master_sw = val;
10348 alc262_hp_master_update(codec);
10349 return 1;
10350}
10351
Takashi Iwaib72519b2009-05-08 14:31:55 +020010352#define ALC262_HP_MASTER_SWITCH \
10353 { \
10354 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10355 .name = "Master Playback Switch", \
10356 .info = snd_ctl_boolean_mono_info, \
10357 .get = alc262_hp_master_sw_get, \
10358 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010359 }, \
10360 { \
10361 .iface = NID_MAPPING, \
10362 .name = "Master Playback Switch", \
10363 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020010364 }
10365
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010366
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010367static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010368 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010369 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10370 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10371 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010372 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10373 HDA_OUTPUT),
10374 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10375 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010376 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10377 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010378 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010379 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10380 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010381 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010382 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10383 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10384 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10385 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010386 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10387 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10388 { } /* end */
10389};
10390
Kailang Yangcd7509a2007-01-26 18:33:17 +010010391static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010392 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010393 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10394 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10395 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10396 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010397 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10398 HDA_OUTPUT),
10399 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10400 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010401 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10402 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010403 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010404 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10405 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10406 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10407 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010408 { } /* end */
10409};
10410
10411static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10412 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10413 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010414 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010415 { } /* end */
10416};
10417
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010418/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010419static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010420{
10421 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010422
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010423 spec->autocfg.hp_pins[0] = 0x15;
10424 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010425}
10426
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010427static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010428 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10429 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010430 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10431 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10432 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10433 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10434 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10435 { } /* end */
10436};
10437
10438static struct hda_verb alc262_hp_t5735_verbs[] = {
10439 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10440 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10441
10442 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10443 { }
10444};
10445
Kailang Yang8c427222008-01-10 13:03:59 +010010446static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010447 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10448 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010449 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10450 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010451 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10452 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10453 { } /* end */
10454};
10455
10456static struct hda_verb alc262_hp_rp5700_verbs[] = {
10457 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10458 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10459 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10460 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10461 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10462 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10463 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10464 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10465 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10466 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10467 {}
10468};
10469
10470static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10471 .num_items = 1,
10472 .items = {
10473 { "Line", 0x1 },
10474 },
10475};
10476
Takashi Iwai42171c12009-05-08 14:11:43 +020010477/* bind hp and internal speaker mute (with plug check) as master switch */
10478static void alc262_hippo_master_update(struct hda_codec *codec)
10479{
10480 struct alc_spec *spec = codec->spec;
10481 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10482 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10483 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10484 unsigned int mute;
10485
10486 /* HP */
10487 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10488 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10489 HDA_AMP_MUTE, mute);
10490 /* mute internal speaker per jack sense */
10491 if (spec->jack_present)
10492 mute = HDA_AMP_MUTE;
10493 if (line_nid)
10494 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10495 HDA_AMP_MUTE, mute);
10496 if (speaker_nid && speaker_nid != line_nid)
10497 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10498 HDA_AMP_MUTE, mute);
10499}
10500
10501#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10502
10503static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10504 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010505{
10506 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010507 struct alc_spec *spec = codec->spec;
10508 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010509
Takashi Iwai42171c12009-05-08 14:11:43 +020010510 if (val == spec->master_sw)
10511 return 0;
10512 spec->master_sw = val;
10513 alc262_hippo_master_update(codec);
10514 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010515}
Takashi Iwai5b319542007-07-26 11:49:22 +020010516
Takashi Iwai42171c12009-05-08 14:11:43 +020010517#define ALC262_HIPPO_MASTER_SWITCH \
10518 { \
10519 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10520 .name = "Master Playback Switch", \
10521 .info = snd_ctl_boolean_mono_info, \
10522 .get = alc262_hippo_master_sw_get, \
10523 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010524 }, \
10525 { \
10526 .iface = NID_MAPPING, \
10527 .name = "Master Playback Switch", \
10528 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
10529 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020010530 }
10531
10532static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10533 ALC262_HIPPO_MASTER_SWITCH,
10534 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10535 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10536 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10537 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10538 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10539 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10540 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10541 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10542 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10543 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10544 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10545 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10546 { } /* end */
10547};
10548
10549static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10550 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10551 ALC262_HIPPO_MASTER_SWITCH,
10552 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10553 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10554 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10555 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10556 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10557 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10558 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10559 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10560 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10561 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10562 { } /* end */
10563};
10564
10565/* mute/unmute internal speaker according to the hp jack and mute state */
10566static void alc262_hippo_automute(struct hda_codec *codec)
10567{
10568 struct alc_spec *spec = codec->spec;
10569 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020010570
Wu Fengguang864f92b2009-11-18 12:38:02 +080010571 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020010572 alc262_hippo_master_update(codec);
10573}
10574
10575static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10576{
10577 if ((res >> 26) != ALC880_HP_EVENT)
10578 return;
10579 alc262_hippo_automute(codec);
10580}
10581
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010582static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010583{
10584 struct alc_spec *spec = codec->spec;
10585
10586 spec->autocfg.hp_pins[0] = 0x15;
10587 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010588}
10589
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010590static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010591{
10592 struct alc_spec *spec = codec->spec;
10593
10594 spec->autocfg.hp_pins[0] = 0x1b;
10595 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010596}
10597
10598
Kailang Yang272a5272007-05-14 11:00:38 +020010599static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010600 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010601 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010602 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10603 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10604 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10605 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10606 { } /* end */
10607};
10608
Kailang Yang83c34212007-07-05 11:43:05 +020010609static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010610 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10611 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010612 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10613 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10614 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10615 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10616 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10617 { } /* end */
10618};
Kailang Yang272a5272007-05-14 11:00:38 +020010619
Tony Vroonba340e82009-02-02 19:01:30 +000010620static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10621 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10622 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10623 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10624 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10625 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10626 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10627 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10628 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10629 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10630 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10631 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10632 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10633 { } /* end */
10634};
10635
10636static struct hda_verb alc262_tyan_verbs[] = {
10637 /* Headphone automute */
10638 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10639 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10640 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10641
10642 /* P11 AUX_IN, white 4-pin connector */
10643 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10644 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10645 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10646 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10647
10648 {}
10649};
10650
10651/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010652static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010653{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010654 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010655
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010656 spec->autocfg.hp_pins[0] = 0x1b;
10657 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010658}
10659
Tony Vroonba340e82009-02-02 19:01:30 +000010660
Kailang Yangdf694da2005-12-05 19:42:22 +010010661#define alc262_capture_mixer alc882_capture_mixer
10662#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10663
10664/*
10665 * generic initialization of ADC, input mixers and output mixers
10666 */
10667static struct hda_verb alc262_init_verbs[] = {
10668 /*
10669 * Unmute ADC0-2 and set the default input to mic-in
10670 */
10671 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10672 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10673 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10674 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10675 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10676 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10677
Takashi Iwaicb53c622007-08-10 17:21:45 +020010678 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010679 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010680 * Note: PASD motherboards uses the Line In 2 as the input for
10681 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010682 */
10683 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010684 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10685 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10686 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10687 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10688 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010689
10690 /*
10691 * Set up output mixers (0x0c - 0x0e)
10692 */
10693 /* set vol=0 to output mixers */
10694 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10695 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10696 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10697 /* set up input amps for analog loopback */
10698 /* Amp Indices: DAC = 0, mixer = 1 */
10699 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10700 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10701 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10702 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10703 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10704 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10705
10706 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10707 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10708 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10709 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10710 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10711 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10712
10713 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10714 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10715 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10716 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10717 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010718
Kailang Yangdf694da2005-12-05 19:42:22 +010010719 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10720 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010721
Kailang Yangdf694da2005-12-05 19:42:22 +010010722 /* FIXME: use matrix-type input source selection */
10723 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10724 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10725 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10726 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10727 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10728 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10729 /* Input mixer2 */
10730 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10731 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10732 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10733 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10734 /* Input mixer3 */
10735 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10736 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10737 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010738 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010739
10740 { }
10741};
10742
Kailang Yang4e555fe2008-08-26 13:05:55 +020010743static struct hda_verb alc262_eapd_verbs[] = {
10744 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10745 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10746 { }
10747};
10748
Kailang Yangccc656c2006-10-17 12:32:26 +020010749static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10750 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10751 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10752 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10753
10754 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10755 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10756 {}
10757};
10758
Kailang Yang272a5272007-05-14 11:00:38 +020010759static struct hda_verb alc262_sony_unsol_verbs[] = {
10760 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10761 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10762 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10763
10764 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10765 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010766 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010767};
10768
Kailang Yang4e555fe2008-08-26 13:05:55 +020010769static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10770 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10771 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10772 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10773 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10774 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010775 { } /* end */
10776};
10777
10778static struct hda_verb alc262_toshiba_s06_verbs[] = {
10779 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10780 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10781 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10782 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10783 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10784 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10785 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10786 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10787 {}
10788};
10789
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010790static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020010791{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010792 struct alc_spec *spec = codec->spec;
10793
10794 spec->autocfg.hp_pins[0] = 0x15;
10795 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010796 spec->ext_mic.pin = 0x18;
10797 spec->ext_mic.mux_idx = 0;
10798 spec->int_mic.pin = 0x12;
10799 spec->int_mic.mux_idx = 9;
10800 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020010801}
10802
Takashi Iwai834be882006-03-01 14:16:17 +010010803/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010804 * nec model
10805 * 0x15 = headphone
10806 * 0x16 = internal speaker
10807 * 0x18 = external mic
10808 */
10809
10810static struct snd_kcontrol_new alc262_nec_mixer[] = {
10811 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10812 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10813
10814 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10815 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10816 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10817
10818 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10819 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10820 { } /* end */
10821};
10822
10823static struct hda_verb alc262_nec_verbs[] = {
10824 /* Unmute Speaker */
10825 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10826
10827 /* Headphone */
10828 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10829 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10830
10831 /* External mic to headphone */
10832 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10833 /* External mic to speaker */
10834 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10835 {}
10836};
10837
10838/*
Takashi Iwai834be882006-03-01 14:16:17 +010010839 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010840 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10841 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010842 */
10843
10844#define ALC_HP_EVENT 0x37
10845
10846static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10847 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10848 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010849 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10850 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010851 {}
10852};
10853
Jiang zhe0e31daf2008-03-20 12:12:39 +010010854static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10855 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10856 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10857 {}
10858};
10859
Daniel T Chene2595322009-12-19 18:19:02 -050010860static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
10861 /* Front Mic pin: input vref at 50% */
10862 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10863 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10864 {}
10865};
10866
Takashi Iwai834be882006-03-01 14:16:17 +010010867static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010868 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010869 .items = {
10870 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010871 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010872 { "CD", 0x4 },
10873 },
10874};
10875
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010876static struct hda_input_mux alc262_HP_capture_source = {
10877 .num_items = 5,
10878 .items = {
10879 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010880 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010881 { "Line", 0x2 },
10882 { "CD", 0x4 },
10883 { "AUX IN", 0x6 },
10884 },
10885};
10886
zhejiangaccbe492007-08-31 12:36:05 +020010887static struct hda_input_mux alc262_HP_D7000_capture_source = {
10888 .num_items = 4,
10889 .items = {
10890 { "Mic", 0x0 },
10891 { "Front Mic", 0x2 },
10892 { "Line", 0x1 },
10893 { "CD", 0x4 },
10894 },
10895};
10896
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010897/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010898static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10899{
10900 struct alc_spec *spec = codec->spec;
10901 unsigned int mute;
10902
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010903 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080010904 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
10905 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010010906 spec->sense_updated = 1;
10907 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010908 /* unmute internal speaker only if both HPs are unplugged and
10909 * master switch is on
10910 */
10911 if (spec->jack_present)
10912 mute = HDA_AMP_MUTE;
10913 else
Takashi Iwai834be882006-03-01 14:16:17 +010010914 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010915 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10916 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010917}
10918
10919/* unsolicited event for HP jack sensing */
10920static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10921 unsigned int res)
10922{
10923 if ((res >> 26) != ALC_HP_EVENT)
10924 return;
10925 alc262_fujitsu_automute(codec, 1);
10926}
10927
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010928static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10929{
10930 alc262_fujitsu_automute(codec, 1);
10931}
10932
Takashi Iwai834be882006-03-01 14:16:17 +010010933/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010934static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10935 .ops = &snd_hda_bind_vol,
10936 .values = {
10937 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10938 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10939 0
10940 },
10941};
Takashi Iwai834be882006-03-01 14:16:17 +010010942
Jiang zhe0e31daf2008-03-20 12:12:39 +010010943/* mute/unmute internal speaker according to the hp jack and mute state */
10944static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10945{
10946 struct alc_spec *spec = codec->spec;
10947 unsigned int mute;
10948
10949 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080010950 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010951 spec->sense_updated = 1;
10952 }
10953 if (spec->jack_present) {
10954 /* mute internal speaker */
10955 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10956 HDA_AMP_MUTE, HDA_AMP_MUTE);
10957 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10958 HDA_AMP_MUTE, HDA_AMP_MUTE);
10959 } else {
10960 /* unmute internal speaker if necessary */
10961 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10962 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10963 HDA_AMP_MUTE, mute);
10964 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10965 HDA_AMP_MUTE, mute);
10966 }
10967}
10968
10969/* unsolicited event for HP jack sensing */
10970static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10971 unsigned int res)
10972{
10973 if ((res >> 26) != ALC_HP_EVENT)
10974 return;
10975 alc262_lenovo_3000_automute(codec, 1);
10976}
10977
Takashi Iwai8de56b72009-07-24 16:51:47 +020010978static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10979 int dir, int idx, long *valp)
10980{
10981 int i, change = 0;
10982
10983 for (i = 0; i < 2; i++, valp++)
10984 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10985 HDA_AMP_MUTE,
10986 *valp ? 0 : HDA_AMP_MUTE);
10987 return change;
10988}
10989
Takashi Iwai834be882006-03-01 14:16:17 +010010990/* bind hp and internal speaker mute (with plug check) */
10991static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10992 struct snd_ctl_elem_value *ucontrol)
10993{
10994 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10995 long *valp = ucontrol->value.integer.value;
10996 int change;
10997
Takashi Iwai8de56b72009-07-24 16:51:47 +020010998 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10999 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011000 if (change)
11001 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011002 return change;
11003}
11004
11005static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011006 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011007 {
11008 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11009 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011010 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011011 .info = snd_hda_mixer_amp_switch_info,
11012 .get = snd_hda_mixer_amp_switch_get,
11013 .put = alc262_fujitsu_master_sw_put,
11014 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11015 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011016 {
11017 .iface = NID_MAPPING,
11018 .name = "Master Playback Switch",
11019 .private_value = 0x1b,
11020 },
Takashi Iwai834be882006-03-01 14:16:17 +010011021 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11022 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11023 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11024 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11025 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011026 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11027 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11028 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011029 { } /* end */
11030};
11031
Jiang zhe0e31daf2008-03-20 12:12:39 +010011032/* bind hp and internal speaker mute (with plug check) */
11033static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11034 struct snd_ctl_elem_value *ucontrol)
11035{
11036 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11037 long *valp = ucontrol->value.integer.value;
11038 int change;
11039
Takashi Iwai8de56b72009-07-24 16:51:47 +020011040 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011041 if (change)
11042 alc262_lenovo_3000_automute(codec, 0);
11043 return change;
11044}
11045
11046static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11047 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11048 {
11049 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11050 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011051 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011052 .info = snd_hda_mixer_amp_switch_info,
11053 .get = snd_hda_mixer_amp_switch_get,
11054 .put = alc262_lenovo_3000_master_sw_put,
11055 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11056 },
11057 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11058 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11059 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11060 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11061 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11062 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11063 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11064 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11065 { } /* end */
11066};
11067
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011068static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11069 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011070 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011071 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11072 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11073 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11074 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11075 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11076 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11077 { } /* end */
11078};
11079
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011080/* additional init verbs for Benq laptops */
11081static struct hda_verb alc262_EAPD_verbs[] = {
11082 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11083 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11084 {}
11085};
11086
Kailang Yang83c34212007-07-05 11:43:05 +020011087static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11088 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11089 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11090
11091 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11092 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11093 {}
11094};
11095
Tobin Davisf651b502007-10-26 12:40:47 +020011096/* Samsung Q1 Ultra Vista model setup */
11097static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011098 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11099 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011100 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11101 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11102 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011103 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011104 { } /* end */
11105};
11106
11107static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011108 /* output mixer */
11109 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11110 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11111 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11112 /* speaker */
11113 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11114 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11115 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11116 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11117 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011118 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011119 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11120 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11121 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11122 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11123 /* internal mic */
11124 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11125 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11126 /* ADC, choose mic */
11127 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11128 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11129 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11130 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11131 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11132 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11133 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11134 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11135 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11136 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011137 {}
11138};
11139
Tobin Davisf651b502007-10-26 12:40:47 +020011140/* mute/unmute internal speaker according to the hp jack and mute state */
11141static void alc262_ultra_automute(struct hda_codec *codec)
11142{
11143 struct alc_spec *spec = codec->spec;
11144 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011145
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011146 mute = 0;
11147 /* auto-mute only when HP is used as HP */
11148 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011149 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011150 if (spec->jack_present)
11151 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011152 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011153 /* mute/unmute internal speaker */
11154 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11155 HDA_AMP_MUTE, mute);
11156 /* mute/unmute HP */
11157 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11158 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011159}
11160
11161/* unsolicited event for HP jack sensing */
11162static void alc262_ultra_unsol_event(struct hda_codec *codec,
11163 unsigned int res)
11164{
11165 if ((res >> 26) != ALC880_HP_EVENT)
11166 return;
11167 alc262_ultra_automute(codec);
11168}
11169
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011170static struct hda_input_mux alc262_ultra_capture_source = {
11171 .num_items = 2,
11172 .items = {
11173 { "Mic", 0x1 },
11174 { "Headphone", 0x7 },
11175 },
11176};
11177
11178static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11179 struct snd_ctl_elem_value *ucontrol)
11180{
11181 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11182 struct alc_spec *spec = codec->spec;
11183 int ret;
11184
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011185 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011186 if (!ret)
11187 return 0;
11188 /* reprogram the HP pin as mic or HP according to the input source */
11189 snd_hda_codec_write_cache(codec, 0x15, 0,
11190 AC_VERB_SET_PIN_WIDGET_CONTROL,
11191 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11192 alc262_ultra_automute(codec); /* mute/unmute HP */
11193 return ret;
11194}
11195
11196static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11197 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11198 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11199 {
11200 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11201 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011202 .info = alc_mux_enum_info,
11203 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011204 .put = alc262_ultra_mux_enum_put,
11205 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011206 {
11207 .iface = NID_MAPPING,
11208 .name = "Capture Source",
11209 .private_value = 0x15,
11210 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011211 { } /* end */
11212};
11213
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011214/* We use two mixers depending on the output pin; 0x16 is a mono output
11215 * and thus it's bound with a different mixer.
11216 * This function returns which mixer amp should be used.
11217 */
11218static int alc262_check_volbit(hda_nid_t nid)
11219{
11220 if (!nid)
11221 return 0;
11222 else if (nid == 0x16)
11223 return 2;
11224 else
11225 return 1;
11226}
11227
11228static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
11229 const char *pfx, int *vbits)
11230{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011231 unsigned long val;
11232 int vbit;
11233
11234 vbit = alc262_check_volbit(nid);
11235 if (!vbit)
11236 return 0;
11237 if (*vbits & vbit) /* a volume control for this mixer already there */
11238 return 0;
11239 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011240 if (vbit == 2)
11241 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11242 else
11243 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011244 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011245}
11246
11247static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
11248 const char *pfx)
11249{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011250 unsigned long val;
11251
11252 if (!nid)
11253 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011254 if (nid == 0x16)
11255 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11256 else
11257 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011258 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011259}
11260
Kailang Yangdf694da2005-12-05 19:42:22 +010011261/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011262static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11263 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011264{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011265 const char *pfx;
11266 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010011267 int err;
11268
11269 spec->multiout.num_dacs = 1; /* only use one dac */
11270 spec->multiout.dac_nids = spec->private_dac_nids;
11271 spec->multiout.dac_nids[0] = 2;
11272
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011273 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11274 pfx = "Master";
11275 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11276 pfx = "Speaker";
11277 else
11278 pfx = "Front";
11279 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11280 if (err < 0)
11281 return err;
11282 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11283 if (err < 0)
11284 return err;
11285 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11286 if (err < 0)
11287 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011288
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011289 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11290 alc262_check_volbit(cfg->speaker_pins[0]) |
11291 alc262_check_volbit(cfg->hp_pins[0]);
11292 if (vbits == 1 || vbits == 2)
11293 pfx = "Master"; /* only one mixer is used */
11294 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11295 pfx = "Speaker";
11296 else
11297 pfx = "Front";
11298 vbits = 0;
11299 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11300 if (err < 0)
11301 return err;
11302 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11303 &vbits);
11304 if (err < 0)
11305 return err;
11306 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11307 &vbits);
11308 if (err < 0)
11309 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011310 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011311}
11312
Takashi Iwai05f5f472009-08-25 13:10:18 +020011313#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010011314 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011315
11316/*
11317 * generic initialization of ADC, input mixers and output mixers
11318 */
11319static struct hda_verb alc262_volume_init_verbs[] = {
11320 /*
11321 * Unmute ADC0-2 and set the default input to mic-in
11322 */
11323 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11324 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11325 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11326 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11327 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11328 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11329
Takashi Iwaicb53c622007-08-10 17:21:45 +020011330 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011331 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011332 * Note: PASD motherboards uses the Line In 2 as the input for
11333 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011334 */
11335 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011336 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11337 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11338 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11339 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11340 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011341
11342 /*
11343 * Set up output mixers (0x0c - 0x0f)
11344 */
11345 /* set vol=0 to output mixers */
11346 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11347 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011349
Kailang Yangdf694da2005-12-05 19:42:22 +010011350 /* set up input amps for analog loopback */
11351 /* Amp Indices: DAC = 0, mixer = 1 */
11352 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11353 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11354 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11355 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11356 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11357 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11358
11359 /* FIXME: use matrix-type input source selection */
11360 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11361 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11362 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11363 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11364 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11365 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11366 /* Input mixer2 */
11367 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11368 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11369 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11370 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11371 /* Input mixer3 */
11372 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11373 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11374 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11375 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11376
11377 { }
11378};
11379
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011380static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11381 /*
11382 * Unmute ADC0-2 and set the default input to mic-in
11383 */
11384 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11385 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11386 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11387 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11388 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11389 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11390
Takashi Iwaicb53c622007-08-10 17:21:45 +020011391 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011392 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011393 * Note: PASD motherboards uses the Line In 2 as the input for
11394 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011395 */
11396 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011397 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11398 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11399 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11400 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11401 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11402 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11403 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011404
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011405 /*
11406 * Set up output mixers (0x0c - 0x0e)
11407 */
11408 /* set vol=0 to output mixers */
11409 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11410 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11411 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11412
11413 /* set up input amps for analog loopback */
11414 /* Amp Indices: DAC = 0, mixer = 1 */
11415 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11416 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11417 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11418 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11419 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11420 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11421
Takashi Iwaice875f02008-01-28 18:17:43 +010011422 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011423 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11424 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11425
11426 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11427 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11428
11429 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11430 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11431
11432 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11433 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11434 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11435 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11436 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11437
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011438 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011439 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11440 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011441 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011442 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11443 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11444
11445
11446 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011447 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11448 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011449 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011450 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11451 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11452 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11453 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11454 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11455 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11456 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11457 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011458 /* Input mixer2 */
11459 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011460 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11461 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11462 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11463 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11464 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11465 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11466 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11467 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011468 /* Input mixer3 */
11469 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011470 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11471 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11472 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11473 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11474 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11475 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11476 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11477 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011478
Takashi Iwaice875f02008-01-28 18:17:43 +010011479 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11480
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011481 { }
11482};
11483
Kailang Yangcd7509a2007-01-26 18:33:17 +010011484static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11485 /*
11486 * Unmute ADC0-2 and set the default input to mic-in
11487 */
11488 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11489 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11490 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11491 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11492 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11493 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11494
Takashi Iwaicb53c622007-08-10 17:21:45 +020011495 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011496 * mixer widget
11497 * Note: PASD motherboards uses the Line In 2 as the input for front
11498 * panel mic (mic 2)
11499 */
11500 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011501 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11502 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11503 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11504 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11505 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11506 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11507 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11508 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011509 /*
11510 * Set up output mixers (0x0c - 0x0e)
11511 */
11512 /* set vol=0 to output mixers */
11513 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11514 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11515 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11516
11517 /* set up input amps for analog loopback */
11518 /* Amp Indices: DAC = 0, mixer = 1 */
11519 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11520 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11521 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11522 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11523 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11524 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11525
11526
11527 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11528 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11529 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11530 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11531 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11532 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11533 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11534
11535 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11536 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11537
11538 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11539 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11540
11541 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11542 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11543 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11544 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11545 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11546 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11547
11548 /* FIXME: use matrix-type input source selection */
11549 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11550 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11551 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11552 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11553 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11554 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11555 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11556 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11557 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11558 /* Input mixer2 */
11559 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11560 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11561 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11562 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11563 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11564 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11565 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11566 /* Input mixer3 */
11567 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11568 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11569 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11570 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11571 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11572 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11573 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11574
Takashi Iwaice875f02008-01-28 18:17:43 +010011575 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11576
Kailang Yangcd7509a2007-01-26 18:33:17 +010011577 { }
11578};
11579
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011580static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11581
11582 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11583 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11584 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11585
11586 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11587 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11588 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11589 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11590
11591 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11592 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11593 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11594 {}
11595};
11596
11597
Takashi Iwaicb53c622007-08-10 17:21:45 +020011598#ifdef CONFIG_SND_HDA_POWER_SAVE
11599#define alc262_loopbacks alc880_loopbacks
11600#endif
11601
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011602/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011603#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11604#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11605#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11606#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11607
11608/*
11609 * BIOS auto configuration
11610 */
11611static int alc262_parse_auto_config(struct hda_codec *codec)
11612{
11613 struct alc_spec *spec = codec->spec;
11614 int err;
11615 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11616
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011617 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11618 alc262_ignore);
11619 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011620 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011621 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011622 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011623 spec->multiout.max_channels = 2;
11624 spec->no_analog = 1;
11625 goto dig_only;
11626 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011627 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011628 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011629 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11630 if (err < 0)
11631 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011632 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011633 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011634 return err;
11635
11636 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11637
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011638 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011639 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011640 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011641 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011642 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011643 if (spec->autocfg.dig_in_pin)
11644 spec->dig_in_nid = ALC262_DIGIN_NID;
11645
Takashi Iwai603c4012008-07-30 15:01:44 +020011646 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011647 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011648
Takashi Iwaid88897e2008-10-31 15:01:37 +010011649 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011650 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011651 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011652
Takashi Iwai776e1842007-08-29 15:07:11 +020011653 err = alc_auto_add_mic_boost(codec);
11654 if (err < 0)
11655 return err;
11656
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011657 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11658
Kailang Yangdf694da2005-12-05 19:42:22 +010011659 return 1;
11660}
11661
11662#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11663#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11664#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011665#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011666
11667
11668/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011669static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011670{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011671 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011672 alc262_auto_init_multi_out(codec);
11673 alc262_auto_init_hp_out(codec);
11674 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011675 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011676 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011677 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011678}
11679
11680/*
11681 * configuration and preset
11682 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011683static const char *alc262_models[ALC262_MODEL_LAST] = {
11684 [ALC262_BASIC] = "basic",
11685 [ALC262_HIPPO] = "hippo",
11686 [ALC262_HIPPO_1] = "hippo_1",
11687 [ALC262_FUJITSU] = "fujitsu",
11688 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011689 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011690 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011691 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011692 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011693 [ALC262_BENQ_T31] = "benq-t31",
11694 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011695 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011696 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011697 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011698 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011699 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011700 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011701 [ALC262_AUTO] = "auto",
11702};
11703
11704static struct snd_pci_quirk alc262_cfg_tbl[] = {
11705 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011706 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011707 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11708 ALC262_HP_BPC),
11709 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11710 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011711 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11712 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011713 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011714 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011715 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011716 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011717 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011718 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011719 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011720 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011721 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11722 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11723 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011724 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11725 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011726 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011727 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011728 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011729 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011730 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011731 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050011732 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010011733 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011734#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010011735 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11736 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011737#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090011738 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011739 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011740 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011741 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011742 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011743 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011744 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11745 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011746 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011747 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011748 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011749 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011750 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011751 {}
11752};
11753
11754static struct alc_config_preset alc262_presets[] = {
11755 [ALC262_BASIC] = {
11756 .mixers = { alc262_base_mixer },
11757 .init_verbs = { alc262_init_verbs },
11758 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11759 .dac_nids = alc262_dac_nids,
11760 .hp_nid = 0x03,
11761 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11762 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011763 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011764 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011765 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011766 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011767 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011768 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11769 .dac_nids = alc262_dac_nids,
11770 .hp_nid = 0x03,
11771 .dig_out_nid = ALC262_DIGOUT_NID,
11772 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11773 .channel_mode = alc262_modes,
11774 .input_mux = &alc262_capture_source,
11775 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011776 .setup = alc262_hippo_setup,
11777 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011778 },
11779 [ALC262_HIPPO_1] = {
11780 .mixers = { alc262_hippo1_mixer },
11781 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11782 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11783 .dac_nids = alc262_dac_nids,
11784 .hp_nid = 0x02,
11785 .dig_out_nid = ALC262_DIGOUT_NID,
11786 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11787 .channel_mode = alc262_modes,
11788 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011789 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011790 .setup = alc262_hippo1_setup,
11791 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011792 },
Takashi Iwai834be882006-03-01 14:16:17 +010011793 [ALC262_FUJITSU] = {
11794 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011795 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11796 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011797 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11798 .dac_nids = alc262_dac_nids,
11799 .hp_nid = 0x03,
11800 .dig_out_nid = ALC262_DIGOUT_NID,
11801 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11802 .channel_mode = alc262_modes,
11803 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011804 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011805 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011806 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011807 [ALC262_HP_BPC] = {
11808 .mixers = { alc262_HP_BPC_mixer },
11809 .init_verbs = { alc262_HP_BPC_init_verbs },
11810 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11811 .dac_nids = alc262_dac_nids,
11812 .hp_nid = 0x03,
11813 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11814 .channel_mode = alc262_modes,
11815 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011816 .unsol_event = alc262_hp_bpc_unsol_event,
11817 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011818 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011819 [ALC262_HP_BPC_D7000_WF] = {
11820 .mixers = { alc262_HP_BPC_WildWest_mixer },
11821 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11822 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11823 .dac_nids = alc262_dac_nids,
11824 .hp_nid = 0x03,
11825 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11826 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011827 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011828 .unsol_event = alc262_hp_wildwest_unsol_event,
11829 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011830 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011831 [ALC262_HP_BPC_D7000_WL] = {
11832 .mixers = { alc262_HP_BPC_WildWest_mixer,
11833 alc262_HP_BPC_WildWest_option_mixer },
11834 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11835 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11836 .dac_nids = alc262_dac_nids,
11837 .hp_nid = 0x03,
11838 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11839 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011840 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011841 .unsol_event = alc262_hp_wildwest_unsol_event,
11842 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011843 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011844 [ALC262_HP_TC_T5735] = {
11845 .mixers = { alc262_hp_t5735_mixer },
11846 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11847 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11848 .dac_nids = alc262_dac_nids,
11849 .hp_nid = 0x03,
11850 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11851 .channel_mode = alc262_modes,
11852 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011853 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011854 .setup = alc262_hp_t5735_setup,
11855 .init_hook = alc_automute_amp,
Kailang Yang8c427222008-01-10 13:03:59 +010011856 },
11857 [ALC262_HP_RP5700] = {
11858 .mixers = { alc262_hp_rp5700_mixer },
11859 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11860 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11861 .dac_nids = alc262_dac_nids,
11862 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11863 .channel_mode = alc262_modes,
11864 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011865 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011866 [ALC262_BENQ_ED8] = {
11867 .mixers = { alc262_base_mixer },
11868 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11869 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11870 .dac_nids = alc262_dac_nids,
11871 .hp_nid = 0x03,
11872 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11873 .channel_mode = alc262_modes,
11874 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011875 },
Kailang Yang272a5272007-05-14 11:00:38 +020011876 [ALC262_SONY_ASSAMD] = {
11877 .mixers = { alc262_sony_mixer },
11878 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11879 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11880 .dac_nids = alc262_dac_nids,
11881 .hp_nid = 0x02,
11882 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11883 .channel_mode = alc262_modes,
11884 .input_mux = &alc262_capture_source,
11885 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011886 .setup = alc262_hippo_setup,
11887 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020011888 },
11889 [ALC262_BENQ_T31] = {
11890 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011891 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
11892 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020011893 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11894 .dac_nids = alc262_dac_nids,
11895 .hp_nid = 0x03,
11896 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11897 .channel_mode = alc262_modes,
11898 .input_mux = &alc262_capture_source,
11899 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011900 .setup = alc262_hippo_setup,
11901 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020011902 },
Tobin Davisf651b502007-10-26 12:40:47 +020011903 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011904 .mixers = { alc262_ultra_mixer },
11905 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011906 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011907 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11908 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011909 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11910 .channel_mode = alc262_modes,
11911 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011912 .adc_nids = alc262_adc_nids, /* ADC0 */
11913 .capsrc_nids = alc262_capsrc_nids,
11914 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011915 .unsol_event = alc262_ultra_unsol_event,
11916 .init_hook = alc262_ultra_automute,
11917 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011918 [ALC262_LENOVO_3000] = {
11919 .mixers = { alc262_lenovo_3000_mixer },
11920 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050011921 alc262_lenovo_3000_unsol_verbs,
11922 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011923 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11924 .dac_nids = alc262_dac_nids,
11925 .hp_nid = 0x03,
11926 .dig_out_nid = ALC262_DIGOUT_NID,
11927 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11928 .channel_mode = alc262_modes,
11929 .input_mux = &alc262_fujitsu_capture_source,
11930 .unsol_event = alc262_lenovo_3000_unsol_event,
11931 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011932 [ALC262_NEC] = {
11933 .mixers = { alc262_nec_mixer },
11934 .init_verbs = { alc262_nec_verbs },
11935 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11936 .dac_nids = alc262_dac_nids,
11937 .hp_nid = 0x03,
11938 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11939 .channel_mode = alc262_modes,
11940 .input_mux = &alc262_capture_source,
11941 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011942 [ALC262_TOSHIBA_S06] = {
11943 .mixers = { alc262_toshiba_s06_mixer },
11944 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11945 alc262_eapd_verbs },
11946 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11947 .capsrc_nids = alc262_dmic_capsrc_nids,
11948 .dac_nids = alc262_dac_nids,
11949 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011950 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011951 .dig_out_nid = ALC262_DIGOUT_NID,
11952 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11953 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011954 .unsol_event = alc_sku_unsol_event,
11955 .setup = alc262_toshiba_s06_setup,
11956 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020011957 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011958 [ALC262_TOSHIBA_RX1] = {
11959 .mixers = { alc262_toshiba_rx1_mixer },
11960 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11961 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11962 .dac_nids = alc262_dac_nids,
11963 .hp_nid = 0x03,
11964 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11965 .channel_mode = alc262_modes,
11966 .input_mux = &alc262_capture_source,
11967 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011968 .setup = alc262_hippo_setup,
11969 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011970 },
Tony Vroonba340e82009-02-02 19:01:30 +000011971 [ALC262_TYAN] = {
11972 .mixers = { alc262_tyan_mixer },
11973 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11974 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11975 .dac_nids = alc262_dac_nids,
11976 .hp_nid = 0x02,
11977 .dig_out_nid = ALC262_DIGOUT_NID,
11978 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11979 .channel_mode = alc262_modes,
11980 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011981 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011982 .setup = alc262_tyan_setup,
11983 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000011984 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011985};
11986
11987static int patch_alc262(struct hda_codec *codec)
11988{
11989 struct alc_spec *spec;
11990 int board_config;
11991 int err;
11992
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011993 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011994 if (spec == NULL)
11995 return -ENOMEM;
11996
11997 codec->spec = spec;
11998#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011999 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12000 * under-run
12001 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012002 {
12003 int tmp;
12004 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12005 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12006 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12007 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12008 }
12009#endif
12010
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012011 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12012
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012013 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12014 alc262_models,
12015 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012016
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012017 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012018 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12019 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012020 board_config = ALC262_AUTO;
12021 }
12022
12023 if (board_config == ALC262_AUTO) {
12024 /* automatic parse from the BIOS config */
12025 err = alc262_parse_auto_config(codec);
12026 if (err < 0) {
12027 alc_free(codec);
12028 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012029 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012030 printk(KERN_INFO
12031 "hda_codec: Cannot set up configuration "
12032 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012033 board_config = ALC262_BASIC;
12034 }
12035 }
12036
Takashi Iwai07eba612009-02-19 08:06:35 +010012037 if (!spec->no_analog) {
12038 err = snd_hda_attach_beep_device(codec, 0x1);
12039 if (err < 0) {
12040 alc_free(codec);
12041 return err;
12042 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012043 }
12044
Kailang Yangdf694da2005-12-05 19:42:22 +010012045 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012046 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012047
Kailang Yangdf694da2005-12-05 19:42:22 +010012048 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12049 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012050
Kailang Yangdf694da2005-12-05 19:42:22 +010012051 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12052 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12053
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012054 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012055 int i;
12056 /* check whether the digital-mic has to be supported */
12057 for (i = 0; i < spec->input_mux->num_items; i++) {
12058 if (spec->input_mux->items[i].index >= 9)
12059 break;
12060 }
12061 if (i < spec->input_mux->num_items) {
12062 /* use only ADC0 */
12063 spec->adc_nids = alc262_dmic_adc_nids;
12064 spec->num_adc_nids = 1;
12065 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012066 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012067 /* all analog inputs */
12068 /* check whether NID 0x07 is valid */
12069 unsigned int wcap = get_wcaps(codec, 0x07);
12070
12071 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012072 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012073 if (wcap != AC_WID_AUD_IN) {
12074 spec->adc_nids = alc262_adc_nids_alt;
12075 spec->num_adc_nids =
12076 ARRAY_SIZE(alc262_adc_nids_alt);
12077 spec->capsrc_nids = alc262_capsrc_nids_alt;
12078 } else {
12079 spec->adc_nids = alc262_adc_nids;
12080 spec->num_adc_nids =
12081 ARRAY_SIZE(alc262_adc_nids);
12082 spec->capsrc_nids = alc262_capsrc_nids;
12083 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012084 }
12085 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012086 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012087 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010012088 if (!spec->no_analog)
12089 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012090
Takashi Iwai2134ea42008-01-10 16:53:55 +010012091 spec->vmaster_nid = 0x0c;
12092
Kailang Yangdf694da2005-12-05 19:42:22 +010012093 codec->patch_ops = alc_patch_ops;
12094 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012095 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012096#ifdef CONFIG_SND_HDA_POWER_SAVE
12097 if (!spec->loopback.amplist)
12098 spec->loopback.amplist = alc262_loopbacks;
12099#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012100
Kailang Yangdf694da2005-12-05 19:42:22 +010012101 return 0;
12102}
12103
Kailang Yangdf694da2005-12-05 19:42:22 +010012104/*
Kailang Yanga361d842007-06-05 12:30:55 +020012105 * ALC268 channel source setting (2 channel)
12106 */
12107#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12108#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012109
Kailang Yanga361d842007-06-05 12:30:55 +020012110static hda_nid_t alc268_dac_nids[2] = {
12111 /* front, hp */
12112 0x02, 0x03
12113};
12114
12115static hda_nid_t alc268_adc_nids[2] = {
12116 /* ADC0-1 */
12117 0x08, 0x07
12118};
12119
12120static hda_nid_t alc268_adc_nids_alt[1] = {
12121 /* ADC0 */
12122 0x08
12123};
12124
Takashi Iwaie1406342008-02-11 18:32:32 +010012125static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12126
Kailang Yanga361d842007-06-05 12:30:55 +020012127static struct snd_kcontrol_new alc268_base_mixer[] = {
12128 /* output mixer control */
12129 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12130 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12131 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12132 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012133 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12134 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12135 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012136 { }
12137};
12138
Takashi Iwai42171c12009-05-08 14:11:43 +020012139static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12140 /* output mixer control */
12141 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12142 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12143 ALC262_HIPPO_MASTER_SWITCH,
12144 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12145 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12146 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12147 { }
12148};
12149
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012150/* bind Beep switches of both NID 0x0f and 0x10 */
12151static struct hda_bind_ctls alc268_bind_beep_sw = {
12152 .ops = &snd_hda_bind_sw,
12153 .values = {
12154 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12155 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12156 0
12157 },
12158};
12159
12160static struct snd_kcontrol_new alc268_beep_mixer[] = {
12161 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12162 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12163 { }
12164};
12165
Kailang Yangd1a991a2007-08-15 16:21:59 +020012166static struct hda_verb alc268_eapd_verbs[] = {
12167 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12168 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12169 { }
12170};
12171
Takashi Iwaid2738092007-08-16 14:59:45 +020012172/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012173static struct hda_verb alc268_toshiba_verbs[] = {
12174 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12175 { } /* end */
12176};
12177
12178/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012179/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012180static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12181 .ops = &snd_hda_bind_vol,
12182 .values = {
12183 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12184 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12185 0
12186 },
12187};
12188
Takashi Iwai889c4392007-08-23 18:56:52 +020012189/* mute/unmute internal speaker according to the hp jack and mute state */
12190static void alc268_acer_automute(struct hda_codec *codec, int force)
12191{
12192 struct alc_spec *spec = codec->spec;
12193 unsigned int mute;
12194
12195 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012196 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012197 spec->sense_updated = 1;
12198 }
12199 if (spec->jack_present)
12200 mute = HDA_AMP_MUTE; /* mute internal speaker */
12201 else /* unmute internal speaker if necessary */
12202 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12203 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12204 HDA_AMP_MUTE, mute);
12205}
12206
12207
12208/* bind hp and internal speaker mute (with plug check) */
12209static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12210 struct snd_ctl_elem_value *ucontrol)
12211{
12212 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12213 long *valp = ucontrol->value.integer.value;
12214 int change;
12215
Takashi Iwai8de56b72009-07-24 16:51:47 +020012216 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012217 if (change)
12218 alc268_acer_automute(codec, 0);
12219 return change;
12220}
Takashi Iwaid2738092007-08-16 14:59:45 +020012221
Kailang Yang8ef355d2008-08-26 13:10:22 +020012222static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12223 /* output mixer control */
12224 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12225 {
12226 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12227 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012228 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012229 .info = snd_hda_mixer_amp_switch_info,
12230 .get = snd_hda_mixer_amp_switch_get,
12231 .put = alc268_acer_master_sw_put,
12232 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12233 },
12234 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12235 { }
12236};
12237
Takashi Iwaid2738092007-08-16 14:59:45 +020012238static struct snd_kcontrol_new alc268_acer_mixer[] = {
12239 /* output mixer control */
12240 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12241 {
12242 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12243 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012244 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020012245 .info = snd_hda_mixer_amp_switch_info,
12246 .get = snd_hda_mixer_amp_switch_get,
12247 .put = alc268_acer_master_sw_put,
12248 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12249 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012250 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12251 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12252 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012253 { }
12254};
12255
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012256static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12257 /* output mixer control */
12258 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12259 {
12260 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12261 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012262 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012263 .info = snd_hda_mixer_amp_switch_info,
12264 .get = snd_hda_mixer_amp_switch_get,
12265 .put = alc268_acer_master_sw_put,
12266 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12267 },
12268 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12269 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12270 { }
12271};
12272
Kailang Yang8ef355d2008-08-26 13:10:22 +020012273static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12274 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12275 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12276 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12277 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12278 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12279 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12280 { }
12281};
12282
Takashi Iwaid2738092007-08-16 14:59:45 +020012283static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012284 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12285 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012286 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12287 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012288 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12289 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012290 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12291 { }
12292};
12293
12294/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012295#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012296#define alc268_toshiba_setup alc262_hippo_setup
12297#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012298
12299static void alc268_acer_unsol_event(struct hda_codec *codec,
12300 unsigned int res)
12301{
Takashi Iwai889c4392007-08-23 18:56:52 +020012302 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012303 return;
12304 alc268_acer_automute(codec, 1);
12305}
12306
Takashi Iwai889c4392007-08-23 18:56:52 +020012307static void alc268_acer_init_hook(struct hda_codec *codec)
12308{
12309 alc268_acer_automute(codec, 1);
12310}
12311
Kailang Yang8ef355d2008-08-26 13:10:22 +020012312/* toggle speaker-output according to the hp-jack state */
12313static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12314{
12315 unsigned int present;
12316 unsigned char bits;
12317
Wu Fengguang864f92b2009-11-18 12:38:02 +080012318 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012319 bits = present ? AMP_IN_MUTE(0) : 0;
12320 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
12321 AMP_IN_MUTE(0), bits);
12322 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
12323 AMP_IN_MUTE(0), bits);
12324}
12325
Kailang Yang8ef355d2008-08-26 13:10:22 +020012326static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12327 unsigned int res)
12328{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012329 switch (res >> 26) {
12330 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012331 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012332 break;
12333 case ALC880_MIC_EVENT:
12334 alc_mic_automute(codec);
12335 break;
12336 }
12337}
12338
12339static void alc268_acer_lc_setup(struct hda_codec *codec)
12340{
12341 struct alc_spec *spec = codec->spec;
12342 spec->ext_mic.pin = 0x18;
12343 spec->ext_mic.mux_idx = 0;
12344 spec->int_mic.pin = 0x12;
12345 spec->int_mic.mux_idx = 6;
12346 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012347}
12348
12349static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12350{
12351 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012352 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012353}
12354
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012355static struct snd_kcontrol_new alc268_dell_mixer[] = {
12356 /* output mixer control */
12357 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12358 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12359 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12360 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12361 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12362 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12363 { }
12364};
12365
12366static struct hda_verb alc268_dell_verbs[] = {
12367 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12368 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12369 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012370 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012371 { }
12372};
12373
12374/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012375static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012376{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012377 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012378
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012379 spec->autocfg.hp_pins[0] = 0x15;
12380 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012381 spec->ext_mic.pin = 0x18;
12382 spec->ext_mic.mux_idx = 0;
12383 spec->int_mic.pin = 0x19;
12384 spec->int_mic.mux_idx = 1;
12385 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012386}
12387
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012388static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12389 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12390 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12391 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12392 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12393 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12394 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12395 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12396 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12397 { }
12398};
12399
12400static struct hda_verb alc267_quanta_il1_verbs[] = {
12401 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12402 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12403 { }
12404};
12405
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012406static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012407{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012408 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012409 spec->autocfg.hp_pins[0] = 0x15;
12410 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012411 spec->ext_mic.pin = 0x18;
12412 spec->ext_mic.mux_idx = 0;
12413 spec->int_mic.pin = 0x19;
12414 spec->int_mic.mux_idx = 1;
12415 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012416}
12417
Kailang Yanga361d842007-06-05 12:30:55 +020012418/*
12419 * generic initialization of ADC, input mixers and output mixers
12420 */
12421static struct hda_verb alc268_base_init_verbs[] = {
12422 /* Unmute DAC0-1 and set vol = 0 */
12423 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012424 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012425
12426 /*
12427 * Set up output mixers (0x0c - 0x0e)
12428 */
12429 /* set vol=0 to output mixers */
12430 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012431 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12432
12433 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12434 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12435
12436 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12437 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12438 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12439 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12440 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12441 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12442 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12443 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12444
12445 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12446 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12447 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12448 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012449 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012450
12451 /* set PCBEEP vol = 0, mute connections */
12452 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12453 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12454 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012455
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012456 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012457
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012458 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12459 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12460 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12461 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012462
Kailang Yanga361d842007-06-05 12:30:55 +020012463 { }
12464};
12465
12466/*
12467 * generic initialization of ADC, input mixers and output mixers
12468 */
12469static struct hda_verb alc268_volume_init_verbs[] = {
12470 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012471 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12472 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012473
12474 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12475 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12476 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12477 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12478 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12479
Kailang Yanga361d842007-06-05 12:30:55 +020012480 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012481 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12482 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12483
12484 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012485 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012486
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012487 /* set PCBEEP vol = 0, mute connections */
12488 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12489 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12490 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012491
12492 { }
12493};
12494
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012495static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12496 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12497 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12498 { } /* end */
12499};
12500
Kailang Yanga361d842007-06-05 12:30:55 +020012501static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12502 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12503 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012504 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012505 { } /* end */
12506};
12507
12508static struct snd_kcontrol_new alc268_capture_mixer[] = {
12509 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12510 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12511 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12512 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012513 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012514 { } /* end */
12515};
12516
12517static struct hda_input_mux alc268_capture_source = {
12518 .num_items = 4,
12519 .items = {
12520 { "Mic", 0x0 },
12521 { "Front Mic", 0x1 },
12522 { "Line", 0x2 },
12523 { "CD", 0x3 },
12524 },
12525};
12526
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012527static struct hda_input_mux alc268_acer_capture_source = {
12528 .num_items = 3,
12529 .items = {
12530 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012531 { "Internal Mic", 0x1 },
12532 { "Line", 0x2 },
12533 },
12534};
12535
12536static struct hda_input_mux alc268_acer_dmic_capture_source = {
12537 .num_items = 3,
12538 .items = {
12539 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012540 { "Internal Mic", 0x6 },
12541 { "Line", 0x2 },
12542 },
12543};
12544
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012545#ifdef CONFIG_SND_DEBUG
12546static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012547 /* Volume widgets */
12548 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12549 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12550 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12551 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12552 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12553 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12554 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12555 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12556 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12557 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12558 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12559 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12560 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012561 /* The below appears problematic on some hardwares */
12562 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012563 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12564 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12565 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12566 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12567
12568 /* Modes for retasking pin widgets */
12569 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12570 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12571 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12572 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12573
12574 /* Controls for GPIO pins, assuming they are configured as outputs */
12575 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12576 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12577 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12578 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12579
12580 /* Switches to allow the digital SPDIF output pin to be enabled.
12581 * The ALC268 does not have an SPDIF input.
12582 */
12583 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12584
12585 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12586 * this output to turn on an external amplifier.
12587 */
12588 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12589 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12590
12591 { } /* end */
12592};
12593#endif
12594
Kailang Yanga361d842007-06-05 12:30:55 +020012595/* create input playback/capture controls for the given pin */
12596static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12597 const char *ctlname, int idx)
12598{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012599 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012600 int err;
12601
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012602 switch (nid) {
12603 case 0x14:
12604 case 0x16:
12605 dac = 0x02;
12606 break;
12607 case 0x15:
Takashi Iwai4feabef2010-01-19 15:38:44 +010012608 case 0x21:
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012609 dac = 0x03;
12610 break;
12611 default:
12612 return 0;
12613 }
12614 if (spec->multiout.dac_nids[0] != dac &&
12615 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012616 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012617 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012618 HDA_OUTPUT));
12619 if (err < 0)
12620 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012621 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12622 }
12623
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012624 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012625 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020012626 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012627 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012628 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012629 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012630 if (err < 0)
12631 return err;
12632 return 0;
12633}
12634
12635/* add playback controls from the parsed DAC table */
12636static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12637 const struct auto_pin_cfg *cfg)
12638{
12639 hda_nid_t nid;
12640 int err;
12641
Kailang Yanga361d842007-06-05 12:30:55 +020012642 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012643
12644 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012645 if (nid) {
12646 const char *name;
12647 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12648 name = "Speaker";
12649 else
12650 name = "Front";
12651 err = alc268_new_analog_output(spec, nid, name, 0);
12652 if (err < 0)
12653 return err;
12654 }
Kailang Yanga361d842007-06-05 12:30:55 +020012655
12656 nid = cfg->speaker_pins[0];
12657 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012658 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020012659 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12660 if (err < 0)
12661 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012662 } else {
12663 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12664 if (err < 0)
12665 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012666 }
12667 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012668 if (nid) {
12669 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12670 if (err < 0)
12671 return err;
12672 }
Kailang Yanga361d842007-06-05 12:30:55 +020012673
12674 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12675 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012676 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012677 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012678 if (err < 0)
12679 return err;
12680 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012681 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012682}
12683
12684/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020012685static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020012686 const struct auto_pin_cfg *cfg)
12687{
Takashi Iwai05f5f472009-08-25 13:10:18 +020012688 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020012689}
12690
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012691static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12692 hda_nid_t nid, int pin_type)
12693{
12694 int idx;
12695
12696 alc_set_pin_output(codec, nid, pin_type);
12697 if (nid == 0x14 || nid == 0x16)
12698 idx = 0;
12699 else
12700 idx = 1;
12701 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12702}
12703
12704static void alc268_auto_init_multi_out(struct hda_codec *codec)
12705{
12706 struct alc_spec *spec = codec->spec;
12707 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12708 if (nid) {
12709 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12710 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12711 }
12712}
12713
12714static void alc268_auto_init_hp_out(struct hda_codec *codec)
12715{
12716 struct alc_spec *spec = codec->spec;
12717 hda_nid_t pin;
12718
12719 pin = spec->autocfg.hp_pins[0];
12720 if (pin)
12721 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12722 pin = spec->autocfg.speaker_pins[0];
12723 if (pin)
12724 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12725}
12726
Kailang Yanga361d842007-06-05 12:30:55 +020012727static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12728{
12729 struct alc_spec *spec = codec->spec;
12730 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12731 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12732 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12733 unsigned int dac_vol1, dac_vol2;
12734
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012735 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020012736 snd_hda_codec_write(codec, speaker_nid, 0,
12737 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012738 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012739 snd_hda_codec_write(codec, 0x0f, 0,
12740 AC_VERB_SET_AMP_GAIN_MUTE,
12741 AMP_IN_UNMUTE(1));
12742 snd_hda_codec_write(codec, 0x10, 0,
12743 AC_VERB_SET_AMP_GAIN_MUTE,
12744 AMP_IN_UNMUTE(1));
12745 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012746 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012747 snd_hda_codec_write(codec, 0x0f, 0,
12748 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12749 snd_hda_codec_write(codec, 0x10, 0,
12750 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12751 }
12752
12753 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012754 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012755 dac_vol2 = AMP_OUT_ZERO;
12756 else if (line_nid == 0x15)
12757 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012758 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012759 dac_vol2 = AMP_OUT_ZERO;
12760 else if (hp_nid == 0x15)
12761 dac_vol1 = AMP_OUT_ZERO;
12762 if (line_nid != 0x16 || hp_nid != 0x16 ||
12763 spec->autocfg.line_out_pins[1] != 0x16 ||
12764 spec->autocfg.line_out_pins[2] != 0x16)
12765 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12766
12767 snd_hda_codec_write(codec, 0x02, 0,
12768 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12769 snd_hda_codec_write(codec, 0x03, 0,
12770 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12771}
12772
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012773/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012774#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12775#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012776#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012777#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12778
12779/*
12780 * BIOS auto configuration
12781 */
12782static int alc268_parse_auto_config(struct hda_codec *codec)
12783{
12784 struct alc_spec *spec = codec->spec;
12785 int err;
12786 static hda_nid_t alc268_ignore[] = { 0 };
12787
12788 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12789 alc268_ignore);
12790 if (err < 0)
12791 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012792 if (!spec->autocfg.line_outs) {
12793 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12794 spec->multiout.max_channels = 2;
12795 spec->no_analog = 1;
12796 goto dig_only;
12797 }
Kailang Yanga361d842007-06-05 12:30:55 +020012798 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012799 }
Kailang Yanga361d842007-06-05 12:30:55 +020012800 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12801 if (err < 0)
12802 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012803 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020012804 if (err < 0)
12805 return err;
12806
12807 spec->multiout.max_channels = 2;
12808
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012809 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012810 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012811 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012812 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012813 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12814 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012815 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012816 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012817
Takashi Iwai892981f2009-03-02 08:04:35 +010012818 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012819 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012820
Takashi Iwaid88897e2008-10-31 15:01:37 +010012821 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012822 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012823 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012824
Takashi Iwai776e1842007-08-29 15:07:11 +020012825 err = alc_auto_add_mic_boost(codec);
12826 if (err < 0)
12827 return err;
12828
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012829 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12830
Kailang Yanga361d842007-06-05 12:30:55 +020012831 return 1;
12832}
12833
Kailang Yanga361d842007-06-05 12:30:55 +020012834#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12835
12836/* init callback for auto-configuration model -- overriding the default init */
12837static void alc268_auto_init(struct hda_codec *codec)
12838{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012839 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012840 alc268_auto_init_multi_out(codec);
12841 alc268_auto_init_hp_out(codec);
12842 alc268_auto_init_mono_speaker_out(codec);
12843 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012844 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012845 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012846}
12847
12848/*
12849 * configuration and preset
12850 */
12851static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012852 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012853 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012854 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012855 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012856 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012857 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012858 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012859 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012860#ifdef CONFIG_SND_DEBUG
12861 [ALC268_TEST] = "test",
12862#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012863 [ALC268_AUTO] = "auto",
12864};
12865
12866static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012867 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012868 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012869 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012870 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012871 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012872 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12873 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012874 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050012875 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
12876 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020012877 /* almost compatible with toshiba but with optional digital outs;
12878 * auto-probing seems working fine
12879 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012880 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020012881 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020012882 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012883 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012884 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012885 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012886 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012887 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012888 {}
12889};
12890
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012891/* Toshiba laptops have no unique PCI SSID but only codec SSID */
12892static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
12893 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
12894 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
12895 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12896 ALC268_TOSHIBA),
12897 {}
12898};
12899
Kailang Yanga361d842007-06-05 12:30:55 +020012900static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012901 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012902 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
12903 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012904 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12905 alc267_quanta_il1_verbs },
12906 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12907 .dac_nids = alc268_dac_nids,
12908 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12909 .adc_nids = alc268_adc_nids_alt,
12910 .hp_nid = 0x03,
12911 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12912 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012913 .unsol_event = alc_sku_unsol_event,
12914 .setup = alc267_quanta_il1_setup,
12915 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012916 },
Kailang Yanga361d842007-06-05 12:30:55 +020012917 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012918 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12919 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012920 .init_verbs = { alc268_base_init_verbs },
12921 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12922 .dac_nids = alc268_dac_nids,
12923 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12924 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012925 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012926 .hp_nid = 0x03,
12927 .dig_out_nid = ALC268_DIGOUT_NID,
12928 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12929 .channel_mode = alc268_modes,
12930 .input_mux = &alc268_capture_source,
12931 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012932 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012933 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012934 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012935 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12936 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012937 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12938 .dac_nids = alc268_dac_nids,
12939 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12940 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012941 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012942 .hp_nid = 0x03,
12943 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12944 .channel_mode = alc268_modes,
12945 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012946 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012947 .setup = alc268_toshiba_setup,
12948 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020012949 },
12950 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020012951 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012952 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012953 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12954 alc268_acer_verbs },
12955 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12956 .dac_nids = alc268_dac_nids,
12957 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12958 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012959 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012960 .hp_nid = 0x02,
12961 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12962 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012963 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012964 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012965 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012966 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012967 [ALC268_ACER_DMIC] = {
12968 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12969 alc268_beep_mixer },
12970 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12971 alc268_acer_verbs },
12972 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12973 .dac_nids = alc268_dac_nids,
12974 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12975 .adc_nids = alc268_adc_nids_alt,
12976 .capsrc_nids = alc268_capsrc_nids,
12977 .hp_nid = 0x02,
12978 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12979 .channel_mode = alc268_modes,
12980 .input_mux = &alc268_acer_dmic_capture_source,
12981 .unsol_event = alc268_acer_unsol_event,
12982 .init_hook = alc268_acer_init_hook,
12983 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012984 [ALC268_ACER_ASPIRE_ONE] = {
12985 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012986 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012987 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012988 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12989 alc268_acer_aspire_one_verbs },
12990 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12991 .dac_nids = alc268_dac_nids,
12992 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12993 .adc_nids = alc268_adc_nids_alt,
12994 .capsrc_nids = alc268_capsrc_nids,
12995 .hp_nid = 0x03,
12996 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12997 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012998 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012999 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013000 .init_hook = alc268_acer_lc_init_hook,
13001 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013002 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013003 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13004 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013005 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13006 alc268_dell_verbs },
13007 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13008 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013009 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13010 .adc_nids = alc268_adc_nids_alt,
13011 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013012 .hp_nid = 0x02,
13013 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13014 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013015 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013016 .setup = alc268_dell_setup,
13017 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013018 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013019 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013020 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13021 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013022 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13023 alc268_toshiba_verbs },
13024 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13025 .dac_nids = alc268_dac_nids,
13026 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13027 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013028 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013029 .hp_nid = 0x03,
13030 .dig_out_nid = ALC268_DIGOUT_NID,
13031 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13032 .channel_mode = alc268_modes,
13033 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013034 .setup = alc268_toshiba_setup,
13035 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013036 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013037#ifdef CONFIG_SND_DEBUG
13038 [ALC268_TEST] = {
13039 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13040 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13041 alc268_volume_init_verbs },
13042 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13043 .dac_nids = alc268_dac_nids,
13044 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13045 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013046 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013047 .hp_nid = 0x03,
13048 .dig_out_nid = ALC268_DIGOUT_NID,
13049 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13050 .channel_mode = alc268_modes,
13051 .input_mux = &alc268_capture_source,
13052 },
13053#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013054};
13055
13056static int patch_alc268(struct hda_codec *codec)
13057{
13058 struct alc_spec *spec;
13059 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013060 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013061
Julia Lawallef86f582009-12-19 08:18:03 +010013062 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013063 if (spec == NULL)
13064 return -ENOMEM;
13065
13066 codec->spec = spec;
13067
13068 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13069 alc268_models,
13070 alc268_cfg_tbl);
13071
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013072 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13073 board_config = snd_hda_check_board_codec_sid_config(codec,
13074 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
13075
Kailang Yanga361d842007-06-05 12:30:55 +020013076 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013077 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13078 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013079 board_config = ALC268_AUTO;
13080 }
13081
13082 if (board_config == ALC268_AUTO) {
13083 /* automatic parse from the BIOS config */
13084 err = alc268_parse_auto_config(codec);
13085 if (err < 0) {
13086 alc_free(codec);
13087 return err;
13088 } else if (!err) {
13089 printk(KERN_INFO
13090 "hda_codec: Cannot set up configuration "
13091 "from BIOS. Using base mode...\n");
13092 board_config = ALC268_3ST;
13093 }
13094 }
13095
13096 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013097 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013098
Kailang Yanga361d842007-06-05 12:30:55 +020013099 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13100 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013101 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013102
Kailang Yanga361d842007-06-05 12:30:55 +020013103 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13104
Takashi Iwai22971e32009-02-10 11:56:44 +010013105 has_beep = 0;
13106 for (i = 0; i < spec->num_mixers; i++) {
13107 if (spec->mixers[i] == alc268_beep_mixer) {
13108 has_beep = 1;
13109 break;
13110 }
13111 }
13112
13113 if (has_beep) {
13114 err = snd_hda_attach_beep_device(codec, 0x1);
13115 if (err < 0) {
13116 alc_free(codec);
13117 return err;
13118 }
13119 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13120 /* override the amp caps for beep generator */
13121 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013122 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13123 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13124 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13125 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013126 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013127
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013128 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013129 /* check whether NID 0x07 is valid */
13130 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013131 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013132
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013133 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013134 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013135 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013136 if (spec->auto_mic ||
13137 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013138 spec->adc_nids = alc268_adc_nids_alt;
13139 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013140 if (spec->auto_mic)
13141 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013142 if (spec->auto_mic || spec->input_mux->num_items == 1)
13143 add_mixer(spec, alc268_capture_nosrc_mixer);
13144 else
13145 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013146 } else {
13147 spec->adc_nids = alc268_adc_nids;
13148 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013149 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013150 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013151 /* set default input source */
13152 for (i = 0; i < spec->num_adc_nids; i++)
13153 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13154 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013155 i < spec->num_mux_defs ?
13156 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013157 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013158 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013159
13160 spec->vmaster_nid = 0x02;
13161
Kailang Yanga361d842007-06-05 12:30:55 +020013162 codec->patch_ops = alc_patch_ops;
13163 if (board_config == ALC268_AUTO)
13164 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013165
Kailang Yanga361d842007-06-05 12:30:55 +020013166 return 0;
13167}
13168
13169/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013170 * ALC269 channel source setting (2 channel)
13171 */
13172#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13173
13174#define alc269_dac_nids alc260_dac_nids
13175
13176static hda_nid_t alc269_adc_nids[1] = {
13177 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013178 0x08,
13179};
13180
Takashi Iwaie01bf502008-08-21 16:25:07 +020013181static hda_nid_t alc269_capsrc_nids[1] = {
13182 0x23,
13183};
13184
13185/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
13186 * not a mux!
13187 */
13188
Kailang Yangf6a92242007-12-13 16:52:54 +010013189#define alc269_modes alc260_modes
13190#define alc269_capture_source alc880_lg_lw_capture_source
13191
13192static struct snd_kcontrol_new alc269_base_mixer[] = {
13193 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13194 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13195 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13196 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13197 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13198 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13199 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13200 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13201 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13202 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13203 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13204 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13205 { } /* end */
13206};
13207
Kailang Yang60db6b52008-08-26 13:13:00 +020013208static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13209 /* output mixer control */
13210 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13211 {
13212 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13213 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013214 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020013215 .info = snd_hda_mixer_amp_switch_info,
13216 .get = snd_hda_mixer_amp_switch_get,
13217 .put = alc268_acer_master_sw_put,
13218 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13219 },
13220 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13221 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13222 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13223 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13224 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13225 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013226 { }
13227};
13228
Tony Vroon64154832008-11-06 15:08:49 +000013229static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13230 /* output mixer control */
13231 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13232 {
13233 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13234 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013235 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000013236 .info = snd_hda_mixer_amp_switch_info,
13237 .get = snd_hda_mixer_amp_switch_get,
13238 .put = alc268_acer_master_sw_put,
13239 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13240 },
13241 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13242 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13243 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13244 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13245 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13246 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13247 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13248 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13249 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013250 { }
13251};
13252
Kailang Yangf53281e2008-07-18 12:36:43 +020013253static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013254 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013255 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013256 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013257 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013258 { } /* end */
13259};
13260
Kailang Yangf6a92242007-12-13 16:52:54 +010013261/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020013262static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
13263 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13264 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013265 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13266 { } /* end */
13267};
13268
13269/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020013270#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013271
Kailang Yang60db6b52008-08-26 13:13:00 +020013272static struct hda_verb alc269_quanta_fl1_verbs[] = {
13273 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13274 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13275 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13276 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13277 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13278 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13279 { }
13280};
13281
Tony Vroon64154832008-11-06 15:08:49 +000013282static struct hda_verb alc269_lifebook_verbs[] = {
13283 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13284 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13285 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13286 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13287 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13288 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13289 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13290 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13291 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13292 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13293 { }
13294};
13295
Kailang Yang60db6b52008-08-26 13:13:00 +020013296/* toggle speaker-output according to the hp-jack state */
13297static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13298{
13299 unsigned int present;
13300 unsigned char bits;
13301
Wu Fengguang864f92b2009-11-18 12:38:02 +080013302 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang60db6b52008-08-26 13:13:00 +020013303 bits = present ? AMP_IN_MUTE(0) : 0;
13304 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13305 AMP_IN_MUTE(0), bits);
13306 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13307 AMP_IN_MUTE(0), bits);
13308
13309 snd_hda_codec_write(codec, 0x20, 0,
13310 AC_VERB_SET_COEF_INDEX, 0x0c);
13311 snd_hda_codec_write(codec, 0x20, 0,
13312 AC_VERB_SET_PROC_COEF, 0x680);
13313
13314 snd_hda_codec_write(codec, 0x20, 0,
13315 AC_VERB_SET_COEF_INDEX, 0x0c);
13316 snd_hda_codec_write(codec, 0x20, 0,
13317 AC_VERB_SET_PROC_COEF, 0x480);
13318}
13319
Tony Vroon64154832008-11-06 15:08:49 +000013320/* toggle speaker-output according to the hp-jacks state */
13321static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13322{
13323 unsigned int present;
13324 unsigned char bits;
13325
13326 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013327 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013328
13329 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013330 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013331
13332 bits = present ? AMP_IN_MUTE(0) : 0;
13333 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13334 AMP_IN_MUTE(0), bits);
13335 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13336 AMP_IN_MUTE(0), bits);
13337
13338 snd_hda_codec_write(codec, 0x20, 0,
13339 AC_VERB_SET_COEF_INDEX, 0x0c);
13340 snd_hda_codec_write(codec, 0x20, 0,
13341 AC_VERB_SET_PROC_COEF, 0x680);
13342
13343 snd_hda_codec_write(codec, 0x20, 0,
13344 AC_VERB_SET_COEF_INDEX, 0x0c);
13345 snd_hda_codec_write(codec, 0x20, 0,
13346 AC_VERB_SET_PROC_COEF, 0x480);
13347}
13348
Tony Vroon64154832008-11-06 15:08:49 +000013349static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13350{
13351 unsigned int present_laptop;
13352 unsigned int present_dock;
13353
Wu Fengguang864f92b2009-11-18 12:38:02 +080013354 present_laptop = snd_hda_jack_detect(codec, 0x18);
13355 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000013356
13357 /* Laptop mic port overrides dock mic port, design decision */
13358 if (present_dock)
13359 snd_hda_codec_write(codec, 0x23, 0,
13360 AC_VERB_SET_CONNECT_SEL, 0x3);
13361 if (present_laptop)
13362 snd_hda_codec_write(codec, 0x23, 0,
13363 AC_VERB_SET_CONNECT_SEL, 0x0);
13364 if (!present_dock && !present_laptop)
13365 snd_hda_codec_write(codec, 0x23, 0,
13366 AC_VERB_SET_CONNECT_SEL, 0x1);
13367}
13368
Kailang Yang60db6b52008-08-26 13:13:00 +020013369static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13370 unsigned int res)
13371{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013372 switch (res >> 26) {
13373 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013374 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013375 break;
13376 case ALC880_MIC_EVENT:
13377 alc_mic_automute(codec);
13378 break;
13379 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013380}
13381
Tony Vroon64154832008-11-06 15:08:49 +000013382static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13383 unsigned int res)
13384{
13385 if ((res >> 26) == ALC880_HP_EVENT)
13386 alc269_lifebook_speaker_automute(codec);
13387 if ((res >> 26) == ALC880_MIC_EVENT)
13388 alc269_lifebook_mic_autoswitch(codec);
13389}
13390
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013391static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13392{
13393 struct alc_spec *spec = codec->spec;
13394 spec->ext_mic.pin = 0x18;
13395 spec->ext_mic.mux_idx = 0;
13396 spec->int_mic.pin = 0x19;
13397 spec->int_mic.mux_idx = 1;
13398 spec->auto_mic = 1;
13399}
13400
Kailang Yang60db6b52008-08-26 13:13:00 +020013401static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13402{
13403 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013404 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013405}
13406
Tony Vroon64154832008-11-06 15:08:49 +000013407static void alc269_lifebook_init_hook(struct hda_codec *codec)
13408{
13409 alc269_lifebook_speaker_automute(codec);
13410 alc269_lifebook_mic_autoswitch(codec);
13411}
13412
Kailang Yang60db6b52008-08-26 13:13:00 +020013413static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
13414 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13415 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13416 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13417 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13418 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13419 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13420 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13421 {}
13422};
13423
13424static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
13425 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13426 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13427 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13428 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13429 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13430 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13431 {}
13432};
13433
13434/* toggle speaker-output according to the hp-jack state */
13435static void alc269_speaker_automute(struct hda_codec *codec)
13436{
Kailang Yangebb83ee2009-12-17 12:23:00 +010013437 struct alc_spec *spec = codec->spec;
13438 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020013439 unsigned int present;
13440 unsigned char bits;
13441
Kailang Yangebb83ee2009-12-17 12:23:00 +010013442 present = snd_hda_jack_detect(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020013443 bits = present ? AMP_IN_MUTE(0) : 0;
13444 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13445 AMP_IN_MUTE(0), bits);
13446 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13447 AMP_IN_MUTE(0), bits);
13448}
13449
Kailang Yang60db6b52008-08-26 13:13:00 +020013450/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013451static void alc269_eeepc_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013452 unsigned int res)
13453{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013454 switch (res >> 26) {
13455 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013456 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013457 break;
13458 case ALC880_MIC_EVENT:
13459 alc_mic_automute(codec);
13460 break;
13461 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013462}
13463
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013464static void alc269_eeepc_dmic_setup(struct hda_codec *codec)
13465{
13466 struct alc_spec *spec = codec->spec;
13467 spec->ext_mic.pin = 0x18;
13468 spec->ext_mic.mux_idx = 0;
13469 spec->int_mic.pin = 0x12;
13470 spec->int_mic.mux_idx = 5;
13471 spec->auto_mic = 1;
13472}
13473
13474static void alc269_eeepc_amic_setup(struct hda_codec *codec)
13475{
13476 struct alc_spec *spec = codec->spec;
13477 spec->ext_mic.pin = 0x18;
13478 spec->ext_mic.mux_idx = 0;
13479 spec->int_mic.pin = 0x19;
13480 spec->int_mic.mux_idx = 1;
13481 spec->auto_mic = 1;
13482}
13483
13484static void alc269_eeepc_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013485{
13486 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013487 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013488}
13489
Kailang Yangf6a92242007-12-13 16:52:54 +010013490/*
13491 * generic initialization of ADC, input mixers and output mixers
13492 */
13493static struct hda_verb alc269_init_verbs[] = {
13494 /*
13495 * Unmute ADC0 and set the default input to mic-in
13496 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013497 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013498
13499 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13500 * analog-loopback mixer widget
13501 * Note: PASD motherboards uses the Line In 2 as the input for
13502 * front panel mic (mic 2)
13503 */
13504 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13505 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13506 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13507 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13508 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13509 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13510
13511 /*
13512 * Set up output mixers (0x0c - 0x0e)
13513 */
13514 /* set vol=0 to output mixers */
13515 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13516 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13517
13518 /* set up input amps for analog loopback */
13519 /* Amp Indices: DAC = 0, mixer = 1 */
13520 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13521 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13522 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13523 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13524 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13525 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13526
13527 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13528 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13529 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13530 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13531 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13532 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13533 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13534
13535 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13536 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13537 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13538 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13539 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13540 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13541 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13542
13543 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13544 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13545
13546 /* FIXME: use matrix-type input source selection */
13547 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13548 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013549 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13550 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013551 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13552 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13553
13554 /* set EAPD */
13555 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13556 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13557 { }
13558};
13559
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013560#define alc269_auto_create_multi_out_ctls \
13561 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020013562#define alc269_auto_create_input_ctls \
13563 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013564
13565#ifdef CONFIG_SND_HDA_POWER_SAVE
13566#define alc269_loopbacks alc880_loopbacks
13567#endif
13568
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013569/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013570#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13571#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13572#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13573#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13574
Takashi Iwaif03d3112009-03-05 14:18:16 +010013575static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13576 .substreams = 1,
13577 .channels_min = 2,
13578 .channels_max = 8,
13579 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13580 /* NID is set in alc_build_pcms */
13581 .ops = {
13582 .open = alc880_playback_pcm_open,
13583 .prepare = alc880_playback_pcm_prepare,
13584 .cleanup = alc880_playback_pcm_cleanup
13585 },
13586};
13587
13588static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13589 .substreams = 1,
13590 .channels_min = 2,
13591 .channels_max = 2,
13592 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13593 /* NID is set in alc_build_pcms */
13594};
13595
Kailang Yangf6a92242007-12-13 16:52:54 +010013596/*
13597 * BIOS auto configuration
13598 */
13599static int alc269_parse_auto_config(struct hda_codec *codec)
13600{
13601 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013602 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013603 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13604
13605 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13606 alc269_ignore);
13607 if (err < 0)
13608 return err;
13609
13610 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13611 if (err < 0)
13612 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013613 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010013614 if (err < 0)
13615 return err;
13616
13617 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13618
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013619 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013620 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13621
Takashi Iwai603c4012008-07-30 15:01:44 +020013622 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013623 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013624
Takashi Iwaid88897e2008-10-31 15:01:37 +010013625 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013626 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013627 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013628 /* set default input source */
13629 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13630 0, AC_VERB_SET_CONNECT_SEL,
13631 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013632
13633 err = alc_auto_add_mic_boost(codec);
13634 if (err < 0)
13635 return err;
13636
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013637 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013638 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013639
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013640 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13641
Kailang Yangf6a92242007-12-13 16:52:54 +010013642 return 1;
13643}
13644
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013645#define alc269_auto_init_multi_out alc268_auto_init_multi_out
13646#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010013647#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13648
13649
13650/* init callback for auto-configuration model -- overriding the default init */
13651static void alc269_auto_init(struct hda_codec *codec)
13652{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013653 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013654 alc269_auto_init_multi_out(codec);
13655 alc269_auto_init_hp_out(codec);
13656 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013657 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013658 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013659}
13660
13661/*
13662 * configuration and preset
13663 */
13664static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013665 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013666 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013667 [ALC269_ASUS_AMIC] = "asus-amic",
13668 [ALC269_ASUS_DMIC] = "asus-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000013669 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020013670 [ALC269_LIFEBOOK] = "lifebook",
13671 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010013672};
13673
13674static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013675 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013676 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013677 ALC269_ASUS_AMIC),
13678 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_ASUS_AMIC),
13679 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80JT", ALC269_ASUS_AMIC),
13680 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_ASUS_AMIC),
13681 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_ASUS_AMIC),
13682 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_ASUS_AMIC),
13683 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_ASUS_AMIC),
13684 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_ASUS_AMIC),
13685 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_ASUS_AMIC),
13686 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_ASUS_AMIC),
13687 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_ASUS_AMIC),
13688 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_ASUS_AMIC),
13689 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_ASUS_AMIC),
13690 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_ASUS_AMIC),
13691 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_ASUS_AMIC),
13692 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_ASUS_AMIC),
13693 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_ASUS_AMIC),
13694 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_ASUS_AMIC),
13695 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_ASUS_AMIC),
13696 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_ASUS_AMIC),
13697 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_ASUS_AMIC),
13698 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_AMIC),
13699 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_ASUS_AMIC),
13700 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_AMIC),
13701 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_DMIC),
13702 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_AMIC),
13703 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_AMIC),
13704 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_AMIC),
13705 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020013706 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013707 ALC269_ASUS_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020013708 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013709 ALC269_ASUS_DMIC),
13710 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_ASUS_DMIC),
13711 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_ASUS_DMIC),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013712 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013713 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013714 {}
13715};
13716
13717static struct alc_config_preset alc269_presets[] = {
13718 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013719 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013720 .init_verbs = { alc269_init_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 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013728 [ALC269_QUANTA_FL1] = {
13729 .mixers = { alc269_quanta_fl1_mixer },
13730 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13731 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13732 .dac_nids = alc269_dac_nids,
13733 .hp_nid = 0x03,
13734 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13735 .channel_mode = alc269_modes,
13736 .input_mux = &alc269_capture_source,
13737 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013738 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020013739 .init_hook = alc269_quanta_fl1_init_hook,
13740 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010013741 [ALC269_ASUS_AMIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013742 .mixers = { alc269_eeepc_mixer },
13743 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013744 .init_verbs = { alc269_init_verbs,
13745 alc269_eeepc_amic_init_verbs },
13746 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13747 .dac_nids = alc269_dac_nids,
13748 .hp_nid = 0x03,
13749 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13750 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013751 .unsol_event = alc269_eeepc_unsol_event,
13752 .setup = alc269_eeepc_amic_setup,
13753 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013754 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010013755 [ALC269_ASUS_DMIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013756 .mixers = { alc269_eeepc_mixer },
13757 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013758 .init_verbs = { alc269_init_verbs,
13759 alc269_eeepc_dmic_init_verbs },
13760 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13761 .dac_nids = alc269_dac_nids,
13762 .hp_nid = 0x03,
13763 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13764 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013765 .unsol_event = alc269_eeepc_unsol_event,
13766 .setup = alc269_eeepc_dmic_setup,
13767 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013768 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013769 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013770 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013771 .cap_mixer = alc269_epc_capture_mixer,
13772 .init_verbs = { alc269_init_verbs,
13773 alc269_eeepc_dmic_init_verbs },
13774 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13775 .dac_nids = alc269_dac_nids,
13776 .hp_nid = 0x03,
13777 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13778 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013779 .unsol_event = alc269_eeepc_unsol_event,
13780 .setup = alc269_eeepc_dmic_setup,
13781 .init_hook = alc269_eeepc_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010013782 },
Tony Vroon64154832008-11-06 15:08:49 +000013783 [ALC269_LIFEBOOK] = {
13784 .mixers = { alc269_lifebook_mixer },
13785 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13786 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13787 .dac_nids = alc269_dac_nids,
13788 .hp_nid = 0x03,
13789 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13790 .channel_mode = alc269_modes,
13791 .input_mux = &alc269_capture_source,
13792 .unsol_event = alc269_lifebook_unsol_event,
13793 .init_hook = alc269_lifebook_init_hook,
13794 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013795};
13796
13797static int patch_alc269(struct hda_codec *codec)
13798{
13799 struct alc_spec *spec;
13800 int board_config;
13801 int err;
13802
13803 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13804 if (spec == NULL)
13805 return -ENOMEM;
13806
13807 codec->spec = spec;
13808
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013809 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13810
Kailang Yang274693f2009-12-03 10:07:50 +010013811 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
13812 kfree(codec->chip_name);
13813 codec->chip_name = kstrdup("ALC259", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010013814 if (!codec->chip_name) {
13815 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010013816 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010013817 }
Kailang Yang274693f2009-12-03 10:07:50 +010013818 }
13819
Kailang Yangf6a92242007-12-13 16:52:54 +010013820 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13821 alc269_models,
13822 alc269_cfg_tbl);
13823
13824 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013825 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13826 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013827 board_config = ALC269_AUTO;
13828 }
13829
13830 if (board_config == ALC269_AUTO) {
13831 /* automatic parse from the BIOS config */
13832 err = alc269_parse_auto_config(codec);
13833 if (err < 0) {
13834 alc_free(codec);
13835 return err;
13836 } else if (!err) {
13837 printk(KERN_INFO
13838 "hda_codec: Cannot set up configuration "
13839 "from BIOS. Using base mode...\n");
13840 board_config = ALC269_BASIC;
13841 }
13842 }
13843
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013844 err = snd_hda_attach_beep_device(codec, 0x1);
13845 if (err < 0) {
13846 alc_free(codec);
13847 return err;
13848 }
13849
Kailang Yangf6a92242007-12-13 16:52:54 +010013850 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013851 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010013852
Takashi Iwaif03d3112009-03-05 14:18:16 +010013853 if (codec->subsystem_id == 0x17aa3bf8) {
13854 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13855 * fix the sample rate of analog I/O to 44.1kHz
13856 */
13857 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13858 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13859 } else {
13860 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13861 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13862 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013863 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13864 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13865
13866 spec->adc_nids = alc269_adc_nids;
13867 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013868 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013869 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013870 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013871 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013872
Takashi Iwai100d5eb2009-08-10 11:55:51 +020013873 spec->vmaster_nid = 0x02;
13874
Kailang Yangf6a92242007-12-13 16:52:54 +010013875 codec->patch_ops = alc_patch_ops;
13876 if (board_config == ALC269_AUTO)
13877 spec->init_hook = alc269_auto_init;
13878#ifdef CONFIG_SND_HDA_POWER_SAVE
13879 if (!spec->loopback.amplist)
13880 spec->loopback.amplist = alc269_loopbacks;
13881#endif
13882
13883 return 0;
13884}
13885
13886/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013887 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13888 */
13889
13890/*
13891 * set the path ways for 2 channel output
13892 * need to set the codec line out and mic 1 pin widgets to inputs
13893 */
13894static struct hda_verb alc861_threestack_ch2_init[] = {
13895 /* set pin widget 1Ah (line in) for input */
13896 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013897 /* set pin widget 18h (mic1/2) for input, for mic also enable
13898 * the vref
13899 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013900 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13901
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013902 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13903#if 0
13904 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13905 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13906#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013907 { } /* end */
13908};
13909/*
13910 * 6ch mode
13911 * need to set the codec line out and mic 1 pin widgets to outputs
13912 */
13913static struct hda_verb alc861_threestack_ch6_init[] = {
13914 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13915 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13916 /* set pin widget 18h (mic1) for output (CLFE)*/
13917 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13918
13919 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013920 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013921
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013922 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13923#if 0
13924 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13925 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13926#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013927 { } /* end */
13928};
13929
13930static struct hda_channel_mode alc861_threestack_modes[2] = {
13931 { 2, alc861_threestack_ch2_init },
13932 { 6, alc861_threestack_ch6_init },
13933};
Takashi Iwai22309c32006-08-09 16:57:28 +020013934/* Set mic1 as input and unmute the mixer */
13935static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13936 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13937 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13938 { } /* end */
13939};
13940/* Set mic1 as output and mute mixer */
13941static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13942 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13943 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13944 { } /* end */
13945};
13946
13947static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13948 { 2, alc861_uniwill_m31_ch2_init },
13949 { 4, alc861_uniwill_m31_ch4_init },
13950};
Kailang Yangdf694da2005-12-05 19:42:22 +010013951
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013952/* Set mic1 and line-in as input and unmute the mixer */
13953static struct hda_verb alc861_asus_ch2_init[] = {
13954 /* set pin widget 1Ah (line in) for input */
13955 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013956 /* set pin widget 18h (mic1/2) for input, for mic also enable
13957 * the vref
13958 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013959 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13960
13961 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13962#if 0
13963 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13964 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13965#endif
13966 { } /* end */
13967};
13968/* Set mic1 nad line-in as output and mute mixer */
13969static struct hda_verb alc861_asus_ch6_init[] = {
13970 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13971 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13972 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13973 /* set pin widget 18h (mic1) for output (CLFE)*/
13974 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13975 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13976 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13977 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13978
13979 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13980#if 0
13981 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13982 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13983#endif
13984 { } /* end */
13985};
13986
13987static struct hda_channel_mode alc861_asus_modes[2] = {
13988 { 2, alc861_asus_ch2_init },
13989 { 6, alc861_asus_ch6_init },
13990};
13991
Kailang Yangdf694da2005-12-05 19:42:22 +010013992/* patch-ALC861 */
13993
13994static struct snd_kcontrol_new alc861_base_mixer[] = {
13995 /* output mixer control */
13996 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13997 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13998 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13999 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14000 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14001
14002 /*Input mixer control */
14003 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14004 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14005 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14006 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14007 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14008 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14009 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14010 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14011 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14012 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014013
Kailang Yangdf694da2005-12-05 19:42:22 +010014014 { } /* end */
14015};
14016
14017static struct snd_kcontrol_new alc861_3ST_mixer[] = {
14018 /* output mixer control */
14019 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14020 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14021 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14022 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14023 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14024
14025 /* Input mixer control */
14026 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14027 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14028 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14029 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14030 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14031 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14032 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14033 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14034 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14035 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014036
Kailang Yangdf694da2005-12-05 19:42:22 +010014037 {
14038 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14039 .name = "Channel Mode",
14040 .info = alc_ch_mode_info,
14041 .get = alc_ch_mode_get,
14042 .put = alc_ch_mode_put,
14043 .private_value = ARRAY_SIZE(alc861_threestack_modes),
14044 },
14045 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014046};
14047
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014048static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014049 /* output mixer control */
14050 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14051 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14052 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014053
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014054 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014055};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014056
Takashi Iwai22309c32006-08-09 16:57:28 +020014057static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
14058 /* output mixer control */
14059 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14060 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14061 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14062 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14063 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14064
14065 /* Input mixer control */
14066 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14067 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14068 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14069 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14070 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14071 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14072 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14073 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14074 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14075 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014076
Takashi Iwai22309c32006-08-09 16:57:28 +020014077 {
14078 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14079 .name = "Channel Mode",
14080 .info = alc_ch_mode_info,
14081 .get = alc_ch_mode_get,
14082 .put = alc_ch_mode_put,
14083 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
14084 },
14085 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014086};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014087
14088static struct snd_kcontrol_new alc861_asus_mixer[] = {
14089 /* output mixer control */
14090 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14091 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14092 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14093 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14094 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14095
14096 /* Input mixer control */
14097 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14098 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14099 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14100 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14101 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14102 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14103 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14104 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14105 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014106 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
14107
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014108 {
14109 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14110 .name = "Channel Mode",
14111 .info = alc_ch_mode_info,
14112 .get = alc_ch_mode_get,
14113 .put = alc_ch_mode_put,
14114 .private_value = ARRAY_SIZE(alc861_asus_modes),
14115 },
14116 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014117};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014118
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014119/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014120static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014121 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14122 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014123 { }
14124};
14125
Kailang Yangdf694da2005-12-05 19:42:22 +010014126/*
14127 * generic initialization of ADC, input mixers and output mixers
14128 */
14129static struct hda_verb alc861_base_init_verbs[] = {
14130 /*
14131 * Unmute ADC0 and set the default input to mic-in
14132 */
14133 /* port-A for surround (rear panel) */
14134 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14135 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
14136 /* port-B for mic-in (rear panel) with vref */
14137 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14138 /* port-C for line-in (rear panel) */
14139 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14140 /* port-D for Front */
14141 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14142 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14143 /* port-E for HP out (front panel) */
14144 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14145 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014146 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014147 /* port-F for mic-in (front panel) with vref */
14148 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14149 /* port-G for CLFE (rear panel) */
14150 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14151 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
14152 /* port-H for side (rear panel) */
14153 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14154 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
14155 /* CD-in */
14156 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14157 /* route front mic to ADC1*/
14158 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14159 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014160
Kailang Yangdf694da2005-12-05 19:42:22 +010014161 /* Unmute DAC0~3 & spdif out*/
14162 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14163 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14164 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14165 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14166 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014167
Kailang Yangdf694da2005-12-05 19:42:22 +010014168 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14169 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14170 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14171 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14172 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014173
Kailang Yangdf694da2005-12-05 19:42:22 +010014174 /* Unmute Stereo Mixer 15 */
14175 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14176 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14177 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014178 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014179
14180 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14181 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14182 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14183 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14184 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14185 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14186 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14187 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014188 /* hp used DAC 3 (Front) */
14189 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014190 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14191
14192 { }
14193};
14194
14195static struct hda_verb alc861_threestack_init_verbs[] = {
14196 /*
14197 * Unmute ADC0 and set the default input to mic-in
14198 */
14199 /* port-A for surround (rear panel) */
14200 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14201 /* port-B for mic-in (rear panel) with vref */
14202 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14203 /* port-C for line-in (rear panel) */
14204 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14205 /* port-D for Front */
14206 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14207 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14208 /* port-E for HP out (front panel) */
14209 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14210 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014211 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014212 /* port-F for mic-in (front panel) with vref */
14213 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14214 /* port-G for CLFE (rear panel) */
14215 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14216 /* port-H for side (rear panel) */
14217 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14218 /* CD-in */
14219 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14220 /* route front mic to ADC1*/
14221 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14222 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14223 /* Unmute DAC0~3 & spdif out*/
14224 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14225 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14226 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14227 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14228 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014229
Kailang Yangdf694da2005-12-05 19:42:22 +010014230 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14231 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14232 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14233 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14234 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014235
Kailang Yangdf694da2005-12-05 19:42:22 +010014236 /* Unmute Stereo Mixer 15 */
14237 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14238 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14239 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014240 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014241
14242 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14243 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14244 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14245 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14246 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14247 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14248 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14249 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014250 /* hp used DAC 3 (Front) */
14251 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014252 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14253 { }
14254};
Takashi Iwai22309c32006-08-09 16:57:28 +020014255
14256static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
14257 /*
14258 * Unmute ADC0 and set the default input to mic-in
14259 */
14260 /* port-A for surround (rear panel) */
14261 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14262 /* port-B for mic-in (rear panel) with vref */
14263 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14264 /* port-C for line-in (rear panel) */
14265 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14266 /* port-D for Front */
14267 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14268 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14269 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014270 /* this has to be set to VREF80 */
14271 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014272 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014273 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014274 /* port-F for mic-in (front panel) with vref */
14275 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14276 /* port-G for CLFE (rear panel) */
14277 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14278 /* port-H for side (rear panel) */
14279 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14280 /* CD-in */
14281 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14282 /* route front mic to ADC1*/
14283 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14284 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14285 /* Unmute DAC0~3 & spdif out*/
14286 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14287 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14288 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14289 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14290 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014291
Takashi Iwai22309c32006-08-09 16:57:28 +020014292 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14293 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14294 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14295 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14296 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014297
Takashi Iwai22309c32006-08-09 16:57:28 +020014298 /* Unmute Stereo Mixer 15 */
14299 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14300 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14301 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014302 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014303
14304 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14305 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14306 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14307 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14308 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14309 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14310 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14311 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014312 /* hp used DAC 3 (Front) */
14313 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014314 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14315 { }
14316};
14317
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014318static struct hda_verb alc861_asus_init_verbs[] = {
14319 /*
14320 * Unmute ADC0 and set the default input to mic-in
14321 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014322 /* port-A for surround (rear panel)
14323 * according to codec#0 this is the HP jack
14324 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014325 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14326 /* route front PCM to HP */
14327 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14328 /* port-B for mic-in (rear panel) with vref */
14329 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14330 /* port-C for line-in (rear panel) */
14331 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14332 /* port-D for Front */
14333 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14334 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14335 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014336 /* this has to be set to VREF80 */
14337 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014338 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014339 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014340 /* port-F for mic-in (front panel) with vref */
14341 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14342 /* port-G for CLFE (rear panel) */
14343 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14344 /* port-H for side (rear panel) */
14345 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14346 /* CD-in */
14347 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14348 /* route front mic to ADC1*/
14349 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14350 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14351 /* Unmute DAC0~3 & spdif out*/
14352 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14353 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14354 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14355 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14356 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14357 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14358 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14359 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14360 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14361 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014362
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014363 /* Unmute Stereo Mixer 15 */
14364 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14365 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14366 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014367 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014368
14369 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14370 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14371 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14372 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14373 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14374 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14375 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14376 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014377 /* hp used DAC 3 (Front) */
14378 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014379 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14380 { }
14381};
14382
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014383/* additional init verbs for ASUS laptops */
14384static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14385 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14386 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14387 { }
14388};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014389
Kailang Yangdf694da2005-12-05 19:42:22 +010014390/*
14391 * generic initialization of ADC, input mixers and output mixers
14392 */
14393static struct hda_verb alc861_auto_init_verbs[] = {
14394 /*
14395 * Unmute ADC0 and set the default input to mic-in
14396 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014397 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014398 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014399
Kailang Yangdf694da2005-12-05 19:42:22 +010014400 /* Unmute DAC0~3 & spdif out*/
14401 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14402 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14403 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14404 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14405 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014406
Kailang Yangdf694da2005-12-05 19:42:22 +010014407 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14408 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14409 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14410 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14411 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014412
Kailang Yangdf694da2005-12-05 19:42:22 +010014413 /* Unmute Stereo Mixer 15 */
14414 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14415 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14416 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14417 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14418
Takashi Iwai1c209302009-07-22 15:17:45 +020014419 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14420 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14421 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14422 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14423 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14424 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14425 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14426 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014427
14428 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14429 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014430 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14431 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014432 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14433 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014434 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14435 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014436
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014437 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014438
14439 { }
14440};
14441
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014442static struct hda_verb alc861_toshiba_init_verbs[] = {
14443 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014444
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014445 { }
14446};
14447
14448/* toggle speaker-output according to the hp-jack state */
14449static void alc861_toshiba_automute(struct hda_codec *codec)
14450{
Wu Fengguang864f92b2009-11-18 12:38:02 +080014451 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014452
Takashi Iwai47fd8302007-08-10 17:11:07 +020014453 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14454 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14455 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14456 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014457}
14458
14459static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14460 unsigned int res)
14461{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014462 if ((res >> 26) == ALC880_HP_EVENT)
14463 alc861_toshiba_automute(codec);
14464}
14465
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014466/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014467#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14468#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14469#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14470#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14471
14472
14473#define ALC861_DIGOUT_NID 0x07
14474
14475static struct hda_channel_mode alc861_8ch_modes[1] = {
14476 { 8, NULL }
14477};
14478
14479static hda_nid_t alc861_dac_nids[4] = {
14480 /* front, surround, clfe, side */
14481 0x03, 0x06, 0x05, 0x04
14482};
14483
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014484static hda_nid_t alc660_dac_nids[3] = {
14485 /* front, clfe, surround */
14486 0x03, 0x05, 0x06
14487};
14488
Kailang Yangdf694da2005-12-05 19:42:22 +010014489static hda_nid_t alc861_adc_nids[1] = {
14490 /* ADC0-2 */
14491 0x08,
14492};
14493
14494static struct hda_input_mux alc861_capture_source = {
14495 .num_items = 5,
14496 .items = {
14497 { "Mic", 0x0 },
14498 { "Front Mic", 0x3 },
14499 { "Line", 0x1 },
14500 { "CD", 0x4 },
14501 { "Mixer", 0x5 },
14502 },
14503};
14504
Takashi Iwai1c209302009-07-22 15:17:45 +020014505static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14506{
14507 struct alc_spec *spec = codec->spec;
14508 hda_nid_t mix, srcs[5];
14509 int i, j, num;
14510
14511 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14512 return 0;
14513 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14514 if (num < 0)
14515 return 0;
14516 for (i = 0; i < num; i++) {
14517 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014518 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014519 if (type != AC_WID_AUD_OUT)
14520 continue;
14521 for (j = 0; j < spec->multiout.num_dacs; j++)
14522 if (spec->multiout.dac_nids[j] == srcs[i])
14523 break;
14524 if (j >= spec->multiout.num_dacs)
14525 return srcs[i];
14526 }
14527 return 0;
14528}
14529
Kailang Yangdf694da2005-12-05 19:42:22 +010014530/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014531static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014532 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014533{
Takashi Iwai1c209302009-07-22 15:17:45 +020014534 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014535 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014536 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014537
14538 spec->multiout.dac_nids = spec->private_dac_nids;
14539 for (i = 0; i < cfg->line_outs; i++) {
14540 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014541 dac = alc861_look_for_dac(codec, nid);
14542 if (!dac)
14543 continue;
14544 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014545 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014546 return 0;
14547}
14548
Takashi Iwai1c209302009-07-22 15:17:45 +020014549static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14550 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014551{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020014552 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020014553 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14554}
14555
14556/* add playback controls from the parsed DAC table */
14557static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14558 const struct auto_pin_cfg *cfg)
14559{
14560 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014561 static const char *chname[4] = {
14562 "Front", "Surround", NULL /*CLFE*/, "Side"
14563 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014564 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014565 int i, err;
14566
14567 if (cfg->line_outs == 1) {
14568 const char *pfx = NULL;
14569 if (!cfg->hp_outs)
14570 pfx = "Master";
14571 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14572 pfx = "Speaker";
14573 if (pfx) {
14574 nid = spec->multiout.dac_nids[0];
14575 return alc861_create_out_sw(codec, pfx, nid, 3);
14576 }
14577 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014578
14579 for (i = 0; i < cfg->line_outs; i++) {
14580 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014581 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014582 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014583 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014584 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014585 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014586 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014587 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014588 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014589 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014590 return err;
14591 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014592 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014593 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014594 return err;
14595 }
14596 }
14597 return 0;
14598}
14599
Takashi Iwai1c209302009-07-22 15:17:45 +020014600static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014601{
Takashi Iwai1c209302009-07-22 15:17:45 +020014602 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014603 int err;
14604 hda_nid_t nid;
14605
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014606 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014607 return 0;
14608
14609 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014610 nid = alc861_look_for_dac(codec, pin);
14611 if (nid) {
14612 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14613 if (err < 0)
14614 return err;
14615 spec->multiout.hp_nid = nid;
14616 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014617 }
14618 return 0;
14619}
14620
14621/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020014622static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014623 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014624{
Takashi Iwai05f5f472009-08-25 13:10:18 +020014625 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014626}
14627
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014628static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14629 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014630 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014631{
Takashi Iwai1c209302009-07-22 15:17:45 +020014632 hda_nid_t mix, srcs[5];
14633 int i, num;
14634
Jacek Luczak564c5be2008-05-03 18:41:23 +020014635 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14636 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014637 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014638 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014639 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14640 return;
14641 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14642 if (num < 0)
14643 return;
14644 for (i = 0; i < num; i++) {
14645 unsigned int mute;
14646 if (srcs[i] == dac || srcs[i] == 0x15)
14647 mute = AMP_IN_UNMUTE(i);
14648 else
14649 mute = AMP_IN_MUTE(i);
14650 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14651 mute);
14652 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014653}
14654
14655static void alc861_auto_init_multi_out(struct hda_codec *codec)
14656{
14657 struct alc_spec *spec = codec->spec;
14658 int i;
14659
14660 for (i = 0; i < spec->autocfg.line_outs; i++) {
14661 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014662 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014663 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014664 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014665 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014666 }
14667}
14668
14669static void alc861_auto_init_hp_out(struct hda_codec *codec)
14670{
14671 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014672
Takashi Iwai15870f02009-10-05 08:25:13 +020014673 if (spec->autocfg.hp_outs)
14674 alc861_auto_set_output_and_unmute(codec,
14675 spec->autocfg.hp_pins[0],
14676 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014677 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020014678 if (spec->autocfg.speaker_outs)
14679 alc861_auto_set_output_and_unmute(codec,
14680 spec->autocfg.speaker_pins[0],
14681 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020014682 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014683}
14684
14685static void alc861_auto_init_analog_input(struct hda_codec *codec)
14686{
14687 struct alc_spec *spec = codec->spec;
14688 int i;
14689
14690 for (i = 0; i < AUTO_PIN_LAST; i++) {
14691 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014692 if (nid >= 0x0c && nid <= 0x11)
14693 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014694 }
14695}
14696
14697/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014698/* return 1 if successful, 0 if the proper config is not found,
14699 * or a negative error code
14700 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014701static int alc861_parse_auto_config(struct hda_codec *codec)
14702{
14703 struct alc_spec *spec = codec->spec;
14704 int err;
14705 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14706
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014707 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14708 alc861_ignore);
14709 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014710 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014711 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014712 return 0; /* can't find valid BIOS pin config */
14713
Takashi Iwai1c209302009-07-22 15:17:45 +020014714 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014715 if (err < 0)
14716 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014717 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014718 if (err < 0)
14719 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014720 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014721 if (err < 0)
14722 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014723 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014724 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014725 return err;
14726
14727 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14728
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014729 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014730 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14731
Takashi Iwai603c4012008-07-30 15:01:44 +020014732 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014733 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014734
Takashi Iwaid88897e2008-10-31 15:01:37 +010014735 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014736
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014737 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014738 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014739
14740 spec->adc_nids = alc861_adc_nids;
14741 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014742 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014743
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014744 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14745
Kailang Yangdf694da2005-12-05 19:42:22 +010014746 return 1;
14747}
14748
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014749/* additional initialization for auto-configuration model */
14750static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014751{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014752 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014753 alc861_auto_init_multi_out(codec);
14754 alc861_auto_init_hp_out(codec);
14755 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014756 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014757 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014758}
14759
Takashi Iwaicb53c622007-08-10 17:21:45 +020014760#ifdef CONFIG_SND_HDA_POWER_SAVE
14761static struct hda_amp_list alc861_loopbacks[] = {
14762 { 0x15, HDA_INPUT, 0 },
14763 { 0x15, HDA_INPUT, 1 },
14764 { 0x15, HDA_INPUT, 2 },
14765 { 0x15, HDA_INPUT, 3 },
14766 { } /* end */
14767};
14768#endif
14769
Kailang Yangdf694da2005-12-05 19:42:22 +010014770
14771/*
14772 * configuration and preset
14773 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014774static const char *alc861_models[ALC861_MODEL_LAST] = {
14775 [ALC861_3ST] = "3stack",
14776 [ALC660_3ST] = "3stack-660",
14777 [ALC861_3ST_DIG] = "3stack-dig",
14778 [ALC861_6ST_DIG] = "6stack-dig",
14779 [ALC861_UNIWILL_M31] = "uniwill-m31",
14780 [ALC861_TOSHIBA] = "toshiba",
14781 [ALC861_ASUS] = "asus",
14782 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14783 [ALC861_AUTO] = "auto",
14784};
14785
14786static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014787 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014788 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14789 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14790 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014791 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014792 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014793 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014794 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14795 * Any other models that need this preset?
14796 */
14797 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014798 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14799 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014800 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14801 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14802 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14803 /* FIXME: the below seems conflict */
14804 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14805 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14806 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014807 {}
14808};
14809
14810static struct alc_config_preset alc861_presets[] = {
14811 [ALC861_3ST] = {
14812 .mixers = { alc861_3ST_mixer },
14813 .init_verbs = { alc861_threestack_init_verbs },
14814 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14815 .dac_nids = alc861_dac_nids,
14816 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14817 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014818 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014819 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14820 .adc_nids = alc861_adc_nids,
14821 .input_mux = &alc861_capture_source,
14822 },
14823 [ALC861_3ST_DIG] = {
14824 .mixers = { alc861_base_mixer },
14825 .init_verbs = { alc861_threestack_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_threestack_modes),
14830 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014831 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014832 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14833 .adc_nids = alc861_adc_nids,
14834 .input_mux = &alc861_capture_source,
14835 },
14836 [ALC861_6ST_DIG] = {
14837 .mixers = { alc861_base_mixer },
14838 .init_verbs = { alc861_base_init_verbs },
14839 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14840 .dac_nids = alc861_dac_nids,
14841 .dig_out_nid = ALC861_DIGOUT_NID,
14842 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14843 .channel_mode = alc861_8ch_modes,
14844 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14845 .adc_nids = alc861_adc_nids,
14846 .input_mux = &alc861_capture_source,
14847 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014848 [ALC660_3ST] = {
14849 .mixers = { alc861_3ST_mixer },
14850 .init_verbs = { alc861_threestack_init_verbs },
14851 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14852 .dac_nids = alc660_dac_nids,
14853 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14854 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014855 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014856 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14857 .adc_nids = alc861_adc_nids,
14858 .input_mux = &alc861_capture_source,
14859 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014860 [ALC861_UNIWILL_M31] = {
14861 .mixers = { alc861_uniwill_m31_mixer },
14862 .init_verbs = { alc861_uniwill_m31_init_verbs },
14863 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14864 .dac_nids = alc861_dac_nids,
14865 .dig_out_nid = ALC861_DIGOUT_NID,
14866 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14867 .channel_mode = alc861_uniwill_m31_modes,
14868 .need_dac_fix = 1,
14869 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14870 .adc_nids = alc861_adc_nids,
14871 .input_mux = &alc861_capture_source,
14872 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014873 [ALC861_TOSHIBA] = {
14874 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014875 .init_verbs = { alc861_base_init_verbs,
14876 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014877 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14878 .dac_nids = alc861_dac_nids,
14879 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14880 .channel_mode = alc883_3ST_2ch_modes,
14881 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14882 .adc_nids = alc861_adc_nids,
14883 .input_mux = &alc861_capture_source,
14884 .unsol_event = alc861_toshiba_unsol_event,
14885 .init_hook = alc861_toshiba_automute,
14886 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014887 [ALC861_ASUS] = {
14888 .mixers = { alc861_asus_mixer },
14889 .init_verbs = { alc861_asus_init_verbs },
14890 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14891 .dac_nids = alc861_dac_nids,
14892 .dig_out_nid = ALC861_DIGOUT_NID,
14893 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14894 .channel_mode = alc861_asus_modes,
14895 .need_dac_fix = 1,
14896 .hp_nid = 0x06,
14897 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14898 .adc_nids = alc861_adc_nids,
14899 .input_mux = &alc861_capture_source,
14900 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014901 [ALC861_ASUS_LAPTOP] = {
14902 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14903 .init_verbs = { alc861_asus_init_verbs,
14904 alc861_asus_laptop_init_verbs },
14905 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14906 .dac_nids = alc861_dac_nids,
14907 .dig_out_nid = ALC861_DIGOUT_NID,
14908 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14909 .channel_mode = alc883_3ST_2ch_modes,
14910 .need_dac_fix = 1,
14911 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14912 .adc_nids = alc861_adc_nids,
14913 .input_mux = &alc861_capture_source,
14914 },
14915};
Kailang Yangdf694da2005-12-05 19:42:22 +010014916
Takashi Iwaicfc9b062009-12-01 12:19:37 +010014917/* Pin config fixes */
14918enum {
14919 PINFIX_FSC_AMILO_PI1505,
14920};
14921
14922static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = {
14923 { 0x0b, 0x0221101f }, /* HP */
14924 { 0x0f, 0x90170310 }, /* speaker */
14925 { }
14926};
14927
14928static const struct alc_fixup alc861_fixups[] = {
14929 [PINFIX_FSC_AMILO_PI1505] = {
14930 .pins = alc861_fsc_amilo_pi1505_pinfix
14931 },
14932};
14933
14934static struct snd_pci_quirk alc861_fixup_tbl[] = {
14935 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
14936 {}
14937};
Kailang Yangdf694da2005-12-05 19:42:22 +010014938
14939static int patch_alc861(struct hda_codec *codec)
14940{
14941 struct alc_spec *spec;
14942 int board_config;
14943 int err;
14944
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014945 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014946 if (spec == NULL)
14947 return -ENOMEM;
14948
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014949 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014950
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014951 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14952 alc861_models,
14953 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014954
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014955 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014956 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14957 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014958 board_config = ALC861_AUTO;
14959 }
14960
Takashi Iwaicfc9b062009-12-01 12:19:37 +010014961 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups);
14962
Kailang Yangdf694da2005-12-05 19:42:22 +010014963 if (board_config == ALC861_AUTO) {
14964 /* automatic parse from the BIOS config */
14965 err = alc861_parse_auto_config(codec);
14966 if (err < 0) {
14967 alc_free(codec);
14968 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014969 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014970 printk(KERN_INFO
14971 "hda_codec: Cannot set up configuration "
14972 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014973 board_config = ALC861_3ST_DIG;
14974 }
14975 }
14976
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014977 err = snd_hda_attach_beep_device(codec, 0x23);
14978 if (err < 0) {
14979 alc_free(codec);
14980 return err;
14981 }
14982
Kailang Yangdf694da2005-12-05 19:42:22 +010014983 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014984 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014985
Kailang Yangdf694da2005-12-05 19:42:22 +010014986 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14987 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14988
Kailang Yangdf694da2005-12-05 19:42:22 +010014989 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14990 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14991
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010014992 if (!spec->cap_mixer)
14993 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014994 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14995
Takashi Iwai2134ea42008-01-10 16:53:55 +010014996 spec->vmaster_nid = 0x03;
14997
Kailang Yangdf694da2005-12-05 19:42:22 +010014998 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050014999 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015000 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015001#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050015002 spec->power_hook = alc_power_eapd;
15003#endif
15004 }
15005#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020015006 if (!spec->loopback.amplist)
15007 spec->loopback.amplist = alc861_loopbacks;
15008#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020015009
Kailang Yangdf694da2005-12-05 19:42:22 +010015010 return 0;
15011}
15012
15013/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015014 * ALC861-VD support
15015 *
15016 * Based on ALC882
15017 *
15018 * In addition, an independent DAC
15019 */
15020#define ALC861VD_DIGOUT_NID 0x06
15021
15022static hda_nid_t alc861vd_dac_nids[4] = {
15023 /* front, surr, clfe, side surr */
15024 0x02, 0x03, 0x04, 0x05
15025};
15026
15027/* dac_nids for ALC660vd are in a different order - according to
15028 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015029 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015030 * of ALC660vd codecs, but for now there is only 3stack mixer
15031 * - and it is the same as in 861vd.
15032 * adc_nids in ALC660vd are (is) the same as in 861vd
15033 */
15034static hda_nid_t alc660vd_dac_nids[3] = {
15035 /* front, rear, clfe, rear_surr */
15036 0x02, 0x04, 0x03
15037};
15038
15039static hda_nid_t alc861vd_adc_nids[1] = {
15040 /* ADC0 */
15041 0x09,
15042};
15043
Takashi Iwaie1406342008-02-11 18:32:32 +010015044static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
15045
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015046/* input MUX */
15047/* FIXME: should be a matrix-type input source selection */
15048static struct hda_input_mux alc861vd_capture_source = {
15049 .num_items = 4,
15050 .items = {
15051 { "Mic", 0x0 },
15052 { "Front Mic", 0x1 },
15053 { "Line", 0x2 },
15054 { "CD", 0x4 },
15055 },
15056};
15057
Kailang Yang272a5272007-05-14 11:00:38 +020015058static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010015059 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020015060 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010015061 { "Ext Mic", 0x0 },
15062 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020015063 },
15064};
15065
Kailang Yangd1a991a2007-08-15 16:21:59 +020015066static struct hda_input_mux alc861vd_hp_capture_source = {
15067 .num_items = 2,
15068 .items = {
15069 { "Front Mic", 0x0 },
15070 { "ATAPI Mic", 0x1 },
15071 },
15072};
15073
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015074/*
15075 * 2ch mode
15076 */
15077static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
15078 { 2, NULL }
15079};
15080
15081/*
15082 * 6ch mode
15083 */
15084static struct hda_verb alc861vd_6stack_ch6_init[] = {
15085 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15086 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15087 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15088 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15089 { } /* end */
15090};
15091
15092/*
15093 * 8ch mode
15094 */
15095static struct hda_verb alc861vd_6stack_ch8_init[] = {
15096 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15097 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15098 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15099 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15100 { } /* end */
15101};
15102
15103static struct hda_channel_mode alc861vd_6stack_modes[2] = {
15104 { 6, alc861vd_6stack_ch6_init },
15105 { 8, alc861vd_6stack_ch8_init },
15106};
15107
15108static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
15109 {
15110 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15111 .name = "Channel Mode",
15112 .info = alc_ch_mode_info,
15113 .get = alc_ch_mode_get,
15114 .put = alc_ch_mode_put,
15115 },
15116 { } /* end */
15117};
15118
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015119/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15120 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15121 */
15122static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
15123 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15124 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15125
15126 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15127 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
15128
15129 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
15130 HDA_OUTPUT),
15131 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
15132 HDA_OUTPUT),
15133 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
15134 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
15135
15136 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
15137 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
15138
15139 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15140
15141 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15142 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15143 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15144
15145 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15146 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15147 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15148
15149 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15150 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15151
15152 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15153 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15154
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015155 { } /* end */
15156};
15157
15158static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
15159 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15160 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15161
15162 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15163
15164 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15165 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15166 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15167
15168 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15169 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15170 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15171
15172 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15173 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15174
15175 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15176 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15177
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015178 { } /* end */
15179};
15180
Kailang Yangbdd148a2007-05-08 15:19:08 +020015181static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
15182 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15183 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
15184 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15185
15186 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15187
15188 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15189 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15190 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15191
15192 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15193 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15194 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15195
15196 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15197 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15198
15199 { } /* end */
15200};
15201
Tobin Davisb419f342008-03-07 11:57:51 +010015202/* Pin assignment: Speaker=0x14, HP = 0x15,
15203 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020015204 */
15205static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010015206 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15207 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015208 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15209 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010015210 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
15211 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15212 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15213 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
15214 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15215 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015216 { } /* end */
15217};
15218
Kailang Yangd1a991a2007-08-15 16:21:59 +020015219/* Pin assignment: Speaker=0x14, Line-out = 0x15,
15220 * Front Mic=0x18, ATAPI Mic = 0x19,
15221 */
15222static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
15223 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15224 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15225 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15226 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
15227 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15228 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15229 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15230 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015231
Kailang Yangd1a991a2007-08-15 16:21:59 +020015232 { } /* end */
15233};
15234
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015235/*
15236 * generic initialization of ADC, input mixers and output mixers
15237 */
15238static struct hda_verb alc861vd_volume_init_verbs[] = {
15239 /*
15240 * Unmute ADC0 and set the default input to mic-in
15241 */
15242 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15243 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15244
15245 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
15246 * the analog-loopback mixer widget
15247 */
15248 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015249 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15250 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15251 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15252 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15253 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015254
15255 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020015256 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15257 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15258 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015259 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015260
15261 /*
15262 * Set up output mixers (0x02 - 0x05)
15263 */
15264 /* set vol=0 to output mixers */
15265 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15266 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15267 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15268 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15269
15270 /* set up input amps for analog loopback */
15271 /* Amp Indices: DAC = 0, mixer = 1 */
15272 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15273 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15274 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15275 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15276 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15277 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15278 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15279 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15280
15281 { }
15282};
15283
15284/*
15285 * 3-stack pin configuration:
15286 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
15287 */
15288static struct hda_verb alc861vd_3stack_init_verbs[] = {
15289 /*
15290 * Set pin mode and muting
15291 */
15292 /* set front pin widgets 0x14 for output */
15293 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15294 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15295 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15296
15297 /* Mic (rear) pin: input vref at 80% */
15298 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15299 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15300 /* Front Mic pin: input vref at 80% */
15301 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15302 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15303 /* Line In pin: input */
15304 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15305 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15306 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15307 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15308 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15309 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15310 /* CD pin widget for input */
15311 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15312
15313 { }
15314};
15315
15316/*
15317 * 6-stack pin configuration:
15318 */
15319static struct hda_verb alc861vd_6stack_init_verbs[] = {
15320 /*
15321 * Set pin mode and muting
15322 */
15323 /* set front pin widgets 0x14 for output */
15324 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15325 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15326 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15327
15328 /* Rear Pin: output 1 (0x0d) */
15329 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15330 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15331 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15332 /* CLFE Pin: output 2 (0x0e) */
15333 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15334 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15335 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15336 /* Side Pin: output 3 (0x0f) */
15337 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15338 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15339 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15340
15341 /* Mic (rear) pin: input vref at 80% */
15342 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15343 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15344 /* Front Mic pin: input vref at 80% */
15345 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15346 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15347 /* Line In pin: input */
15348 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15349 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15350 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15351 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15352 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15353 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15354 /* CD pin widget for input */
15355 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15356
15357 { }
15358};
15359
Kailang Yangbdd148a2007-05-08 15:19:08 +020015360static struct hda_verb alc861vd_eapd_verbs[] = {
15361 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15362 { }
15363};
15364
Kailang Yangf9423e72008-05-27 12:32:25 +020015365static struct hda_verb alc660vd_eapd_verbs[] = {
15366 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15367 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15368 { }
15369};
15370
Kailang Yangbdd148a2007-05-08 15:19:08 +020015371static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15372 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15373 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15374 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15375 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015376 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015377 {}
15378};
15379
Kailang Yangbdd148a2007-05-08 15:19:08 +020015380static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15381{
15382 unsigned int present;
15383 unsigned char bits;
15384
Wu Fengguang864f92b2009-11-18 12:38:02 +080015385 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020015386 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080015387
Takashi Iwai47fd8302007-08-10 17:11:07 +020015388 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15389 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015390}
15391
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015392static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015393{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015394 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015395 spec->autocfg.hp_pins[0] = 0x1b;
15396 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015397}
15398
15399static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15400{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015401 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015402 alc861vd_lenovo_mic_automute(codec);
15403}
15404
15405static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15406 unsigned int res)
15407{
15408 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015409 case ALC880_MIC_EVENT:
15410 alc861vd_lenovo_mic_automute(codec);
15411 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015412 default:
15413 alc_automute_amp_unsol_event(codec, res);
15414 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015415 }
15416}
15417
Kailang Yang272a5272007-05-14 11:00:38 +020015418static struct hda_verb alc861vd_dallas_verbs[] = {
15419 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15420 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15421 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15422 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15423
15424 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15425 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15426 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15427 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15428 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15429 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15430 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15431 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015432
Kailang Yang272a5272007-05-14 11:00:38 +020015433 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15434 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15435 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15436 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15437 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15438 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15439 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15440 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15441
15442 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15443 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15444 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15445 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15446 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15447 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15448 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15449 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15450
15451 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15452 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15453 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15454 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15455
15456 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015457 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015458 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15459
15460 { } /* end */
15461};
15462
15463/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015464static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015465{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015466 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015467
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015468 spec->autocfg.hp_pins[0] = 0x15;
15469 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020015470}
15471
Takashi Iwaicb53c622007-08-10 17:21:45 +020015472#ifdef CONFIG_SND_HDA_POWER_SAVE
15473#define alc861vd_loopbacks alc880_loopbacks
15474#endif
15475
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015476/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015477#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15478#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15479#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15480#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15481
15482/*
15483 * configuration and preset
15484 */
15485static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15486 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015487 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015488 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015489 [ALC861VD_3ST] = "3stack",
15490 [ALC861VD_3ST_DIG] = "3stack-digout",
15491 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015492 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015493 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015494 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015495 [ALC861VD_AUTO] = "auto",
15496};
15497
15498static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015499 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15500 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015501 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015502 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010015503 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015504 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015505 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015506 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015507 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015508 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015509 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015510 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015511 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015512 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015513 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015514 {}
15515};
15516
15517static struct alc_config_preset alc861vd_presets[] = {
15518 [ALC660VD_3ST] = {
15519 .mixers = { alc861vd_3st_mixer },
15520 .init_verbs = { alc861vd_volume_init_verbs,
15521 alc861vd_3stack_init_verbs },
15522 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15523 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015524 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15525 .channel_mode = alc861vd_3stack_2ch_modes,
15526 .input_mux = &alc861vd_capture_source,
15527 },
Mike Crash6963f842007-06-25 12:12:51 +020015528 [ALC660VD_3ST_DIG] = {
15529 .mixers = { alc861vd_3st_mixer },
15530 .init_verbs = { alc861vd_volume_init_verbs,
15531 alc861vd_3stack_init_verbs },
15532 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15533 .dac_nids = alc660vd_dac_nids,
15534 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015535 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15536 .channel_mode = alc861vd_3stack_2ch_modes,
15537 .input_mux = &alc861vd_capture_source,
15538 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015539 [ALC861VD_3ST] = {
15540 .mixers = { alc861vd_3st_mixer },
15541 .init_verbs = { alc861vd_volume_init_verbs,
15542 alc861vd_3stack_init_verbs },
15543 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15544 .dac_nids = alc861vd_dac_nids,
15545 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15546 .channel_mode = alc861vd_3stack_2ch_modes,
15547 .input_mux = &alc861vd_capture_source,
15548 },
15549 [ALC861VD_3ST_DIG] = {
15550 .mixers = { alc861vd_3st_mixer },
15551 .init_verbs = { alc861vd_volume_init_verbs,
15552 alc861vd_3stack_init_verbs },
15553 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15554 .dac_nids = alc861vd_dac_nids,
15555 .dig_out_nid = ALC861VD_DIGOUT_NID,
15556 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15557 .channel_mode = alc861vd_3stack_2ch_modes,
15558 .input_mux = &alc861vd_capture_source,
15559 },
15560 [ALC861VD_6ST_DIG] = {
15561 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15562 .init_verbs = { alc861vd_volume_init_verbs,
15563 alc861vd_6stack_init_verbs },
15564 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15565 .dac_nids = alc861vd_dac_nids,
15566 .dig_out_nid = ALC861VD_DIGOUT_NID,
15567 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15568 .channel_mode = alc861vd_6stack_modes,
15569 .input_mux = &alc861vd_capture_source,
15570 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015571 [ALC861VD_LENOVO] = {
15572 .mixers = { alc861vd_lenovo_mixer },
15573 .init_verbs = { alc861vd_volume_init_verbs,
15574 alc861vd_3stack_init_verbs,
15575 alc861vd_eapd_verbs,
15576 alc861vd_lenovo_unsol_verbs },
15577 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15578 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015579 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15580 .channel_mode = alc861vd_3stack_2ch_modes,
15581 .input_mux = &alc861vd_capture_source,
15582 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015583 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015584 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015585 },
Kailang Yang272a5272007-05-14 11:00:38 +020015586 [ALC861VD_DALLAS] = {
15587 .mixers = { alc861vd_dallas_mixer },
15588 .init_verbs = { alc861vd_dallas_verbs },
15589 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15590 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015591 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15592 .channel_mode = alc861vd_3stack_2ch_modes,
15593 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015594 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015595 .setup = alc861vd_dallas_setup,
15596 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015597 },
15598 [ALC861VD_HP] = {
15599 .mixers = { alc861vd_hp_mixer },
15600 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15601 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15602 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015603 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015604 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15605 .channel_mode = alc861vd_3stack_2ch_modes,
15606 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015607 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015608 .setup = alc861vd_dallas_setup,
15609 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020015610 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015611 [ALC660VD_ASUS_V1S] = {
15612 .mixers = { alc861vd_lenovo_mixer },
15613 .init_verbs = { alc861vd_volume_init_verbs,
15614 alc861vd_3stack_init_verbs,
15615 alc861vd_eapd_verbs,
15616 alc861vd_lenovo_unsol_verbs },
15617 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15618 .dac_nids = alc660vd_dac_nids,
15619 .dig_out_nid = ALC861VD_DIGOUT_NID,
15620 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15621 .channel_mode = alc861vd_3stack_2ch_modes,
15622 .input_mux = &alc861vd_capture_source,
15623 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015624 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015625 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015626 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015627};
15628
15629/*
15630 * BIOS auto configuration
15631 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015632static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15633 const struct auto_pin_cfg *cfg)
15634{
Takashi Iwai9c0afc82010-01-12 14:00:11 +010015635 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x22, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020015636}
15637
15638
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015639static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15640 hda_nid_t nid, int pin_type, int dac_idx)
15641{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015642 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015643}
15644
15645static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15646{
15647 struct alc_spec *spec = codec->spec;
15648 int i;
15649
15650 for (i = 0; i <= HDA_SIDE; i++) {
15651 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015652 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015653 if (nid)
15654 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015655 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015656 }
15657}
15658
15659
15660static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15661{
15662 struct alc_spec *spec = codec->spec;
15663 hda_nid_t pin;
15664
15665 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015666 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015667 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015668 pin = spec->autocfg.speaker_pins[0];
15669 if (pin)
15670 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015671}
15672
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015673#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15674
15675static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15676{
15677 struct alc_spec *spec = codec->spec;
15678 int i;
15679
15680 for (i = 0; i < AUTO_PIN_LAST; i++) {
15681 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020015682 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015683 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015684 if (nid != ALC861VD_PIN_CD_NID &&
15685 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015686 snd_hda_codec_write(codec, nid, 0,
15687 AC_VERB_SET_AMP_GAIN_MUTE,
15688 AMP_OUT_MUTE);
15689 }
15690 }
15691}
15692
Takashi Iwaif511b012008-08-15 16:46:42 +020015693#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15694
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015695#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15696#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15697
15698/* add playback controls from the parsed DAC table */
15699/* Based on ALC880 version. But ALC861VD has separate,
15700 * different NIDs for mute/unmute switch and volume control */
15701static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15702 const struct auto_pin_cfg *cfg)
15703{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015704 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15705 hda_nid_t nid_v, nid_s;
15706 int i, err;
15707
15708 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015709 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015710 continue;
15711 nid_v = alc861vd_idx_to_mixer_vol(
15712 alc880_dac_to_idx(
15713 spec->multiout.dac_nids[i]));
15714 nid_s = alc861vd_idx_to_mixer_switch(
15715 alc880_dac_to_idx(
15716 spec->multiout.dac_nids[i]));
15717
15718 if (i == 2) {
15719 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015720 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
15721 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015722 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15723 HDA_OUTPUT));
15724 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015725 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015726 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
15727 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015728 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15729 HDA_OUTPUT));
15730 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015731 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015732 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
15733 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015734 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15735 HDA_INPUT));
15736 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015737 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015738 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
15739 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015740 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15741 HDA_INPUT));
15742 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015743 return err;
15744 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015745 const char *pfx;
15746 if (cfg->line_outs == 1 &&
15747 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
15748 if (!cfg->hp_pins)
15749 pfx = "Speaker";
15750 else
15751 pfx = "PCM";
15752 } else
15753 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015754 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015755 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15756 HDA_OUTPUT));
15757 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015758 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015759 if (cfg->line_outs == 1 &&
15760 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15761 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015762 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015763 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015764 HDA_INPUT));
15765 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015766 return err;
15767 }
15768 }
15769 return 0;
15770}
15771
15772/* add playback controls for speaker and HP outputs */
15773/* Based on ALC880 version. But ALC861VD has separate,
15774 * different NIDs for mute/unmute switch and volume control */
15775static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15776 hda_nid_t pin, const char *pfx)
15777{
15778 hda_nid_t nid_v, nid_s;
15779 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015780
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015781 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015782 return 0;
15783
15784 if (alc880_is_fixed_pin(pin)) {
15785 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15786 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015787 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015788 spec->multiout.hp_nid = nid_v;
15789 else
15790 spec->multiout.extra_out_nid[0] = nid_v;
15791 /* control HP volume/switch on the output mixer amp */
15792 nid_v = alc861vd_idx_to_mixer_vol(
15793 alc880_fixed_pin_idx(pin));
15794 nid_s = alc861vd_idx_to_mixer_switch(
15795 alc880_fixed_pin_idx(pin));
15796
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015797 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015798 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15799 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015800 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015801 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015802 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15803 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015804 return err;
15805 } else if (alc880_is_multi_pin(pin)) {
15806 /* set manual connection */
15807 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015808 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015809 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15810 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015811 return err;
15812 }
15813 return 0;
15814}
15815
15816/* parse the BIOS configuration and set up the alc_spec
15817 * return 1 if successful, 0 if the proper config is not found,
15818 * or a negative error code
15819 * Based on ALC880 version - had to change it to override
15820 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15821static int alc861vd_parse_auto_config(struct hda_codec *codec)
15822{
15823 struct alc_spec *spec = codec->spec;
15824 int err;
15825 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15826
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015827 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15828 alc861vd_ignore);
15829 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015830 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015831 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015832 return 0; /* can't find valid BIOS pin config */
15833
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015834 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15835 if (err < 0)
15836 return err;
15837 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15838 if (err < 0)
15839 return err;
15840 err = alc861vd_auto_create_extra_out(spec,
15841 spec->autocfg.speaker_pins[0],
15842 "Speaker");
15843 if (err < 0)
15844 return err;
15845 err = alc861vd_auto_create_extra_out(spec,
15846 spec->autocfg.hp_pins[0],
15847 "Headphone");
15848 if (err < 0)
15849 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015850 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015851 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015852 return err;
15853
15854 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15855
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015856 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015857 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15858
Takashi Iwai603c4012008-07-30 15:01:44 +020015859 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015860 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015861
Takashi Iwaid88897e2008-10-31 15:01:37 +010015862 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015863
15864 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015865 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015866
Takashi Iwai776e1842007-08-29 15:07:11 +020015867 err = alc_auto_add_mic_boost(codec);
15868 if (err < 0)
15869 return err;
15870
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015871 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15872
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015873 return 1;
15874}
15875
15876/* additional initialization for auto-configuration model */
15877static void alc861vd_auto_init(struct hda_codec *codec)
15878{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015879 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015880 alc861vd_auto_init_multi_out(codec);
15881 alc861vd_auto_init_hp_out(codec);
15882 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015883 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015884 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015885 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015886}
15887
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015888enum {
15889 ALC660VD_FIX_ASUS_GPIO1
15890};
15891
15892/* reset GPIO1 */
15893static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
15894 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
15895 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
15896 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
15897 { }
15898};
15899
15900static const struct alc_fixup alc861vd_fixups[] = {
15901 [ALC660VD_FIX_ASUS_GPIO1] = {
15902 .verbs = alc660vd_fix_asus_gpio1_verbs,
15903 },
15904};
15905
15906static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
15907 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
15908 {}
15909};
15910
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015911static int patch_alc861vd(struct hda_codec *codec)
15912{
15913 struct alc_spec *spec;
15914 int err, board_config;
15915
15916 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15917 if (spec == NULL)
15918 return -ENOMEM;
15919
15920 codec->spec = spec;
15921
15922 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15923 alc861vd_models,
15924 alc861vd_cfg_tbl);
15925
15926 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015927 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15928 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015929 board_config = ALC861VD_AUTO;
15930 }
15931
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015932 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups);
15933
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015934 if (board_config == ALC861VD_AUTO) {
15935 /* automatic parse from the BIOS config */
15936 err = alc861vd_parse_auto_config(codec);
15937 if (err < 0) {
15938 alc_free(codec);
15939 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015940 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015941 printk(KERN_INFO
15942 "hda_codec: Cannot set up configuration "
15943 "from BIOS. Using base mode...\n");
15944 board_config = ALC861VD_3ST;
15945 }
15946 }
15947
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015948 err = snd_hda_attach_beep_device(codec, 0x23);
15949 if (err < 0) {
15950 alc_free(codec);
15951 return err;
15952 }
15953
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015954 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015955 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015956
Kailang Yang2f893282008-05-27 12:14:47 +020015957 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015958 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015959 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015960 }
15961
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015962 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15963 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15964
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015965 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15966 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15967
Takashi Iwaidd704692009-08-11 08:45:11 +020015968 if (!spec->adc_nids) {
15969 spec->adc_nids = alc861vd_adc_nids;
15970 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15971 }
15972 if (!spec->capsrc_nids)
15973 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015974
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015975 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015976 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015977
Takashi Iwai2134ea42008-01-10 16:53:55 +010015978 spec->vmaster_nid = 0x02;
15979
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015980 codec->patch_ops = alc_patch_ops;
15981
15982 if (board_config == ALC861VD_AUTO)
15983 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015984#ifdef CONFIG_SND_HDA_POWER_SAVE
15985 if (!spec->loopback.amplist)
15986 spec->loopback.amplist = alc861vd_loopbacks;
15987#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015988
15989 return 0;
15990}
15991
15992/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015993 * ALC662 support
15994 *
15995 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15996 * configuration. Each pin widget can choose any input DACs and a mixer.
15997 * Each ADC is connected from a mixer of all inputs. This makes possible
15998 * 6-channel independent captures.
15999 *
16000 * In addition, an independent DAC for the multi-playback (not used in this
16001 * driver yet).
16002 */
16003#define ALC662_DIGOUT_NID 0x06
16004#define ALC662_DIGIN_NID 0x0a
16005
16006static hda_nid_t alc662_dac_nids[4] = {
16007 /* front, rear, clfe, rear_surr */
16008 0x02, 0x03, 0x04
16009};
16010
Kailang Yang622e84c2009-04-21 07:39:04 +020016011static hda_nid_t alc272_dac_nids[2] = {
16012 0x02, 0x03
16013};
16014
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016015static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016016 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016017 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016018};
Takashi Iwaie1406342008-02-11 18:32:32 +010016019
Kailang Yang622e84c2009-04-21 07:39:04 +020016020static hda_nid_t alc272_adc_nids[1] = {
16021 /* ADC1-2 */
16022 0x08,
16023};
16024
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016025static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020016026static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
16027
Takashi Iwaie1406342008-02-11 18:32:32 +010016028
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016029/* input MUX */
16030/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016031static struct hda_input_mux alc662_capture_source = {
16032 .num_items = 4,
16033 .items = {
16034 { "Mic", 0x0 },
16035 { "Front Mic", 0x1 },
16036 { "Line", 0x2 },
16037 { "CD", 0x4 },
16038 },
16039};
16040
16041static struct hda_input_mux alc662_lenovo_101e_capture_source = {
16042 .num_items = 2,
16043 .items = {
16044 { "Mic", 0x1 },
16045 { "Line", 0x2 },
16046 },
16047};
Kailang Yang291702f2007-10-16 14:28:03 +020016048
Kailang Yang6dda9f42008-05-27 12:05:31 +020016049static struct hda_input_mux alc663_capture_source = {
16050 .num_items = 3,
16051 .items = {
16052 { "Mic", 0x0 },
16053 { "Front Mic", 0x1 },
16054 { "Line", 0x2 },
16055 },
16056};
16057
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016058#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020016059static struct hda_input_mux alc272_nc10_capture_source = {
16060 .num_items = 16,
16061 .items = {
16062 { "Autoselect Mic", 0x0 },
16063 { "Internal Mic", 0x1 },
16064 { "In-0x02", 0x2 },
16065 { "In-0x03", 0x3 },
16066 { "In-0x04", 0x4 },
16067 { "In-0x05", 0x5 },
16068 { "In-0x06", 0x6 },
16069 { "In-0x07", 0x7 },
16070 { "In-0x08", 0x8 },
16071 { "In-0x09", 0x9 },
16072 { "In-0x0a", 0x0a },
16073 { "In-0x0b", 0x0b },
16074 { "In-0x0c", 0x0c },
16075 { "In-0x0d", 0x0d },
16076 { "In-0x0e", 0x0e },
16077 { "In-0x0f", 0x0f },
16078 },
16079};
16080#endif
16081
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016082/*
16083 * 2ch mode
16084 */
16085static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
16086 { 2, NULL }
16087};
16088
16089/*
16090 * 2ch mode
16091 */
16092static struct hda_verb alc662_3ST_ch2_init[] = {
16093 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
16094 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16095 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
16096 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16097 { } /* end */
16098};
16099
16100/*
16101 * 6ch mode
16102 */
16103static struct hda_verb alc662_3ST_ch6_init[] = {
16104 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16105 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16106 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
16107 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16108 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16109 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
16110 { } /* end */
16111};
16112
16113static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
16114 { 2, alc662_3ST_ch2_init },
16115 { 6, alc662_3ST_ch6_init },
16116};
16117
16118/*
16119 * 2ch mode
16120 */
16121static struct hda_verb alc662_sixstack_ch6_init[] = {
16122 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16123 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16124 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16125 { } /* end */
16126};
16127
16128/*
16129 * 6ch mode
16130 */
16131static struct hda_verb alc662_sixstack_ch8_init[] = {
16132 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16133 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16134 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16135 { } /* end */
16136};
16137
16138static struct hda_channel_mode alc662_5stack_modes[2] = {
16139 { 2, alc662_sixstack_ch6_init },
16140 { 6, alc662_sixstack_ch8_init },
16141};
16142
16143/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16144 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16145 */
16146
16147static struct snd_kcontrol_new alc662_base_mixer[] = {
16148 /* output mixer control */
16149 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016150 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016151 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016152 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016153 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16154 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016155 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16156 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016157 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16158
16159 /*Input mixer control */
16160 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
16161 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
16162 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
16163 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
16164 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
16165 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
16166 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
16167 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016168 { } /* end */
16169};
16170
16171static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
16172 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016173 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016174 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16175 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16176 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16177 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16178 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16179 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16180 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16181 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16182 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016183 { } /* end */
16184};
16185
16186static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
16187 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016188 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016189 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016190 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016191 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16192 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016193 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16194 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016195 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16196 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16197 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16198 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16199 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16200 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16201 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16202 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16203 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016204 { } /* end */
16205};
16206
16207static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
16208 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16209 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010016210 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16211 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016212 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16213 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16214 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16215 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16216 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016217 { } /* end */
16218};
16219
Kailang Yang291702f2007-10-16 14:28:03 +020016220static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016221 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16222 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020016223
16224 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
16225 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16226 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16227
16228 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16229 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16230 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16231 { } /* end */
16232};
16233
Kailang Yang8c427222008-01-10 13:03:59 +010016234static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016235 ALC262_HIPPO_MASTER_SWITCH,
16236 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016237 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016238 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16239 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016240 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
16241 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16242 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16243 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16244 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16245 { } /* end */
16246};
16247
Kailang Yangf1d4e282008-08-26 14:03:29 +020016248static struct hda_bind_ctls alc663_asus_bind_master_vol = {
16249 .ops = &snd_hda_bind_vol,
16250 .values = {
16251 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16252 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
16253 0
16254 },
16255};
16256
16257static struct hda_bind_ctls alc663_asus_one_bind_switch = {
16258 .ops = &snd_hda_bind_sw,
16259 .values = {
16260 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16261 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16262 0
16263 },
16264};
16265
Kailang Yang6dda9f42008-05-27 12:05:31 +020016266static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016267 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16268 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
16269 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16270 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16271 { } /* end */
16272};
16273
16274static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
16275 .ops = &snd_hda_bind_sw,
16276 .values = {
16277 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16278 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16279 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16280 0
16281 },
16282};
16283
16284static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
16285 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16286 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
16287 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16288 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16289 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16290 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16291
16292 { } /* end */
16293};
16294
16295static struct hda_bind_ctls alc663_asus_four_bind_switch = {
16296 .ops = &snd_hda_bind_sw,
16297 .values = {
16298 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16299 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16300 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16301 0
16302 },
16303};
16304
16305static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
16306 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16307 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
16308 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16309 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16310 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16311 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16312 { } /* end */
16313};
16314
16315static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016316 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16317 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016318 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16319 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16320 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16321 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16322 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16323 { } /* end */
16324};
16325
16326static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
16327 .ops = &snd_hda_bind_vol,
16328 .values = {
16329 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16330 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16331 0
16332 },
16333};
16334
16335static struct hda_bind_ctls alc663_asus_two_bind_switch = {
16336 .ops = &snd_hda_bind_sw,
16337 .values = {
16338 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16339 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
16340 0
16341 },
16342};
16343
16344static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16345 HDA_BIND_VOL("Master Playback Volume",
16346 &alc663_asus_two_bind_master_vol),
16347 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16348 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016349 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16350 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16351 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016352 { } /* end */
16353};
16354
16355static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16356 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16357 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16358 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16359 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16360 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16361 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016362 { } /* end */
16363};
16364
16365static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16366 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16367 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16368 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16369 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16370 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16371
16372 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16373 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16374 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16375 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16376 { } /* end */
16377};
16378
16379static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16380 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16381 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16382 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16383
16384 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16385 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16386 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16387 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16388 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16389 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16390 { } /* end */
16391};
16392
Kailang Yangebb83ee2009-12-17 12:23:00 +010016393static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
16394 .ops = &snd_hda_bind_sw,
16395 .values = {
16396 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16397 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16398 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16399 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16400 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16401 0
16402 },
16403};
16404
16405static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
16406 .ops = &snd_hda_bind_sw,
16407 .values = {
16408 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16409 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16410 0
16411 },
16412};
16413
16414static struct snd_kcontrol_new alc663_mode7_mixer[] = {
16415 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16416 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16417 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16418 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16419 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16420 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16421 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16422 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16423 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16424 { } /* end */
16425};
16426
16427static struct snd_kcontrol_new alc663_mode8_mixer[] = {
16428 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16429 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16430 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16431 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16432 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16433 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16434 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16435 { } /* end */
16436};
16437
16438
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016439static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16440 {
16441 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16442 .name = "Channel Mode",
16443 .info = alc_ch_mode_info,
16444 .get = alc_ch_mode_get,
16445 .put = alc_ch_mode_put,
16446 },
16447 { } /* end */
16448};
16449
16450static struct hda_verb alc662_init_verbs[] = {
16451 /* ADC: mute amp left and right */
16452 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16453 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16454 /* Front mixer: unmute input/output amp left and right (volume = 0) */
16455
Takashi Iwaicb53c622007-08-10 17:21:45 +020016456 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16457 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16458 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16459 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16460 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016461
Kailang Yangb60dd392007-09-20 12:50:29 +020016462 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16463 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16464 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16465 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16466 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16467 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016468
16469 /* Front Pin: output 0 (0x0c) */
16470 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16471 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16472
16473 /* Rear Pin: output 1 (0x0d) */
16474 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16475 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16476
16477 /* CLFE Pin: output 2 (0x0e) */
16478 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16479 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16480
16481 /* Mic (rear) pin: input vref at 80% */
16482 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16483 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16484 /* Front Mic pin: input vref at 80% */
16485 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16486 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16487 /* Line In pin: input */
16488 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16489 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16490 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16491 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16492 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16493 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16494 /* CD pin widget for input */
16495 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16496
16497 /* FIXME: use matrix-type input source selection */
16498 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16499 /* Input mixer */
16500 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016501 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016502
16503 /* always trun on EAPD */
16504 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16505 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16506
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016507 { }
16508};
16509
16510static struct hda_verb alc662_sue_init_verbs[] = {
16511 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16512 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016513 {}
16514};
16515
16516static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16517 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16518 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16519 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016520};
16521
Kailang Yang8c427222008-01-10 13:03:59 +010016522/* Set Unsolicited Event*/
16523static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16524 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16525 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16526 {}
16527};
16528
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016529/*
16530 * generic initialization of ADC, input mixers and output mixers
16531 */
16532static struct hda_verb alc662_auto_init_verbs[] = {
16533 /*
16534 * Unmute ADC and set the default input to mic-in
16535 */
16536 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16537 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16538
16539 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16540 * mixer widget
16541 * Note: PASD motherboards uses the Line In 2 as the input for front
16542 * panel mic (mic 2)
16543 */
16544 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016545 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16546 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16547 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16548 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16549 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016550
16551 /*
16552 * Set up output mixers (0x0c - 0x0f)
16553 */
16554 /* set vol=0 to output mixers */
16555 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16556 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16557 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16558
16559 /* set up input amps for analog loopback */
16560 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020016561 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16562 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16563 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16564 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16565 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16566 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016567
16568
16569 /* FIXME: use matrix-type input source selection */
16570 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16571 /* Input mixer */
16572 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016573 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016574 { }
16575};
16576
Takashi Iwai24fb9172008-09-02 14:48:20 +020016577/* additional verbs for ALC663 */
16578static struct hda_verb alc663_auto_init_verbs[] = {
16579 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16580 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16581 { }
16582};
16583
Kailang Yang6dda9f42008-05-27 12:05:31 +020016584static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016585 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16586 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016587 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16588 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016589 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16590 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16591 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016592 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16593 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16594 {}
16595};
16596
Kailang Yangf1d4e282008-08-26 14:03:29 +020016597static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16598 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16599 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16600 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16601 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16602 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16603 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16604 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16605 {}
16606};
16607
16608static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16609 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16610 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16611 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16612 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16613 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16614 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16615 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16616 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16617 {}
16618};
16619
16620static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16621 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16622 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16623 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16624 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16625 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16626 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16627 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16628 {}
16629};
16630
16631static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16632 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16633 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16634 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16635 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16636 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16637 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16638 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16639 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16640 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16641 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16642 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16643 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16644 {}
16645};
16646
16647static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16648 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16649 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16650 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16651 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16652 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16653 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16654 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16655 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16656 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16657 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16658 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16659 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16660 {}
16661};
16662
Kailang Yang6dda9f42008-05-27 12:05:31 +020016663static struct hda_verb alc663_g71v_init_verbs[] = {
16664 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16665 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16666 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16667
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, 0x00}, /* Headphone */
16671
16672 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16673 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16674 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16675 {}
16676};
16677
16678static struct hda_verb alc663_g50v_init_verbs[] = {
16679 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16680 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16681 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16682
16683 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16684 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16685 {}
16686};
16687
Kailang Yangf1d4e282008-08-26 14:03:29 +020016688static struct hda_verb alc662_ecs_init_verbs[] = {
16689 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16690 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16691 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16692 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16693 {}
16694};
16695
Kailang Yang622e84c2009-04-21 07:39:04 +020016696static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16697 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16698 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16699 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16700 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16701 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16702 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16703 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16704 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16705 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16706 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16707 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16708 {}
16709};
16710
16711static struct hda_verb alc272_dell_init_verbs[] = {
16712 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16713 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16714 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16715 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16716 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16717 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16718 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16719 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16720 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16721 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16722 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16723 {}
16724};
16725
Kailang Yangebb83ee2009-12-17 12:23:00 +010016726static struct hda_verb alc663_mode7_init_verbs[] = {
16727 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16728 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16729 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16730 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16731 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16732 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16733 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
16734 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16735 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16736 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16737 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16738 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16739 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16740 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16741 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16742 {}
16743};
16744
16745static struct hda_verb alc663_mode8_init_verbs[] = {
16746 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16747 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16748 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16749 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16750 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16751 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16752 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16753 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16754 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16755 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16756 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16757 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16758 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16759 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16760 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16761 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16762 {}
16763};
16764
Kailang Yangf1d4e282008-08-26 14:03:29 +020016765static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16766 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16767 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16768 { } /* end */
16769};
16770
Kailang Yang622e84c2009-04-21 07:39:04 +020016771static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16772 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16773 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16774 { } /* end */
16775};
16776
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016777static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16778{
16779 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016780 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016781
Wu Fengguang864f92b2009-11-18 12:38:02 +080016782 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016783 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016784
Takashi Iwai47fd8302007-08-10 17:11:07 +020016785 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16786 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016787}
16788
16789static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16790{
16791 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016792 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016793
Wu Fengguang864f92b2009-11-18 12:38:02 +080016794 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016795 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016796
Takashi Iwai47fd8302007-08-10 17:11:07 +020016797 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16798 HDA_AMP_MUTE, bits);
16799 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16800 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016801}
16802
16803static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16804 unsigned int res)
16805{
16806 if ((res >> 26) == ALC880_HP_EVENT)
16807 alc662_lenovo_101e_all_automute(codec);
16808 if ((res >> 26) == ALC880_FRONT_EVENT)
16809 alc662_lenovo_101e_ispeaker_automute(codec);
16810}
16811
Kailang Yang291702f2007-10-16 14:28:03 +020016812/* unsolicited event for HP jack sensing */
16813static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16814 unsigned int res)
16815{
Kailang Yang291702f2007-10-16 14:28:03 +020016816 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016817 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016818 else
16819 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016820}
16821
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016822static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020016823{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016824 struct alc_spec *spec = codec->spec;
16825
16826 alc262_hippo1_setup(codec);
16827 spec->ext_mic.pin = 0x18;
16828 spec->ext_mic.mux_idx = 0;
16829 spec->int_mic.pin = 0x19;
16830 spec->int_mic.mux_idx = 1;
16831 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020016832}
16833
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016834static void alc662_eeepc_inithook(struct hda_codec *codec)
16835{
16836 alc262_hippo_automute(codec);
16837 alc_mic_automute(codec);
16838}
16839
16840static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010016841{
Takashi Iwai42171c12009-05-08 14:11:43 +020016842 struct alc_spec *spec = codec->spec;
16843
16844 spec->autocfg.hp_pins[0] = 0x14;
16845 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010016846}
16847
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016848#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
16849
Kailang Yang6dda9f42008-05-27 12:05:31 +020016850static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16851{
16852 unsigned int present;
16853 unsigned char bits;
16854
Wu Fengguang864f92b2009-11-18 12:38:02 +080016855 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016856 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016857 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16858 AMP_IN_MUTE(0), bits);
16859 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16860 AMP_IN_MUTE(0), bits);
16861}
16862
16863static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16864{
16865 unsigned int present;
16866 unsigned char bits;
16867
Wu Fengguang864f92b2009-11-18 12:38:02 +080016868 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016869 bits = present ? HDA_AMP_MUTE : 0;
16870 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16871 AMP_IN_MUTE(0), bits);
16872 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16873 AMP_IN_MUTE(0), bits);
16874 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16875 AMP_IN_MUTE(0), bits);
16876 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16877 AMP_IN_MUTE(0), bits);
16878}
16879
16880static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16881{
16882 unsigned int present;
16883 unsigned char bits;
16884
Wu Fengguang864f92b2009-11-18 12:38:02 +080016885 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016886 bits = present ? HDA_AMP_MUTE : 0;
16887 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16888 AMP_IN_MUTE(0), bits);
16889 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16890 AMP_IN_MUTE(0), bits);
16891 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16892 AMP_IN_MUTE(0), bits);
16893 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16894 AMP_IN_MUTE(0), bits);
16895}
16896
16897static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16898{
16899 unsigned int present;
16900 unsigned char bits;
16901
Wu Fengguang864f92b2009-11-18 12:38:02 +080016902 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016903 bits = present ? 0 : PIN_OUT;
16904 snd_hda_codec_write(codec, 0x14, 0,
16905 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16906}
16907
16908static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16909{
16910 unsigned int present1, present2;
16911
Wu Fengguang864f92b2009-11-18 12:38:02 +080016912 present1 = snd_hda_jack_detect(codec, 0x21);
16913 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016914
16915 if (present1 || present2) {
16916 snd_hda_codec_write_cache(codec, 0x14, 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 }
16922}
16923
16924static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16925{
16926 unsigned int present1, present2;
16927
Wu Fengguang864f92b2009-11-18 12:38:02 +080016928 present1 = snd_hda_jack_detect(codec, 0x1b);
16929 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016930
16931 if (present1 || present2) {
16932 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16933 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16934 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16935 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16936 } else {
16937 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16938 AMP_IN_MUTE(0), 0);
16939 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16940 AMP_IN_MUTE(0), 0);
16941 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016942}
16943
Kailang Yangebb83ee2009-12-17 12:23:00 +010016944static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
16945{
16946 unsigned int present1, present2;
16947
16948 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16949 AC_VERB_GET_PIN_SENSE, 0)
16950 & AC_PINSENSE_PRESENCE;
16951 present2 = snd_hda_codec_read(codec, 0x21, 0,
16952 AC_VERB_GET_PIN_SENSE, 0)
16953 & AC_PINSENSE_PRESENCE;
16954
16955 if (present1 || present2) {
16956 snd_hda_codec_write_cache(codec, 0x14, 0,
16957 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16958 snd_hda_codec_write_cache(codec, 0x17, 0,
16959 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16960 } else {
16961 snd_hda_codec_write_cache(codec, 0x14, 0,
16962 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16963 snd_hda_codec_write_cache(codec, 0x17, 0,
16964 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16965 }
16966}
16967
16968static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
16969{
16970 unsigned int present1, present2;
16971
16972 present1 = snd_hda_codec_read(codec, 0x21, 0,
16973 AC_VERB_GET_PIN_SENSE, 0)
16974 & AC_PINSENSE_PRESENCE;
16975 present2 = snd_hda_codec_read(codec, 0x15, 0,
16976 AC_VERB_GET_PIN_SENSE, 0)
16977 & AC_PINSENSE_PRESENCE;
16978
16979 if (present1 || present2) {
16980 snd_hda_codec_write_cache(codec, 0x14, 0,
16981 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16982 snd_hda_codec_write_cache(codec, 0x17, 0,
16983 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16984 } else {
16985 snd_hda_codec_write_cache(codec, 0x14, 0,
16986 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16987 snd_hda_codec_write_cache(codec, 0x17, 0,
16988 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16989 }
16990}
16991
Kailang Yang6dda9f42008-05-27 12:05:31 +020016992static void alc663_m51va_unsol_event(struct hda_codec *codec,
16993 unsigned int res)
16994{
16995 switch (res >> 26) {
16996 case ALC880_HP_EVENT:
16997 alc663_m51va_speaker_automute(codec);
16998 break;
16999 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017000 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017001 break;
17002 }
17003}
17004
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017005static void alc663_m51va_setup(struct hda_codec *codec)
17006{
17007 struct alc_spec *spec = codec->spec;
17008 spec->ext_mic.pin = 0x18;
17009 spec->ext_mic.mux_idx = 0;
17010 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010017011 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017012 spec->auto_mic = 1;
17013}
17014
Kailang Yang6dda9f42008-05-27 12:05:31 +020017015static void alc663_m51va_inithook(struct hda_codec *codec)
17016{
17017 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017018 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017019}
17020
Kailang Yangf1d4e282008-08-26 14:03:29 +020017021/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017022#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010017023
17024static void alc663_mode1_setup(struct hda_codec *codec)
17025{
17026 struct alc_spec *spec = codec->spec;
17027 spec->ext_mic.pin = 0x18;
17028 spec->ext_mic.mux_idx = 0;
17029 spec->int_mic.pin = 0x19;
17030 spec->int_mic.mux_idx = 1;
17031 spec->auto_mic = 1;
17032}
17033
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017034#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020017035
Kailang Yangf1d4e282008-08-26 14:03:29 +020017036/* ***************** Mode2 ******************************/
17037static void alc662_mode2_unsol_event(struct hda_codec *codec,
17038 unsigned int res)
17039{
17040 switch (res >> 26) {
17041 case ALC880_HP_EVENT:
17042 alc662_f5z_speaker_automute(codec);
17043 break;
17044 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017045 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017046 break;
17047 }
17048}
17049
Kailang Yangebb83ee2009-12-17 12:23:00 +010017050#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017051
Kailang Yangf1d4e282008-08-26 14:03:29 +020017052static void alc662_mode2_inithook(struct hda_codec *codec)
17053{
17054 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017055 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017056}
17057/* ***************** Mode3 ******************************/
17058static void alc663_mode3_unsol_event(struct hda_codec *codec,
17059 unsigned int res)
17060{
17061 switch (res >> 26) {
17062 case ALC880_HP_EVENT:
17063 alc663_two_hp_m1_speaker_automute(codec);
17064 break;
17065 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017066 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017067 break;
17068 }
17069}
17070
Kailang Yangebb83ee2009-12-17 12:23:00 +010017071#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017072
Kailang Yangf1d4e282008-08-26 14:03:29 +020017073static void alc663_mode3_inithook(struct hda_codec *codec)
17074{
17075 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017076 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017077}
17078/* ***************** Mode4 ******************************/
17079static void alc663_mode4_unsol_event(struct hda_codec *codec,
17080 unsigned int res)
17081{
17082 switch (res >> 26) {
17083 case ALC880_HP_EVENT:
17084 alc663_21jd_two_speaker_automute(codec);
17085 break;
17086 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017087 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017088 break;
17089 }
17090}
17091
Kailang Yangebb83ee2009-12-17 12:23:00 +010017092#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017093
Kailang Yangf1d4e282008-08-26 14:03:29 +020017094static void alc663_mode4_inithook(struct hda_codec *codec)
17095{
17096 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017097 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017098}
17099/* ***************** Mode5 ******************************/
17100static void alc663_mode5_unsol_event(struct hda_codec *codec,
17101 unsigned int res)
17102{
17103 switch (res >> 26) {
17104 case ALC880_HP_EVENT:
17105 alc663_15jd_two_speaker_automute(codec);
17106 break;
17107 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017108 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017109 break;
17110 }
17111}
17112
Kailang Yangebb83ee2009-12-17 12:23:00 +010017113#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017114
Kailang Yangf1d4e282008-08-26 14:03:29 +020017115static void alc663_mode5_inithook(struct hda_codec *codec)
17116{
17117 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017118 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017119}
17120/* ***************** Mode6 ******************************/
17121static void alc663_mode6_unsol_event(struct hda_codec *codec,
17122 unsigned int res)
17123{
17124 switch (res >> 26) {
17125 case ALC880_HP_EVENT:
17126 alc663_two_hp_m2_speaker_automute(codec);
17127 break;
17128 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017129 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017130 break;
17131 }
17132}
17133
Kailang Yangebb83ee2009-12-17 12:23:00 +010017134#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017135
Kailang Yangf1d4e282008-08-26 14:03:29 +020017136static void alc663_mode6_inithook(struct hda_codec *codec)
17137{
17138 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017139 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017140}
17141
Kailang Yangebb83ee2009-12-17 12:23:00 +010017142/* ***************** Mode7 ******************************/
17143static void alc663_mode7_unsol_event(struct hda_codec *codec,
17144 unsigned int res)
17145{
17146 switch (res >> 26) {
17147 case ALC880_HP_EVENT:
17148 alc663_two_hp_m7_speaker_automute(codec);
17149 break;
17150 case ALC880_MIC_EVENT:
17151 alc_mic_automute(codec);
17152 break;
17153 }
17154}
17155
17156#define alc663_mode7_setup alc663_mode1_setup
17157
17158static void alc663_mode7_inithook(struct hda_codec *codec)
17159{
17160 alc663_two_hp_m7_speaker_automute(codec);
17161 alc_mic_automute(codec);
17162}
17163
17164/* ***************** Mode8 ******************************/
17165static void alc663_mode8_unsol_event(struct hda_codec *codec,
17166 unsigned int res)
17167{
17168 switch (res >> 26) {
17169 case ALC880_HP_EVENT:
17170 alc663_two_hp_m8_speaker_automute(codec);
17171 break;
17172 case ALC880_MIC_EVENT:
17173 alc_mic_automute(codec);
17174 break;
17175 }
17176}
17177
17178#define alc663_mode8_setup alc663_m51va_setup
17179
17180static void alc663_mode8_inithook(struct hda_codec *codec)
17181{
17182 alc663_two_hp_m8_speaker_automute(codec);
17183 alc_mic_automute(codec);
17184}
17185
Kailang Yang6dda9f42008-05-27 12:05:31 +020017186static void alc663_g71v_hp_automute(struct hda_codec *codec)
17187{
17188 unsigned int present;
17189 unsigned char bits;
17190
Wu Fengguang864f92b2009-11-18 12:38:02 +080017191 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017192 bits = present ? HDA_AMP_MUTE : 0;
17193 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17194 HDA_AMP_MUTE, bits);
17195 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17196 HDA_AMP_MUTE, bits);
17197}
17198
17199static void alc663_g71v_front_automute(struct hda_codec *codec)
17200{
17201 unsigned int present;
17202 unsigned char bits;
17203
Wu Fengguang864f92b2009-11-18 12:38:02 +080017204 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017205 bits = present ? HDA_AMP_MUTE : 0;
17206 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17207 HDA_AMP_MUTE, bits);
17208}
17209
17210static void alc663_g71v_unsol_event(struct hda_codec *codec,
17211 unsigned int res)
17212{
17213 switch (res >> 26) {
17214 case ALC880_HP_EVENT:
17215 alc663_g71v_hp_automute(codec);
17216 break;
17217 case ALC880_FRONT_EVENT:
17218 alc663_g71v_front_automute(codec);
17219 break;
17220 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017221 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017222 break;
17223 }
17224}
17225
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017226#define alc663_g71v_setup alc663_m51va_setup
17227
Kailang Yang6dda9f42008-05-27 12:05:31 +020017228static void alc663_g71v_inithook(struct hda_codec *codec)
17229{
17230 alc663_g71v_front_automute(codec);
17231 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017232 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017233}
17234
17235static void alc663_g50v_unsol_event(struct hda_codec *codec,
17236 unsigned int res)
17237{
17238 switch (res >> 26) {
17239 case ALC880_HP_EVENT:
17240 alc663_m51va_speaker_automute(codec);
17241 break;
17242 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017243 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017244 break;
17245 }
17246}
17247
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017248#define alc663_g50v_setup alc663_m51va_setup
17249
Kailang Yang6dda9f42008-05-27 12:05:31 +020017250static void alc663_g50v_inithook(struct hda_codec *codec)
17251{
17252 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017253 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017254}
17255
Kailang Yangf1d4e282008-08-26 14:03:29 +020017256static struct snd_kcontrol_new alc662_ecs_mixer[] = {
17257 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020017258 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017259
17260 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
17261 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
17262 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
17263
17264 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17265 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17266 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17267 { } /* end */
17268};
17269
Chris Pockelé9541ba12009-05-12 08:08:53 +020017270static struct snd_kcontrol_new alc272_nc10_mixer[] = {
17271 /* Master Playback automatically created from Speaker and Headphone */
17272 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17273 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17274 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17275 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17276
17277 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17278 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17279 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
17280
17281 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17282 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17283 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
17284 { } /* end */
17285};
17286
Takashi Iwaicb53c622007-08-10 17:21:45 +020017287#ifdef CONFIG_SND_HDA_POWER_SAVE
17288#define alc662_loopbacks alc880_loopbacks
17289#endif
17290
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017291
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017292/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017293#define alc662_pcm_analog_playback alc880_pcm_analog_playback
17294#define alc662_pcm_analog_capture alc880_pcm_analog_capture
17295#define alc662_pcm_digital_playback alc880_pcm_digital_playback
17296#define alc662_pcm_digital_capture alc880_pcm_digital_capture
17297
17298/*
17299 * configuration and preset
17300 */
17301static const char *alc662_models[ALC662_MODEL_LAST] = {
17302 [ALC662_3ST_2ch_DIG] = "3stack-dig",
17303 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
17304 [ALC662_3ST_6ch] = "3stack-6ch",
17305 [ALC662_5ST_DIG] = "6stack-dig",
17306 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020017307 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010017308 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017309 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020017310 [ALC663_ASUS_M51VA] = "m51va",
17311 [ALC663_ASUS_G71V] = "g71v",
17312 [ALC663_ASUS_H13] = "h13",
17313 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017314 [ALC663_ASUS_MODE1] = "asus-mode1",
17315 [ALC662_ASUS_MODE2] = "asus-mode2",
17316 [ALC663_ASUS_MODE3] = "asus-mode3",
17317 [ALC663_ASUS_MODE4] = "asus-mode4",
17318 [ALC663_ASUS_MODE5] = "asus-mode5",
17319 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010017320 [ALC663_ASUS_MODE7] = "asus-mode7",
17321 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020017322 [ALC272_DELL] = "dell",
17323 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020017324 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017325 [ALC662_AUTO] = "auto",
17326};
17327
17328static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010017329 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020017330 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
17331 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017332 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
17333 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
17334 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
17335 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
17336 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
17337 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017338 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
17339 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017340 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017341 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
17342 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
17343 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
17344 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
17345 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017346 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017347 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
17348 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017349 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
17350 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
17351 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
17352 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017353 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017354 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
17355 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
17356 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017357 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
17358 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
17359 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
17360 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017361 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017362 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
17363 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017364 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017365 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
17366 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
17367 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017368 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
17369 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
17370 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017371 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
17372 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
17373 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017374 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017375 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
17376 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017377 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017378 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020017379 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017380 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
17381 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
17382 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017383 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017384 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
17385 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010017386 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020017387 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010017388 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017389 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030017390 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
17391 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010017392 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020017393 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030017394 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
17395 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020017396 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020017397 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017398 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020017399 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020017400 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017401 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
17402 ALC663_ASUS_H13),
David Santinoli7aee6742009-12-09 12:34:26 +010017403 SND_PCI_QUIRK(0x8086, 0xd604, "Intel mobo", ALC662_3ST_2ch_DIG),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017404 {}
17405};
17406
17407static struct alc_config_preset alc662_presets[] = {
17408 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017409 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017410 .init_verbs = { alc662_init_verbs },
17411 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17412 .dac_nids = alc662_dac_nids,
17413 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017414 .dig_in_nid = ALC662_DIGIN_NID,
17415 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17416 .channel_mode = alc662_3ST_2ch_modes,
17417 .input_mux = &alc662_capture_source,
17418 },
17419 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017420 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017421 .init_verbs = { alc662_init_verbs },
17422 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17423 .dac_nids = alc662_dac_nids,
17424 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017425 .dig_in_nid = ALC662_DIGIN_NID,
17426 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17427 .channel_mode = alc662_3ST_6ch_modes,
17428 .need_dac_fix = 1,
17429 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017430 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017431 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017432 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017433 .init_verbs = { alc662_init_verbs },
17434 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17435 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017436 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17437 .channel_mode = alc662_3ST_6ch_modes,
17438 .need_dac_fix = 1,
17439 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017440 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017441 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017442 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017443 .init_verbs = { alc662_init_verbs },
17444 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17445 .dac_nids = alc662_dac_nids,
17446 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017447 .dig_in_nid = ALC662_DIGIN_NID,
17448 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
17449 .channel_mode = alc662_5stack_modes,
17450 .input_mux = &alc662_capture_source,
17451 },
17452 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017453 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017454 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
17455 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17456 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017457 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17458 .channel_mode = alc662_3ST_2ch_modes,
17459 .input_mux = &alc662_lenovo_101e_capture_source,
17460 .unsol_event = alc662_lenovo_101e_unsol_event,
17461 .init_hook = alc662_lenovo_101e_all_automute,
17462 },
Kailang Yang291702f2007-10-16 14:28:03 +020017463 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017464 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020017465 .init_verbs = { alc662_init_verbs,
17466 alc662_eeepc_sue_init_verbs },
17467 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17468 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020017469 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17470 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020017471 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017472 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020017473 .init_hook = alc662_eeepc_inithook,
17474 },
Kailang Yang8c427222008-01-10 13:03:59 +010017475 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017476 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010017477 alc662_chmode_mixer },
17478 .init_verbs = { alc662_init_verbs,
17479 alc662_eeepc_ep20_sue_init_verbs },
17480 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17481 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010017482 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17483 .channel_mode = alc662_3ST_6ch_modes,
17484 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020017485 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017486 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010017487 .init_hook = alc662_eeepc_ep20_inithook,
17488 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017489 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017490 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017491 .init_verbs = { alc662_init_verbs,
17492 alc662_ecs_init_verbs },
17493 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17494 .dac_nids = alc662_dac_nids,
17495 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17496 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017497 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017498 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017499 .init_hook = alc662_eeepc_inithook,
17500 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017501 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017502 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017503 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17504 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17505 .dac_nids = alc662_dac_nids,
17506 .dig_out_nid = ALC662_DIGOUT_NID,
17507 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17508 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017509 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017510 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017511 .init_hook = alc663_m51va_inithook,
17512 },
17513 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017514 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017515 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
17516 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17517 .dac_nids = alc662_dac_nids,
17518 .dig_out_nid = ALC662_DIGOUT_NID,
17519 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17520 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017521 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017522 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017523 .init_hook = alc663_g71v_inithook,
17524 },
17525 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017526 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017527 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17528 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17529 .dac_nids = alc662_dac_nids,
17530 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17531 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017532 .unsol_event = alc663_m51va_unsol_event,
17533 .init_hook = alc663_m51va_inithook,
17534 },
17535 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017536 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017537 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17538 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17539 .dac_nids = alc662_dac_nids,
17540 .dig_out_nid = ALC662_DIGOUT_NID,
17541 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17542 .channel_mode = alc662_3ST_6ch_modes,
17543 .input_mux = &alc663_capture_source,
17544 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017545 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017546 .init_hook = alc663_g50v_inithook,
17547 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017548 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017549 .mixers = { alc663_m51va_mixer },
17550 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017551 .init_verbs = { alc662_init_verbs,
17552 alc663_21jd_amic_init_verbs },
17553 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17554 .hp_nid = 0x03,
17555 .dac_nids = alc662_dac_nids,
17556 .dig_out_nid = ALC662_DIGOUT_NID,
17557 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17558 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017559 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017560 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017561 .init_hook = alc663_mode1_inithook,
17562 },
17563 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017564 .mixers = { alc662_1bjd_mixer },
17565 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017566 .init_verbs = { alc662_init_verbs,
17567 alc662_1bjd_amic_init_verbs },
17568 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17569 .dac_nids = alc662_dac_nids,
17570 .dig_out_nid = ALC662_DIGOUT_NID,
17571 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17572 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017573 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017574 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017575 .init_hook = alc662_mode2_inithook,
17576 },
17577 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017578 .mixers = { alc663_two_hp_m1_mixer },
17579 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017580 .init_verbs = { alc662_init_verbs,
17581 alc663_two_hp_amic_m1_init_verbs },
17582 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17583 .hp_nid = 0x03,
17584 .dac_nids = alc662_dac_nids,
17585 .dig_out_nid = ALC662_DIGOUT_NID,
17586 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17587 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017588 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017589 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017590 .init_hook = alc663_mode3_inithook,
17591 },
17592 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017593 .mixers = { alc663_asus_21jd_clfe_mixer },
17594 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017595 .init_verbs = { alc662_init_verbs,
17596 alc663_21jd_amic_init_verbs},
17597 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17598 .hp_nid = 0x03,
17599 .dac_nids = alc662_dac_nids,
17600 .dig_out_nid = ALC662_DIGOUT_NID,
17601 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17602 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017603 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017604 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017605 .init_hook = alc663_mode4_inithook,
17606 },
17607 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017608 .mixers = { alc663_asus_15jd_clfe_mixer },
17609 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017610 .init_verbs = { alc662_init_verbs,
17611 alc663_15jd_amic_init_verbs },
17612 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17613 .hp_nid = 0x03,
17614 .dac_nids = alc662_dac_nids,
17615 .dig_out_nid = ALC662_DIGOUT_NID,
17616 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17617 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017618 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017619 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017620 .init_hook = alc663_mode5_inithook,
17621 },
17622 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017623 .mixers = { alc663_two_hp_m2_mixer },
17624 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017625 .init_verbs = { alc662_init_verbs,
17626 alc663_two_hp_amic_m2_init_verbs },
17627 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17628 .hp_nid = 0x03,
17629 .dac_nids = alc662_dac_nids,
17630 .dig_out_nid = ALC662_DIGOUT_NID,
17631 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17632 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017633 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017634 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017635 .init_hook = alc663_mode6_inithook,
17636 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010017637 [ALC663_ASUS_MODE7] = {
17638 .mixers = { alc663_mode7_mixer },
17639 .cap_mixer = alc662_auto_capture_mixer,
17640 .init_verbs = { alc662_init_verbs,
17641 alc663_mode7_init_verbs },
17642 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17643 .hp_nid = 0x03,
17644 .dac_nids = alc662_dac_nids,
17645 .dig_out_nid = ALC662_DIGOUT_NID,
17646 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17647 .channel_mode = alc662_3ST_2ch_modes,
17648 .unsol_event = alc663_mode7_unsol_event,
17649 .setup = alc663_mode7_setup,
17650 .init_hook = alc663_mode7_inithook,
17651 },
17652 [ALC663_ASUS_MODE8] = {
17653 .mixers = { alc663_mode8_mixer },
17654 .cap_mixer = alc662_auto_capture_mixer,
17655 .init_verbs = { alc662_init_verbs,
17656 alc663_mode8_init_verbs },
17657 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17658 .hp_nid = 0x03,
17659 .dac_nids = alc662_dac_nids,
17660 .dig_out_nid = ALC662_DIGOUT_NID,
17661 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17662 .channel_mode = alc662_3ST_2ch_modes,
17663 .unsol_event = alc663_mode8_unsol_event,
17664 .setup = alc663_mode8_setup,
17665 .init_hook = alc663_mode8_inithook,
17666 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017667 [ALC272_DELL] = {
17668 .mixers = { alc663_m51va_mixer },
17669 .cap_mixer = alc272_auto_capture_mixer,
17670 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17671 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17672 .dac_nids = alc662_dac_nids,
17673 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17674 .adc_nids = alc272_adc_nids,
17675 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17676 .capsrc_nids = alc272_capsrc_nids,
17677 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017678 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017679 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017680 .init_hook = alc663_m51va_inithook,
17681 },
17682 [ALC272_DELL_ZM1] = {
17683 .mixers = { alc663_m51va_mixer },
17684 .cap_mixer = alc662_auto_capture_mixer,
17685 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17686 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17687 .dac_nids = alc662_dac_nids,
17688 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17689 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017690 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020017691 .capsrc_nids = alc662_capsrc_nids,
17692 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017693 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017694 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017695 .init_hook = alc663_m51va_inithook,
17696 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017697 [ALC272_SAMSUNG_NC10] = {
17698 .mixers = { alc272_nc10_mixer },
17699 .init_verbs = { alc662_init_verbs,
17700 alc663_21jd_amic_init_verbs },
17701 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17702 .dac_nids = alc272_dac_nids,
17703 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17704 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017705 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020017706 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017707 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020017708 .init_hook = alc663_mode4_inithook,
17709 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017710};
17711
17712
17713/*
17714 * BIOS auto configuration
17715 */
17716
Takashi Iwai7085ec12009-10-02 09:03:58 +020017717/* convert from MIX nid to DAC */
17718static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
17719{
17720 if (nid == 0x0f)
17721 return 0x02;
17722 else if (nid >= 0x0c && nid <= 0x0e)
17723 return nid - 0x0c + 0x02;
17724 else
17725 return 0;
17726}
17727
17728/* get MIX nid connected to the given pin targeted to DAC */
17729static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
17730 hda_nid_t dac)
17731{
17732 hda_nid_t mix[4];
17733 int i, num;
17734
17735 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
17736 for (i = 0; i < num; i++) {
17737 if (alc662_mix_to_dac(mix[i]) == dac)
17738 return mix[i];
17739 }
17740 return 0;
17741}
17742
17743/* look for an empty DAC slot */
17744static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
17745{
17746 struct alc_spec *spec = codec->spec;
17747 hda_nid_t srcs[5];
17748 int i, j, num;
17749
17750 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
17751 if (num < 0)
17752 return 0;
17753 for (i = 0; i < num; i++) {
17754 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
17755 if (!nid)
17756 continue;
17757 for (j = 0; j < spec->multiout.num_dacs; j++)
17758 if (spec->multiout.dac_nids[j] == nid)
17759 break;
17760 if (j >= spec->multiout.num_dacs)
17761 return nid;
17762 }
17763 return 0;
17764}
17765
17766/* fill in the dac_nids table from the parsed pin configuration */
17767static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
17768 const struct auto_pin_cfg *cfg)
17769{
17770 struct alc_spec *spec = codec->spec;
17771 int i;
17772 hda_nid_t dac;
17773
17774 spec->multiout.dac_nids = spec->private_dac_nids;
17775 for (i = 0; i < cfg->line_outs; i++) {
17776 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
17777 if (!dac)
17778 continue;
17779 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
17780 }
17781 return 0;
17782}
17783
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017784static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017785 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017786{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017787 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017788 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
17789}
17790
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017791static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017792 hda_nid_t nid, unsigned int chs)
17793{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017794 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017795 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
17796}
17797
17798#define alc662_add_stereo_vol(spec, pfx, nid) \
17799 alc662_add_vol_ctl(spec, pfx, nid, 3)
17800#define alc662_add_stereo_sw(spec, pfx, nid) \
17801 alc662_add_sw_ctl(spec, pfx, nid, 3)
17802
17803/* add playback controls from the parsed DAC table */
17804static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
17805 const struct auto_pin_cfg *cfg)
17806{
17807 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017808 static const char *chname[4] = {
17809 "Front", "Surround", NULL /*CLFE*/, "Side"
17810 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020017811 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017812 int i, err;
17813
17814 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017815 nid = spec->multiout.dac_nids[i];
17816 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017817 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017818 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
17819 if (!mix)
17820 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017821 if (i == 2) {
17822 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017823 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017824 if (err < 0)
17825 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017826 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017827 if (err < 0)
17828 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017829 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017830 if (err < 0)
17831 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017832 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017833 if (err < 0)
17834 return err;
17835 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017836 const char *pfx;
17837 if (cfg->line_outs == 1 &&
17838 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017839 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017840 pfx = "Speaker";
17841 else
17842 pfx = "PCM";
17843 } else
17844 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017845 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017846 if (err < 0)
17847 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017848 if (cfg->line_outs == 1 &&
17849 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
17850 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020017851 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017852 if (err < 0)
17853 return err;
17854 }
17855 }
17856 return 0;
17857}
17858
17859/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017860/* return DAC nid if any new DAC is assigned */
17861static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017862 const char *pfx)
17863{
Takashi Iwai7085ec12009-10-02 09:03:58 +020017864 struct alc_spec *spec = codec->spec;
17865 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017866 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017867
17868 if (!pin)
17869 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017870 nid = alc662_look_for_dac(codec, pin);
17871 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017872 /* the corresponding DAC is already occupied */
17873 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
17874 return 0; /* no way */
17875 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017876 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017877 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17878 }
17879
17880 mix = alc662_dac_to_mix(codec, pin, nid);
17881 if (!mix)
17882 return 0;
17883 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
17884 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020017885 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017886 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
17887 if (err < 0)
17888 return err;
17889 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017890}
17891
17892/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017893#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020017894 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017895
17896static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17897 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017898 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017899{
Takashi Iwai7085ec12009-10-02 09:03:58 +020017900 int i, num;
17901 hda_nid_t srcs[4];
17902
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017903 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017904 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017905 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
17906 if (num <= 1)
17907 return;
17908 for (i = 0; i < num; i++) {
17909 if (alc662_mix_to_dac(srcs[i]) != dac)
17910 continue;
17911 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
17912 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017913 }
17914}
17915
17916static void alc662_auto_init_multi_out(struct hda_codec *codec)
17917{
17918 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017919 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017920 int i;
17921
17922 for (i = 0; i <= HDA_SIDE; i++) {
17923 hda_nid_t nid = spec->autocfg.line_out_pins[i];
17924 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017925 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017926 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017927 }
17928}
17929
17930static void alc662_auto_init_hp_out(struct hda_codec *codec)
17931{
17932 struct alc_spec *spec = codec->spec;
17933 hda_nid_t pin;
17934
17935 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017936 if (pin)
17937 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
17938 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017939 pin = spec->autocfg.speaker_pins[0];
17940 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020017941 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
17942 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017943}
17944
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017945#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17946
17947static void alc662_auto_init_analog_input(struct hda_codec *codec)
17948{
17949 struct alc_spec *spec = codec->spec;
17950 int i;
17951
17952 for (i = 0; i < AUTO_PIN_LAST; i++) {
17953 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020017954 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017955 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017956 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017957 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017958 snd_hda_codec_write(codec, nid, 0,
17959 AC_VERB_SET_AMP_GAIN_MUTE,
17960 AMP_OUT_MUTE);
17961 }
17962 }
17963}
17964
Takashi Iwaif511b012008-08-15 16:46:42 +020017965#define alc662_auto_init_input_src alc882_auto_init_input_src
17966
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017967static int alc662_parse_auto_config(struct hda_codec *codec)
17968{
17969 struct alc_spec *spec = codec->spec;
17970 int err;
17971 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17972
17973 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17974 alc662_ignore);
17975 if (err < 0)
17976 return err;
17977 if (!spec->autocfg.line_outs)
17978 return 0; /* can't find valid BIOS pin config */
17979
Takashi Iwai7085ec12009-10-02 09:03:58 +020017980 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017981 if (err < 0)
17982 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017983 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017984 if (err < 0)
17985 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017986 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017987 spec->autocfg.speaker_pins[0],
17988 "Speaker");
17989 if (err < 0)
17990 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017991 if (err)
17992 spec->multiout.extra_out_nid[0] = err;
17993 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017994 "Headphone");
17995 if (err < 0)
17996 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017997 if (err)
17998 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017999 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018000 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018001 return err;
18002
18003 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
18004
Takashi Iwai0852d7a2009-02-11 11:35:15 +010018005 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018006 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
18007
Takashi Iwai603c4012008-07-30 15:01:44 +020018008 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010018009 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018010
18011 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020018012 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020018013
Takashi Iwaid88897e2008-10-31 15:01:37 +010018014 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020018015 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010018016 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020018017
18018 err = alc_auto_add_mic_boost(codec);
18019 if (err < 0)
18020 return err;
18021
Takashi Iwai4a79ba32009-04-22 16:31:35 +020018022 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
18023
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018024 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018025}
18026
18027/* additional initialization for auto-configuration model */
18028static void alc662_auto_init(struct hda_codec *codec)
18029{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018030 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018031 alc662_auto_init_multi_out(codec);
18032 alc662_auto_init_hp_out(codec);
18033 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020018034 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018035 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020018036 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018037}
18038
18039static int patch_alc662(struct hda_codec *codec)
18040{
18041 struct alc_spec *spec;
18042 int err, board_config;
18043
18044 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
18045 if (!spec)
18046 return -ENOMEM;
18047
18048 codec->spec = spec;
18049
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020018050 alc_fix_pll_init(codec, 0x20, 0x04, 15);
18051
Kailang Yang274693f2009-12-03 10:07:50 +010018052 if (alc_read_coef_idx(codec, 0)==0x8020){
18053 kfree(codec->chip_name);
18054 codec->chip_name = kstrdup("ALC661", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018055 if (!codec->chip_name) {
18056 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018057 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018058 }
Kailang Yang274693f2009-12-03 10:07:50 +010018059 }
18060
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018061 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
18062 alc662_models,
18063 alc662_cfg_tbl);
18064 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020018065 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
18066 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018067 board_config = ALC662_AUTO;
18068 }
18069
18070 if (board_config == ALC662_AUTO) {
18071 /* automatic parse from the BIOS config */
18072 err = alc662_parse_auto_config(codec);
18073 if (err < 0) {
18074 alc_free(codec);
18075 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018076 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018077 printk(KERN_INFO
18078 "hda_codec: Cannot set up configuration "
18079 "from BIOS. Using base mode...\n");
18080 board_config = ALC662_3ST_2ch_DIG;
18081 }
18082 }
18083
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090018084 err = snd_hda_attach_beep_device(codec, 0x1);
18085 if (err < 0) {
18086 alc_free(codec);
18087 return err;
18088 }
18089
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018090 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020018091 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018092
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018093 spec->stream_analog_playback = &alc662_pcm_analog_playback;
18094 spec->stream_analog_capture = &alc662_pcm_analog_capture;
18095
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018096 spec->stream_digital_playback = &alc662_pcm_digital_playback;
18097 spec->stream_digital_capture = &alc662_pcm_digital_capture;
18098
Takashi Iwaidd704692009-08-11 08:45:11 +020018099 if (!spec->adc_nids) {
18100 spec->adc_nids = alc662_adc_nids;
18101 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
18102 }
18103 if (!spec->capsrc_nids)
18104 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018105
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018106 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018107 set_capture_mixer(codec);
Takashi Iwaib9591442009-03-16 15:25:00 +010018108 if (codec->vendor_id == 0x10ec0662)
18109 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
18110 else
18111 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018112
Takashi Iwai2134ea42008-01-10 16:53:55 +010018113 spec->vmaster_nid = 0x02;
18114
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018115 codec->patch_ops = alc_patch_ops;
18116 if (board_config == ALC662_AUTO)
18117 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020018118#ifdef CONFIG_SND_HDA_POWER_SAVE
18119 if (!spec->loopback.amplist)
18120 spec->loopback.amplist = alc662_loopbacks;
18121#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018122
18123 return 0;
18124}
18125
Kailang Yang274693f2009-12-03 10:07:50 +010018126static int patch_alc888(struct hda_codec *codec)
18127{
18128 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
18129 kfree(codec->chip_name);
18130 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018131 if (!codec->chip_name) {
18132 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018133 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018134 }
18135 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018136 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018137 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018138}
18139
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018140/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070018141 * patch entries
18142 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018143static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070018144 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018145 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018146 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020018147 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018148 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018149 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020018150 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018151 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018152 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018153 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018154 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
18155 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
18156 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018157 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018158 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018159 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
18160 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018161 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018162 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018163 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018164 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020018165 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018166 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020018167 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018168 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018169 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018170 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020018171 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018172 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018173 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018174 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018175 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018176 {} /* terminator */
18177};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018178
18179MODULE_ALIAS("snd-hda-codec-id:10ec*");
18180
18181MODULE_LICENSE("GPL");
18182MODULE_DESCRIPTION("Realtek HD-audio codec");
18183
18184static struct hda_codec_preset_list realtek_list = {
18185 .preset = snd_hda_preset_realtek,
18186 .owner = THIS_MODULE,
18187};
18188
18189static int __init patch_realtek_init(void)
18190{
18191 return snd_hda_add_codec_preset(&realtek_list);
18192}
18193
18194static void __exit patch_realtek_exit(void)
18195{
18196 snd_hda_delete_codec_preset(&realtek_list);
18197}
18198
18199module_init(patch_realtek_init)
18200module_exit(patch_realtek_exit)