blob: d00e6d1da085162eff93a8f2d267efda73f424f2 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090033#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020075 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010076 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010078 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020079 ALC260_WILL,
80 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010081 ALC260_FAVORIT100,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010082#ifdef CONFIG_SND_DEBUG
83 ALC260_TEST,
84#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010085 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020086 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087};
88
Kailang Yangdf694da2005-12-05 19:42:22 +010089/* ALC262 models */
90enum {
91 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020092 ALC262_HIPPO,
93 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010094 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020095 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010096 ALC262_HP_BPC_D7000_WL,
97 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010098 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010099 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200100 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200101 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200102 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200103 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100104 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200105 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200106 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200107 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000108 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100109 ALC262_AUTO,
110 ALC262_MODEL_LAST /* last tag */
111};
112
Kailang Yanga361d842007-06-05 12:30:55 +0200113/* ALC268 models */
114enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200115 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200116 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200117 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200118 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100119 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200120 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100121 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100122 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100123#ifdef CONFIG_SND_DEBUG
124 ALC268_TEST,
125#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200126 ALC268_AUTO,
127 ALC268_MODEL_LAST /* last tag */
128};
129
Kailang Yangf6a92242007-12-13 16:52:54 +0100130/* ALC269 models */
131enum {
132 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200133 ALC269_QUANTA_FL1,
Kailang Yangebb83ee2009-12-17 12:23:00 +0100134 ALC269_ASUS_AMIC,
135 ALC269_ASUS_DMIC,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100136 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000137 ALC269_LIFEBOOK,
Kailang Yangf6a92242007-12-13 16:52:54 +0100138 ALC269_AUTO,
139 ALC269_MODEL_LAST /* last tag */
140};
141
Kailang Yangdf694da2005-12-05 19:42:22 +0100142/* ALC861 models */
143enum {
144 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200145 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100146 ALC861_3ST_DIG,
147 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200148 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200149 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200150 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100151 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100152 ALC861_AUTO,
153 ALC861_MODEL_LAST,
154};
155
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100156/* ALC861-VD models */
157enum {
158 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200159 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100160 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100161 ALC861VD_3ST,
162 ALC861VD_3ST_DIG,
163 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200164 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200165 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200166 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100167 ALC861VD_AUTO,
168 ALC861VD_MODEL_LAST,
169};
170
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200171/* ALC662 models */
172enum {
173 ALC662_3ST_2ch_DIG,
174 ALC662_3ST_6ch_DIG,
175 ALC662_3ST_6ch,
176 ALC662_5ST_DIG,
177 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200178 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100179 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200180 ALC663_ASUS_M51VA,
181 ALC663_ASUS_G71V,
182 ALC663_ASUS_H13,
183 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200184 ALC662_ECS,
185 ALC663_ASUS_MODE1,
186 ALC662_ASUS_MODE2,
187 ALC663_ASUS_MODE3,
188 ALC663_ASUS_MODE4,
189 ALC663_ASUS_MODE5,
190 ALC663_ASUS_MODE6,
Kailang Yangebb83ee2009-12-17 12:23:00 +0100191 ALC663_ASUS_MODE7,
192 ALC663_ASUS_MODE8,
Kailang Yang622e84c2009-04-21 07:39:04 +0200193 ALC272_DELL,
194 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200195 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200196 ALC662_AUTO,
197 ALC662_MODEL_LAST,
198};
199
Kailang Yangdf694da2005-12-05 19:42:22 +0100200/* ALC882 models */
201enum {
202 ALC882_3ST_DIG,
203 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200204 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200205 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200206 ALC882_TARGA,
207 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200208 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100209 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200210 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200211 ALC885_MB5,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200212 ALC885_IMAC24,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -0800213 ALC885_IMAC91,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200214 ALC883_3ST_2ch_DIG,
215 ALC883_3ST_6ch_DIG,
216 ALC883_3ST_6ch,
217 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200218 ALC883_TARGA_DIG,
219 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200220 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200221 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200222 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800223 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100224 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200225 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200226 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200227 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200228 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100229 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200230 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200231 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200232 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200233 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200234 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200235 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100236 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100237 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430238 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100239 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100240 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800241 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200242 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200243 ALC889A_INTEL,
244 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200245 ALC888_ASUS_M90V,
246 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200247 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100248 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200249 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200250 ALC882_AUTO,
251 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200252};
253
Kailang Yangdf694da2005-12-05 19:42:22 +0100254/* for GPIO Poll */
255#define GPIO_MASK 0x03
256
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200257/* extra amp-initialization sequence types */
258enum {
259 ALC_INIT_NONE,
260 ALC_INIT_DEFAULT,
261 ALC_INIT_GPIO1,
262 ALC_INIT_GPIO2,
263 ALC_INIT_GPIO3,
264};
265
Takashi Iwai6c819492009-08-10 18:47:44 +0200266struct alc_mic_route {
267 hda_nid_t pin;
268 unsigned char mux_idx;
269 unsigned char amix_idx;
270};
271
272#define MUX_IDX_UNDEF ((unsigned char)-1)
273
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274struct alc_spec {
275 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100276 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100278 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100279 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200281 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200282 * don't forget NULL
283 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200284 */
285 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200287 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 struct hda_pcm_stream *stream_analog_playback;
289 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100290 struct hda_pcm_stream *stream_analog_alt_playback;
291 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200293 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 struct hda_pcm_stream *stream_digital_playback;
295 struct hda_pcm_stream *stream_digital_capture;
296
297 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200298 struct hda_multi_out multiout; /* playback set-up
299 * max_channels, dacs must be set
300 * dig_out_nid and hp_nid are optional
301 */
Takashi Iwai63300792008-01-24 15:31:36 +0100302 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100303 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100304 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305
306 /* capture */
307 unsigned int num_adc_nids;
308 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100309 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200310 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311
312 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200313 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314 const struct hda_input_mux *input_mux;
315 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200316 struct alc_mic_route ext_mic;
317 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318
319 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100320 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200322 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200323 int const_channel_count;
324 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325
326 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100327 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200328
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200329 /* dynamic controls, init_verbs and input_mux */
330 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200331 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200332 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200333 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200334 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
335 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100336
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100337 /* hooks */
338 void (*init_hook)(struct hda_codec *codec);
339 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100340#ifdef CONFIG_SND_HDA_POWER_SAVE
341 void (*power_hook)(struct hda_codec *codec, int power);
342#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100343
Takashi Iwai834be882006-03-01 14:16:17 +0100344 /* for pin sensing */
345 unsigned int sense_updated: 1;
346 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100347 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200348 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200349
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100350 /* other flags */
351 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200352 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100353
Takashi Iwai2134ea42008-01-10 16:53:55 +0100354 /* for virtual master */
355 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200356#ifdef CONFIG_SND_HDA_POWER_SAVE
357 struct hda_loopback_check loopback;
358#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200359
360 /* for PLL fix */
361 hda_nid_t pll_nid;
362 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100363};
364
365/*
366 * configuration template - to be copied to the spec instance
367 */
368struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200369 struct snd_kcontrol_new *mixers[5]; /* should be identical size
370 * with spec
371 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100372 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100373 const struct hda_verb *init_verbs[5];
374 unsigned int num_dacs;
375 hda_nid_t *dac_nids;
376 hda_nid_t dig_out_nid; /* optional */
377 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800378 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100379 unsigned int num_adc_nids;
380 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100381 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100382 hda_nid_t dig_in_nid;
383 unsigned int num_channel_mode;
384 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200385 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200386 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200387 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100388 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100389 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200390 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100391 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200392#ifdef CONFIG_SND_HDA_POWER_SAVE
393 struct hda_amp_list *loopbacks;
Hector Martinf5de24b2009-12-20 22:51:31 +0100394 void (*power_hook)(struct hda_codec *codec, int power);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200395#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396};
397
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398
399/*
400 * input MUX handling
401 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200402static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
403 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404{
405 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
406 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200407 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
408 if (mux_idx >= spec->num_mux_defs)
409 mux_idx = 0;
410 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411}
412
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200413static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
414 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415{
416 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
417 struct alc_spec *spec = codec->spec;
418 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
419
420 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
421 return 0;
422}
423
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200424static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
425 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426{
427 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
428 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100429 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100431 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100432 hda_nid_t nid = spec->capsrc_nids ?
433 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200434 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435
Takashi Iwaicd896c32008-11-18 12:36:33 +0100436 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
437 imux = &spec->input_mux[mux_idx];
438
Takashi Iwaia22d5432009-07-27 12:54:26 +0200439 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200440 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100441 /* Matrix-mixer style (e.g. ALC882) */
442 unsigned int *cur_val = &spec->cur_mux[adc_idx];
443 unsigned int i, idx;
444
445 idx = ucontrol->value.enumerated.item[0];
446 if (idx >= imux->num_items)
447 idx = imux->num_items - 1;
448 if (*cur_val == idx)
449 return 0;
450 for (i = 0; i < imux->num_items; i++) {
451 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
452 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
453 imux->items[i].index,
454 HDA_AMP_MUTE, v);
455 }
456 *cur_val = idx;
457 return 1;
458 } else {
459 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100460 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100461 &spec->cur_mux[adc_idx]);
462 }
463}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200464
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465/*
466 * channel mode setting
467 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200468static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
469 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470{
471 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
472 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100473 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
474 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475}
476
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200477static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
478 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479{
480 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
481 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100482 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200483 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200484 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485}
486
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200487static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
488 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489{
490 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
491 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200492 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
493 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200494 &spec->ext_channel_count);
495 if (err >= 0 && !spec->const_channel_count) {
496 spec->multiout.max_channels = spec->ext_channel_count;
497 if (spec->need_dac_fix)
498 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
499 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200500 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501}
502
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100504 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200505 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100506 * being part of a format specifier. Maximum allowed length of a value is
507 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100508 *
509 * Note: some retasking pin complexes seem to ignore requests for input
510 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
511 * are requested. Therefore order this list so that this behaviour will not
512 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200513 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
514 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200515 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100516static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100517 "Mic 50pc bias", "Mic 80pc bias",
518 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100519};
520static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100521 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100522};
523/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200524 * in the pin being assumed to be exclusively an input or an output pin. In
525 * addition, "input" pins may or may not process the mic bias option
526 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
527 * accept requests for bias as of chip versions up to March 2006) and/or
528 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100529 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200530#define ALC_PIN_DIR_IN 0x00
531#define ALC_PIN_DIR_OUT 0x01
532#define ALC_PIN_DIR_INOUT 0x02
533#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
534#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100535
Kailang Yangea1fb292008-08-26 12:58:38 +0200536/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100537 * For each direction the minimum and maximum values are given.
538 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200539static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100540 { 0, 2 }, /* ALC_PIN_DIR_IN */
541 { 3, 4 }, /* ALC_PIN_DIR_OUT */
542 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200543 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
544 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100545};
546#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
547#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
548#define alc_pin_mode_n_items(_dir) \
549 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
550
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200551static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
552 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200553{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100554 unsigned int item_num = uinfo->value.enumerated.item;
555 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
556
557 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200558 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100559 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
560
561 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
562 item_num = alc_pin_mode_min(dir);
563 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200564 return 0;
565}
566
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200567static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
568 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200569{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100570 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200571 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
572 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100573 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200574 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200575 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
576 AC_VERB_GET_PIN_WIDGET_CONTROL,
577 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200578
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100579 /* Find enumerated value for current pinctl setting */
580 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200581 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100582 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200583 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100584 return 0;
585}
586
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200587static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
588 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100589{
590 signed int change;
591 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
592 hda_nid_t nid = kcontrol->private_value & 0xffff;
593 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
594 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200595 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
596 AC_VERB_GET_PIN_WIDGET_CONTROL,
597 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100598
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200599 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100600 val = alc_pin_mode_min(dir);
601
602 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100603 if (change) {
604 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200605 snd_hda_codec_write_cache(codec, nid, 0,
606 AC_VERB_SET_PIN_WIDGET_CONTROL,
607 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100608
Kailang Yangea1fb292008-08-26 12:58:38 +0200609 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100610 * for the requested pin mode. Enum values of 2 or less are
611 * input modes.
612 *
613 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200614 * reduces noise slightly (particularly on input) so we'll
615 * do it. However, having both input and output buffers
616 * enabled simultaneously doesn't seem to be problematic if
617 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100618 */
619 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200620 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
621 HDA_AMP_MUTE, HDA_AMP_MUTE);
622 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
623 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100624 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200625 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
626 HDA_AMP_MUTE, HDA_AMP_MUTE);
627 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
628 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100629 }
630 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200631 return change;
632}
633
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100634#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200635 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100636 .info = alc_pin_mode_info, \
637 .get = alc_pin_mode_get, \
638 .put = alc_pin_mode_put, \
639 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100640
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100641/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
642 * together using a mask with more than one bit set. This control is
643 * currently used only by the ALC260 test model. At this stage they are not
644 * needed for any "production" models.
645 */
646#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200647#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200648
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200649static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
650 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100651{
652 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
653 hda_nid_t nid = kcontrol->private_value & 0xffff;
654 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
655 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200656 unsigned int val = snd_hda_codec_read(codec, nid, 0,
657 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100658
659 *valp = (val & mask) != 0;
660 return 0;
661}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200662static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
663 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100664{
665 signed int change;
666 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
667 hda_nid_t nid = kcontrol->private_value & 0xffff;
668 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
669 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200670 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
671 AC_VERB_GET_GPIO_DATA,
672 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100673
674 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200675 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
676 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100677 gpio_data &= ~mask;
678 else
679 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200680 snd_hda_codec_write_cache(codec, nid, 0,
681 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100682
683 return change;
684}
685#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
686 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
687 .info = alc_gpio_data_info, \
688 .get = alc_gpio_data_get, \
689 .put = alc_gpio_data_put, \
690 .private_value = nid | (mask<<16) }
691#endif /* CONFIG_SND_DEBUG */
692
Jonathan Woithe92621f12006-02-28 11:47:47 +0100693/* A switch control to allow the enabling of the digital IO pins on the
694 * ALC260. This is incredibly simplistic; the intention of this control is
695 * to provide something in the test model allowing digital outputs to be
696 * identified if present. If models are found which can utilise these
697 * outputs a more complete mixer control can be devised for those models if
698 * necessary.
699 */
700#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200701#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200702
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200703static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
704 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100705{
706 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
707 hda_nid_t nid = kcontrol->private_value & 0xffff;
708 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
709 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200710 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100711 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100712
713 *valp = (val & mask) != 0;
714 return 0;
715}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200716static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
717 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100718{
719 signed int change;
720 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
721 hda_nid_t nid = kcontrol->private_value & 0xffff;
722 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
723 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200724 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100725 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200726 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100727
728 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200729 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100730 if (val==0)
731 ctrl_data &= ~mask;
732 else
733 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200734 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
735 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100736
737 return change;
738}
739#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
740 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
741 .info = alc_spdif_ctrl_info, \
742 .get = alc_spdif_ctrl_get, \
743 .put = alc_spdif_ctrl_put, \
744 .private_value = nid | (mask<<16) }
745#endif /* CONFIG_SND_DEBUG */
746
Jonathan Woithef8225f62008-01-08 12:16:54 +0100747/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
748 * Again, this is only used in the ALC26x test models to help identify when
749 * the EAPD line must be asserted for features to work.
750 */
751#ifdef CONFIG_SND_DEBUG
752#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
753
754static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
755 struct snd_ctl_elem_value *ucontrol)
756{
757 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
758 hda_nid_t nid = kcontrol->private_value & 0xffff;
759 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
760 long *valp = ucontrol->value.integer.value;
761 unsigned int val = snd_hda_codec_read(codec, nid, 0,
762 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
763
764 *valp = (val & mask) != 0;
765 return 0;
766}
767
768static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
769 struct snd_ctl_elem_value *ucontrol)
770{
771 int change;
772 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
773 hda_nid_t nid = kcontrol->private_value & 0xffff;
774 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
775 long val = *ucontrol->value.integer.value;
776 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
777 AC_VERB_GET_EAPD_BTLENABLE,
778 0x00);
779
780 /* Set/unset the masked control bit(s) as needed */
781 change = (!val ? 0 : mask) != (ctrl_data & mask);
782 if (!val)
783 ctrl_data &= ~mask;
784 else
785 ctrl_data |= mask;
786 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
787 ctrl_data);
788
789 return change;
790}
791
792#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
793 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
794 .info = alc_eapd_ctrl_info, \
795 .get = alc_eapd_ctrl_get, \
796 .put = alc_eapd_ctrl_put, \
797 .private_value = nid | (mask<<16) }
798#endif /* CONFIG_SND_DEBUG */
799
Kailang Yangdf694da2005-12-05 19:42:22 +0100800/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100801 * set up the input pin config (depending on the given auto-pin type)
802 */
803static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
804 int auto_pin_type)
805{
806 unsigned int val = PIN_IN;
807
808 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
809 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100810 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100811 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
812 if (pincap & AC_PINCAP_VREF_80)
813 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200814 else if (pincap & AC_PINCAP_VREF_50)
815 val = PIN_VREF50;
816 else if (pincap & AC_PINCAP_VREF_100)
817 val = PIN_VREF100;
818 else if (pincap & AC_PINCAP_VREF_GRD)
819 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100820 }
821 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
822}
823
824/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100825 */
826static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
827{
828 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
829 return;
830 spec->mixers[spec->num_mixers++] = mix;
831}
832
833static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
834{
835 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
836 return;
837 spec->init_verbs[spec->num_init_verbs++] = verb;
838}
839
Takashi Iwaidaead532008-11-28 12:55:36 +0100840#ifdef CONFIG_PROC_FS
841/*
842 * hook for proc
843 */
844static void print_realtek_coef(struct snd_info_buffer *buffer,
845 struct hda_codec *codec, hda_nid_t nid)
846{
847 int coeff;
848
849 if (nid != 0x20)
850 return;
851 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
852 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
853 coeff = snd_hda_codec_read(codec, nid, 0,
854 AC_VERB_GET_COEF_INDEX, 0);
855 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
856}
857#else
858#define print_realtek_coef NULL
859#endif
860
Takashi Iwaid88897e2008-10-31 15:01:37 +0100861/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100862 * set up from the preset table
863 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200864static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200865 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100866{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200867 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100868 int i;
869
870 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100871 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100872 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200873 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
874 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100875 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200876
Kailang Yangdf694da2005-12-05 19:42:22 +0100877 spec->channel_mode = preset->channel_mode;
878 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200879 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200880 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100881
Hector Martin3b315d72009-06-02 10:54:19 +0200882 if (preset->const_channel_count)
883 spec->multiout.max_channels = preset->const_channel_count;
884 else
885 spec->multiout.max_channels = spec->channel_mode[0].channels;
886 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100887
888 spec->multiout.num_dacs = preset->num_dacs;
889 spec->multiout.dac_nids = preset->dac_nids;
890 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800891 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100892 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200893
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200894 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200895 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200896 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100897 spec->input_mux = preset->input_mux;
898
899 spec->num_adc_nids = preset->num_adc_nids;
900 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100901 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100902 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100903
904 spec->unsol_event = preset->unsol_event;
905 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200906#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100907 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200908 spec->loopback.amplist = preset->loopbacks;
909#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200910
911 if (preset->setup)
912 preset->setup(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100913}
914
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200915/* Enable GPIO mask and set output */
916static struct hda_verb alc_gpio1_init_verbs[] = {
917 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
918 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
919 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
920 { }
921};
922
923static struct hda_verb alc_gpio2_init_verbs[] = {
924 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
925 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
926 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
927 { }
928};
929
Kailang Yangbdd148a2007-05-08 15:19:08 +0200930static struct hda_verb alc_gpio3_init_verbs[] = {
931 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
932 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
933 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
934 { }
935};
936
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200937/*
938 * Fix hardware PLL issue
939 * On some codecs, the analog PLL gating control must be off while
940 * the default value is 1.
941 */
942static void alc_fix_pll(struct hda_codec *codec)
943{
944 struct alc_spec *spec = codec->spec;
945 unsigned int val;
946
947 if (!spec->pll_nid)
948 return;
949 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
950 spec->pll_coef_idx);
951 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
952 AC_VERB_GET_PROC_COEF, 0);
953 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
954 spec->pll_coef_idx);
955 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
956 val & ~(1 << spec->pll_coef_bit));
957}
958
959static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
960 unsigned int coef_idx, unsigned int coef_bit)
961{
962 struct alc_spec *spec = codec->spec;
963 spec->pll_nid = nid;
964 spec->pll_coef_idx = coef_idx;
965 spec->pll_coef_bit = coef_bit;
966 alc_fix_pll(codec);
967}
968
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200969static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200970{
971 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200972 unsigned int nid = spec->autocfg.hp_pins[0];
973 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200974
Takashi Iwaiad87c642009-11-02 14:23:15 +0100975 if (!nid)
976 return;
Wu Fengguang864f92b2009-11-18 12:38:02 +0800977 spec->jack_present = snd_hda_jack_detect(codec, nid);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200978 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
979 nid = spec->autocfg.speaker_pins[i];
980 if (!nid)
981 break;
982 snd_hda_codec_write(codec, nid, 0,
983 AC_VERB_SET_PIN_WIDGET_CONTROL,
984 spec->jack_present ? 0 : PIN_OUT);
985 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200986}
987
Takashi Iwai6c819492009-08-10 18:47:44 +0200988static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
989 hda_nid_t nid)
990{
991 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
992 int i, nums;
993
994 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
995 for (i = 0; i < nums; i++)
996 if (conn[i] == nid)
997 return i;
998 return -1;
999}
1000
Kailang Yang7fb0d782008-10-15 11:12:35 +02001001static void alc_mic_automute(struct hda_codec *codec)
1002{
1003 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001004 struct alc_mic_route *dead, *alive;
1005 unsigned int present, type;
1006 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001007
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001008 if (!spec->auto_mic)
1009 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001010 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1011 return;
1012 if (snd_BUG_ON(!spec->adc_nids))
1013 return;
1014
1015 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1016
Wu Fengguang864f92b2009-11-18 12:38:02 +08001017 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001018 if (present) {
1019 alive = &spec->ext_mic;
1020 dead = &spec->int_mic;
1021 } else {
1022 alive = &spec->int_mic;
1023 dead = &spec->ext_mic;
1024 }
1025
Takashi Iwai6c819492009-08-10 18:47:44 +02001026 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1027 if (type == AC_WID_AUD_MIX) {
1028 /* Matrix-mixer style (e.g. ALC882) */
1029 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1030 alive->mux_idx,
1031 HDA_AMP_MUTE, 0);
1032 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1033 dead->mux_idx,
1034 HDA_AMP_MUTE, HDA_AMP_MUTE);
1035 } else {
1036 /* MUX style (e.g. ALC880) */
1037 snd_hda_codec_write_cache(codec, cap_nid, 0,
1038 AC_VERB_SET_CONNECT_SEL,
1039 alive->mux_idx);
1040 }
1041
1042 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001043}
1044
Kailang Yangc9b58002007-10-16 14:30:01 +02001045/* unsolicited event for HP jack sensing */
1046static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1047{
1048 if (codec->vendor_id == 0x10ec0880)
1049 res >>= 28;
1050 else
1051 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001052 switch (res) {
1053 case ALC880_HP_EVENT:
1054 alc_automute_pin(codec);
1055 break;
1056 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001057 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001058 break;
1059 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001060}
1061
1062static void alc_inithook(struct hda_codec *codec)
1063{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001064 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001065 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001066}
1067
Kailang Yangf9423e72008-05-27 12:32:25 +02001068/* additional initialization for ALC888 variants */
1069static void alc888_coef_init(struct hda_codec *codec)
1070{
1071 unsigned int tmp;
1072
1073 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1074 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1075 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001076 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001077 /* alc888S-VC */
1078 snd_hda_codec_read(codec, 0x20, 0,
1079 AC_VERB_SET_PROC_COEF, 0x830);
1080 else
1081 /* alc888-VB */
1082 snd_hda_codec_read(codec, 0x20, 0,
1083 AC_VERB_SET_PROC_COEF, 0x3030);
1084}
1085
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001086static void alc889_coef_init(struct hda_codec *codec)
1087{
1088 unsigned int tmp;
1089
1090 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1091 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1092 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1093 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1094}
1095
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001096/* turn on/off EAPD control (only if available) */
1097static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1098{
1099 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1100 return;
1101 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1102 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1103 on ? 2 : 0);
1104}
1105
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001106static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001107{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001108 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001109
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001110 switch (type) {
1111 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001112 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1113 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001114 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001115 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1116 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001117 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001118 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1119 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001120 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001121 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001122 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001123 set_eapd(codec, 0x0f, 1);
1124 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001125 break;
1126 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001127 case 0x10ec0267:
1128 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001129 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001130 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001131 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001132 case 0x10ec0660:
1133 case 0x10ec0662:
1134 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001135 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001136 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001137 set_eapd(codec, 0x14, 1);
1138 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001139 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001140 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001141 switch (codec->vendor_id) {
1142 case 0x10ec0260:
1143 snd_hda_codec_write(codec, 0x1a, 0,
1144 AC_VERB_SET_COEF_INDEX, 7);
1145 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1146 AC_VERB_GET_PROC_COEF, 0);
1147 snd_hda_codec_write(codec, 0x1a, 0,
1148 AC_VERB_SET_COEF_INDEX, 7);
1149 snd_hda_codec_write(codec, 0x1a, 0,
1150 AC_VERB_SET_PROC_COEF,
1151 tmp | 0x2010);
1152 break;
1153 case 0x10ec0262:
1154 case 0x10ec0880:
1155 case 0x10ec0882:
1156 case 0x10ec0883:
1157 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001158 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001159 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001160 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001161 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001162 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001163 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001164 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001165 case 0x10ec0267:
1166 case 0x10ec0268:
1167 snd_hda_codec_write(codec, 0x20, 0,
1168 AC_VERB_SET_COEF_INDEX, 7);
1169 tmp = snd_hda_codec_read(codec, 0x20, 0,
1170 AC_VERB_GET_PROC_COEF, 0);
1171 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001172 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001173 snd_hda_codec_write(codec, 0x20, 0,
1174 AC_VERB_SET_PROC_COEF,
1175 tmp | 0x3000);
1176 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001177 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001178 break;
1179 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001180}
Kailang Yangea1fb292008-08-26 12:58:38 +02001181
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001182static void alc_init_auto_hp(struct hda_codec *codec)
1183{
1184 struct alc_spec *spec = codec->spec;
1185
1186 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001187 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001188
Kailang Yangc9b58002007-10-16 14:30:01 +02001189 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001190 if (spec->autocfg.line_out_pins[0] &&
1191 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001192 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001193 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001194 else
1195 return;
1196 }
1197
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001198 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1199 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001200 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1201 AC_VERB_SET_UNSOLICITED_ENABLE,
1202 AC_USRSP_EN | ALC880_HP_EVENT);
1203 spec->unsol_event = alc_sku_unsol_event;
1204}
1205
Takashi Iwai6c819492009-08-10 18:47:44 +02001206static void alc_init_auto_mic(struct hda_codec *codec)
1207{
1208 struct alc_spec *spec = codec->spec;
1209 struct auto_pin_cfg *cfg = &spec->autocfg;
1210 hda_nid_t fixed, ext;
1211 int i;
1212
1213 /* there must be only two mic inputs exclusively */
1214 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1215 if (cfg->input_pins[i])
1216 return;
1217
1218 fixed = ext = 0;
1219 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1220 hda_nid_t nid = cfg->input_pins[i];
1221 unsigned int defcfg;
1222 if (!nid)
1223 return;
1224 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1225 switch (get_defcfg_connect(defcfg)) {
1226 case AC_JACK_PORT_FIXED:
1227 if (fixed)
1228 return; /* already occupied */
1229 fixed = nid;
1230 break;
1231 case AC_JACK_PORT_COMPLEX:
1232 if (ext)
1233 return; /* already occupied */
1234 ext = nid;
1235 break;
1236 default:
1237 return; /* invalid entry */
1238 }
1239 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001240 if (!ext || !fixed)
1241 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001242 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1243 return; /* no unsol support */
1244 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1245 ext, fixed);
1246 spec->ext_mic.pin = ext;
1247 spec->int_mic.pin = fixed;
1248 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1249 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1250 spec->auto_mic = 1;
1251 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1252 AC_VERB_SET_UNSOLICITED_ENABLE,
1253 AC_USRSP_EN | ALC880_MIC_EVENT);
1254 spec->unsol_event = alc_sku_unsol_event;
1255}
1256
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001257/* check subsystem ID and set up device-specific initialization;
1258 * return 1 if initialized, 0 if invalid SSID
1259 */
1260/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1261 * 31 ~ 16 : Manufacture ID
1262 * 15 ~ 8 : SKU ID
1263 * 7 ~ 0 : Assembly ID
1264 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1265 */
1266static int alc_subsystem_id(struct hda_codec *codec,
1267 hda_nid_t porta, hda_nid_t porte,
1268 hda_nid_t portd)
1269{
1270 unsigned int ass, tmp, i;
1271 unsigned nid;
1272 struct alc_spec *spec = codec->spec;
1273
1274 ass = codec->subsystem_id & 0xffff;
1275 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1276 goto do_sku;
1277
1278 /* invalid SSID, check the special NID pin defcfg instead */
1279 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001280 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001281 * 29~21 : reserve
1282 * 20 : PCBEEP input
1283 * 19~16 : Check sum (15:1)
1284 * 15~1 : Custom
1285 * 0 : override
1286 */
1287 nid = 0x1d;
1288 if (codec->vendor_id == 0x10ec0260)
1289 nid = 0x17;
1290 ass = snd_hda_codec_get_pincfg(codec, nid);
1291 snd_printd("realtek: No valid SSID, "
1292 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001293 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001294 if (!(ass & 1) && !(ass & 0x100000))
1295 return 0;
1296 if ((ass >> 30) != 1) /* no physical connection */
1297 return 0;
1298
1299 /* check sum */
1300 tmp = 0;
1301 for (i = 1; i < 16; i++) {
1302 if ((ass >> i) & 1)
1303 tmp++;
1304 }
1305 if (((ass >> 16) & 0xf) != tmp)
1306 return 0;
1307do_sku:
1308 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1309 ass & 0xffff, codec->vendor_id);
1310 /*
1311 * 0 : override
1312 * 1 : Swap Jack
1313 * 2 : 0 --> Desktop, 1 --> Laptop
1314 * 3~5 : External Amplifier control
1315 * 7~6 : Reserved
1316 */
1317 tmp = (ass & 0x38) >> 3; /* external Amp control */
1318 switch (tmp) {
1319 case 1:
1320 spec->init_amp = ALC_INIT_GPIO1;
1321 break;
1322 case 3:
1323 spec->init_amp = ALC_INIT_GPIO2;
1324 break;
1325 case 7:
1326 spec->init_amp = ALC_INIT_GPIO3;
1327 break;
1328 case 5:
1329 spec->init_amp = ALC_INIT_DEFAULT;
1330 break;
1331 }
1332
1333 /* is laptop or Desktop and enable the function "Mute internal speaker
1334 * when the external headphone out jack is plugged"
1335 */
1336 if (!(ass & 0x8000))
1337 return 1;
1338 /*
1339 * 10~8 : Jack location
1340 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1341 * 14~13: Resvered
1342 * 15 : 1 --> enable the function "Mute internal speaker
1343 * when the external headphone out jack is plugged"
1344 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001345 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001346 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001347 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1348 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001349 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001350 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001351 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001352 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001353 nid = portd;
Kailang Yangc9b58002007-10-16 14:30:01 +02001354 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001355 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001356 for (i = 0; i < spec->autocfg.line_outs; i++)
1357 if (spec->autocfg.line_out_pins[i] == nid)
1358 return 1;
1359 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001360 }
1361
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001362 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001363 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001364 return 1;
1365}
Kailang Yangea1fb292008-08-26 12:58:38 +02001366
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001367static void alc_ssid_check(struct hda_codec *codec,
1368 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1369{
1370 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1371 struct alc_spec *spec = codec->spec;
1372 snd_printd("realtek: "
1373 "Enable default setup for auto mode as fallback\n");
1374 spec->init_amp = ALC_INIT_DEFAULT;
1375 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001376 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001377 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001378}
1379
Takashi Iwai41e41f12005-06-08 14:48:49 +02001380/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001381 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001382 */
1383
1384struct alc_pincfg {
1385 hda_nid_t nid;
1386 u32 val;
1387};
1388
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001389struct alc_fixup {
1390 const struct alc_pincfg *pins;
1391 const struct hda_verb *verbs;
1392};
1393
1394static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001395 const struct snd_pci_quirk *quirk,
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001396 const struct alc_fixup *fix)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001397{
1398 const struct alc_pincfg *cfg;
1399
1400 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1401 if (!quirk)
1402 return;
1403
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001404 fix += quirk->value;
1405 cfg = fix->pins;
1406 if (cfg) {
1407 for (; cfg->nid; cfg++)
1408 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1409 }
1410 if (fix->verbs)
1411 add_verb(codec->spec, fix->verbs);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001412}
1413
Kailang Yang274693f2009-12-03 10:07:50 +01001414static int alc_read_coef_idx(struct hda_codec *codec,
1415 unsigned int coef_idx)
1416{
1417 unsigned int val;
1418 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1419 coef_idx);
1420 val = snd_hda_codec_read(codec, 0x20, 0,
1421 AC_VERB_GET_PROC_COEF, 0);
1422 return val;
1423}
1424
Takashi Iwaif95474e2007-07-10 00:47:43 +02001425/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001426 * ALC888
1427 */
1428
1429/*
1430 * 2ch mode
1431 */
1432static struct hda_verb alc888_4ST_ch2_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 Line in */
1437 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1438 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1439/* Line-Out as Front */
1440 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1441 { } /* end */
1442};
1443
1444/*
1445 * 4ch mode
1446 */
1447static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1448/* Mic-in jack as mic in */
1449 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1450 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
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 Front */
1455 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1456 { } /* end */
1457};
1458
1459/*
1460 * 6ch mode
1461 */
1462static struct hda_verb alc888_4ST_ch6_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 CLFE (workaround because Mic-in is not loud enough) */
1470 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1471 { } /* end */
1472};
1473
1474/*
1475 * 8ch mode
1476 */
1477static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1478/* Mic-in jack as CLFE */
1479 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1480 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1481/* Line-in jack as Surround */
1482 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1483 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1484/* Line-Out as Side */
1485 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1486 { } /* end */
1487};
1488
1489static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1490 { 2, alc888_4ST_ch2_intel_init },
1491 { 4, alc888_4ST_ch4_intel_init },
1492 { 6, alc888_4ST_ch6_intel_init },
1493 { 8, alc888_4ST_ch8_intel_init },
1494};
1495
1496/*
1497 * ALC888 Fujitsu Siemens Amillo xa3530
1498 */
1499
1500static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1501/* Front Mic: set to PIN_IN (empty by default) */
1502 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1503/* Connect Internal HP to Front */
1504 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1505 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1506 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1507/* Connect Bass HP to Front */
1508 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1509 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1510 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1511/* Connect Line-Out side jack (SPDIF) to Side */
1512 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1513 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1514 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1515/* Connect Mic jack to CLFE */
1516 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1517 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1518 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1519/* Connect Line-in jack to Surround */
1520 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1521 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1522 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1523/* Connect HP out jack to Front */
1524 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1525 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1526 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1527/* Enable unsolicited event for HP jack and Line-out jack */
1528 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1529 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1530 {}
1531};
1532
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001533static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001534{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001535 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001536 unsigned int mute;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001537 hda_nid_t nid;
1538 int i;
1539
1540 spec->jack_present = 0;
1541 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1542 nid = spec->autocfg.hp_pins[i];
1543 if (!nid)
1544 break;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001545 if (snd_hda_jack_detect(codec, nid)) {
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001546 spec->jack_present = 1;
1547 break;
1548 }
1549 }
1550
1551 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001552 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001553 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1554 nid = spec->autocfg.speaker_pins[i];
1555 if (!nid)
1556 break;
1557 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1558 HDA_AMP_MUTE, mute);
1559 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001560}
1561
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001562static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1563 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001564{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001565 if (codec->vendor_id == 0x10ec0880)
1566 res >>= 28;
1567 else
1568 res >>= 26;
1569 if (res == ALC880_HP_EVENT)
1570 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001571}
1572
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001573static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001574{
1575 struct alc_spec *spec = codec->spec;
1576
1577 spec->autocfg.hp_pins[0] = 0x15;
1578 spec->autocfg.speaker_pins[0] = 0x14;
1579 spec->autocfg.speaker_pins[1] = 0x16;
1580 spec->autocfg.speaker_pins[2] = 0x17;
1581 spec->autocfg.speaker_pins[3] = 0x19;
1582 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001583}
1584
1585static void alc889_intel_init_hook(struct hda_codec *codec)
1586{
1587 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001588 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001589}
1590
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001591static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001592{
1593 struct alc_spec *spec = codec->spec;
1594
1595 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1596 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1597 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1598 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001599}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001600
1601/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001602 * ALC888 Acer Aspire 4930G model
1603 */
1604
1605static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1606/* Front Mic: set to PIN_IN (empty by default) */
1607 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1608/* Unselect Front Mic by default in input mixer 3 */
1609 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001610/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001611 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1612/* Connect Internal HP to front */
1613 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1614 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1615 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1616/* Connect HP out to front */
1617 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1618 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1619 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1620 { }
1621};
1622
Hector Martin3b315d72009-06-02 10:54:19 +02001623/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001624 * ALC888 Acer Aspire 6530G model
1625 */
1626
1627static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1628/* Bias voltage on for external mic port */
1629 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001630/* Front Mic: set to PIN_IN (empty by default) */
1631 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1632/* Unselect Front Mic by default in input mixer 3 */
1633 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001634/* Enable unsolicited event for HP jack */
1635 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1636/* Enable speaker output */
1637 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1638 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1639/* Enable headphone output */
1640 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1641 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1642 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1643 { }
1644};
1645
1646/*
Hector Martin018df412009-06-04 00:13:40 +02001647 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001648 */
1649
Hector Martin018df412009-06-04 00:13:40 +02001650static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001651/* Front Mic: set to PIN_IN (empty by default) */
1652 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1653/* Unselect Front Mic by default in input mixer 3 */
1654 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1655/* Enable unsolicited event for HP jack */
1656 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1657/* Connect Internal Front to Front */
1658 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1659 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1660 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1661/* Connect Internal Rear to Rear */
1662 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1663 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1664 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1665/* Connect Internal CLFE to CLFE */
1666 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1667 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1668 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1669/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001670 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001671 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1672 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1673/* Enable all DACs */
1674/* DAC DISABLE/MUTE 1? */
1675/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1676 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1677 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1678/* DAC DISABLE/MUTE 2? */
1679/* some bit here disables the other DACs. Init=0x4900 */
1680 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1681 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02001682/* DMIC fix
1683 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1684 * which makes the stereo useless. However, either the mic or the ALC889
1685 * makes the signal become a difference/sum signal instead of standard
1686 * stereo, which is annoying. So instead we flip this bit which makes the
1687 * codec replicate the sum signal to both channels, turning it into a
1688 * normal mono mic.
1689 */
1690/* DMIC_CONTROL? Init value = 0x0001 */
1691 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1692 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001693 { }
1694};
1695
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001696static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001697 /* Front mic only available on one ADC */
1698 {
1699 .num_items = 4,
1700 .items = {
1701 { "Mic", 0x0 },
1702 { "Line", 0x2 },
1703 { "CD", 0x4 },
1704 { "Front Mic", 0xb },
1705 },
1706 },
1707 {
1708 .num_items = 3,
1709 .items = {
1710 { "Mic", 0x0 },
1711 { "Line", 0x2 },
1712 { "CD", 0x4 },
1713 },
1714 }
1715};
1716
Tony Vroond2fd4b02009-06-21 00:40:10 +01001717static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1718 /* Interal mic only available on one ADC */
1719 {
Tony Vroon684a8842009-06-26 09:27:50 +01001720 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001721 .items = {
1722 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001723 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001724 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001725 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001726 { "Int Mic", 0xb },
1727 },
1728 },
1729 {
Tony Vroon684a8842009-06-26 09:27:50 +01001730 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001731 .items = {
1732 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001733 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001734 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001735 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001736 },
1737 }
1738};
1739
Hector Martin018df412009-06-04 00:13:40 +02001740static struct hda_input_mux alc889_capture_sources[3] = {
1741 /* Digital mic only available on first "ADC" */
1742 {
1743 .num_items = 5,
1744 .items = {
1745 { "Mic", 0x0 },
1746 { "Line", 0x2 },
1747 { "CD", 0x4 },
1748 { "Front Mic", 0xb },
1749 { "Input Mix", 0xa },
1750 },
1751 },
1752 {
1753 .num_items = 4,
1754 .items = {
1755 { "Mic", 0x0 },
1756 { "Line", 0x2 },
1757 { "CD", 0x4 },
1758 { "Input Mix", 0xa },
1759 },
1760 },
1761 {
1762 .num_items = 4,
1763 .items = {
1764 { "Mic", 0x0 },
1765 { "Line", 0x2 },
1766 { "CD", 0x4 },
1767 { "Input Mix", 0xa },
1768 },
1769 }
1770};
1771
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001772static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001773 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1774 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1775 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1776 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1777 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1778 HDA_OUTPUT),
1779 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1780 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1781 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1782 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1783 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1784 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1785 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1786 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1787 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1788 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1789 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1790 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001791 { } /* end */
1792};
1793
Hector Martin556eea92009-12-20 22:51:23 +01001794static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
1795 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1796 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1797 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1798 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1799 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1800 HDA_OUTPUT),
1801 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1802 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1803 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1804 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1805 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1806 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1807 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1808 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1809 { } /* end */
1810};
1811
1812
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001813static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001814{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001815 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001816
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001817 spec->autocfg.hp_pins[0] = 0x15;
1818 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01001819 spec->autocfg.speaker_pins[1] = 0x16;
1820 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001821}
1822
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001823static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001824{
1825 struct alc_spec *spec = codec->spec;
1826
1827 spec->autocfg.hp_pins[0] = 0x15;
1828 spec->autocfg.speaker_pins[0] = 0x14;
1829 spec->autocfg.speaker_pins[1] = 0x16;
1830 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001831}
1832
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001833static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001834{
1835 struct alc_spec *spec = codec->spec;
1836
1837 spec->autocfg.hp_pins[0] = 0x15;
1838 spec->autocfg.speaker_pins[0] = 0x14;
1839 spec->autocfg.speaker_pins[1] = 0x16;
1840 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001841}
1842
Hector Martinf5de24b2009-12-20 22:51:31 +01001843#ifdef CONFIG_SND_HDA_POWER_SAVE
1844static void alc889_power_eapd(struct hda_codec *codec, int power)
1845{
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001846 set_eapd(codec, 0x14, power);
1847 set_eapd(codec, 0x15, power);
Hector Martinf5de24b2009-12-20 22:51:31 +01001848}
1849#endif
1850
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001851/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001852 * ALC880 3-stack model
1853 *
1854 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001855 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1856 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001857 */
1858
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001859static hda_nid_t alc880_dac_nids[4] = {
1860 /* front, rear, clfe, rear_surr */
1861 0x02, 0x05, 0x04, 0x03
1862};
1863
1864static hda_nid_t alc880_adc_nids[3] = {
1865 /* ADC0-2 */
1866 0x07, 0x08, 0x09,
1867};
1868
1869/* The datasheet says the node 0x07 is connected from inputs,
1870 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001871 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001872 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001873static hda_nid_t alc880_adc_nids_alt[2] = {
1874 /* ADC1-2 */
1875 0x08, 0x09,
1876};
1877
1878#define ALC880_DIGOUT_NID 0x06
1879#define ALC880_DIGIN_NID 0x0a
1880
1881static struct hda_input_mux alc880_capture_source = {
1882 .num_items = 4,
1883 .items = {
1884 { "Mic", 0x0 },
1885 { "Front Mic", 0x3 },
1886 { "Line", 0x2 },
1887 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001888 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001889};
1890
1891/* channel source setting (2/6 channel selection for 3-stack) */
1892/* 2ch mode */
1893static struct hda_verb alc880_threestack_ch2_init[] = {
1894 /* set line-in to input, mute it */
1895 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1896 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1897 /* set mic-in to input vref 80%, mute it */
1898 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1899 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001900 { } /* end */
1901};
1902
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001903/* 6ch mode */
1904static struct hda_verb alc880_threestack_ch6_init[] = {
1905 /* set line-in to output, unmute it */
1906 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1907 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1908 /* set mic-in to output, unmute it */
1909 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1910 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1911 { } /* end */
1912};
1913
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001914static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001915 { 2, alc880_threestack_ch2_init },
1916 { 6, alc880_threestack_ch6_init },
1917};
1918
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001919static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001920 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001921 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001922 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001923 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001924 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1925 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001926 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1927 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001928 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1929 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1930 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1931 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1932 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1933 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1934 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1935 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001936 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001937 {
1938 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1939 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001940 .info = alc_ch_mode_info,
1941 .get = alc_ch_mode_get,
1942 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001943 },
1944 { } /* end */
1945};
1946
1947/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001948static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1949 struct snd_ctl_elem_info *uinfo)
1950{
1951 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1952 struct alc_spec *spec = codec->spec;
1953 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001954
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001955 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001956 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1957 HDA_INPUT);
1958 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001959 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001960 return err;
1961}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001962
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001963static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1964 unsigned int size, unsigned int __user *tlv)
1965{
1966 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1967 struct alc_spec *spec = codec->spec;
1968 int err;
1969
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001970 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001971 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1972 HDA_INPUT);
1973 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001974 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001975 return err;
1976}
1977
1978typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1979 struct snd_ctl_elem_value *ucontrol);
1980
1981static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1982 struct snd_ctl_elem_value *ucontrol,
1983 getput_call_t func)
1984{
1985 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1986 struct alc_spec *spec = codec->spec;
1987 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1988 int err;
1989
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001990 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001991 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1992 3, 0, HDA_INPUT);
1993 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001994 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001995 return err;
1996}
1997
1998static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1999 struct snd_ctl_elem_value *ucontrol)
2000{
2001 return alc_cap_getput_caller(kcontrol, ucontrol,
2002 snd_hda_mixer_amp_volume_get);
2003}
2004
2005static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2006 struct snd_ctl_elem_value *ucontrol)
2007{
2008 return alc_cap_getput_caller(kcontrol, ucontrol,
2009 snd_hda_mixer_amp_volume_put);
2010}
2011
2012/* capture mixer elements */
2013#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2014
2015static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2016 struct snd_ctl_elem_value *ucontrol)
2017{
2018 return alc_cap_getput_caller(kcontrol, ucontrol,
2019 snd_hda_mixer_amp_switch_get);
2020}
2021
2022static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2023 struct snd_ctl_elem_value *ucontrol)
2024{
2025 return alc_cap_getput_caller(kcontrol, ucontrol,
2026 snd_hda_mixer_amp_switch_put);
2027}
2028
Takashi Iwaia23b6882009-03-23 15:21:36 +01002029#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002030 { \
2031 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2032 .name = "Capture Switch", \
2033 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2034 .count = num, \
2035 .info = alc_cap_sw_info, \
2036 .get = alc_cap_sw_get, \
2037 .put = alc_cap_sw_put, \
2038 }, \
2039 { \
2040 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2041 .name = "Capture Volume", \
2042 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2043 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2044 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2045 .count = num, \
2046 .info = alc_cap_vol_info, \
2047 .get = alc_cap_vol_get, \
2048 .put = alc_cap_vol_put, \
2049 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002050 }
2051
2052#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002053 { \
2054 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2055 /* .name = "Capture Source", */ \
2056 .name = "Input Source", \
2057 .count = num, \
2058 .info = alc_mux_enum_info, \
2059 .get = alc_mux_enum_get, \
2060 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002061 }
2062
2063#define DEFINE_CAPMIX(num) \
2064static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2065 _DEFINE_CAPMIX(num), \
2066 _DEFINE_CAPSRC(num), \
2067 { } /* end */ \
2068}
2069
2070#define DEFINE_CAPMIX_NOSRC(num) \
2071static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2072 _DEFINE_CAPMIX(num), \
2073 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002074}
2075
2076/* up to three ADCs */
2077DEFINE_CAPMIX(1);
2078DEFINE_CAPMIX(2);
2079DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002080DEFINE_CAPMIX_NOSRC(1);
2081DEFINE_CAPMIX_NOSRC(2);
2082DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002083
2084/*
2085 * ALC880 5-stack model
2086 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002087 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2088 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002089 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2090 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2091 */
2092
2093/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002094static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002095 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002096 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002097 { } /* end */
2098};
2099
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002100/* channel source setting (6/8 channel selection for 5-stack) */
2101/* 6ch mode */
2102static struct hda_verb alc880_fivestack_ch6_init[] = {
2103 /* set line-in to input, mute it */
2104 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2105 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002106 { } /* end */
2107};
2108
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002109/* 8ch mode */
2110static struct hda_verb alc880_fivestack_ch8_init[] = {
2111 /* set line-in to output, unmute it */
2112 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2113 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2114 { } /* end */
2115};
2116
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002117static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002118 { 6, alc880_fivestack_ch6_init },
2119 { 8, alc880_fivestack_ch8_init },
2120};
2121
2122
2123/*
2124 * ALC880 6-stack model
2125 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002126 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2127 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002128 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2129 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2130 */
2131
2132static hda_nid_t alc880_6st_dac_nids[4] = {
2133 /* front, rear, clfe, rear_surr */
2134 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002135};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002136
2137static struct hda_input_mux alc880_6stack_capture_source = {
2138 .num_items = 4,
2139 .items = {
2140 { "Mic", 0x0 },
2141 { "Front Mic", 0x1 },
2142 { "Line", 0x2 },
2143 { "CD", 0x4 },
2144 },
2145};
2146
2147/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002148static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002149 { 8, NULL },
2150};
2151
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002152static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002153 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002154 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002155 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002156 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002157 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2158 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002159 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2160 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002161 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002162 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002163 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2164 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2165 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2166 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2167 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2168 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2169 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2170 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002171 {
2172 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2173 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002174 .info = alc_ch_mode_info,
2175 .get = alc_ch_mode_get,
2176 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002177 },
2178 { } /* end */
2179};
2180
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002181
2182/*
2183 * ALC880 W810 model
2184 *
2185 * W810 has rear IO for:
2186 * Front (DAC 02)
2187 * Surround (DAC 03)
2188 * Center/LFE (DAC 04)
2189 * Digital out (06)
2190 *
2191 * The system also has a pair of internal speakers, and a headphone jack.
2192 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002193 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002194 * There is a variable resistor to control the speaker or headphone
2195 * volume. This is a hardware-only device without a software API.
2196 *
2197 * Plugging headphones in will disable the internal speakers. This is
2198 * implemented in hardware, not via the driver using jack sense. In
2199 * a similar fashion, plugging into the rear socket marked "front" will
2200 * disable both the speakers and headphones.
2201 *
2202 * For input, there's a microphone jack, and an "audio in" jack.
2203 * These may not do anything useful with this driver yet, because I
2204 * haven't setup any initialization verbs for these yet...
2205 */
2206
2207static hda_nid_t alc880_w810_dac_nids[3] = {
2208 /* front, rear/surround, clfe */
2209 0x02, 0x03, 0x04
2210};
2211
2212/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002213static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002214 { 6, NULL }
2215};
2216
2217/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002218static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002219 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002220 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002221 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002222 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002223 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2224 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002225 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2226 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002227 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2228 { } /* end */
2229};
2230
2231
2232/*
2233 * Z710V model
2234 *
2235 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002236 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2237 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002238 */
2239
2240static hda_nid_t alc880_z71v_dac_nids[1] = {
2241 0x02
2242};
2243#define ALC880_Z71V_HP_DAC 0x03
2244
2245/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002246static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002247 { 2, NULL }
2248};
2249
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002250static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002251 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002252 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002253 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002254 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002255 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2256 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2257 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2258 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2259 { } /* end */
2260};
2261
2262
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002263/*
2264 * ALC880 F1734 model
2265 *
2266 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2267 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2268 */
2269
2270static hda_nid_t alc880_f1734_dac_nids[1] = {
2271 0x03
2272};
2273#define ALC880_F1734_HP_DAC 0x02
2274
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002275static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002276 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002277 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002278 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2279 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002280 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2281 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002282 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2283 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002284 { } /* end */
2285};
2286
Takashi Iwai937b4162008-02-11 14:52:36 +01002287static struct hda_input_mux alc880_f1734_capture_source = {
2288 .num_items = 2,
2289 .items = {
2290 { "Mic", 0x1 },
2291 { "CD", 0x4 },
2292 },
2293};
2294
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002295
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002296/*
2297 * ALC880 ASUS model
2298 *
2299 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2300 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2301 * Mic = 0x18, Line = 0x1a
2302 */
2303
2304#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2305#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2306
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002307static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002308 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002309 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002310 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002311 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002312 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2313 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002314 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2315 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002316 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2317 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2318 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2319 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2320 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2321 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002322 {
2323 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2324 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002325 .info = alc_ch_mode_info,
2326 .get = alc_ch_mode_get,
2327 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002328 },
2329 { } /* end */
2330};
2331
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002332/*
2333 * ALC880 ASUS W1V model
2334 *
2335 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2336 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2337 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2338 */
2339
2340/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002341static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002342 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2343 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002344 { } /* end */
2345};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002346
Kailang Yangdf694da2005-12-05 19:42:22 +01002347/* TCL S700 */
2348static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2349 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2350 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2351 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2352 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2353 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2354 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2355 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2356 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2357 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002358 { } /* end */
2359};
2360
Kailang Yangccc656c2006-10-17 12:32:26 +02002361/* Uniwill */
2362static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002363 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2364 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2365 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2366 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002367 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2368 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2369 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2370 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 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("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2374 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2375 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2376 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2377 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2378 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002379 {
2380 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2381 .name = "Channel Mode",
2382 .info = alc_ch_mode_info,
2383 .get = alc_ch_mode_get,
2384 .put = alc_ch_mode_put,
2385 },
2386 { } /* end */
2387};
2388
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002389static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2390 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2391 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2392 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2393 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2394 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2395 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2396 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2397 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2398 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2399 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2400 { } /* end */
2401};
2402
Kailang Yangccc656c2006-10-17 12:32:26 +02002403static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002404 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2405 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2406 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2407 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002408 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2409 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2410 { } /* end */
2411};
2412
Linus Torvalds1da177e2005-04-16 15:20:36 -07002413/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002414 * virtual master controls
2415 */
2416
2417/*
2418 * slave controls for virtual master
2419 */
2420static const char *alc_slave_vols[] = {
2421 "Front Playback Volume",
2422 "Surround Playback Volume",
2423 "Center Playback Volume",
2424 "LFE Playback Volume",
2425 "Side Playback Volume",
2426 "Headphone Playback Volume",
2427 "Speaker Playback Volume",
2428 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002429 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002430 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002431 NULL,
2432};
2433
2434static const char *alc_slave_sws[] = {
2435 "Front Playback Switch",
2436 "Surround Playback Switch",
2437 "Center Playback Switch",
2438 "LFE Playback Switch",
2439 "Side Playback Switch",
2440 "Headphone Playback Switch",
2441 "Speaker Playback Switch",
2442 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002443 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002444 "Line-Out Playback Switch",
2445 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002446 NULL,
2447};
2448
2449/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002450 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002451 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002452
2453static void alc_free_kctls(struct hda_codec *codec);
2454
Takashi Iwai67d634c2009-11-16 15:35:59 +01002455#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002456/* additional beep mixers; the actual parameters are overwritten at build */
2457static struct snd_kcontrol_new alc_beep_mixer[] = {
2458 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002459 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002460 { } /* end */
2461};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002462#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002463
Linus Torvalds1da177e2005-04-16 15:20:36 -07002464static int alc_build_controls(struct hda_codec *codec)
2465{
2466 struct alc_spec *spec = codec->spec;
2467 int err;
2468 int i;
2469
2470 for (i = 0; i < spec->num_mixers; i++) {
2471 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2472 if (err < 0)
2473 return err;
2474 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002475 if (spec->cap_mixer) {
2476 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2477 if (err < 0)
2478 return err;
2479 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002480 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002481 err = snd_hda_create_spdif_out_ctls(codec,
2482 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002483 if (err < 0)
2484 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002485 if (!spec->no_analog) {
2486 err = snd_hda_create_spdif_share_sw(codec,
2487 &spec->multiout);
2488 if (err < 0)
2489 return err;
2490 spec->multiout.share_spdif = 1;
2491 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002492 }
2493 if (spec->dig_in_nid) {
2494 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2495 if (err < 0)
2496 return err;
2497 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002498
Takashi Iwai67d634c2009-11-16 15:35:59 +01002499#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002500 /* create beep controls if needed */
2501 if (spec->beep_amp) {
2502 struct snd_kcontrol_new *knew;
2503 for (knew = alc_beep_mixer; knew->name; knew++) {
2504 struct snd_kcontrol *kctl;
2505 kctl = snd_ctl_new1(knew, codec);
2506 if (!kctl)
2507 return -ENOMEM;
2508 kctl->private_value = spec->beep_amp;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01002509 err = snd_hda_ctl_add(codec,
2510 get_amp_nid_(spec->beep_amp), kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002511 if (err < 0)
2512 return err;
2513 }
2514 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002515#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002516
Takashi Iwai2134ea42008-01-10 16:53:55 +01002517 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002518 if (!spec->no_analog &&
2519 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002520 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002521 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002522 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002523 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002524 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002525 if (err < 0)
2526 return err;
2527 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002528 if (!spec->no_analog &&
2529 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002530 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2531 NULL, alc_slave_sws);
2532 if (err < 0)
2533 return err;
2534 }
2535
Takashi Iwai603c4012008-07-30 15:01:44 +02002536 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002537 return 0;
2538}
2539
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002540
Linus Torvalds1da177e2005-04-16 15:20:36 -07002541/*
2542 * initialize the codec volumes, etc
2543 */
2544
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002545/*
2546 * generic initialization of ADC, input mixers and output mixers
2547 */
2548static struct hda_verb alc880_volume_init_verbs[] = {
2549 /*
2550 * Unmute ADC0-2 and set the default input to mic-in
2551 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002552 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002553 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002554 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002555 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002556 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002557 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002558
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002559 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2560 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002561 * Note: PASD motherboards uses the Line In 2 as the input for front
2562 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002563 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002564 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002565 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2566 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2567 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2568 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2569 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002572
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002573 /*
2574 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002575 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002576 /* set vol=0 to output mixers */
2577 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2578 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2579 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2580 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2581 /* set up input amps for analog loopback */
2582 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002583 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2584 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002585 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2586 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002587 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2588 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002589 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2590 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002591
2592 { }
2593};
2594
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002595/*
2596 * 3-stack pin configuration:
2597 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2598 */
2599static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2600 /*
2601 * preset connection lists of input pins
2602 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2603 */
2604 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2605 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2606 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2607
2608 /*
2609 * Set pin mode and muting
2610 */
2611 /* set front pin widgets 0x14 for output */
2612 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2613 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2614 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2615 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2616 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2617 /* Mic2 (as headphone out) for HP output */
2618 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2619 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2620 /* Line In pin widget for input */
2621 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2622 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2623 /* Line2 (as front mic) pin widget for input and vref at 80% */
2624 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2625 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2626 /* CD pin widget for input */
2627 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2628
2629 { }
2630};
2631
2632/*
2633 * 5-stack pin configuration:
2634 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2635 * line-in/side = 0x1a, f-mic = 0x1b
2636 */
2637static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2638 /*
2639 * preset connection lists of input pins
2640 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2641 */
2642 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2643 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2644
2645 /*
2646 * Set pin mode and muting
2647 */
2648 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002649 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2650 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2651 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2652 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002653 /* unmute pins for output (no gain on this amp) */
2654 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2655 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2656 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2657 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2658
Linus Torvalds1da177e2005-04-16 15:20:36 -07002659 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002660 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002661 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2662 /* Mic2 (as headphone out) for HP output */
2663 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002664 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002665 /* Line In pin widget for input */
2666 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2667 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2668 /* Line2 (as front mic) pin widget for input and vref at 80% */
2669 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2670 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2671 /* CD pin widget for input */
2672 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002673
2674 { }
2675};
2676
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002677/*
2678 * W810 pin configuration:
2679 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2680 */
2681static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002682 /* hphone/speaker input selector: front DAC */
2683 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2684
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002685 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2686 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2687 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2688 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2689 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2690 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2691
2692 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002693 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002694
Linus Torvalds1da177e2005-04-16 15:20:36 -07002695 { }
2696};
2697
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002698/*
2699 * Z71V pin configuration:
2700 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2701 */
2702static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002703 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002704 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002705 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002706 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002707
Takashi Iwai16ded522005-06-10 19:58:24 +02002708 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002709 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002710 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002711 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002712
2713 { }
2714};
2715
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002716/*
2717 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002718 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2719 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002720 */
2721static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2722 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2723
Takashi Iwai16ded522005-06-10 19:58:24 +02002724 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002725 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002726 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002727 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002728 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002729 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002730 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002731 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2732
Takashi Iwai16ded522005-06-10 19:58:24 +02002733 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002734 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002735 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002736 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002737 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002738 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002739 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002740 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002741 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002742
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002743 { }
2744};
Takashi Iwai16ded522005-06-10 19:58:24 +02002745
Kailang Yangccc656c2006-10-17 12:32:26 +02002746/*
2747 * Uniwill pin configuration:
2748 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2749 * line = 0x1a
2750 */
2751static struct hda_verb alc880_uniwill_init_verbs[] = {
2752 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2753
2754 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2755 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2756 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2757 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2758 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2759 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2760 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2761 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2762 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2763 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2764 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2765 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2766 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2767 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2768
2769 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2770 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2771 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2772 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2773 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2774 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2775 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2776 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2777 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2778
2779 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2780 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2781
2782 { }
2783};
2784
2785/*
2786* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002787* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002788 */
2789static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2790 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2791
2792 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2793 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2794 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2795 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2796 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2797 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2798 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2799 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2800 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2801 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2802 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2803 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2804
2805 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2806 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2807 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2808 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2809 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2810 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2811
2812 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2813 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2814
2815 { }
2816};
2817
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002818static struct hda_verb alc880_beep_init_verbs[] = {
2819 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2820 { }
2821};
2822
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002823/* auto-toggle front mic */
2824static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2825{
2826 unsigned int present;
2827 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002828
Wu Fengguang864f92b2009-11-18 12:38:02 +08002829 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002830 bits = present ? HDA_AMP_MUTE : 0;
2831 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002832}
2833
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002834static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002835{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002836 struct alc_spec *spec = codec->spec;
2837
2838 spec->autocfg.hp_pins[0] = 0x14;
2839 spec->autocfg.speaker_pins[0] = 0x15;
2840 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002841}
2842
2843static void alc880_uniwill_init_hook(struct hda_codec *codec)
2844{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002845 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002846 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002847}
2848
2849static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2850 unsigned int res)
2851{
2852 /* Looks like the unsol event is incompatible with the standard
2853 * definition. 4bit tag is placed at 28 bit!
2854 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002855 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002856 case ALC880_MIC_EVENT:
2857 alc880_uniwill_mic_automute(codec);
2858 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002859 default:
2860 alc_automute_amp_unsol_event(codec, res);
2861 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002862 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002863}
2864
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002865static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002866{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002867 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002868
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002869 spec->autocfg.hp_pins[0] = 0x14;
2870 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02002871}
2872
2873static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2874{
2875 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002876
Kailang Yangccc656c2006-10-17 12:32:26 +02002877 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002878 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2879 present &= HDA_AMP_VOLMASK;
2880 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2881 HDA_AMP_VOLMASK, present);
2882 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2883 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002884}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002885
Kailang Yangccc656c2006-10-17 12:32:26 +02002886static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2887 unsigned int res)
2888{
2889 /* Looks like the unsol event is incompatible with the standard
2890 * definition. 4bit tag is placed at 28 bit!
2891 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002892 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002893 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002894 else
2895 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002896}
2897
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002898/*
2899 * F1734 pin configuration:
2900 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2901 */
2902static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002903 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002904 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2905 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2906 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2907 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2908
2909 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2910 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2911 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2912 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2913
2914 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2915 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002916 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002917 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2918 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2919 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2920 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2921 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2922 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002923
Takashi Iwai937b4162008-02-11 14:52:36 +01002924 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2925 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2926
Takashi Iwai16ded522005-06-10 19:58:24 +02002927 { }
2928};
2929
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002930/*
2931 * ASUS pin configuration:
2932 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2933 */
2934static struct hda_verb alc880_pin_asus_init_verbs[] = {
2935 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2936 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2937 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2938 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2939
2940 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2941 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2942 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2943 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2944 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2945 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2946 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2947 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2948
2949 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2950 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2951 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2952 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2953 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2954 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2955 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2956 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2957 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002958
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002959 { }
2960};
2961
2962/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002963#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2964#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02002965#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002966
Kailang Yangdf694da2005-12-05 19:42:22 +01002967/* Clevo m520g init */
2968static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2969 /* headphone output */
2970 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2971 /* line-out */
2972 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2973 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2974 /* Line-in */
2975 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2976 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2977 /* CD */
2978 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2979 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2980 /* Mic1 (rear panel) */
2981 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2982 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2983 /* Mic2 (front panel) */
2984 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2985 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2986 /* headphone */
2987 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2988 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2989 /* change to EAPD mode */
2990 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2991 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2992
2993 { }
2994};
2995
2996static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002997 /* change to EAPD mode */
2998 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2999 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3000
Kailang Yangdf694da2005-12-05 19:42:22 +01003001 /* Headphone output */
3002 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3003 /* Front output*/
3004 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3005 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3006
3007 /* Line In pin widget for input */
3008 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3009 /* CD pin widget for input */
3010 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3011 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3012 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3013
3014 /* change to EAPD mode */
3015 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3016 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3017
3018 { }
3019};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003020
3021/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003022 * LG m1 express dual
3023 *
3024 * Pin assignment:
3025 * Rear Line-In/Out (blue): 0x14
3026 * Build-in Mic-In: 0x15
3027 * Speaker-out: 0x17
3028 * HP-Out (green): 0x1b
3029 * Mic-In/Out (red): 0x19
3030 * SPDIF-Out: 0x1e
3031 */
3032
3033/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3034static hda_nid_t alc880_lg_dac_nids[3] = {
3035 0x05, 0x02, 0x03
3036};
3037
3038/* seems analog CD is not working */
3039static struct hda_input_mux alc880_lg_capture_source = {
3040 .num_items = 3,
3041 .items = {
3042 { "Mic", 0x1 },
3043 { "Line", 0x5 },
3044 { "Internal Mic", 0x6 },
3045 },
3046};
3047
3048/* 2,4,6 channel modes */
3049static struct hda_verb alc880_lg_ch2_init[] = {
3050 /* set line-in and mic-in to input */
3051 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3052 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3053 { }
3054};
3055
3056static struct hda_verb alc880_lg_ch4_init[] = {
3057 /* set line-in to out and mic-in to input */
3058 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3059 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3060 { }
3061};
3062
3063static struct hda_verb alc880_lg_ch6_init[] = {
3064 /* set line-in and mic-in to output */
3065 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3066 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3067 { }
3068};
3069
3070static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3071 { 2, alc880_lg_ch2_init },
3072 { 4, alc880_lg_ch4_init },
3073 { 6, alc880_lg_ch6_init },
3074};
3075
3076static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003077 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3078 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003079 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3080 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3081 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3082 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3083 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3084 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3085 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3086 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3087 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3088 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3089 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3090 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3091 {
3092 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3093 .name = "Channel Mode",
3094 .info = alc_ch_mode_info,
3095 .get = alc_ch_mode_get,
3096 .put = alc_ch_mode_put,
3097 },
3098 { } /* end */
3099};
3100
3101static struct hda_verb alc880_lg_init_verbs[] = {
3102 /* set capture source to mic-in */
3103 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3104 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3105 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3106 /* mute all amp mixer inputs */
3107 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003108 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3109 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003110 /* line-in to input */
3111 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3112 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3113 /* built-in mic */
3114 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3115 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3116 /* speaker-out */
3117 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3118 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3119 /* mic-in to input */
3120 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3121 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3122 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3123 /* HP-out */
3124 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3125 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3126 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3127 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003128 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003129 { }
3130};
3131
3132/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003133static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003134{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003135 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003136
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003137 spec->autocfg.hp_pins[0] = 0x1b;
3138 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003139}
3140
3141/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003142 * LG LW20
3143 *
3144 * Pin assignment:
3145 * Speaker-out: 0x14
3146 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003147 * Built-in Mic-In: 0x19
3148 * Line-In: 0x1b
3149 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003150 * SPDIF-Out: 0x1e
3151 */
3152
Takashi Iwaid6815182006-03-23 16:06:23 +01003153static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003154 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003155 .items = {
3156 { "Mic", 0x0 },
3157 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003158 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003159 },
3160};
3161
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003162#define alc880_lg_lw_modes alc880_threestack_modes
3163
Takashi Iwaid6815182006-03-23 16:06:23 +01003164static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003165 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3166 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3167 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3168 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3169 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3170 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3171 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3172 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3173 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3174 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003175 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3176 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3177 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3178 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003179 {
3180 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3181 .name = "Channel Mode",
3182 .info = alc_ch_mode_info,
3183 .get = alc_ch_mode_get,
3184 .put = alc_ch_mode_put,
3185 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003186 { } /* end */
3187};
3188
3189static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003190 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3191 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3192 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3193
Takashi Iwaid6815182006-03-23 16:06:23 +01003194 /* set capture source to mic-in */
3195 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3196 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3197 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003198 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003199 /* speaker-out */
3200 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3201 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3202 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003203 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3204 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3205 /* mic-in to input */
3206 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3207 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3208 /* built-in mic */
3209 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3210 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3211 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003212 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003213 { }
3214};
3215
3216/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003217static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003218{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003219 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003220
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003221 spec->autocfg.hp_pins[0] = 0x1b;
3222 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003223}
3224
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003225static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3226 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3227 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3228 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3229 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3230 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3231 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3232 { } /* end */
3233};
3234
3235static struct hda_input_mux alc880_medion_rim_capture_source = {
3236 .num_items = 2,
3237 .items = {
3238 { "Mic", 0x0 },
3239 { "Internal Mic", 0x1 },
3240 },
3241};
3242
3243static struct hda_verb alc880_medion_rim_init_verbs[] = {
3244 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3245
3246 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3247 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3248
3249 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3250 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3251 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3252 /* Mic2 (as headphone out) for HP output */
3253 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3254 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3255 /* Internal Speaker */
3256 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3257 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3258
3259 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3260 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3261
3262 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3263 { }
3264};
3265
3266/* toggle speaker-output according to the hp-jack state */
3267static void alc880_medion_rim_automute(struct hda_codec *codec)
3268{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003269 struct alc_spec *spec = codec->spec;
3270 alc_automute_amp(codec);
3271 /* toggle EAPD */
3272 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003273 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3274 else
3275 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3276}
3277
3278static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3279 unsigned int res)
3280{
3281 /* Looks like the unsol event is incompatible with the standard
3282 * definition. 4bit tag is placed at 28 bit!
3283 */
3284 if ((res >> 28) == ALC880_HP_EVENT)
3285 alc880_medion_rim_automute(codec);
3286}
3287
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003288static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003289{
3290 struct alc_spec *spec = codec->spec;
3291
3292 spec->autocfg.hp_pins[0] = 0x14;
3293 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003294}
3295
Takashi Iwaicb53c622007-08-10 17:21:45 +02003296#ifdef CONFIG_SND_HDA_POWER_SAVE
3297static struct hda_amp_list alc880_loopbacks[] = {
3298 { 0x0b, HDA_INPUT, 0 },
3299 { 0x0b, HDA_INPUT, 1 },
3300 { 0x0b, HDA_INPUT, 2 },
3301 { 0x0b, HDA_INPUT, 3 },
3302 { 0x0b, HDA_INPUT, 4 },
3303 { } /* end */
3304};
3305
3306static struct hda_amp_list alc880_lg_loopbacks[] = {
3307 { 0x0b, HDA_INPUT, 1 },
3308 { 0x0b, HDA_INPUT, 6 },
3309 { 0x0b, HDA_INPUT, 7 },
3310 { } /* end */
3311};
3312#endif
3313
Takashi Iwaid6815182006-03-23 16:06:23 +01003314/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003315 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003316 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003317
Linus Torvalds1da177e2005-04-16 15:20:36 -07003318static int alc_init(struct hda_codec *codec)
3319{
3320 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003321 unsigned int i;
3322
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003323 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003324 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003325
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003326 for (i = 0; i < spec->num_init_verbs; i++)
3327 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003328
3329 if (spec->init_hook)
3330 spec->init_hook(codec);
3331
Linus Torvalds1da177e2005-04-16 15:20:36 -07003332 return 0;
3333}
3334
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003335static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3336{
3337 struct alc_spec *spec = codec->spec;
3338
3339 if (spec->unsol_event)
3340 spec->unsol_event(codec, res);
3341}
3342
Takashi Iwaicb53c622007-08-10 17:21:45 +02003343#ifdef CONFIG_SND_HDA_POWER_SAVE
3344static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3345{
3346 struct alc_spec *spec = codec->spec;
3347 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3348}
3349#endif
3350
Linus Torvalds1da177e2005-04-16 15:20:36 -07003351/*
3352 * Analog playback callbacks
3353 */
3354static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3355 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003356 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003357{
3358 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003359 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3360 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003361}
3362
3363static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3364 struct hda_codec *codec,
3365 unsigned int stream_tag,
3366 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003367 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003368{
3369 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003370 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3371 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003372}
3373
3374static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3375 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003376 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003377{
3378 struct alc_spec *spec = codec->spec;
3379 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3380}
3381
3382/*
3383 * Digital out
3384 */
3385static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3386 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003387 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003388{
3389 struct alc_spec *spec = codec->spec;
3390 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3391}
3392
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003393static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3394 struct hda_codec *codec,
3395 unsigned int stream_tag,
3396 unsigned int format,
3397 struct snd_pcm_substream *substream)
3398{
3399 struct alc_spec *spec = codec->spec;
3400 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3401 stream_tag, format, substream);
3402}
3403
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003404static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3405 struct hda_codec *codec,
3406 struct snd_pcm_substream *substream)
3407{
3408 struct alc_spec *spec = codec->spec;
3409 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3410}
3411
Linus Torvalds1da177e2005-04-16 15:20:36 -07003412static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3413 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003414 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003415{
3416 struct alc_spec *spec = codec->spec;
3417 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3418}
3419
3420/*
3421 * Analog capture
3422 */
Takashi Iwai63300792008-01-24 15:31:36 +01003423static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003424 struct hda_codec *codec,
3425 unsigned int stream_tag,
3426 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003427 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003428{
3429 struct alc_spec *spec = codec->spec;
3430
Takashi Iwai63300792008-01-24 15:31:36 +01003431 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003432 stream_tag, 0, format);
3433 return 0;
3434}
3435
Takashi Iwai63300792008-01-24 15:31:36 +01003436static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003437 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003438 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003439{
3440 struct alc_spec *spec = codec->spec;
3441
Takashi Iwai888afa12008-03-18 09:57:50 +01003442 snd_hda_codec_cleanup_stream(codec,
3443 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003444 return 0;
3445}
3446
3447
3448/*
3449 */
3450static struct hda_pcm_stream alc880_pcm_analog_playback = {
3451 .substreams = 1,
3452 .channels_min = 2,
3453 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003454 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003455 .ops = {
3456 .open = alc880_playback_pcm_open,
3457 .prepare = alc880_playback_pcm_prepare,
3458 .cleanup = alc880_playback_pcm_cleanup
3459 },
3460};
3461
3462static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003463 .substreams = 1,
3464 .channels_min = 2,
3465 .channels_max = 2,
3466 /* NID is set in alc_build_pcms */
3467};
3468
3469static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3470 .substreams = 1,
3471 .channels_min = 2,
3472 .channels_max = 2,
3473 /* NID is set in alc_build_pcms */
3474};
3475
3476static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3477 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003478 .channels_min = 2,
3479 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003480 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003481 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003482 .prepare = alc880_alt_capture_pcm_prepare,
3483 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003484 },
3485};
3486
3487static struct hda_pcm_stream alc880_pcm_digital_playback = {
3488 .substreams = 1,
3489 .channels_min = 2,
3490 .channels_max = 2,
3491 /* NID is set in alc_build_pcms */
3492 .ops = {
3493 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003494 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003495 .prepare = alc880_dig_playback_pcm_prepare,
3496 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003497 },
3498};
3499
3500static struct hda_pcm_stream alc880_pcm_digital_capture = {
3501 .substreams = 1,
3502 .channels_min = 2,
3503 .channels_max = 2,
3504 /* NID is set in alc_build_pcms */
3505};
3506
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003507/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003508static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003509 .substreams = 0,
3510 .channels_min = 0,
3511 .channels_max = 0,
3512};
3513
Linus Torvalds1da177e2005-04-16 15:20:36 -07003514static int alc_build_pcms(struct hda_codec *codec)
3515{
3516 struct alc_spec *spec = codec->spec;
3517 struct hda_pcm *info = spec->pcm_rec;
3518 int i;
3519
3520 codec->num_pcms = 1;
3521 codec->pcm_info = info;
3522
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003523 if (spec->no_analog)
3524 goto skip_analog;
3525
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003526 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3527 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003528 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003529
Takashi Iwai4a471b72005-12-07 13:56:29 +01003530 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003531 if (snd_BUG_ON(!spec->multiout.dac_nids))
3532 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003533 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3534 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3535 }
3536 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003537 if (snd_BUG_ON(!spec->adc_nids))
3538 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003539 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3540 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3541 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003542
Takashi Iwai4a471b72005-12-07 13:56:29 +01003543 if (spec->channel_mode) {
3544 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3545 for (i = 0; i < spec->num_channel_mode; i++) {
3546 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3547 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3548 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003549 }
3550 }
3551
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003552 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003553 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003554 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003555 snprintf(spec->stream_name_digital,
3556 sizeof(spec->stream_name_digital),
3557 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003558 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003559 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003560 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003561 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003562 if (spec->dig_out_type)
3563 info->pcm_type = spec->dig_out_type;
3564 else
3565 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003566 if (spec->multiout.dig_out_nid &&
3567 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003568 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3569 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3570 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003571 if (spec->dig_in_nid &&
3572 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003573 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3574 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3575 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003576 /* FIXME: do we need this for all Realtek codec models? */
3577 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003578 }
3579
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003580 if (spec->no_analog)
3581 return 0;
3582
Takashi Iwaie08a0072006-09-07 17:52:14 +02003583 /* If the use of more than one ADC is requested for the current
3584 * model, configure a second analog capture-only PCM.
3585 */
3586 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003587 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3588 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003589 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003590 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003591 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003592 if (spec->alt_dac_nid) {
3593 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3594 *spec->stream_analog_alt_playback;
3595 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3596 spec->alt_dac_nid;
3597 } else {
3598 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3599 alc_pcm_null_stream;
3600 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3601 }
3602 if (spec->num_adc_nids > 1) {
3603 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3604 *spec->stream_analog_alt_capture;
3605 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3606 spec->adc_nids[1];
3607 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3608 spec->num_adc_nids - 1;
3609 } else {
3610 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3611 alc_pcm_null_stream;
3612 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003613 }
3614 }
3615
Linus Torvalds1da177e2005-04-16 15:20:36 -07003616 return 0;
3617}
3618
Takashi Iwai603c4012008-07-30 15:01:44 +02003619static void alc_free_kctls(struct hda_codec *codec)
3620{
3621 struct alc_spec *spec = codec->spec;
3622
3623 if (spec->kctls.list) {
3624 struct snd_kcontrol_new *kctl = spec->kctls.list;
3625 int i;
3626 for (i = 0; i < spec->kctls.used; i++)
3627 kfree(kctl[i].name);
3628 }
3629 snd_array_free(&spec->kctls);
3630}
3631
Linus Torvalds1da177e2005-04-16 15:20:36 -07003632static void alc_free(struct hda_codec *codec)
3633{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003634 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003635
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003636 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003637 return;
3638
Takashi Iwai603c4012008-07-30 15:01:44 +02003639 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003640 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003641 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003642}
3643
Hector Martinf5de24b2009-12-20 22:51:31 +01003644#ifdef CONFIG_SND_HDA_POWER_SAVE
3645static int alc_suspend(struct hda_codec *codec, pm_message_t state)
3646{
3647 struct alc_spec *spec = codec->spec;
3648 if (spec && spec->power_hook)
3649 spec->power_hook(codec, 0);
3650 return 0;
3651}
3652#endif
3653
Takashi Iwaie044c392008-10-27 16:56:24 +01003654#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003655static int alc_resume(struct hda_codec *codec)
3656{
Hector Martinf5de24b2009-12-20 22:51:31 +01003657#ifdef CONFIG_SND_HDA_POWER_SAVE
3658 struct alc_spec *spec = codec->spec;
3659#endif
Takashi Iwaie044c392008-10-27 16:56:24 +01003660 codec->patch_ops.init(codec);
3661 snd_hda_codec_resume_amp(codec);
3662 snd_hda_codec_resume_cache(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003663#ifdef CONFIG_SND_HDA_POWER_SAVE
3664 if (spec && spec->power_hook)
3665 spec->power_hook(codec, 1);
3666#endif
Takashi Iwaie044c392008-10-27 16:56:24 +01003667 return 0;
3668}
Takashi Iwaie044c392008-10-27 16:56:24 +01003669#endif
3670
Linus Torvalds1da177e2005-04-16 15:20:36 -07003671/*
3672 */
3673static struct hda_codec_ops alc_patch_ops = {
3674 .build_controls = alc_build_controls,
3675 .build_pcms = alc_build_pcms,
3676 .init = alc_init,
3677 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003678 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003679#ifdef SND_HDA_NEEDS_RESUME
3680 .resume = alc_resume,
3681#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003682#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01003683 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003684 .check_power_status = alc_check_power_status,
3685#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003686};
3687
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003688
3689/*
3690 * Test configuration for debugging
3691 *
3692 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3693 * enum controls.
3694 */
3695#ifdef CONFIG_SND_DEBUG
3696static hda_nid_t alc880_test_dac_nids[4] = {
3697 0x02, 0x03, 0x04, 0x05
3698};
3699
3700static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003701 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003702 .items = {
3703 { "In-1", 0x0 },
3704 { "In-2", 0x1 },
3705 { "In-3", 0x2 },
3706 { "In-4", 0x3 },
3707 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003708 { "Front", 0x5 },
3709 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003710 },
3711};
3712
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003713static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003714 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003715 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003716 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003717 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003718};
3719
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003720static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3721 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003722{
3723 static char *texts[] = {
3724 "N/A", "Line Out", "HP Out",
3725 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3726 };
3727 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3728 uinfo->count = 1;
3729 uinfo->value.enumerated.items = 8;
3730 if (uinfo->value.enumerated.item >= 8)
3731 uinfo->value.enumerated.item = 7;
3732 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3733 return 0;
3734}
3735
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003736static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3737 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003738{
3739 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3740 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3741 unsigned int pin_ctl, item = 0;
3742
3743 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3744 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3745 if (pin_ctl & AC_PINCTL_OUT_EN) {
3746 if (pin_ctl & AC_PINCTL_HP_EN)
3747 item = 2;
3748 else
3749 item = 1;
3750 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3751 switch (pin_ctl & AC_PINCTL_VREFEN) {
3752 case AC_PINCTL_VREF_HIZ: item = 3; break;
3753 case AC_PINCTL_VREF_50: item = 4; break;
3754 case AC_PINCTL_VREF_GRD: item = 5; break;
3755 case AC_PINCTL_VREF_80: item = 6; break;
3756 case AC_PINCTL_VREF_100: item = 7; break;
3757 }
3758 }
3759 ucontrol->value.enumerated.item[0] = item;
3760 return 0;
3761}
3762
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003763static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3764 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003765{
3766 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3767 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3768 static unsigned int ctls[] = {
3769 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3770 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3771 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3772 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3773 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3774 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3775 };
3776 unsigned int old_ctl, new_ctl;
3777
3778 old_ctl = snd_hda_codec_read(codec, nid, 0,
3779 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3780 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3781 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003782 int val;
3783 snd_hda_codec_write_cache(codec, nid, 0,
3784 AC_VERB_SET_PIN_WIDGET_CONTROL,
3785 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003786 val = ucontrol->value.enumerated.item[0] >= 3 ?
3787 HDA_AMP_MUTE : 0;
3788 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3789 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003790 return 1;
3791 }
3792 return 0;
3793}
3794
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003795static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3796 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003797{
3798 static char *texts[] = {
3799 "Front", "Surround", "CLFE", "Side"
3800 };
3801 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3802 uinfo->count = 1;
3803 uinfo->value.enumerated.items = 4;
3804 if (uinfo->value.enumerated.item >= 4)
3805 uinfo->value.enumerated.item = 3;
3806 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3807 return 0;
3808}
3809
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003810static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3811 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003812{
3813 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3814 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3815 unsigned int sel;
3816
3817 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3818 ucontrol->value.enumerated.item[0] = sel & 3;
3819 return 0;
3820}
3821
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003822static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3823 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003824{
3825 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3826 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3827 unsigned int sel;
3828
3829 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3830 if (ucontrol->value.enumerated.item[0] != sel) {
3831 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003832 snd_hda_codec_write_cache(codec, nid, 0,
3833 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003834 return 1;
3835 }
3836 return 0;
3837}
3838
3839#define PIN_CTL_TEST(xname,nid) { \
3840 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3841 .name = xname, \
3842 .info = alc_test_pin_ctl_info, \
3843 .get = alc_test_pin_ctl_get, \
3844 .put = alc_test_pin_ctl_put, \
3845 .private_value = nid \
3846 }
3847
3848#define PIN_SRC_TEST(xname,nid) { \
3849 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3850 .name = xname, \
3851 .info = alc_test_pin_src_info, \
3852 .get = alc_test_pin_src_get, \
3853 .put = alc_test_pin_src_put, \
3854 .private_value = nid \
3855 }
3856
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003857static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003858 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3859 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3860 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3861 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003862 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3863 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3864 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3865 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003866 PIN_CTL_TEST("Front Pin Mode", 0x14),
3867 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3868 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3869 PIN_CTL_TEST("Side Pin Mode", 0x17),
3870 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3871 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3872 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3873 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3874 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3875 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3876 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3877 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3878 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3879 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3880 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3881 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3882 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3883 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3884 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3885 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3886 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3887 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003888 {
3889 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3890 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003891 .info = alc_ch_mode_info,
3892 .get = alc_ch_mode_get,
3893 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003894 },
3895 { } /* end */
3896};
3897
3898static struct hda_verb alc880_test_init_verbs[] = {
3899 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003900 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3901 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3902 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3903 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3904 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3905 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3906 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3907 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003908 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003909 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3910 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3911 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3912 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003913 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003914 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3915 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3916 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3917 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003918 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003919 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3920 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3921 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3922 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003923 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003924 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3925 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003926 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3927 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3928 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003929 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003930 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3931 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3932 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3933 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003934 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003935 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003936 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003937 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003938 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003939 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003940 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003941 /* Analog input/passthru */
3942 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3943 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3944 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3945 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3946 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003947 { }
3948};
3949#endif
3950
Linus Torvalds1da177e2005-04-16 15:20:36 -07003951/*
3952 */
3953
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003954static const char *alc880_models[ALC880_MODEL_LAST] = {
3955 [ALC880_3ST] = "3stack",
3956 [ALC880_TCL_S700] = "tcl",
3957 [ALC880_3ST_DIG] = "3stack-digout",
3958 [ALC880_CLEVO] = "clevo",
3959 [ALC880_5ST] = "5stack",
3960 [ALC880_5ST_DIG] = "5stack-digout",
3961 [ALC880_W810] = "w810",
3962 [ALC880_Z71V] = "z71v",
3963 [ALC880_6ST] = "6stack",
3964 [ALC880_6ST_DIG] = "6stack-digout",
3965 [ALC880_ASUS] = "asus",
3966 [ALC880_ASUS_W1V] = "asus-w1v",
3967 [ALC880_ASUS_DIG] = "asus-dig",
3968 [ALC880_ASUS_DIG2] = "asus-dig2",
3969 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003970 [ALC880_UNIWILL_P53] = "uniwill-p53",
3971 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003972 [ALC880_F1734] = "F1734",
3973 [ALC880_LG] = "lg",
3974 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003975 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003976#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003977 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003978#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003979 [ALC880_AUTO] = "auto",
3980};
3981
3982static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003983 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003984 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3985 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3986 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3987 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3988 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3989 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3990 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3991 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003992 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3993 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003994 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3995 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3996 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3997 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3998 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3999 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4000 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4001 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4002 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4003 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004004 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004005 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4006 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4007 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004008 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004009 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004010 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4011 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004012 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4013 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004014 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4015 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4016 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4017 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004018 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4019 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004020 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004021 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004022 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004023 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004024 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4025 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004026 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004027 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004028 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004029 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004030 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004031 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004032 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004033 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004034 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004035 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4036 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004037 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004038 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4039 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4040 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4041 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004042 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4043 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004044 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004045 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004046 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4047 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004048 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4049 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4050 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004051 /* default Intel */
4052 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004053 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4054 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004055 {}
4056};
4057
Takashi Iwai16ded522005-06-10 19:58:24 +02004058/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004059 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004060 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004061static struct alc_config_preset alc880_presets[] = {
4062 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004063 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004064 .init_verbs = { alc880_volume_init_verbs,
4065 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004066 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004067 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004068 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4069 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004070 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004071 .input_mux = &alc880_capture_source,
4072 },
4073 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004074 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004075 .init_verbs = { alc880_volume_init_verbs,
4076 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004077 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004078 .dac_nids = alc880_dac_nids,
4079 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004080 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4081 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004082 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004083 .input_mux = &alc880_capture_source,
4084 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004085 [ALC880_TCL_S700] = {
4086 .mixers = { alc880_tcl_s700_mixer },
4087 .init_verbs = { alc880_volume_init_verbs,
4088 alc880_pin_tcl_S700_init_verbs,
4089 alc880_gpio2_init_verbs },
4090 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4091 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004092 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4093 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004094 .hp_nid = 0x03,
4095 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4096 .channel_mode = alc880_2_jack_modes,
4097 .input_mux = &alc880_capture_source,
4098 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004099 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004100 .mixers = { alc880_three_stack_mixer,
4101 alc880_five_stack_mixer},
4102 .init_verbs = { alc880_volume_init_verbs,
4103 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004104 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4105 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004106 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4107 .channel_mode = alc880_fivestack_modes,
4108 .input_mux = &alc880_capture_source,
4109 },
4110 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004111 .mixers = { alc880_three_stack_mixer,
4112 alc880_five_stack_mixer },
4113 .init_verbs = { alc880_volume_init_verbs,
4114 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004115 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4116 .dac_nids = alc880_dac_nids,
4117 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004118 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4119 .channel_mode = alc880_fivestack_modes,
4120 .input_mux = &alc880_capture_source,
4121 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004122 [ALC880_6ST] = {
4123 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004124 .init_verbs = { alc880_volume_init_verbs,
4125 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004126 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4127 .dac_nids = alc880_6st_dac_nids,
4128 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4129 .channel_mode = alc880_sixstack_modes,
4130 .input_mux = &alc880_6stack_capture_source,
4131 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004132 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004133 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004134 .init_verbs = { alc880_volume_init_verbs,
4135 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004136 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4137 .dac_nids = alc880_6st_dac_nids,
4138 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004139 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4140 .channel_mode = alc880_sixstack_modes,
4141 .input_mux = &alc880_6stack_capture_source,
4142 },
4143 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004144 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004145 .init_verbs = { alc880_volume_init_verbs,
4146 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004147 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004148 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4149 .dac_nids = alc880_w810_dac_nids,
4150 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004151 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4152 .channel_mode = alc880_w810_modes,
4153 .input_mux = &alc880_capture_source,
4154 },
4155 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004156 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004157 .init_verbs = { alc880_volume_init_verbs,
4158 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004159 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4160 .dac_nids = alc880_z71v_dac_nids,
4161 .dig_out_nid = ALC880_DIGOUT_NID,
4162 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004163 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4164 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004165 .input_mux = &alc880_capture_source,
4166 },
4167 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004168 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004169 .init_verbs = { alc880_volume_init_verbs,
4170 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004171 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4172 .dac_nids = alc880_f1734_dac_nids,
4173 .hp_nid = 0x02,
4174 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4175 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004176 .input_mux = &alc880_f1734_capture_source,
4177 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004178 .setup = alc880_uniwill_p53_setup,
4179 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004180 },
4181 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004182 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004183 .init_verbs = { alc880_volume_init_verbs,
4184 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004185 alc880_gpio1_init_verbs },
4186 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4187 .dac_nids = alc880_asus_dac_nids,
4188 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4189 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004190 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004191 .input_mux = &alc880_capture_source,
4192 },
4193 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004194 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004195 .init_verbs = { alc880_volume_init_verbs,
4196 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004197 alc880_gpio1_init_verbs },
4198 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4199 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004200 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004201 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4202 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004203 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004204 .input_mux = &alc880_capture_source,
4205 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004206 [ALC880_ASUS_DIG2] = {
4207 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004208 .init_verbs = { alc880_volume_init_verbs,
4209 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004210 alc880_gpio2_init_verbs }, /* use GPIO2 */
4211 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4212 .dac_nids = alc880_asus_dac_nids,
4213 .dig_out_nid = ALC880_DIGOUT_NID,
4214 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4215 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004216 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004217 .input_mux = &alc880_capture_source,
4218 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004219 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004220 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004221 .init_verbs = { alc880_volume_init_verbs,
4222 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004223 alc880_gpio1_init_verbs },
4224 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4225 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004226 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004227 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4228 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004229 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004230 .input_mux = &alc880_capture_source,
4231 },
4232 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004233 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004234 .init_verbs = { alc880_volume_init_verbs,
4235 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004236 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4237 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004238 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004239 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4240 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004241 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004242 .input_mux = &alc880_capture_source,
4243 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004244 [ALC880_UNIWILL] = {
4245 .mixers = { alc880_uniwill_mixer },
4246 .init_verbs = { alc880_volume_init_verbs,
4247 alc880_uniwill_init_verbs },
4248 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4249 .dac_nids = alc880_asus_dac_nids,
4250 .dig_out_nid = ALC880_DIGOUT_NID,
4251 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4252 .channel_mode = alc880_threestack_modes,
4253 .need_dac_fix = 1,
4254 .input_mux = &alc880_capture_source,
4255 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004256 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004257 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004258 },
4259 [ALC880_UNIWILL_P53] = {
4260 .mixers = { alc880_uniwill_p53_mixer },
4261 .init_verbs = { alc880_volume_init_verbs,
4262 alc880_uniwill_p53_init_verbs },
4263 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4264 .dac_nids = alc880_asus_dac_nids,
4265 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004266 .channel_mode = alc880_threestack_modes,
4267 .input_mux = &alc880_capture_source,
4268 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004269 .setup = alc880_uniwill_p53_setup,
4270 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004271 },
4272 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004273 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004274 .init_verbs = { alc880_volume_init_verbs,
4275 alc880_uniwill_p53_init_verbs,
4276 alc880_beep_init_verbs },
4277 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4278 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004279 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004280 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4281 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004282 .input_mux = &alc880_capture_source,
4283 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004284 .setup = alc880_uniwill_p53_setup,
4285 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004286 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004287 [ALC880_CLEVO] = {
4288 .mixers = { alc880_three_stack_mixer },
4289 .init_verbs = { alc880_volume_init_verbs,
4290 alc880_pin_clevo_init_verbs },
4291 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4292 .dac_nids = alc880_dac_nids,
4293 .hp_nid = 0x03,
4294 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4295 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004296 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004297 .input_mux = &alc880_capture_source,
4298 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004299 [ALC880_LG] = {
4300 .mixers = { alc880_lg_mixer },
4301 .init_verbs = { alc880_volume_init_verbs,
4302 alc880_lg_init_verbs },
4303 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4304 .dac_nids = alc880_lg_dac_nids,
4305 .dig_out_nid = ALC880_DIGOUT_NID,
4306 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4307 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004308 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004309 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004310 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004311 .setup = alc880_lg_setup,
4312 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004313#ifdef CONFIG_SND_HDA_POWER_SAVE
4314 .loopbacks = alc880_lg_loopbacks,
4315#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004316 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004317 [ALC880_LG_LW] = {
4318 .mixers = { alc880_lg_lw_mixer },
4319 .init_verbs = { alc880_volume_init_verbs,
4320 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004321 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004322 .dac_nids = alc880_dac_nids,
4323 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004324 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4325 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004326 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004327 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004328 .setup = alc880_lg_lw_setup,
4329 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004330 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004331 [ALC880_MEDION_RIM] = {
4332 .mixers = { alc880_medion_rim_mixer },
4333 .init_verbs = { alc880_volume_init_verbs,
4334 alc880_medion_rim_init_verbs,
4335 alc_gpio2_init_verbs },
4336 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4337 .dac_nids = alc880_dac_nids,
4338 .dig_out_nid = ALC880_DIGOUT_NID,
4339 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4340 .channel_mode = alc880_2_jack_modes,
4341 .input_mux = &alc880_medion_rim_capture_source,
4342 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004343 .setup = alc880_medion_rim_setup,
4344 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004345 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004346#ifdef CONFIG_SND_DEBUG
4347 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004348 .mixers = { alc880_test_mixer },
4349 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004350 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4351 .dac_nids = alc880_test_dac_nids,
4352 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004353 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4354 .channel_mode = alc880_test_modes,
4355 .input_mux = &alc880_test_capture_source,
4356 },
4357#endif
4358};
4359
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004360/*
4361 * Automatic parse of I/O pins from the BIOS configuration
4362 */
4363
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004364enum {
4365 ALC_CTL_WIDGET_VOL,
4366 ALC_CTL_WIDGET_MUTE,
4367 ALC_CTL_BIND_MUTE,
4368};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004369static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004370 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4371 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004372 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004373};
4374
4375/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004376static int add_control(struct alc_spec *spec, int type, const char *name,
4377 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004378{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004379 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004380
Takashi Iwai603c4012008-07-30 15:01:44 +02004381 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4382 knew = snd_array_new(&spec->kctls);
4383 if (!knew)
4384 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004385 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004386 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004387 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004388 return -ENOMEM;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004389 if (get_amp_nid_(val))
Takashi Iwai9c96fa52009-11-16 11:25:33 +01004390 knew->subdevice = HDA_SUBDEV_NID_FLAG | get_amp_nid_(val);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004391 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004392 return 0;
4393}
4394
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004395static int add_control_with_pfx(struct alc_spec *spec, int type,
4396 const char *pfx, const char *dir,
4397 const char *sfx, unsigned long val)
4398{
4399 char name[32];
4400 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
4401 return add_control(spec, type, name, val);
4402}
4403
4404#define add_pb_vol_ctrl(spec, type, pfx, val) \
4405 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val)
4406#define add_pb_sw_ctrl(spec, type, pfx, val) \
4407 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val)
4408
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004409#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4410#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4411#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4412#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004413#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4414#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4415#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4416#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4417#define ALC880_PIN_CD_NID 0x1c
4418
4419/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004420static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4421 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004422{
4423 hda_nid_t nid;
4424 int assigned[4];
4425 int i, j;
4426
4427 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004428 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004429
4430 /* check the pins hardwired to audio widget */
4431 for (i = 0; i < cfg->line_outs; i++) {
4432 nid = cfg->line_out_pins[i];
4433 if (alc880_is_fixed_pin(nid)) {
4434 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004435 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004436 assigned[idx] = 1;
4437 }
4438 }
4439 /* left pins can be connect to any audio widget */
4440 for (i = 0; i < cfg->line_outs; i++) {
4441 nid = cfg->line_out_pins[i];
4442 if (alc880_is_fixed_pin(nid))
4443 continue;
4444 /* search for an empty channel */
4445 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004446 if (!assigned[j]) {
4447 spec->multiout.dac_nids[i] =
4448 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004449 assigned[j] = 1;
4450 break;
4451 }
4452 }
4453 }
4454 spec->multiout.num_dacs = cfg->line_outs;
4455 return 0;
4456}
4457
4458/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004459static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4460 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004461{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004462 static const char *chname[4] = {
4463 "Front", "Surround", NULL /*CLFE*/, "Side"
4464 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004465 hda_nid_t nid;
4466 int i, err;
4467
4468 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004469 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004470 continue;
4471 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4472 if (i == 2) {
4473 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004474 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4475 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004476 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4477 HDA_OUTPUT));
4478 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004479 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004480 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4481 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004482 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4483 HDA_OUTPUT));
4484 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004485 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004486 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4487 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004488 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4489 HDA_INPUT));
4490 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004491 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004492 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4493 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004494 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4495 HDA_INPUT));
4496 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004497 return err;
4498 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004499 const char *pfx;
4500 if (cfg->line_outs == 1 &&
4501 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4502 pfx = "Speaker";
4503 else
4504 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004505 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004506 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4507 HDA_OUTPUT));
4508 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004509 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004510 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004511 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4512 HDA_INPUT));
4513 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004514 return err;
4515 }
4516 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004517 return 0;
4518}
4519
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004520/* add playback controls for speaker and HP outputs */
4521static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4522 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004523{
4524 hda_nid_t nid;
4525 int err;
4526
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004527 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004528 return 0;
4529
4530 if (alc880_is_fixed_pin(pin)) {
4531 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004532 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004533 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004534 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004535 else
4536 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004537 /* control HP volume/switch on the output mixer amp */
4538 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004539 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004540 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4541 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004542 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004543 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004544 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4545 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004546 return err;
4547 } else if (alc880_is_multi_pin(pin)) {
4548 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004549 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004550 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004551 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4552 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004553 return err;
4554 }
4555 return 0;
4556}
4557
4558/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004559static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4560 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004561 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004562{
Kailang Yangdf694da2005-12-05 19:42:22 +01004563 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004564
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004565 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004566 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4567 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004568 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004569 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004570 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4571 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004572 return err;
4573 return 0;
4574}
4575
Takashi Iwai05f5f472009-08-25 13:10:18 +02004576static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004577{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004578 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4579 return (pincap & AC_PINCAP_IN) != 0;
4580}
4581
4582/* create playback/capture controls for input pins */
4583static int alc_auto_create_input_ctls(struct hda_codec *codec,
4584 const struct auto_pin_cfg *cfg,
4585 hda_nid_t mixer,
4586 hda_nid_t cap1, hda_nid_t cap2)
4587{
4588 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004589 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004590 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004591
4592 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004593 hda_nid_t pin;
4594
4595 pin = cfg->input_pins[i];
4596 if (!alc_is_input_pin(codec, pin))
4597 continue;
4598
4599 if (mixer) {
4600 idx = get_connection_index(codec, mixer, pin);
4601 if (idx >= 0) {
4602 err = new_analog_input(spec, pin,
4603 auto_pin_cfg_labels[i],
4604 idx, mixer);
4605 if (err < 0)
4606 return err;
4607 }
4608 }
4609
4610 if (!cap1)
4611 continue;
4612 idx = get_connection_index(codec, cap1, pin);
4613 if (idx < 0 && cap2)
4614 idx = get_connection_index(codec, cap2, pin);
4615 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004616 imux->items[imux->num_items].label =
4617 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004618 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004619 imux->num_items++;
4620 }
4621 }
4622 return 0;
4623}
4624
Takashi Iwai05f5f472009-08-25 13:10:18 +02004625static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4626 const struct auto_pin_cfg *cfg)
4627{
4628 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4629}
4630
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004631static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4632 unsigned int pin_type)
4633{
4634 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4635 pin_type);
4636 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004637 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4638 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004639}
4640
Kailang Yangdf694da2005-12-05 19:42:22 +01004641static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4642 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004643 int dac_idx)
4644{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004645 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004646 /* need the manual connection? */
4647 if (alc880_is_multi_pin(nid)) {
4648 struct alc_spec *spec = codec->spec;
4649 int idx = alc880_multi_pin_idx(nid);
4650 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4651 AC_VERB_SET_CONNECT_SEL,
4652 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4653 }
4654}
4655
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004656static int get_pin_type(int line_out_type)
4657{
4658 if (line_out_type == AUTO_PIN_HP_OUT)
4659 return PIN_HP;
4660 else
4661 return PIN_OUT;
4662}
4663
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004664static void alc880_auto_init_multi_out(struct hda_codec *codec)
4665{
4666 struct alc_spec *spec = codec->spec;
4667 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004668
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004669 for (i = 0; i < spec->autocfg.line_outs; i++) {
4670 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004671 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4672 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004673 }
4674}
4675
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004676static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004677{
4678 struct alc_spec *spec = codec->spec;
4679 hda_nid_t pin;
4680
Takashi Iwai82bc9552006-03-21 11:24:42 +01004681 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004682 if (pin) /* connect to front */
4683 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004684 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004685 if (pin) /* connect to front */
4686 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4687}
4688
4689static void alc880_auto_init_analog_input(struct hda_codec *codec)
4690{
4691 struct alc_spec *spec = codec->spec;
4692 int i;
4693
4694 for (i = 0; i < AUTO_PIN_LAST; i++) {
4695 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004696 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004697 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004698 if (nid != ALC880_PIN_CD_NID &&
4699 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004700 snd_hda_codec_write(codec, nid, 0,
4701 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004702 AMP_OUT_MUTE);
4703 }
4704 }
4705}
4706
4707/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004708/* return 1 if successful, 0 if the proper config is not found,
4709 * or a negative error code
4710 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004711static int alc880_parse_auto_config(struct hda_codec *codec)
4712{
4713 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004714 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004715 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004716
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004717 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4718 alc880_ignore);
4719 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004720 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004721 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004722 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004723
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004724 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4725 if (err < 0)
4726 return err;
4727 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4728 if (err < 0)
4729 return err;
4730 err = alc880_auto_create_extra_out(spec,
4731 spec->autocfg.speaker_pins[0],
4732 "Speaker");
4733 if (err < 0)
4734 return err;
4735 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4736 "Headphone");
4737 if (err < 0)
4738 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004739 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004740 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004741 return err;
4742
4743 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4744
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004745 /* check multiple SPDIF-out (for recent codecs) */
4746 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4747 hda_nid_t dig_nid;
4748 err = snd_hda_get_connections(codec,
4749 spec->autocfg.dig_out_pins[i],
4750 &dig_nid, 1);
4751 if (err < 0)
4752 continue;
4753 if (!i)
4754 spec->multiout.dig_out_nid = dig_nid;
4755 else {
4756 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004757 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004758 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004759 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004760 }
4761 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004762 if (spec->autocfg.dig_in_pin)
4763 spec->dig_in_nid = ALC880_DIGIN_NID;
4764
Takashi Iwai603c4012008-07-30 15:01:44 +02004765 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004766 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004767
Takashi Iwaid88897e2008-10-31 15:01:37 +01004768 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004769
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004770 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004771 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004772
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004773 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4774
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004775 return 1;
4776}
4777
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004778/* additional initialization for auto-configuration model */
4779static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004780{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004781 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004782 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004783 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004784 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004785 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004786 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004787}
4788
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004789/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4790 * one of two digital mic pins, e.g. on ALC272
4791 */
4792static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004793{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004794 struct alc_spec *spec = codec->spec;
4795 int i;
4796
4797 for (i = 0; i < spec->num_adc_nids; i++) {
4798 hda_nid_t cap = spec->capsrc_nids ?
4799 spec->capsrc_nids[i] : spec->adc_nids[i];
4800 int iidx, eidx;
4801
4802 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4803 if (iidx < 0)
4804 continue;
4805 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4806 if (eidx < 0)
4807 continue;
4808 spec->int_mic.mux_idx = iidx;
4809 spec->ext_mic.mux_idx = eidx;
4810 if (spec->capsrc_nids)
4811 spec->capsrc_nids += i;
4812 spec->adc_nids += i;
4813 spec->num_adc_nids = 1;
4814 return;
4815 }
4816 snd_printd(KERN_INFO "hda_codec: %s: "
4817 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4818 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4819 spec->auto_mic = 0; /* disable auto-mic to be sure */
4820}
4821
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004822/* choose the ADC/MUX containing the input pin and initialize the setup */
4823static void fixup_single_adc(struct hda_codec *codec)
4824{
4825 struct alc_spec *spec = codec->spec;
4826 hda_nid_t pin;
4827 int i;
4828
4829 /* search for the input pin; there must be only one */
4830 for (i = 0; i < AUTO_PIN_LAST; i++) {
4831 if (spec->autocfg.input_pins[i]) {
4832 pin = spec->autocfg.input_pins[i];
4833 break;
4834 }
4835 }
4836 if (!pin)
4837 return;
4838
4839 /* set the default connection to that pin */
4840 for (i = 0; i < spec->num_adc_nids; i++) {
4841 hda_nid_t cap = spec->capsrc_nids ?
4842 spec->capsrc_nids[i] : spec->adc_nids[i];
4843 int idx;
4844
4845 idx = get_connection_index(codec, cap, pin);
4846 if (idx < 0)
4847 continue;
4848 /* use only this ADC */
4849 if (spec->capsrc_nids)
4850 spec->capsrc_nids += i;
4851 spec->adc_nids += i;
4852 spec->num_adc_nids = 1;
4853 /* select or unmute this route */
4854 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
4855 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
4856 HDA_AMP_MUTE, 0);
4857 } else {
4858 snd_hda_codec_write_cache(codec, cap, 0,
4859 AC_VERB_SET_CONNECT_SEL, idx);
4860 }
4861 return;
4862 }
4863}
4864
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004865static void set_capture_mixer(struct hda_codec *codec)
4866{
4867 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01004868 static struct snd_kcontrol_new *caps[2][3] = {
4869 { alc_capture_mixer_nosrc1,
4870 alc_capture_mixer_nosrc2,
4871 alc_capture_mixer_nosrc3 },
4872 { alc_capture_mixer1,
4873 alc_capture_mixer2,
4874 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004875 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004876 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004877 int mux = 0;
4878 if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004879 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004880 else if (spec->input_mux) {
4881 if (spec->input_mux->num_items > 1)
4882 mux = 1;
4883 else if (spec->input_mux->num_items == 1)
4884 fixup_single_adc(codec);
4885 }
Takashi Iwaia23b6882009-03-23 15:21:36 +01004886 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4887 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004888}
4889
Takashi Iwai67d634c2009-11-16 15:35:59 +01004890#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004891#define set_beep_amp(spec, nid, idx, dir) \
4892 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwai67d634c2009-11-16 15:35:59 +01004893#else
4894#define set_beep_amp(spec, nid, idx, dir) /* NOP */
4895#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004896
4897/*
4898 * OK, here we have finally the patch for ALC880
4899 */
4900
Linus Torvalds1da177e2005-04-16 15:20:36 -07004901static int patch_alc880(struct hda_codec *codec)
4902{
4903 struct alc_spec *spec;
4904 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004905 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004906
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004907 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004908 if (spec == NULL)
4909 return -ENOMEM;
4910
4911 codec->spec = spec;
4912
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004913 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4914 alc880_models,
4915 alc880_cfg_tbl);
4916 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004917 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4918 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004919 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004920 }
4921
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004922 if (board_config == ALC880_AUTO) {
4923 /* automatic parse from the BIOS config */
4924 err = alc880_parse_auto_config(codec);
4925 if (err < 0) {
4926 alc_free(codec);
4927 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004928 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004929 printk(KERN_INFO
4930 "hda_codec: Cannot set up configuration "
4931 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004932 board_config = ALC880_3ST;
4933 }
4934 }
4935
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004936 err = snd_hda_attach_beep_device(codec, 0x1);
4937 if (err < 0) {
4938 alc_free(codec);
4939 return err;
4940 }
4941
Kailang Yangdf694da2005-12-05 19:42:22 +01004942 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02004943 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004944
Linus Torvalds1da177e2005-04-16 15:20:36 -07004945 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4946 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004947 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004948
Linus Torvalds1da177e2005-04-16 15:20:36 -07004949 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4950 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4951
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004952 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004953 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004954 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004955 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02004956 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004957 if (wcap != AC_WID_AUD_IN) {
4958 spec->adc_nids = alc880_adc_nids_alt;
4959 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004960 } else {
4961 spec->adc_nids = alc880_adc_nids;
4962 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004963 }
4964 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004965 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004966 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004967
Takashi Iwai2134ea42008-01-10 16:53:55 +01004968 spec->vmaster_nid = 0x0c;
4969
Linus Torvalds1da177e2005-04-16 15:20:36 -07004970 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004971 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004972 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004973#ifdef CONFIG_SND_HDA_POWER_SAVE
4974 if (!spec->loopback.amplist)
4975 spec->loopback.amplist = alc880_loopbacks;
4976#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004977 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004978
4979 return 0;
4980}
4981
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004982
Linus Torvalds1da177e2005-04-16 15:20:36 -07004983/*
4984 * ALC260 support
4985 */
4986
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004987static hda_nid_t alc260_dac_nids[1] = {
4988 /* front */
4989 0x02,
4990};
4991
4992static hda_nid_t alc260_adc_nids[1] = {
4993 /* ADC0 */
4994 0x04,
4995};
4996
Kailang Yangdf694da2005-12-05 19:42:22 +01004997static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004998 /* ADC1 */
4999 0x05,
5000};
5001
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005002/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5003 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5004 */
5005static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005006 /* ADC0, ADC1 */
5007 0x04, 0x05
5008};
5009
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005010#define ALC260_DIGOUT_NID 0x03
5011#define ALC260_DIGIN_NID 0x06
5012
5013static struct hda_input_mux alc260_capture_source = {
5014 .num_items = 4,
5015 .items = {
5016 { "Mic", 0x0 },
5017 { "Front Mic", 0x1 },
5018 { "Line", 0x2 },
5019 { "CD", 0x4 },
5020 },
5021};
5022
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005023/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005024 * headphone jack and the internal CD lines since these are the only pins at
5025 * which audio can appear. For flexibility, also allow the option of
5026 * recording the mixer output on the second ADC (ADC0 doesn't have a
5027 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005028 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005029static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5030 {
5031 .num_items = 3,
5032 .items = {
5033 { "Mic/Line", 0x0 },
5034 { "CD", 0x4 },
5035 { "Headphone", 0x2 },
5036 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005037 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005038 {
5039 .num_items = 4,
5040 .items = {
5041 { "Mic/Line", 0x0 },
5042 { "CD", 0x4 },
5043 { "Headphone", 0x2 },
5044 { "Mixer", 0x5 },
5045 },
5046 },
5047
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005048};
5049
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005050/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5051 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005052 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005053static struct hda_input_mux alc260_acer_capture_sources[2] = {
5054 {
5055 .num_items = 4,
5056 .items = {
5057 { "Mic", 0x0 },
5058 { "Line", 0x2 },
5059 { "CD", 0x4 },
5060 { "Headphone", 0x5 },
5061 },
5062 },
5063 {
5064 .num_items = 5,
5065 .items = {
5066 { "Mic", 0x0 },
5067 { "Line", 0x2 },
5068 { "CD", 0x4 },
5069 { "Headphone", 0x6 },
5070 { "Mixer", 0x5 },
5071 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005072 },
5073};
Michael Schwingencc959482009-02-22 18:58:45 +01005074
5075/* Maxdata Favorit 100XS */
5076static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5077 {
5078 .num_items = 2,
5079 .items = {
5080 { "Line/Mic", 0x0 },
5081 { "CD", 0x4 },
5082 },
5083 },
5084 {
5085 .num_items = 3,
5086 .items = {
5087 { "Line/Mic", 0x0 },
5088 { "CD", 0x4 },
5089 { "Mixer", 0x5 },
5090 },
5091 },
5092};
5093
Linus Torvalds1da177e2005-04-16 15:20:36 -07005094/*
5095 * This is just place-holder, so there's something for alc_build_pcms to look
5096 * at when it calculates the maximum number of channels. ALC260 has no mixer
5097 * element which allows changing the channel mode, so the verb list is
5098 * never used.
5099 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005100static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005101 { 2, NULL },
5102};
5103
Kailang Yangdf694da2005-12-05 19:42:22 +01005104
5105/* Mixer combinations
5106 *
5107 * basic: base_output + input + pc_beep + capture
5108 * HP: base_output + input + capture_alt
5109 * HP_3013: hp_3013 + input + capture
5110 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005111 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005112 */
5113
5114static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005115 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005116 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005117 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5118 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5119 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5120 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5121 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005122};
Kailang Yangdf694da2005-12-05 19:42:22 +01005123
5124static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005125 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5126 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5127 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5128 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5129 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5130 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5131 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5132 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005133 { } /* end */
5134};
5135
Takashi Iwaibec15c32008-01-28 18:16:30 +01005136/* update HP, line and mono out pins according to the master switch */
5137static void alc260_hp_master_update(struct hda_codec *codec,
5138 hda_nid_t hp, hda_nid_t line,
5139 hda_nid_t mono)
5140{
5141 struct alc_spec *spec = codec->spec;
5142 unsigned int val = spec->master_sw ? PIN_HP : 0;
5143 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005144 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005145 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005146 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005147 val);
5148 /* mono (speaker) depending on the HP jack sense */
5149 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005150 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005151 val);
5152}
5153
5154static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5155 struct snd_ctl_elem_value *ucontrol)
5156{
5157 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5158 struct alc_spec *spec = codec->spec;
5159 *ucontrol->value.integer.value = spec->master_sw;
5160 return 0;
5161}
5162
5163static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5164 struct snd_ctl_elem_value *ucontrol)
5165{
5166 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5167 struct alc_spec *spec = codec->spec;
5168 int val = !!*ucontrol->value.integer.value;
5169 hda_nid_t hp, line, mono;
5170
5171 if (val == spec->master_sw)
5172 return 0;
5173 spec->master_sw = val;
5174 hp = (kcontrol->private_value >> 16) & 0xff;
5175 line = (kcontrol->private_value >> 8) & 0xff;
5176 mono = kcontrol->private_value & 0xff;
5177 alc260_hp_master_update(codec, hp, line, mono);
5178 return 1;
5179}
5180
5181static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5182 {
5183 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5184 .name = "Master Playback Switch",
5185 .info = snd_ctl_boolean_mono_info,
5186 .get = alc260_hp_master_sw_get,
5187 .put = alc260_hp_master_sw_put,
5188 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5189 },
5190 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5191 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5192 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5193 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5194 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5195 HDA_OUTPUT),
5196 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5197 { } /* end */
5198};
5199
5200static struct hda_verb alc260_hp_unsol_verbs[] = {
5201 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5202 {},
5203};
5204
5205static void alc260_hp_automute(struct hda_codec *codec)
5206{
5207 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005208
Wu Fengguang864f92b2009-11-18 12:38:02 +08005209 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005210 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5211}
5212
5213static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5214{
5215 if ((res >> 26) == ALC880_HP_EVENT)
5216 alc260_hp_automute(codec);
5217}
5218
Kailang Yangdf694da2005-12-05 19:42:22 +01005219static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005220 {
5221 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5222 .name = "Master Playback Switch",
5223 .info = snd_ctl_boolean_mono_info,
5224 .get = alc260_hp_master_sw_get,
5225 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005226 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005227 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005228 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5229 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5230 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5231 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5232 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5233 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005234 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5235 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005236 { } /* end */
5237};
5238
Kailang Yang3f878302008-08-26 13:02:23 +02005239static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5240 .ops = &snd_hda_bind_vol,
5241 .values = {
5242 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5243 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5244 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5245 0
5246 },
5247};
5248
5249static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5250 .ops = &snd_hda_bind_sw,
5251 .values = {
5252 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5253 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5254 0
5255 },
5256};
5257
5258static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5259 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5260 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5261 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5262 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5263 { } /* end */
5264};
5265
Takashi Iwaibec15c32008-01-28 18:16:30 +01005266static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5267 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5268 {},
5269};
5270
5271static void alc260_hp_3013_automute(struct hda_codec *codec)
5272{
5273 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005274
Wu Fengguang864f92b2009-11-18 12:38:02 +08005275 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005276 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005277}
5278
5279static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5280 unsigned int res)
5281{
5282 if ((res >> 26) == ALC880_HP_EVENT)
5283 alc260_hp_3013_automute(codec);
5284}
5285
Kailang Yang3f878302008-08-26 13:02:23 +02005286static void alc260_hp_3012_automute(struct hda_codec *codec)
5287{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005288 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005289
Kailang Yang3f878302008-08-26 13:02:23 +02005290 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5291 bits);
5292 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5293 bits);
5294 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5295 bits);
5296}
5297
5298static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5299 unsigned int res)
5300{
5301 if ((res >> 26) == ALC880_HP_EVENT)
5302 alc260_hp_3012_automute(codec);
5303}
5304
5305/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005306 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5307 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005308static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005309 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005310 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005311 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005312 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5313 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5314 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5315 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005316 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005317 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5318 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005319 { } /* end */
5320};
5321
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005322/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5323 * versions of the ALC260 don't act on requests to enable mic bias from NID
5324 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5325 * datasheet doesn't mention this restriction. At this stage it's not clear
5326 * whether this behaviour is intentional or is a hardware bug in chip
5327 * revisions available in early 2006. Therefore for now allow the
5328 * "Headphone Jack Mode" control to span all choices, but if it turns out
5329 * that the lack of mic bias for this NID is intentional we could change the
5330 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5331 *
5332 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5333 * don't appear to make the mic bias available from the "line" jack, even
5334 * though the NID used for this jack (0x14) can supply it. The theory is
5335 * that perhaps Acer have included blocking capacitors between the ALC260
5336 * and the output jack. If this turns out to be the case for all such
5337 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5338 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005339 *
5340 * The C20x Tablet series have a mono internal speaker which is controlled
5341 * via the chip's Mono sum widget and pin complex, so include the necessary
5342 * controls for such models. On models without a "mono speaker" the control
5343 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005344 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005345static struct snd_kcontrol_new alc260_acer_mixer[] = {
5346 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5347 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005348 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005349 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005350 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005351 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005352 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005353 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5354 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5355 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5356 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5357 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5358 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5359 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5360 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005361 { } /* end */
5362};
5363
Michael Schwingencc959482009-02-22 18:58:45 +01005364/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5365 */
5366static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5367 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5368 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5369 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5370 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5371 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5372 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5373 { } /* end */
5374};
5375
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005376/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5377 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5378 */
5379static struct snd_kcontrol_new alc260_will_mixer[] = {
5380 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5381 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5382 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5383 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5384 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5385 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5386 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5387 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5388 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5389 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005390 { } /* end */
5391};
5392
5393/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5394 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5395 */
5396static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5397 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5398 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5399 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5400 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5401 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5402 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5403 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5404 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5405 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5406 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5407 { } /* end */
5408};
5409
Kailang Yangdf694da2005-12-05 19:42:22 +01005410/*
5411 * initialization verbs
5412 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005413static struct hda_verb alc260_init_verbs[] = {
5414 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005415 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005416 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005417 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005418 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005419 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005420 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005421 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005422 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005423 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005424 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005425 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005426 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005427 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005428 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005429 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005430 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005431 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5432 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005433 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005434 /* set connection select to line in (default select for this ADC) */
5435 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005436 /* mute capture amp left and right */
5437 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5438 /* set connection select to line in (default select for this ADC) */
5439 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005440 /* set vol=0 Line-Out mixer amp left and right */
5441 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5442 /* unmute pin widget amp left and right (no gain on this amp) */
5443 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5444 /* set vol=0 HP mixer amp left and right */
5445 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5446 /* unmute pin widget amp left and right (no gain on this amp) */
5447 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5448 /* set vol=0 Mono mixer amp left and right */
5449 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5450 /* unmute pin widget amp left and right (no gain on this amp) */
5451 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5452 /* unmute LINE-2 out pin */
5453 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005454 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5455 * Line In 2 = 0x03
5456 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005457 /* mute analog inputs */
5458 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5459 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5461 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5462 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005463 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005464 /* mute Front out path */
5465 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5466 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5467 /* mute Headphone out path */
5468 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5469 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5470 /* mute Mono out path */
5471 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5472 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005473 { }
5474};
5475
Takashi Iwai474167d2006-05-17 17:17:43 +02005476#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005477static struct hda_verb alc260_hp_init_verbs[] = {
5478 /* Headphone and output */
5479 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5480 /* mono output */
5481 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5482 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5483 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5484 /* Mic2 (front panel) pin widget for input and vref at 80% */
5485 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5486 /* Line In pin widget for input */
5487 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5488 /* Line-2 pin widget for output */
5489 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5490 /* CD pin widget for input */
5491 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5492 /* unmute amp left and right */
5493 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5494 /* set connection select to line in (default select for this ADC) */
5495 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5496 /* unmute Line-Out mixer amp left and right (volume = 0) */
5497 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5498 /* mute pin widget amp left and right (no gain on this amp) */
5499 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5500 /* unmute HP mixer amp left and right (volume = 0) */
5501 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5502 /* mute pin widget amp left and right (no gain on this amp) */
5503 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005504 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5505 * Line In 2 = 0x03
5506 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005507 /* mute analog inputs */
5508 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5509 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5510 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5511 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5512 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005513 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5514 /* Unmute Front out path */
5515 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5516 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5517 /* Unmute Headphone out path */
5518 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5519 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5520 /* Unmute Mono out path */
5521 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5522 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5523 { }
5524};
Takashi Iwai474167d2006-05-17 17:17:43 +02005525#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005526
5527static struct hda_verb alc260_hp_3013_init_verbs[] = {
5528 /* Line out and output */
5529 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5530 /* mono output */
5531 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5532 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5533 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5534 /* Mic2 (front panel) pin widget for input and vref at 80% */
5535 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5536 /* Line In pin widget for input */
5537 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5538 /* Headphone pin widget for output */
5539 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5540 /* CD pin widget for input */
5541 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5542 /* unmute amp left and right */
5543 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5544 /* set connection select to line in (default select for this ADC) */
5545 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5546 /* unmute Line-Out mixer amp left and right (volume = 0) */
5547 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5548 /* mute pin widget amp left and right (no gain on this amp) */
5549 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5550 /* unmute HP mixer amp left and right (volume = 0) */
5551 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5552 /* mute pin widget amp left and right (no gain on this amp) */
5553 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005554 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5555 * Line In 2 = 0x03
5556 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005557 /* mute analog inputs */
5558 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5559 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5560 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5561 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5562 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005563 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5564 /* Unmute Front out path */
5565 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5566 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5567 /* Unmute Headphone out path */
5568 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5569 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5570 /* Unmute Mono out path */
5571 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5572 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5573 { }
5574};
5575
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005576/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005577 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5578 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005579 */
5580static struct hda_verb alc260_fujitsu_init_verbs[] = {
5581 /* Disable all GPIOs */
5582 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5583 /* Internal speaker is connected to headphone pin */
5584 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5585 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5586 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005587 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5588 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5589 /* Ensure all other unused pins are disabled and muted. */
5590 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5591 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005592 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005593 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005594 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005595 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5596 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5597 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005598
Jonathan Woithef7ace402006-02-28 11:46:14 +01005599 /* Disable digital (SPDIF) pins */
5600 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5601 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005602
Kailang Yangea1fb292008-08-26 12:58:38 +02005603 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005604 * when acting as an output.
5605 */
5606 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5607
5608 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005609 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5610 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5611 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5612 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5613 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5614 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5615 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5616 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5617 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005618
Jonathan Woithef7ace402006-02-28 11:46:14 +01005619 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5620 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5621 /* Unmute Line1 pin widget output buffer since it starts as an output.
5622 * If the pin mode is changed by the user the pin mode control will
5623 * take care of enabling the pin's input/output buffers as needed.
5624 * Therefore there's no need to enable the input buffer at this
5625 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005626 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005627 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005628 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005629 * mixer ctrl)
5630 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005631 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005632
Jonathan Woithef7ace402006-02-28 11:46:14 +01005633 /* Mute capture amp left and right */
5634 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005635 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005636 * in (on mic1 pin)
5637 */
5638 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005639
Jonathan Woithef7ace402006-02-28 11:46:14 +01005640 /* Do the same for the second ADC: mute capture input amp and
5641 * set ADC connection to line in (on mic1 pin)
5642 */
5643 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5644 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005645
Jonathan Woithef7ace402006-02-28 11:46:14 +01005646 /* Mute all inputs to mixer widget (even unconnected ones) */
5647 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5648 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5649 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5650 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5651 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5652 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5653 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5654 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005655
5656 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005657};
5658
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005659/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5660 * similar laptops (adapted from Fujitsu init verbs).
5661 */
5662static struct hda_verb alc260_acer_init_verbs[] = {
5663 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5664 * the headphone jack. Turn this on and rely on the standard mute
5665 * methods whenever the user wants to turn these outputs off.
5666 */
5667 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5668 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5669 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5670 /* Internal speaker/Headphone jack is connected to Line-out pin */
5671 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5672 /* Internal microphone/Mic jack is connected to Mic1 pin */
5673 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5674 /* Line In jack is connected to Line1 pin */
5675 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005676 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5677 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005678 /* Ensure all other unused pins are disabled and muted. */
5679 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5680 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005681 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5682 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5683 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5684 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5685 /* Disable digital (SPDIF) pins */
5686 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5687 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5688
Kailang Yangea1fb292008-08-26 12:58:38 +02005689 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005690 * bus when acting as outputs.
5691 */
5692 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5693 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5694
5695 /* Start with output sum widgets muted and their output gains at min */
5696 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5697 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5698 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5699 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5700 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5701 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5702 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5703 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5704 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5705
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005706 /* Unmute Line-out pin widget amp left and right
5707 * (no equiv mixer ctrl)
5708 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005709 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005710 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5711 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005712 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5713 * inputs. If the pin mode is changed by the user the pin mode control
5714 * will take care of enabling the pin's input/output buffers as needed.
5715 * Therefore there's no need to enable the input buffer at this
5716 * stage.
5717 */
5718 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5719 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5720
5721 /* Mute capture amp left and right */
5722 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5723 /* Set ADC connection select to match default mixer setting - mic
5724 * (on mic1 pin)
5725 */
5726 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5727
5728 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005729 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005730 */
5731 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005732 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005733
5734 /* Mute all inputs to mixer widget (even unconnected ones) */
5735 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5736 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5737 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5738 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5739 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5740 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5741 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5742 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5743
5744 { }
5745};
5746
Michael Schwingencc959482009-02-22 18:58:45 +01005747/* Initialisation sequence for Maxdata Favorit 100XS
5748 * (adapted from Acer init verbs).
5749 */
5750static struct hda_verb alc260_favorit100_init_verbs[] = {
5751 /* GPIO 0 enables the output jack.
5752 * Turn this on and rely on the standard mute
5753 * methods whenever the user wants to turn these outputs off.
5754 */
5755 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5756 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5757 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5758 /* Line/Mic input jack is connected to Mic1 pin */
5759 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5760 /* Ensure all other unused pins are disabled and muted. */
5761 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5762 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5763 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5764 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5765 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5766 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5767 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5768 {0x14, 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
5775 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5776 * 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
5792 /* Unmute Line-out pin widget amp left and right
5793 * (no equiv mixer ctrl)
5794 */
5795 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5796 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5797 * inputs. If the pin mode is changed by the user the pin mode control
5798 * will take care of enabling the pin's input/output buffers as needed.
5799 * Therefore there's no need to enable the input buffer at this
5800 * stage.
5801 */
5802 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5803
5804 /* Mute capture amp left and right */
5805 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5806 /* Set ADC connection select to match default mixer setting - mic
5807 * (on mic1 pin)
5808 */
5809 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5810
5811 /* Do similar with the second ADC: mute capture input amp and
5812 * set ADC connection to mic to match ALSA's default state.
5813 */
5814 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5815 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5816
5817 /* Mute all inputs to mixer widget (even unconnected ones) */
5818 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5819 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5820 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5821 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5822 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5823 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5824 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5825 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5826
5827 { }
5828};
5829
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005830static struct hda_verb alc260_will_verbs[] = {
5831 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5832 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5833 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5834 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5835 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5836 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5837 {}
5838};
5839
5840static struct hda_verb alc260_replacer_672v_verbs[] = {
5841 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5842 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5843 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5844
5845 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5846 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5847 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5848
5849 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5850 {}
5851};
5852
5853/* toggle speaker-output according to the hp-jack state */
5854static void alc260_replacer_672v_automute(struct hda_codec *codec)
5855{
5856 unsigned int present;
5857
5858 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08005859 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005860 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005861 snd_hda_codec_write_cache(codec, 0x01, 0,
5862 AC_VERB_SET_GPIO_DATA, 1);
5863 snd_hda_codec_write_cache(codec, 0x0f, 0,
5864 AC_VERB_SET_PIN_WIDGET_CONTROL,
5865 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005866 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005867 snd_hda_codec_write_cache(codec, 0x01, 0,
5868 AC_VERB_SET_GPIO_DATA, 0);
5869 snd_hda_codec_write_cache(codec, 0x0f, 0,
5870 AC_VERB_SET_PIN_WIDGET_CONTROL,
5871 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005872 }
5873}
5874
5875static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5876 unsigned int res)
5877{
5878 if ((res >> 26) == ALC880_HP_EVENT)
5879 alc260_replacer_672v_automute(codec);
5880}
5881
Kailang Yang3f878302008-08-26 13:02:23 +02005882static struct hda_verb alc260_hp_dc7600_verbs[] = {
5883 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5884 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5885 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5886 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5887 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5888 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5889 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5890 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5891 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5892 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5893 {}
5894};
5895
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005896/* Test configuration for debugging, modelled after the ALC880 test
5897 * configuration.
5898 */
5899#ifdef CONFIG_SND_DEBUG
5900static hda_nid_t alc260_test_dac_nids[1] = {
5901 0x02,
5902};
5903static hda_nid_t alc260_test_adc_nids[2] = {
5904 0x04, 0x05,
5905};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005906/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005907 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005908 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005909 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005910static struct hda_input_mux alc260_test_capture_sources[2] = {
5911 {
5912 .num_items = 7,
5913 .items = {
5914 { "MIC1 pin", 0x0 },
5915 { "MIC2 pin", 0x1 },
5916 { "LINE1 pin", 0x2 },
5917 { "LINE2 pin", 0x3 },
5918 { "CD pin", 0x4 },
5919 { "LINE-OUT pin", 0x5 },
5920 { "HP-OUT pin", 0x6 },
5921 },
5922 },
5923 {
5924 .num_items = 8,
5925 .items = {
5926 { "MIC1 pin", 0x0 },
5927 { "MIC2 pin", 0x1 },
5928 { "LINE1 pin", 0x2 },
5929 { "LINE2 pin", 0x3 },
5930 { "CD pin", 0x4 },
5931 { "Mixer", 0x5 },
5932 { "LINE-OUT pin", 0x6 },
5933 { "HP-OUT pin", 0x7 },
5934 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005935 },
5936};
5937static struct snd_kcontrol_new alc260_test_mixer[] = {
5938 /* Output driver widgets */
5939 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5940 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5941 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5942 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5943 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5944 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5945
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005946 /* Modes for retasking pin widgets
5947 * Note: the ALC260 doesn't seem to act on requests to enable mic
5948 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5949 * mention this restriction. At this stage it's not clear whether
5950 * this behaviour is intentional or is a hardware bug in chip
5951 * revisions available at least up until early 2006. Therefore for
5952 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5953 * choices, but if it turns out that the lack of mic bias for these
5954 * NIDs is intentional we could change their modes from
5955 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5956 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005957 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5958 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5959 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5960 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5961 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5962 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5963
5964 /* Loopback mixer controls */
5965 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5966 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5967 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5968 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5969 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5970 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5971 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5972 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5973 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5974 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005975 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5976 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5977 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5978 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005979
5980 /* Controls for GPIO pins, assuming they are configured as outputs */
5981 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5982 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5983 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5984 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5985
Jonathan Woithe92621f12006-02-28 11:47:47 +01005986 /* Switches to allow the digital IO pins to be enabled. The datasheet
5987 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005988 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005989 */
5990 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5991 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5992
Jonathan Woithef8225f62008-01-08 12:16:54 +01005993 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5994 * this output to turn on an external amplifier.
5995 */
5996 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5997 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5998
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005999 { } /* end */
6000};
6001static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006002 /* Enable all GPIOs as outputs with an initial value of 0 */
6003 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6004 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6005 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6006
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006007 /* Enable retasking pins as output, initially without power amp */
6008 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6009 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6010 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6011 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6012 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6013 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6014
Jonathan Woithe92621f12006-02-28 11:47:47 +01006015 /* Disable digital (SPDIF) pins initially, but users can enable
6016 * them via a mixer switch. In the case of SPDIF-out, this initverb
6017 * payload also sets the generation to 0, output to be in "consumer"
6018 * PCM format, copyright asserted, no pre-emphasis and no validity
6019 * control.
6020 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006021 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6022 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6023
Kailang Yangea1fb292008-08-26 12:58:38 +02006024 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006025 * OUT1 sum bus when acting as an output.
6026 */
6027 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6028 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6029 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6030 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6031
6032 /* Start with output sum widgets muted and their output gains at min */
6033 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6034 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6035 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6036 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6037 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6038 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6039 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6040 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6041 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6042
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006043 /* Unmute retasking pin widget output buffers since the default
6044 * state appears to be output. As the pin mode is changed by the
6045 * user the pin mode control will take care of enabling the pin's
6046 * input/output buffers as needed.
6047 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006048 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6049 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6050 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6051 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6052 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6053 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6054 /* Also unmute the mono-out pin widget */
6055 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6056
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006057 /* Mute capture amp left and right */
6058 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006059 /* Set ADC connection select to match default mixer setting (mic1
6060 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006061 */
6062 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6063
6064 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006065 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006066 */
6067 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6068 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6069
6070 /* Mute all inputs to mixer widget (even unconnected ones) */
6071 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6072 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6073 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6074 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6075 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6076 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6077 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6078 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6079
6080 { }
6081};
6082#endif
6083
Takashi Iwai63300792008-01-24 15:31:36 +01006084#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6085#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006086
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006087#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6088#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6089
Kailang Yangdf694da2005-12-05 19:42:22 +01006090/*
6091 * for BIOS auto-configuration
6092 */
6093
6094static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006095 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006096{
6097 hda_nid_t nid_vol;
6098 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006099 int err;
6100
6101 if (nid >= 0x0f && nid < 0x11) {
6102 nid_vol = nid - 0x7;
6103 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6104 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6105 } else if (nid == 0x11) {
6106 nid_vol = nid - 0x7;
6107 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6108 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6109 } else if (nid >= 0x12 && nid <= 0x15) {
6110 nid_vol = 0x08;
6111 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6112 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6113 } else
6114 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006115
Takashi Iwai863b4512008-10-21 17:01:47 +02006116 if (!(*vol_bits & (1 << nid_vol))) {
6117 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006118 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006119 if (err < 0)
6120 return err;
6121 *vol_bits |= (1 << nid_vol);
6122 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006123 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006124 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006125 return err;
6126 return 1;
6127}
6128
6129/* add playback controls from the parsed DAC table */
6130static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6131 const struct auto_pin_cfg *cfg)
6132{
6133 hda_nid_t nid;
6134 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006135 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006136
6137 spec->multiout.num_dacs = 1;
6138 spec->multiout.dac_nids = spec->private_dac_nids;
6139 spec->multiout.dac_nids[0] = 0x02;
6140
6141 nid = cfg->line_out_pins[0];
6142 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006143 const char *pfx;
6144 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6145 pfx = "Master";
6146 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6147 pfx = "Speaker";
6148 else
6149 pfx = "Front";
6150 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006151 if (err < 0)
6152 return err;
6153 }
6154
Takashi Iwai82bc9552006-03-21 11:24:42 +01006155 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006156 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006157 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006158 if (err < 0)
6159 return err;
6160 }
6161
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006162 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006163 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006164 err = alc260_add_playback_controls(spec, nid, "Headphone",
6165 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006166 if (err < 0)
6167 return err;
6168 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006169 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006170}
6171
6172/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006173static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006174 const struct auto_pin_cfg *cfg)
6175{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006176 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006177}
6178
6179static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6180 hda_nid_t nid, int pin_type,
6181 int sel_idx)
6182{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006183 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006184 /* need the manual connection? */
6185 if (nid >= 0x12) {
6186 int idx = nid - 0x12;
6187 snd_hda_codec_write(codec, idx + 0x0b, 0,
6188 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006189 }
6190}
6191
6192static void alc260_auto_init_multi_out(struct hda_codec *codec)
6193{
6194 struct alc_spec *spec = codec->spec;
6195 hda_nid_t nid;
6196
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006197 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006198 if (nid) {
6199 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6200 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6201 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006202
Takashi Iwai82bc9552006-03-21 11:24:42 +01006203 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006204 if (nid)
6205 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6206
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006207 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006208 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006209 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006210}
Kailang Yangdf694da2005-12-05 19:42:22 +01006211
6212#define ALC260_PIN_CD_NID 0x16
6213static void alc260_auto_init_analog_input(struct hda_codec *codec)
6214{
6215 struct alc_spec *spec = codec->spec;
6216 int i;
6217
6218 for (i = 0; i < AUTO_PIN_LAST; i++) {
6219 hda_nid_t nid = spec->autocfg.input_pins[i];
6220 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006221 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006222 if (nid != ALC260_PIN_CD_NID &&
6223 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006224 snd_hda_codec_write(codec, nid, 0,
6225 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006226 AMP_OUT_MUTE);
6227 }
6228 }
6229}
6230
6231/*
6232 * generic initialization of ADC, input mixers and output mixers
6233 */
6234static struct hda_verb alc260_volume_init_verbs[] = {
6235 /*
6236 * Unmute ADC0-1 and set the default input to mic-in
6237 */
6238 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6239 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6240 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6241 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006242
Kailang Yangdf694da2005-12-05 19:42:22 +01006243 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6244 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006245 * Note: PASD motherboards uses the Line In 2 as the input for
6246 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006247 */
6248 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006249 /* mute analog inputs */
6250 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6251 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6252 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6253 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6254 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006255
6256 /*
6257 * Set up output mixers (0x08 - 0x0a)
6258 */
6259 /* set vol=0 to output mixers */
6260 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6261 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6262 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6263 /* set up input amps for analog loopback */
6264 /* Amp Indices: DAC = 0, mixer = 1 */
6265 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6266 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6267 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6268 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6269 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6270 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006271
Kailang Yangdf694da2005-12-05 19:42:22 +01006272 { }
6273};
6274
6275static int alc260_parse_auto_config(struct hda_codec *codec)
6276{
6277 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006278 int err;
6279 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6280
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006281 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6282 alc260_ignore);
6283 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006284 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006285 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6286 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006287 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006288 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006289 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006290 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006291 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006292 return err;
6293
6294 spec->multiout.max_channels = 2;
6295
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006296 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006297 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006298 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006299 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006300
Takashi Iwaid88897e2008-10-31 15:01:37 +01006301 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006302
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006303 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006304 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006305
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006306 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6307
Kailang Yangdf694da2005-12-05 19:42:22 +01006308 return 1;
6309}
6310
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006311/* additional initialization for auto-configuration model */
6312static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006313{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006314 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006315 alc260_auto_init_multi_out(codec);
6316 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006317 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006318 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006319}
6320
Takashi Iwaicb53c622007-08-10 17:21:45 +02006321#ifdef CONFIG_SND_HDA_POWER_SAVE
6322static struct hda_amp_list alc260_loopbacks[] = {
6323 { 0x07, HDA_INPUT, 0 },
6324 { 0x07, HDA_INPUT, 1 },
6325 { 0x07, HDA_INPUT, 2 },
6326 { 0x07, HDA_INPUT, 3 },
6327 { 0x07, HDA_INPUT, 4 },
6328 { } /* end */
6329};
6330#endif
6331
Kailang Yangdf694da2005-12-05 19:42:22 +01006332/*
6333 * ALC260 configurations
6334 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006335static const char *alc260_models[ALC260_MODEL_LAST] = {
6336 [ALC260_BASIC] = "basic",
6337 [ALC260_HP] = "hp",
6338 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006339 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006340 [ALC260_FUJITSU_S702X] = "fujitsu",
6341 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006342 [ALC260_WILL] = "will",
6343 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006344 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006345#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006346 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006347#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006348 [ALC260_AUTO] = "auto",
6349};
6350
6351static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006352 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006353 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006354 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006355 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006356 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006357 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006358 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006359 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006360 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006361 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6362 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6363 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6364 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6365 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6366 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6367 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6368 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6369 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006370 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006371 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006372 {}
6373};
6374
Kailang Yangdf694da2005-12-05 19:42:22 +01006375static struct alc_config_preset alc260_presets[] = {
6376 [ALC260_BASIC] = {
6377 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006378 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006379 .init_verbs = { alc260_init_verbs },
6380 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6381 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006382 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006383 .adc_nids = alc260_adc_nids,
6384 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6385 .channel_mode = alc260_modes,
6386 .input_mux = &alc260_capture_source,
6387 },
6388 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006389 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006390 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006391 .init_verbs = { alc260_init_verbs,
6392 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006393 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6394 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006395 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6396 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006397 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6398 .channel_mode = alc260_modes,
6399 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006400 .unsol_event = alc260_hp_unsol_event,
6401 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006402 },
Kailang Yang3f878302008-08-26 13:02:23 +02006403 [ALC260_HP_DC7600] = {
6404 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006405 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006406 .init_verbs = { alc260_init_verbs,
6407 alc260_hp_dc7600_verbs },
6408 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6409 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006410 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6411 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006412 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6413 .channel_mode = alc260_modes,
6414 .input_mux = &alc260_capture_source,
6415 .unsol_event = alc260_hp_3012_unsol_event,
6416 .init_hook = alc260_hp_3012_automute,
6417 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006418 [ALC260_HP_3013] = {
6419 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006420 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006421 .init_verbs = { alc260_hp_3013_init_verbs,
6422 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006423 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6424 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006425 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6426 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006427 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6428 .channel_mode = alc260_modes,
6429 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006430 .unsol_event = alc260_hp_3013_unsol_event,
6431 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006432 },
6433 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006434 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006435 .init_verbs = { alc260_fujitsu_init_verbs },
6436 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6437 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006438 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6439 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006440 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6441 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006442 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6443 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006444 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006445 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006446 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006447 .init_verbs = { alc260_acer_init_verbs },
6448 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6449 .dac_nids = alc260_dac_nids,
6450 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6451 .adc_nids = alc260_dual_adc_nids,
6452 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6453 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006454 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6455 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006456 },
Michael Schwingencc959482009-02-22 18:58:45 +01006457 [ALC260_FAVORIT100] = {
6458 .mixers = { alc260_favorit100_mixer },
6459 .init_verbs = { alc260_favorit100_init_verbs },
6460 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6461 .dac_nids = alc260_dac_nids,
6462 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6463 .adc_nids = alc260_dual_adc_nids,
6464 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6465 .channel_mode = alc260_modes,
6466 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6467 .input_mux = alc260_favorit100_capture_sources,
6468 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006469 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006470 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006471 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6472 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6473 .dac_nids = alc260_dac_nids,
6474 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6475 .adc_nids = alc260_adc_nids,
6476 .dig_out_nid = ALC260_DIGOUT_NID,
6477 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6478 .channel_mode = alc260_modes,
6479 .input_mux = &alc260_capture_source,
6480 },
6481 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006482 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006483 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6484 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6485 .dac_nids = alc260_dac_nids,
6486 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6487 .adc_nids = alc260_adc_nids,
6488 .dig_out_nid = ALC260_DIGOUT_NID,
6489 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6490 .channel_mode = alc260_modes,
6491 .input_mux = &alc260_capture_source,
6492 .unsol_event = alc260_replacer_672v_unsol_event,
6493 .init_hook = alc260_replacer_672v_automute,
6494 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006495#ifdef CONFIG_SND_DEBUG
6496 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006497 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006498 .init_verbs = { alc260_test_init_verbs },
6499 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6500 .dac_nids = alc260_test_dac_nids,
6501 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6502 .adc_nids = alc260_test_adc_nids,
6503 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6504 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006505 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6506 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006507 },
6508#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006509};
6510
Linus Torvalds1da177e2005-04-16 15:20:36 -07006511static int patch_alc260(struct hda_codec *codec)
6512{
6513 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006514 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006515
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006516 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006517 if (spec == NULL)
6518 return -ENOMEM;
6519
6520 codec->spec = spec;
6521
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006522 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6523 alc260_models,
6524 alc260_cfg_tbl);
6525 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006526 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006527 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006528 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006529 }
6530
Kailang Yangdf694da2005-12-05 19:42:22 +01006531 if (board_config == ALC260_AUTO) {
6532 /* automatic parse from the BIOS config */
6533 err = alc260_parse_auto_config(codec);
6534 if (err < 0) {
6535 alc_free(codec);
6536 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006537 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006538 printk(KERN_INFO
6539 "hda_codec: Cannot set up configuration "
6540 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006541 board_config = ALC260_BASIC;
6542 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006543 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006544
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006545 err = snd_hda_attach_beep_device(codec, 0x1);
6546 if (err < 0) {
6547 alc_free(codec);
6548 return err;
6549 }
6550
Kailang Yangdf694da2005-12-05 19:42:22 +01006551 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006552 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006553
Linus Torvalds1da177e2005-04-16 15:20:36 -07006554 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6555 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6556
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006557 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6558 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6559
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006560 if (!spec->adc_nids && spec->input_mux) {
6561 /* check whether NID 0x04 is valid */
6562 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006563 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006564 /* get type */
6565 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6566 spec->adc_nids = alc260_adc_nids_alt;
6567 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6568 } else {
6569 spec->adc_nids = alc260_adc_nids;
6570 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6571 }
6572 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006573 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006574 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006575
Takashi Iwai2134ea42008-01-10 16:53:55 +01006576 spec->vmaster_nid = 0x08;
6577
Linus Torvalds1da177e2005-04-16 15:20:36 -07006578 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006579 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006580 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006581#ifdef CONFIG_SND_HDA_POWER_SAVE
6582 if (!spec->loopback.amplist)
6583 spec->loopback.amplist = alc260_loopbacks;
6584#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006585 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006586
6587 return 0;
6588}
6589
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006590
Linus Torvalds1da177e2005-04-16 15:20:36 -07006591/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006592 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006593 *
6594 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6595 * configuration. Each pin widget can choose any input DACs and a mixer.
6596 * Each ADC is connected from a mixer of all inputs. This makes possible
6597 * 6-channel independent captures.
6598 *
6599 * In addition, an independent DAC for the multi-playback (not used in this
6600 * driver yet).
6601 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006602#define ALC882_DIGOUT_NID 0x06
6603#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006604#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6605#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6606#define ALC1200_DIGOUT_NID 0x10
6607
Linus Torvalds1da177e2005-04-16 15:20:36 -07006608
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006609static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006610 { 8, NULL }
6611};
6612
Takashi Iwai4953550a2009-06-30 15:28:30 +02006613/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006614static hda_nid_t alc882_dac_nids[4] = {
6615 /* front, rear, clfe, rear_surr */
6616 0x02, 0x03, 0x04, 0x05
6617};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006618#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006619
Takashi Iwai4953550a2009-06-30 15:28:30 +02006620/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006621#define alc882_adc_nids alc880_adc_nids
6622#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006623#define alc883_adc_nids alc882_adc_nids_alt
6624static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6625static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6626#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006627
Takashi Iwaie1406342008-02-11 18:32:32 +01006628static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6629static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006630#define alc883_capsrc_nids alc882_capsrc_nids_alt
6631static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6632#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006633
Linus Torvalds1da177e2005-04-16 15:20:36 -07006634/* input MUX */
6635/* FIXME: should be a matrix-type input source selection */
6636
6637static struct hda_input_mux alc882_capture_source = {
6638 .num_items = 4,
6639 .items = {
6640 { "Mic", 0x0 },
6641 { "Front Mic", 0x1 },
6642 { "Line", 0x2 },
6643 { "CD", 0x4 },
6644 },
6645};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006646
Takashi Iwai4953550a2009-06-30 15:28:30 +02006647#define alc883_capture_source alc882_capture_source
6648
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006649static struct hda_input_mux alc889_capture_source = {
6650 .num_items = 3,
6651 .items = {
6652 { "Front Mic", 0x0 },
6653 { "Mic", 0x3 },
6654 { "Line", 0x2 },
6655 },
6656};
6657
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006658static struct hda_input_mux mb5_capture_source = {
6659 .num_items = 3,
6660 .items = {
6661 { "Mic", 0x1 },
6662 { "Line", 0x2 },
6663 { "CD", 0x4 },
6664 },
6665};
6666
Takashi Iwai4953550a2009-06-30 15:28:30 +02006667static struct hda_input_mux alc883_3stack_6ch_intel = {
6668 .num_items = 4,
6669 .items = {
6670 { "Mic", 0x1 },
6671 { "Front Mic", 0x0 },
6672 { "Line", 0x2 },
6673 { "CD", 0x4 },
6674 },
6675};
6676
6677static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6678 .num_items = 2,
6679 .items = {
6680 { "Mic", 0x1 },
6681 { "Line", 0x2 },
6682 },
6683};
6684
6685static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6686 .num_items = 4,
6687 .items = {
6688 { "Mic", 0x0 },
6689 { "iMic", 0x1 },
6690 { "Line", 0x2 },
6691 { "CD", 0x4 },
6692 },
6693};
6694
6695static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6696 .num_items = 2,
6697 .items = {
6698 { "Mic", 0x0 },
6699 { "Int Mic", 0x1 },
6700 },
6701};
6702
6703static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6704 .num_items = 3,
6705 .items = {
6706 { "Mic", 0x0 },
6707 { "Front Mic", 0x1 },
6708 { "Line", 0x4 },
6709 },
6710};
6711
6712static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6713 .num_items = 2,
6714 .items = {
6715 { "Mic", 0x0 },
6716 { "Line", 0x2 },
6717 },
6718};
6719
6720static struct hda_input_mux alc889A_mb31_capture_source = {
6721 .num_items = 2,
6722 .items = {
6723 { "Mic", 0x0 },
6724 /* Front Mic (0x01) unused */
6725 { "Line", 0x2 },
6726 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02006727 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006728 },
6729};
6730
6731/*
6732 * 2ch mode
6733 */
6734static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6735 { 2, NULL }
6736};
6737
Kailang Yangdf694da2005-12-05 19:42:22 +01006738/*
Kailang Yang272a5272007-05-14 11:00:38 +02006739 * 2ch mode
6740 */
6741static struct hda_verb alc882_3ST_ch2_init[] = {
6742 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6743 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6744 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6745 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6746 { } /* end */
6747};
6748
6749/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006750 * 4ch mode
6751 */
6752static struct hda_verb alc882_3ST_ch4_init[] = {
6753 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6754 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6755 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6756 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6757 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6758 { } /* end */
6759};
6760
6761/*
Kailang Yang272a5272007-05-14 11:00:38 +02006762 * 6ch mode
6763 */
6764static struct hda_verb alc882_3ST_ch6_init[] = {
6765 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6766 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6767 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6768 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6769 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6770 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6771 { } /* end */
6772};
6773
Takashi Iwai4953550a2009-06-30 15:28:30 +02006774static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006775 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006776 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006777 { 6, alc882_3ST_ch6_init },
6778};
6779
Takashi Iwai4953550a2009-06-30 15:28:30 +02006780#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6781
Kailang Yang272a5272007-05-14 11:00:38 +02006782/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04306783 * 2ch mode
6784 */
6785static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6786 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6787 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6788 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6789 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6790 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6791 { } /* end */
6792};
6793
6794/*
6795 * 4ch mode
6796 */
6797static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
6798 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6799 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6800 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6801 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6802 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6803 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6804 { } /* end */
6805};
6806
6807/*
6808 * 6ch mode
6809 */
6810static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
6811 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6812 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6813 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6814 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6815 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6816 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6817 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6818 { } /* end */
6819};
6820
6821static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
6822 { 2, alc883_3ST_ch2_clevo_init },
6823 { 4, alc883_3ST_ch4_clevo_init },
6824 { 6, alc883_3ST_ch6_clevo_init },
6825};
6826
6827
6828/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006829 * 6ch mode
6830 */
6831static struct hda_verb alc882_sixstack_ch6_init[] = {
6832 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6833 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6834 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6835 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6836 { } /* end */
6837};
6838
6839/*
6840 * 8ch mode
6841 */
6842static struct hda_verb alc882_sixstack_ch8_init[] = {
6843 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6844 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6845 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6846 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6847 { } /* end */
6848};
6849
6850static struct hda_channel_mode alc882_sixstack_modes[2] = {
6851 { 6, alc882_sixstack_ch6_init },
6852 { 8, alc882_sixstack_ch8_init },
6853};
6854
Takashi Iwai87350ad2007-08-16 18:19:38 +02006855/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006856 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006857 */
6858
6859/*
6860 * 2ch mode
6861 */
6862static struct hda_verb alc885_mbp_ch2_init[] = {
6863 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6864 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6865 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6866 { } /* end */
6867};
6868
6869/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006870 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02006871 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006872static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006873 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6874 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6875 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6876 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6877 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6878 { } /* end */
6879};
6880
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006881static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006882 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006883 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006884};
6885
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006886/*
6887 * 2ch
6888 * Speakers/Woofer/HP = Front
6889 * LineIn = Input
6890 */
6891static struct hda_verb alc885_mb5_ch2_init[] = {
6892 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6893 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6894 { } /* end */
6895};
6896
6897/*
6898 * 6ch mode
6899 * Speakers/HP = Front
6900 * Woofer = LFE
6901 * LineIn = Surround
6902 */
6903static struct hda_verb alc885_mb5_ch6_init[] = {
6904 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6905 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6906 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6907 { } /* end */
6908};
6909
6910static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6911 { 2, alc885_mb5_ch2_init },
6912 { 6, alc885_mb5_ch6_init },
6913};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006914
Takashi Iwai4953550a2009-06-30 15:28:30 +02006915
6916/*
6917 * 2ch mode
6918 */
6919static struct hda_verb alc883_4ST_ch2_init[] = {
6920 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6921 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6922 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6923 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6924 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6925 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6926 { } /* end */
6927};
6928
6929/*
6930 * 4ch mode
6931 */
6932static struct hda_verb alc883_4ST_ch4_init[] = {
6933 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6934 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6935 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6936 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6937 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6938 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6939 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6940 { } /* end */
6941};
6942
6943/*
6944 * 6ch mode
6945 */
6946static struct hda_verb alc883_4ST_ch6_init[] = {
6947 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6948 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6949 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6950 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6951 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6952 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6953 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6954 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6955 { } /* end */
6956};
6957
6958/*
6959 * 8ch mode
6960 */
6961static struct hda_verb alc883_4ST_ch8_init[] = {
6962 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6963 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6964 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6965 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6966 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6967 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6968 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6969 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6970 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6971 { } /* end */
6972};
6973
6974static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6975 { 2, alc883_4ST_ch2_init },
6976 { 4, alc883_4ST_ch4_init },
6977 { 6, alc883_4ST_ch6_init },
6978 { 8, alc883_4ST_ch8_init },
6979};
6980
6981
6982/*
6983 * 2ch mode
6984 */
6985static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6986 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6987 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6988 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6989 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6990 { } /* end */
6991};
6992
6993/*
6994 * 4ch mode
6995 */
6996static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6997 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6998 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6999 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7000 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7001 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7002 { } /* end */
7003};
7004
7005/*
7006 * 6ch mode
7007 */
7008static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7009 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7010 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7011 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7012 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7013 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7014 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7015 { } /* end */
7016};
7017
7018static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7019 { 2, alc883_3ST_ch2_intel_init },
7020 { 4, alc883_3ST_ch4_intel_init },
7021 { 6, alc883_3ST_ch6_intel_init },
7022};
7023
7024/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007025 * 2ch mode
7026 */
7027static struct hda_verb alc889_ch2_intel_init[] = {
7028 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7029 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7030 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7031 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7032 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7033 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7034 { } /* end */
7035};
7036
7037/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007038 * 6ch mode
7039 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007040static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007041 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7042 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7043 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7044 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7045 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007046 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7047 { } /* end */
7048};
7049
7050/*
7051 * 8ch mode
7052 */
7053static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007054 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7055 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7056 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7057 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7058 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007059 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7060 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007061 { } /* end */
7062};
7063
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007064static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7065 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007066 { 6, alc889_ch6_intel_init },
7067 { 8, alc889_ch8_intel_init },
7068};
7069
7070/*
7071 * 6ch mode
7072 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007073static struct hda_verb alc883_sixstack_ch6_init[] = {
7074 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7075 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7076 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7077 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7078 { } /* end */
7079};
7080
7081/*
7082 * 8ch mode
7083 */
7084static struct hda_verb alc883_sixstack_ch8_init[] = {
7085 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7086 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7087 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7088 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7089 { } /* end */
7090};
7091
7092static struct hda_channel_mode alc883_sixstack_modes[2] = {
7093 { 6, alc883_sixstack_ch6_init },
7094 { 8, alc883_sixstack_ch8_init },
7095};
7096
7097
Linus Torvalds1da177e2005-04-16 15:20:36 -07007098/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7099 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7100 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007101static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007102 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007103 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007104 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007105 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007106 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7107 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007108 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7109 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007110 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007111 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007112 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7113 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7114 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7115 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7116 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7117 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007118 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007119 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7120 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007121 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007122 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007123 { } /* end */
7124};
7125
Takashi Iwai87350ad2007-08-16 18:19:38 +02007126static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007127 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7128 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7129 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7130 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7131 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007132 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7133 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007134 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7135 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007136 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007137 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7138 { } /* end */
7139};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007140
7141static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007142 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7143 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7144 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7145 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7146 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7147 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307148 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7149 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007150 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7151 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7152 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7153 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7154 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7155 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7156 { } /* end */
7157};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007158
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007159static struct snd_kcontrol_new alc885_imac91_mixer[] = {
7160 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7161 HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
7162 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
7163 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7164 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7165 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7166 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7167 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7168 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7169 { } /* end */
7170};
7171
7172
Kailang Yangbdd148a2007-05-08 15:19:08 +02007173static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7174 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7175 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7176 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7177 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7178 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7179 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7180 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7181 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7182 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007183 { } /* end */
7184};
7185
Kailang Yang272a5272007-05-14 11:00:38 +02007186static struct snd_kcontrol_new alc882_targa_mixer[] = {
7187 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7188 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7189 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7190 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7191 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7192 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7193 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7194 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7195 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007196 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007197 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7198 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007199 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007200 { } /* end */
7201};
7202
7203/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7204 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7205 */
7206static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7207 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7208 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7209 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7210 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7211 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7212 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7213 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7214 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7215 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7216 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7217 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7218 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007219 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007220 { } /* end */
7221};
7222
Takashi Iwai914759b2007-09-06 14:52:04 +02007223static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7224 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7225 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7226 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7227 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7228 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7229 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7230 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7231 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7232 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7233 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007234 { } /* end */
7235};
7236
Kailang Yangdf694da2005-12-05 19:42:22 +01007237static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7238 {
7239 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7240 .name = "Channel Mode",
7241 .info = alc_ch_mode_info,
7242 .get = alc_ch_mode_get,
7243 .put = alc_ch_mode_put,
7244 },
7245 { } /* end */
7246};
7247
Takashi Iwai4953550a2009-06-30 15:28:30 +02007248static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007249 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007250 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7251 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7252 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007253 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007254 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7255 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7256 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007257 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007258 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7259 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7260 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007261 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007262 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7263 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7264 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007265
Takashi Iwaicb638122009-07-03 10:56:10 +02007266 /* mute analog input loopbacks */
7267 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7268 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7269 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7270 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7271 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7272
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007273 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007274 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007275 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007276 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007277 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007278 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007279 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007280 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007281 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007282 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007283 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007284 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007285 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007286 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007287 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007288 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007289 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007290 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007291 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7292 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007293 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007294 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7295 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007296 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007297 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7298 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7299 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7300 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7301 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007302 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007303 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007304
7305 /* FIXME: use matrix-type input source selection */
7306 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007307 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007308 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7309 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7310 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7311 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007312 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007313 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7315 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7316 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007317 /* ADC2: mute amp left and right */
7318 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007319 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007320 /* ADC3: mute amp left and right */
7321 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007322 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007323
7324 { }
7325};
7326
Takashi Iwai4953550a2009-06-30 15:28:30 +02007327static struct hda_verb alc882_adc1_init_verbs[] = {
7328 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7329 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7330 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7331 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7332 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7333 /* ADC1: mute amp left and right */
7334 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7335 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7336 { }
7337};
7338
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007339static struct hda_verb alc882_eapd_verbs[] = {
7340 /* change to EAPD mode */
7341 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007342 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007343 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007344};
7345
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007346static struct hda_verb alc889_eapd_verbs[] = {
7347 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7348 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7349 { }
7350};
7351
Wu Fengguang6732bd02009-07-30 09:19:14 +02007352static struct hda_verb alc_hp15_unsol_verbs[] = {
7353 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7354 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7355 {}
7356};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007357
7358static struct hda_verb alc885_init_verbs[] = {
7359 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7360 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7361 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7362 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7363 /* Rear mixer */
7364 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7365 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7366 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7367 /* CLFE mixer */
7368 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7369 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7370 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7371 /* Side mixer */
7372 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7373 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7374 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7375
7376 /* mute analog input loopbacks */
7377 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7378 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7379 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7380
7381 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007382 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007383 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7384 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7385 /* Front Pin: output 0 (0x0c) */
7386 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7387 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7388 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7389 /* Rear Pin: output 1 (0x0d) */
7390 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7391 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7392 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7393 /* CLFE Pin: output 2 (0x0e) */
7394 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7395 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7396 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7397 /* Side Pin: output 3 (0x0f) */
7398 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7399 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7400 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7401 /* Mic (rear) pin: input vref at 80% */
7402 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7403 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7404 /* Front Mic pin: input vref at 80% */
7405 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7406 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7407 /* Line In pin: input */
7408 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7409 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7410
7411 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7412 /* Input mixer1 */
7413 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7414 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7415 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7416 /* Input mixer2 */
7417 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7418 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7419 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7420 /* Input mixer3 */
7421 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7422 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7423 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7424 /* ADC2: mute amp left and right */
7425 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7426 /* ADC3: mute amp left and right */
7427 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7428
7429 { }
7430};
7431
7432static struct hda_verb alc885_init_input_verbs[] = {
7433 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7434 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7435 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7436 { }
7437};
7438
7439
7440/* Unmute Selector 24h and set the default input to front mic */
7441static struct hda_verb alc889_init_input_verbs[] = {
7442 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7443 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7444 { }
7445};
7446
7447
Takashi Iwai4953550a2009-06-30 15:28:30 +02007448#define alc883_init_verbs alc882_base_init_verbs
7449
Tobin Davis9102cd12006-12-15 10:02:12 +01007450/* Mac Pro test */
7451static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7452 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7453 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7454 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7455 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7456 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007457 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007458 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7459 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007460 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007461 { } /* end */
7462};
7463
7464static struct hda_verb alc882_macpro_init_verbs[] = {
7465 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7466 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7467 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7468 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7469 /* Front Pin: output 0 (0x0c) */
7470 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7471 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7472 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7473 /* Front Mic pin: input vref at 80% */
7474 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7475 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7476 /* Speaker: output */
7477 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7478 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7479 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7480 /* Headphone output (output 0 - 0x0c) */
7481 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7482 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7483 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7484
7485 /* FIXME: use matrix-type input source selection */
7486 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7487 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7488 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7489 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7490 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7491 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7492 /* Input mixer2 */
7493 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7494 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7495 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7496 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7497 /* Input mixer3 */
7498 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7499 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7500 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7501 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7502 /* ADC1: mute amp left and right */
7503 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7504 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7505 /* ADC2: mute amp left and right */
7506 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7507 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7508 /* ADC3: mute amp left and right */
7509 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7510 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7511
7512 { }
7513};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007514
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007515/* Macbook 5,1 */
7516static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007517 /* DACs */
7518 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7519 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7520 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7521 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007522 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007523 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7524 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7525 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007526 /* Surround mixer */
7527 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7528 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7529 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7530 /* LFE mixer */
7531 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7532 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7533 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7534 /* HP mixer */
7535 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7536 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7537 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7538 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007539 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7540 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007541 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7542 /* LFE Pin (0x0e) */
7543 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7544 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7545 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7546 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007547 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7548 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007549 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10307550 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007551 /* Front Mic pin: input vref at 80% */
7552 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7553 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7554 /* Line In pin */
7555 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7556 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7557
7558 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7559 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7560 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7561 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7562 { }
7563};
7564
Takashi Iwai87350ad2007-08-16 18:19:38 +02007565/* Macbook Pro rev3 */
7566static struct hda_verb alc885_mbp3_init_verbs[] = {
7567 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7568 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7569 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7570 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7571 /* Rear mixer */
7572 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7573 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7574 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007575 /* HP mixer */
7576 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7577 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7578 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007579 /* Front Pin: output 0 (0x0c) */
7580 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7581 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7582 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007583 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007584 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007585 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7586 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007587 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7588 /* Mic (rear) pin: input vref at 80% */
7589 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7590 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7591 /* Front Mic pin: input vref at 80% */
7592 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7593 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7594 /* Line In pin: use output 1 when in LineOut mode */
7595 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7596 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7597 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7598
7599 /* FIXME: use matrix-type input source selection */
7600 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7601 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7602 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7603 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7604 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7605 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7606 /* Input mixer2 */
7607 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7608 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7609 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7610 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7611 /* Input mixer3 */
7612 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7613 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7614 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7615 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7616 /* ADC1: mute amp left and right */
7617 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7618 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7619 /* ADC2: mute amp left and right */
7620 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7621 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7622 /* ADC3: mute amp left and right */
7623 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7624 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7625
7626 { }
7627};
7628
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007629/* iMac 9,1 */
7630static struct hda_verb alc885_imac91_init_verbs[] = {
7631 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
7632 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7633 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7634 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7635 /* Rear mixer */
7636 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7637 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7638 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7639 /* HP Pin: output 0 (0x0c) */
7640 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7641 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7642 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7643 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7644 /* Internal Speakers: output 0 (0x0d) */
7645 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7646 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7647 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7648 /* Mic (rear) pin: input vref at 80% */
7649 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7650 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7651 /* Front Mic pin: input vref at 80% */
7652 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7653 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7654 /* Line In pin: use output 1 when in LineOut mode */
7655 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7656 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7657 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7658
7659 /* FIXME: use matrix-type input source selection */
7660 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7661 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7662 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7663 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7664 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7665 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7666 /* Input mixer2 */
7667 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7668 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7669 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7670 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7671 /* Input mixer3 */
7672 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7673 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7674 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7675 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7676 /* ADC1: mute amp left and right */
7677 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7678 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7679 /* ADC2: mute amp left and right */
7680 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7681 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7682 /* ADC3: mute amp left and right */
7683 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7684 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7685
7686 { }
7687};
7688
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007689/* iMac 24 mixer. */
7690static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7691 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7692 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7693 { } /* end */
7694};
7695
7696/* iMac 24 init verbs. */
7697static struct hda_verb alc885_imac24_init_verbs[] = {
7698 /* Internal speakers: output 0 (0x0c) */
7699 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7700 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7701 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7702 /* Internal speakers: output 0 (0x0c) */
7703 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7704 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7705 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7706 /* Headphone: output 0 (0x0c) */
7707 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7708 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7709 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7710 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7711 /* Front Mic: input vref at 80% */
7712 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7713 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7714 { }
7715};
7716
7717/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007718static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007719{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007720 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007721
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007722 spec->autocfg.hp_pins[0] = 0x14;
7723 spec->autocfg.speaker_pins[0] = 0x18;
7724 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007725}
7726
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007727static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007728{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007729 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007730
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007731 spec->autocfg.hp_pins[0] = 0x15;
7732 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02007733}
7734
Alex Murraya76221d2010-01-13 23:15:03 +10307735static void alc885_mb5_automute(struct hda_codec *codec)
7736{
7737 unsigned int present;
7738
7739 present = snd_hda_codec_read(codec, 0x14, 0,
7740 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7741 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
7742 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7743 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
7744 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7745
7746}
7747
7748static void alc885_mb5_unsol_event(struct hda_codec *codec,
7749 unsigned int res)
7750{
7751 /* Headphone insertion or removal. */
7752 if ((res >> 26) == ALC880_HP_EVENT)
7753 alc885_mb5_automute(codec);
7754}
7755
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007756static void alc885_imac91_automute(struct hda_codec *codec)
7757{
7758 unsigned int present;
7759
7760 present = snd_hda_codec_read(codec, 0x14, 0,
7761 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7762 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7763 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7764 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
7765 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7766
7767}
7768
7769static void alc885_imac91_unsol_event(struct hda_codec *codec,
7770 unsigned int res)
7771{
7772 /* Headphone insertion or removal. */
7773 if ((res >> 26) == ALC880_HP_EVENT)
7774 alc885_imac91_automute(codec);
7775}
Takashi Iwai87350ad2007-08-16 18:19:38 +02007776
Kailang Yang272a5272007-05-14 11:00:38 +02007777static struct hda_verb alc882_targa_verbs[] = {
7778 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7779 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7780
7781 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7782 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007783
Kailang Yang272a5272007-05-14 11:00:38 +02007784 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7785 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7786 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7787
7788 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007789 { } /* end */
7790};
7791
7792/* toggle speaker-output according to the hp-jack state */
7793static void alc882_targa_automute(struct hda_codec *codec)
7794{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007795 struct alc_spec *spec = codec->spec;
7796 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007797 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007798 spec->jack_present ? 1 : 3);
7799}
7800
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007801static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007802{
7803 struct alc_spec *spec = codec->spec;
7804
7805 spec->autocfg.hp_pins[0] = 0x14;
7806 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02007807}
7808
7809static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7810{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007811 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007812 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007813}
7814
7815static struct hda_verb alc882_asus_a7j_verbs[] = {
7816 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7817 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7818
7819 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7820 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7821 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007822
Kailang Yang272a5272007-05-14 11:00:38 +02007823 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7824 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7825 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7826
7827 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7828 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7829 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7830 { } /* end */
7831};
7832
Takashi Iwai914759b2007-09-06 14:52:04 +02007833static struct hda_verb alc882_asus_a7m_verbs[] = {
7834 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7835 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7836
7837 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7838 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7839 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007840
Takashi Iwai914759b2007-09-06 14:52:04 +02007841 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7842 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7843 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7844
7845 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7846 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7847 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7848 { } /* end */
7849};
7850
Tobin Davis9102cd12006-12-15 10:02:12 +01007851static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7852{
7853 unsigned int gpiostate, gpiomask, gpiodir;
7854
7855 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7856 AC_VERB_GET_GPIO_DATA, 0);
7857
7858 if (!muted)
7859 gpiostate |= (1 << pin);
7860 else
7861 gpiostate &= ~(1 << pin);
7862
7863 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7864 AC_VERB_GET_GPIO_MASK, 0);
7865 gpiomask |= (1 << pin);
7866
7867 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7868 AC_VERB_GET_GPIO_DIRECTION, 0);
7869 gpiodir |= (1 << pin);
7870
7871
7872 snd_hda_codec_write(codec, codec->afg, 0,
7873 AC_VERB_SET_GPIO_MASK, gpiomask);
7874 snd_hda_codec_write(codec, codec->afg, 0,
7875 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7876
7877 msleep(1);
7878
7879 snd_hda_codec_write(codec, codec->afg, 0,
7880 AC_VERB_SET_GPIO_DATA, gpiostate);
7881}
7882
Takashi Iwai7debbe52007-08-16 15:01:03 +02007883/* set up GPIO at initialization */
7884static void alc885_macpro_init_hook(struct hda_codec *codec)
7885{
7886 alc882_gpio_mute(codec, 0, 0);
7887 alc882_gpio_mute(codec, 1, 0);
7888}
7889
7890/* set up GPIO and update auto-muting at initialization */
7891static void alc885_imac24_init_hook(struct hda_codec *codec)
7892{
7893 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007894 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007895}
7896
Kailang Yangdf694da2005-12-05 19:42:22 +01007897/*
7898 * generic initialization of ADC, input mixers and output mixers
7899 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007900static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007901 /*
7902 * Unmute ADC0-2 and set the default input to mic-in
7903 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007904 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7905 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7906 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7907 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7908
Takashi Iwaicb53c622007-08-10 17:21:45 +02007909 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007910 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007911 * Note: PASD motherboards uses the Line In 2 as the input for
7912 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007913 */
7914 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007915 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7916 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7917 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7918 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7919 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007920
7921 /*
7922 * Set up output mixers (0x0c - 0x0f)
7923 */
7924 /* set vol=0 to output mixers */
7925 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7926 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7927 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7928 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7929 /* set up input amps for analog loopback */
7930 /* Amp Indices: DAC = 0, mixer = 1 */
7931 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7932 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7933 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7934 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7935 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7936 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7937 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7938 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7939 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7940 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7941
7942 /* FIXME: use matrix-type input source selection */
7943 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01007944 /* Input mixer2 */
7945 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7946 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7947 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7948 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7949 /* Input mixer3 */
7950 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7951 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7952 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7953 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7954
7955 { }
7956};
7957
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007958/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7959static struct hda_verb alc889A_mb31_ch2_init[] = {
7960 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7961 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7962 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7963 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7964 { } /* end */
7965};
7966
7967/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7968static struct hda_verb alc889A_mb31_ch4_init[] = {
7969 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7970 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7971 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7972 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7973 { } /* end */
7974};
7975
7976/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7977static struct hda_verb alc889A_mb31_ch5_init[] = {
7978 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7979 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7980 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7981 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7982 { } /* end */
7983};
7984
7985/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7986static struct hda_verb alc889A_mb31_ch6_init[] = {
7987 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7988 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7989 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7990 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7991 { } /* end */
7992};
7993
7994static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7995 { 2, alc889A_mb31_ch2_init },
7996 { 4, alc889A_mb31_ch4_init },
7997 { 5, alc889A_mb31_ch5_init },
7998 { 6, alc889A_mb31_ch6_init },
7999};
8000
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008001static struct hda_verb alc883_medion_eapd_verbs[] = {
8002 /* eanable EAPD on medion laptop */
8003 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8004 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8005 { }
8006};
8007
Takashi Iwai4953550a2009-06-30 15:28:30 +02008008#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008009
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008010static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8011 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8012 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8013 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8014 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8015 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8016 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8017 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8018 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8019 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8020 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8021 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8022 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8023 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008024 { } /* end */
8025};
8026
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008027static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008028 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8029 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8030 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8031 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8032 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8033 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8034 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8035 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8036 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8037 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008038 { } /* end */
8039};
8040
Jiang zhefb97dc62008-03-06 11:07:11 +01008041static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8042 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8043 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8044 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8045 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8046 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8047 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8048 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8049 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8050 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8051 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008052 { } /* end */
8053};
8054
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008055static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8056 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8057 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8058 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8059 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8060 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8061 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8062 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8063 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008064 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008065 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8066 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008067 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008068 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008069 { } /* end */
8070};
8071
8072static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8073 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8074 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8075 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8076 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8077 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8078 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8079 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8080 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8081 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8082 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8083 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8084 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8085 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8086 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008087 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008088 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8089 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008090 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008091 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008092 { } /* end */
8093};
8094
Jiang zhe17bba1b2008-06-04 12:11:07 +02008095static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8096 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8097 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8098 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8099 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8100 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8101 HDA_OUTPUT),
8102 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8103 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8104 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8105 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8106 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8107 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8108 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8109 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8110 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8111 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8112 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8113 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8114 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8115 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008116 { } /* end */
8117};
8118
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008119static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8120 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8121 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8122 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8123 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8124 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8125 HDA_OUTPUT),
8126 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8127 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8128 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8129 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8130 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8131 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8132 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8133 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8134 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8135 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8136 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8137 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8138 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8139 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8140 { } /* end */
8141};
8142
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008143static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008144 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008145 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008146 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008147 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008148 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8149 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008150 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8151 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008152 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8153 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8154 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8155 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8156 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8157 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008158 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008159 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8160 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008161 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008162 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008163 { } /* end */
8164};
8165
Sasha Alexandrc2592492009-06-16 14:52:54 -04008166static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008167 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008168 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008169 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008170 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008171 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8172 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8173 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8174 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8175 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8176 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8177 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8178 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8179 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8180 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8181 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008182 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008183 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008184 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008185};
Kailang Yangccc656c2006-10-17 12:32:26 +02008186
Sasha Alexandrc2592492009-06-16 14:52:54 -04008187static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008188 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008189 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008190 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008191 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008192 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8193 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8194 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008195 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008196 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008197 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8198 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8199 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008200 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008201};
Kailang Yangccc656c2006-10-17 12:32:26 +02008202
Takashi Iwaib99dba32009-09-17 18:23:00 +02008203static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8204 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8205 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8206 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8207 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8208 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8209 { } /* end */
8210};
8211
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008212static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8213 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8214 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008215 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8216 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008217 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8218 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8219 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8220 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008221 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008222};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008223
Kailang Yang272a5272007-05-14 11:00:38 +02008224static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8225 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8226 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8227 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8228 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8229 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8230 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8231 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8232 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8233 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008234 { } /* end */
8235};
8236
8237static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8238 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8239 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8240 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8241 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8242 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8243 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8244 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8245 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8246 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008247 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008248};
Kailang Yang272a5272007-05-14 11:00:38 +02008249
Tobin Davis2880a862007-08-07 11:50:26 +02008250static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008251 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8252 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008253 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008254 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8255 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008256 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8257 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8258 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008259 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008260};
Tobin Davis2880a862007-08-07 11:50:26 +02008261
Tony Vroond2fd4b02009-06-21 00:40:10 +01008262static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8263 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8264 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8265 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8266 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008267 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8268 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008269 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8270 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8271 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8272 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8273 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8274 { } /* end */
8275};
8276
Kailang Yange2757d52008-08-26 13:17:46 +02008277static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8278 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8279 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8280 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8281 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8282 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8283 0x0d, 1, 0x0, HDA_OUTPUT),
8284 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8285 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8286 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8287 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8288 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008289 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8290 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8291 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8292 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8293 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8294 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8295 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8296 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8297 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8298 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008299 { } /* end */
8300};
8301
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008302static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8303 /* Output mixers */
8304 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8305 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8306 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8307 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8308 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8309 HDA_OUTPUT),
8310 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8311 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8312 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8313 /* Output switches */
8314 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8315 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8316 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8317 /* Boost mixers */
8318 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8319 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8320 /* Input mixers */
8321 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8322 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8323 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8324 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8325 { } /* end */
8326};
8327
Guido Günther3e1647c2009-06-05 00:47:26 +02008328static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8329 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8330 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8331 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8332 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8333 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8334 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8335 { } /* end */
8336};
8337
Kailang Yange2757d52008-08-26 13:17:46 +02008338static struct hda_bind_ctls alc883_bind_cap_vol = {
8339 .ops = &snd_hda_bind_vol,
8340 .values = {
8341 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8342 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8343 0
8344 },
8345};
8346
8347static struct hda_bind_ctls alc883_bind_cap_switch = {
8348 .ops = &snd_hda_bind_sw,
8349 .values = {
8350 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8351 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8352 0
8353 },
8354};
8355
8356static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8357 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8358 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8359 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8360 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8361 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8362 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8363 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8364 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008365 { } /* end */
8366};
8367
8368static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008369 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8370 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8371 {
8372 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8373 /* .name = "Capture Source", */
8374 .name = "Input Source",
8375 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008376 .info = alc_mux_enum_info,
8377 .get = alc_mux_enum_get,
8378 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008379 },
8380 { } /* end */
8381};
8382
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008383static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8384 {
8385 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8386 .name = "Channel Mode",
8387 .info = alc_ch_mode_info,
8388 .get = alc_ch_mode_get,
8389 .put = alc_ch_mode_put,
8390 },
8391 { } /* end */
8392};
8393
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008394/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008395static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008396{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008397 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008398
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008399 spec->autocfg.hp_pins[0] = 0x15;
8400 spec->autocfg.speaker_pins[0] = 0x14;
8401 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008402}
8403
8404/* auto-toggle front mic */
8405/*
8406static void alc883_mitac_mic_automute(struct hda_codec *codec)
8407{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008408 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008409
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008410 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8411}
8412*/
8413
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008414static struct hda_verb alc883_mitac_verbs[] = {
8415 /* HP */
8416 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8417 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8418 /* Subwoofer */
8419 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8420 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8421
8422 /* enable unsolicited event */
8423 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8424 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8425
8426 { } /* end */
8427};
8428
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308429static struct hda_verb alc883_clevo_m540r_verbs[] = {
8430 /* HP */
8431 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8432 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8433 /* Int speaker */
8434 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8435
8436 /* enable unsolicited event */
8437 /*
8438 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8439 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8440 */
8441
8442 { } /* end */
8443};
8444
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008445static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008446 /* HP */
8447 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8448 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8449 /* Int speaker */
8450 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8451 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8452
8453 /* enable unsolicited event */
8454 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008455 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008456
8457 { } /* end */
8458};
8459
Jiang zhefb97dc62008-03-06 11:07:11 +01008460static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8461 /* HP */
8462 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8463 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8464 /* Subwoofer */
8465 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8466 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8467
8468 /* enable unsolicited event */
8469 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8470
8471 { } /* end */
8472};
8473
Sasha Alexandrc2592492009-06-16 14:52:54 -04008474static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008475 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8476 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8477
8478 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8479 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008480
David Heidelberger64a8be72009-06-08 16:15:18 +02008481/* Connect Line-Out side jack (SPDIF) to Side */
8482 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8483 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8484 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8485/* Connect Mic jack to CLFE */
8486 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8487 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8488 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8489/* Connect Line-in jack to Surround */
8490 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8491 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8492 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8493/* Connect HP out jack to Front */
8494 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8495 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8496 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008497
8498 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008499
8500 { } /* end */
8501};
8502
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008503static struct hda_verb alc883_lenovo_101e_verbs[] = {
8504 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8505 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8506 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8507 { } /* end */
8508};
8509
Kailang Yang272a5272007-05-14 11:00:38 +02008510static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8511 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8512 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8513 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8514 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8515 { } /* end */
8516};
8517
8518static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8519 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8520 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8521 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8522 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8523 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8524 { } /* end */
8525};
8526
Kailang Yang189609a2007-08-20 11:31:23 +02008527static struct hda_verb alc883_haier_w66_verbs[] = {
8528 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8529 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8530
8531 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8532
8533 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8534 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8535 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8536 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8537 { } /* end */
8538};
8539
Kailang Yange2757d52008-08-26 13:17:46 +02008540static struct hda_verb alc888_lenovo_sky_verbs[] = {
8541 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8542 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8543 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8544 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8545 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8546 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8547 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8548 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8549 { } /* end */
8550};
8551
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008552static struct hda_verb alc888_6st_dell_verbs[] = {
8553 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8554 { }
8555};
8556
Guido Günther3e1647c2009-06-05 00:47:26 +02008557static struct hda_verb alc883_vaiott_verbs[] = {
8558 /* HP */
8559 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8560 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8561
8562 /* enable unsolicited event */
8563 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8564
8565 { } /* end */
8566};
8567
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008568static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008569{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008570 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008571
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008572 spec->autocfg.hp_pins[0] = 0x1b;
8573 spec->autocfg.speaker_pins[0] = 0x14;
8574 spec->autocfg.speaker_pins[1] = 0x16;
8575 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008576}
8577
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008578static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008579 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008580 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8581 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008582 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008583 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008584};
8585
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008586/*
8587 * 2ch mode
8588 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008589static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008590 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8591 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8592 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8593 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008594 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008595};
8596
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008597/*
8598 * 4ch mode
8599 */
8600static struct hda_verb alc888_3st_hp_4ch_init[] = {
8601 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8602 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8603 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8604 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8605 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8606 { } /* end */
8607};
8608
8609/*
8610 * 6ch mode
8611 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008612static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008613 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8614 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008615 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008616 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8617 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008618 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8619 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008620};
8621
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008622static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008623 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008624 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008625 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008626};
8627
Kailang Yang272a5272007-05-14 11:00:38 +02008628/* toggle front-jack and RCA according to the hp-jack state */
8629static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8630{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008631 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02008632
Takashi Iwai47fd8302007-08-10 17:11:07 +02008633 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8634 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8635 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8636 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008637}
8638
8639/* toggle RCA according to the front-jack state */
8640static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8641{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008642 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02008643
Takashi Iwai47fd8302007-08-10 17:11:07 +02008644 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8645 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008646}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008647
Kailang Yang272a5272007-05-14 11:00:38 +02008648static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8649 unsigned int res)
8650{
8651 if ((res >> 26) == ALC880_HP_EVENT)
8652 alc888_lenovo_ms7195_front_automute(codec);
8653 if ((res >> 26) == ALC880_FRONT_EVENT)
8654 alc888_lenovo_ms7195_rca_automute(codec);
8655}
8656
8657static struct hda_verb alc883_medion_md2_verbs[] = {
8658 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8659 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8660
8661 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8662
8663 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8664 { } /* end */
8665};
8666
8667/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008668static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008669{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008670 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008671
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008672 spec->autocfg.hp_pins[0] = 0x14;
8673 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008674}
8675
Kailang Yangccc656c2006-10-17 12:32:26 +02008676/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008677#define alc883_targa_init_hook alc882_targa_init_hook
8678#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008679
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008680static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8681{
8682 unsigned int present;
8683
Takashi Iwaid56757a2009-11-18 08:00:14 +01008684 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008685 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8686 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8687}
8688
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008689static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008690{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008691 struct alc_spec *spec = codec->spec;
8692
8693 spec->autocfg.hp_pins[0] = 0x15;
8694 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008695}
8696
8697static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8698{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008699 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008700 alc883_clevo_m720_mic_automute(codec);
8701}
8702
8703static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008704 unsigned int res)
8705{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008706 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008707 case ALC880_MIC_EVENT:
8708 alc883_clevo_m720_mic_automute(codec);
8709 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008710 default:
8711 alc_automute_amp_unsol_event(codec, res);
8712 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008713 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008714}
8715
Jiang zhefb97dc62008-03-06 11:07:11 +01008716/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008717static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008718{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008719 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008720
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008721 spec->autocfg.hp_pins[0] = 0x14;
8722 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01008723}
8724
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008725static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008726{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008727 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008728
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008729 spec->autocfg.hp_pins[0] = 0x1b;
8730 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02008731}
8732
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008733static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8734{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008735 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008736
Takashi Iwai47fd8302007-08-10 17:11:07 +02008737 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8738 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008739}
8740
8741static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8742{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008743 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008744
Takashi Iwai47fd8302007-08-10 17:11:07 +02008745 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8746 HDA_AMP_MUTE, bits);
8747 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8748 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008749}
8750
8751static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8752 unsigned int res)
8753{
8754 if ((res >> 26) == ALC880_HP_EVENT)
8755 alc883_lenovo_101e_all_automute(codec);
8756 if ((res >> 26) == ALC880_FRONT_EVENT)
8757 alc883_lenovo_101e_ispeaker_automute(codec);
8758}
8759
Takashi Iwai676a9b52007-08-16 15:23:35 +02008760/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008761static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008762{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008763 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008764
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008765 spec->autocfg.hp_pins[0] = 0x14;
8766 spec->autocfg.speaker_pins[0] = 0x15;
8767 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02008768}
8769
Kailang Yangd1a991a2007-08-15 16:21:59 +02008770static struct hda_verb alc883_acer_eapd_verbs[] = {
8771 /* HP Pin: output 0 (0x0c) */
8772 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8773 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8774 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8775 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008776 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8777 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008778 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008779 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8780 /* eanable EAPD on medion laptop */
8781 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8782 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008783 /* enable unsolicited event */
8784 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008785 { }
8786};
8787
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008788static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8789 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8790 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8791 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8792 { } /* end */
8793};
8794
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008795static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008796{
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] = 0x1b;
8800 spec->autocfg.speaker_pins[0] = 0x14;
8801 spec->autocfg.speaker_pins[1] = 0x15;
8802 spec->autocfg.speaker_pins[2] = 0x16;
8803 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008804}
8805
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008806static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008807{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008808 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008809
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008810 spec->autocfg.hp_pins[0] = 0x1b;
8811 spec->autocfg.speaker_pins[0] = 0x14;
8812 spec->autocfg.speaker_pins[1] = 0x15;
8813 spec->autocfg.speaker_pins[2] = 0x16;
8814 spec->autocfg.speaker_pins[3] = 0x17;
8815 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02008816}
8817
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008818static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02008819{
8820 struct alc_spec *spec = codec->spec;
8821
8822 spec->autocfg.hp_pins[0] = 0x15;
8823 spec->autocfg.speaker_pins[0] = 0x14;
8824 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02008825}
8826
Kailang Yange2757d52008-08-26 13:17:46 +02008827static struct hda_verb alc888_asus_m90v_verbs[] = {
8828 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8829 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8830 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8831 /* enable unsolicited event */
8832 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8833 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8834 { } /* end */
8835};
8836
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008837static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008838{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008839 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008840
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008841 spec->autocfg.hp_pins[0] = 0x1b;
8842 spec->autocfg.speaker_pins[0] = 0x14;
8843 spec->autocfg.speaker_pins[1] = 0x15;
8844 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008845 spec->ext_mic.pin = 0x18;
8846 spec->int_mic.pin = 0x19;
8847 spec->ext_mic.mux_idx = 0;
8848 spec->int_mic.mux_idx = 1;
8849 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02008850}
8851
8852static struct hda_verb alc888_asus_eee1601_verbs[] = {
8853 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8854 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8855 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8856 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8857 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8858 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8859 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8860 /* enable unsolicited event */
8861 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8862 { } /* end */
8863};
8864
Kailang Yange2757d52008-08-26 13:17:46 +02008865static void alc883_eee1601_inithook(struct hda_codec *codec)
8866{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008867 struct alc_spec *spec = codec->spec;
8868
8869 spec->autocfg.hp_pins[0] = 0x14;
8870 spec->autocfg.speaker_pins[0] = 0x1b;
8871 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008872}
8873
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008874static struct hda_verb alc889A_mb31_verbs[] = {
8875 /* Init rear pin (used as headphone output) */
8876 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8877 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8878 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8879 /* Init line pin (used as output in 4ch and 6ch mode) */
8880 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8881 /* Init line 2 pin (used as headphone out by default) */
8882 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8883 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8884 { } /* end */
8885};
8886
8887/* Mute speakers according to the headphone jack state */
8888static void alc889A_mb31_automute(struct hda_codec *codec)
8889{
8890 unsigned int present;
8891
8892 /* Mute only in 2ch or 4ch mode */
8893 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8894 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08008895 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008896 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8897 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8898 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8899 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8900 }
8901}
8902
8903static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8904{
8905 if ((res >> 26) == ALC880_HP_EVENT)
8906 alc889A_mb31_automute(codec);
8907}
8908
Takashi Iwai4953550a2009-06-30 15:28:30 +02008909
Takashi Iwaicb53c622007-08-10 17:21:45 +02008910#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02008911#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02008912#endif
8913
Sasha Alexandrdef319f2009-06-16 16:00:15 -04008914/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008915#define alc882_pcm_analog_playback alc880_pcm_analog_playback
8916#define alc882_pcm_analog_capture alc880_pcm_analog_capture
8917#define alc882_pcm_digital_playback alc880_pcm_digital_playback
8918#define alc882_pcm_digital_capture alc880_pcm_digital_capture
8919
8920static hda_nid_t alc883_slave_dig_outs[] = {
8921 ALC1200_DIGOUT_NID, 0,
8922};
8923
8924static hda_nid_t alc1200_slave_dig_outs[] = {
8925 ALC883_DIGOUT_NID, 0,
8926};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008927
8928/*
8929 * configuration and preset
8930 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008931static const char *alc882_models[ALC882_MODEL_LAST] = {
8932 [ALC882_3ST_DIG] = "3stack-dig",
8933 [ALC882_6ST_DIG] = "6stack-dig",
8934 [ALC882_ARIMA] = "arima",
8935 [ALC882_W2JC] = "w2jc",
8936 [ALC882_TARGA] = "targa",
8937 [ALC882_ASUS_A7J] = "asus-a7j",
8938 [ALC882_ASUS_A7M] = "asus-a7m",
8939 [ALC885_MACPRO] = "macpro",
8940 [ALC885_MB5] = "mb5",
8941 [ALC885_MBP3] = "mbp3",
8942 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008943 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008944 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008945 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8946 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008947 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008948 [ALC883_TARGA_DIG] = "targa-dig",
8949 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02008950 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008951 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008952 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008953 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02008954 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02008955 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008956 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008957 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008958 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008959 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008960 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008961 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8962 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008963 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008964 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008965 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008966 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008967 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308968 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008969 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008970 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008971 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008972 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008973 [ALC889A_INTEL] = "intel-alc889a",
8974 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008975 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008976 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02008977 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008978 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008979};
8980
Takashi Iwai4953550a2009-06-30 15:28:30 +02008981static struct snd_pci_quirk alc882_cfg_tbl[] = {
8982 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8983
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008984 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008985 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008986 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008987 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8988 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008989 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008990 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8991 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008992 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01008993 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02008994 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8995 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02008996 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
8997 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008998 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
8999 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009000 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009001 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009002 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009003 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009004 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9005 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009006 /* default Acer -- disabled as it causes more problems.
9007 * model=auto should work fine now
9008 */
9009 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009010
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009011 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009012
Tobin Davisfebe3372007-06-12 11:27:46 +02009013 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009014 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9015 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009016 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009017 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009018 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009019
9020 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9021 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9022 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009023 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009024 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9025 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9026 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009027 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009028 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009029 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009030 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009031
9032 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009033 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009034 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009035 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009036 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9037 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009038 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009039 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009040 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9041
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009042 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9043 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9044 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009045 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009046 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009047 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009048 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009049 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009050 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9051 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9052 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9053 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9054 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9055 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009056 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009057 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9058 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9059 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009060 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009061 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9062 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009063 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009064 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009065 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009066 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009067 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009068 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009069 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009070 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009071
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009072 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009073 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9074 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309075 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009076 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009077 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009078 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009079 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009080 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009081 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009082 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009083 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009084 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009085 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009086 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9087 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009088 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009089 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009090 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009091 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009092 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009093
Jiang zhe17bba1b2008-06-04 12:11:07 +02009094 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9095 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009096 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009097 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9098 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9099 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009100 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009101
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009102 {}
9103};
9104
Takashi Iwai4953550a2009-06-30 15:28:30 +02009105/* codec SSID table for Intel Mac */
9106static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9107 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9108 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9109 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9110 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9111 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9112 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9113 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
9114 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9115 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9116 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009117 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009118 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009119 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9120 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009121 */
9122 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009123 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009124 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009125};
9126
Takashi Iwai4953550a2009-06-30 15:28:30 +02009127static struct alc_config_preset alc882_presets[] = {
9128 [ALC882_3ST_DIG] = {
9129 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009130 .init_verbs = { alc882_base_init_verbs,
9131 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009132 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9133 .dac_nids = alc882_dac_nids,
9134 .dig_out_nid = ALC882_DIGOUT_NID,
9135 .dig_in_nid = ALC882_DIGIN_NID,
9136 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9137 .channel_mode = alc882_ch_modes,
9138 .need_dac_fix = 1,
9139 .input_mux = &alc882_capture_source,
9140 },
9141 [ALC882_6ST_DIG] = {
9142 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009143 .init_verbs = { alc882_base_init_verbs,
9144 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009145 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9146 .dac_nids = alc882_dac_nids,
9147 .dig_out_nid = ALC882_DIGOUT_NID,
9148 .dig_in_nid = ALC882_DIGIN_NID,
9149 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9150 .channel_mode = alc882_sixstack_modes,
9151 .input_mux = &alc882_capture_source,
9152 },
9153 [ALC882_ARIMA] = {
9154 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009155 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9156 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009157 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9158 .dac_nids = alc882_dac_nids,
9159 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9160 .channel_mode = alc882_sixstack_modes,
9161 .input_mux = &alc882_capture_source,
9162 },
9163 [ALC882_W2JC] = {
9164 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009165 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9166 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009167 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9168 .dac_nids = alc882_dac_nids,
9169 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9170 .channel_mode = alc880_threestack_modes,
9171 .need_dac_fix = 1,
9172 .input_mux = &alc882_capture_source,
9173 .dig_out_nid = ALC882_DIGOUT_NID,
9174 },
9175 [ALC885_MBP3] = {
9176 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9177 .init_verbs = { alc885_mbp3_init_verbs,
9178 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009179 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009180 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009181 .hp_nid = 0x04,
9182 .channel_mode = alc885_mbp_4ch_modes,
9183 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009184 .input_mux = &alc882_capture_source,
9185 .dig_out_nid = ALC882_DIGOUT_NID,
9186 .dig_in_nid = ALC882_DIGIN_NID,
9187 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009188 .setup = alc885_mbp3_setup,
9189 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009190 },
9191 [ALC885_MB5] = {
9192 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9193 .init_verbs = { alc885_mb5_init_verbs,
9194 alc880_gpio1_init_verbs },
9195 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9196 .dac_nids = alc882_dac_nids,
9197 .channel_mode = alc885_mb5_6ch_modes,
9198 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9199 .input_mux = &mb5_capture_source,
9200 .dig_out_nid = ALC882_DIGOUT_NID,
9201 .dig_in_nid = ALC882_DIGIN_NID,
Alex Murraya76221d2010-01-13 23:15:03 +10309202 .unsol_event = alc885_mb5_unsol_event,
9203 .init_hook = alc885_mb5_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009204 },
9205 [ALC885_MACPRO] = {
9206 .mixers = { alc882_macpro_mixer },
9207 .init_verbs = { alc882_macpro_init_verbs },
9208 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9209 .dac_nids = alc882_dac_nids,
9210 .dig_out_nid = ALC882_DIGOUT_NID,
9211 .dig_in_nid = ALC882_DIGIN_NID,
9212 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9213 .channel_mode = alc882_ch_modes,
9214 .input_mux = &alc882_capture_source,
9215 .init_hook = alc885_macpro_init_hook,
9216 },
9217 [ALC885_IMAC24] = {
9218 .mixers = { alc885_imac24_mixer },
9219 .init_verbs = { alc885_imac24_init_verbs },
9220 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9221 .dac_nids = alc882_dac_nids,
9222 .dig_out_nid = ALC882_DIGOUT_NID,
9223 .dig_in_nid = ALC882_DIGIN_NID,
9224 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9225 .channel_mode = alc882_ch_modes,
9226 .input_mux = &alc882_capture_source,
9227 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009228 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009229 .init_hook = alc885_imac24_init_hook,
9230 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009231 [ALC885_IMAC91] = {
9232 .mixers = { alc885_imac91_mixer, alc882_chmode_mixer },
9233 .init_verbs = { alc885_imac91_init_verbs,
9234 alc880_gpio1_init_verbs },
9235 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9236 .dac_nids = alc882_dac_nids,
9237 .channel_mode = alc885_mbp_4ch_modes,
9238 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
9239 .input_mux = &alc882_capture_source,
9240 .dig_out_nid = ALC882_DIGOUT_NID,
9241 .dig_in_nid = ALC882_DIGIN_NID,
9242 .unsol_event = alc885_imac91_unsol_event,
9243 .init_hook = alc885_imac91_automute,
9244 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009245 [ALC882_TARGA] = {
9246 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009247 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009248 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009249 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9250 .dac_nids = alc882_dac_nids,
9251 .dig_out_nid = ALC882_DIGOUT_NID,
9252 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9253 .adc_nids = alc882_adc_nids,
9254 .capsrc_nids = alc882_capsrc_nids,
9255 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9256 .channel_mode = alc882_3ST_6ch_modes,
9257 .need_dac_fix = 1,
9258 .input_mux = &alc882_capture_source,
9259 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009260 .setup = alc882_targa_setup,
9261 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009262 },
9263 [ALC882_ASUS_A7J] = {
9264 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009265 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9266 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009267 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9268 .dac_nids = alc882_dac_nids,
9269 .dig_out_nid = ALC882_DIGOUT_NID,
9270 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9271 .adc_nids = alc882_adc_nids,
9272 .capsrc_nids = alc882_capsrc_nids,
9273 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9274 .channel_mode = alc882_3ST_6ch_modes,
9275 .need_dac_fix = 1,
9276 .input_mux = &alc882_capture_source,
9277 },
9278 [ALC882_ASUS_A7M] = {
9279 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009280 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9281 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009282 alc882_asus_a7m_verbs },
9283 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9284 .dac_nids = alc882_dac_nids,
9285 .dig_out_nid = ALC882_DIGOUT_NID,
9286 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9287 .channel_mode = alc880_threestack_modes,
9288 .need_dac_fix = 1,
9289 .input_mux = &alc882_capture_source,
9290 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009291 [ALC883_3ST_2ch_DIG] = {
9292 .mixers = { alc883_3ST_2ch_mixer },
9293 .init_verbs = { alc883_init_verbs },
9294 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9295 .dac_nids = alc883_dac_nids,
9296 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009297 .dig_in_nid = ALC883_DIGIN_NID,
9298 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9299 .channel_mode = alc883_3ST_2ch_modes,
9300 .input_mux = &alc883_capture_source,
9301 },
9302 [ALC883_3ST_6ch_DIG] = {
9303 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9304 .init_verbs = { alc883_init_verbs },
9305 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9306 .dac_nids = alc883_dac_nids,
9307 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009308 .dig_in_nid = ALC883_DIGIN_NID,
9309 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9310 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009311 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009312 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009313 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009314 [ALC883_3ST_6ch] = {
9315 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9316 .init_verbs = { alc883_init_verbs },
9317 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9318 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009319 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9320 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009321 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009322 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009323 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009324 [ALC883_3ST_6ch_INTEL] = {
9325 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9326 .init_verbs = { alc883_init_verbs },
9327 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9328 .dac_nids = alc883_dac_nids,
9329 .dig_out_nid = ALC883_DIGOUT_NID,
9330 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009331 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009332 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9333 .channel_mode = alc883_3ST_6ch_intel_modes,
9334 .need_dac_fix = 1,
9335 .input_mux = &alc883_3stack_6ch_intel,
9336 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009337 [ALC889A_INTEL] = {
9338 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009339 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9340 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009341 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9342 .dac_nids = alc883_dac_nids,
9343 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9344 .adc_nids = alc889_adc_nids,
9345 .dig_out_nid = ALC883_DIGOUT_NID,
9346 .dig_in_nid = ALC883_DIGIN_NID,
9347 .slave_dig_outs = alc883_slave_dig_outs,
9348 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9349 .channel_mode = alc889_8ch_intel_modes,
9350 .capsrc_nids = alc889_capsrc_nids,
9351 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009352 .setup = alc889_automute_setup,
9353 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009354 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009355 .need_dac_fix = 1,
9356 },
9357 [ALC889_INTEL] = {
9358 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9359 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009360 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009361 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9362 .dac_nids = alc883_dac_nids,
9363 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9364 .adc_nids = alc889_adc_nids,
9365 .dig_out_nid = ALC883_DIGOUT_NID,
9366 .dig_in_nid = ALC883_DIGIN_NID,
9367 .slave_dig_outs = alc883_slave_dig_outs,
9368 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9369 .channel_mode = alc889_8ch_intel_modes,
9370 .capsrc_nids = alc889_capsrc_nids,
9371 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009372 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009373 .init_hook = alc889_intel_init_hook,
9374 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009375 .need_dac_fix = 1,
9376 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009377 [ALC883_6ST_DIG] = {
9378 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9379 .init_verbs = { alc883_init_verbs },
9380 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9381 .dac_nids = alc883_dac_nids,
9382 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009383 .dig_in_nid = ALC883_DIGIN_NID,
9384 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9385 .channel_mode = alc883_sixstack_modes,
9386 .input_mux = &alc883_capture_source,
9387 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009388 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009389 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009390 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9391 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009392 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9393 .dac_nids = alc883_dac_nids,
9394 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009395 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9396 .channel_mode = alc883_3ST_6ch_modes,
9397 .need_dac_fix = 1,
9398 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009399 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009400 .setup = alc882_targa_setup,
9401 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009402 },
9403 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009404 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009405 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9406 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009407 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9408 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009409 .adc_nids = alc883_adc_nids_alt,
9410 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009411 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +02009412 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009413 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9414 .channel_mode = alc883_3ST_2ch_modes,
9415 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009416 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009417 .setup = alc882_targa_setup,
9418 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009419 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009420 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009421 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9422 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +02009423 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009424 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009425 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9426 .dac_nids = alc883_dac_nids,
9427 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9428 .adc_nids = alc883_adc_nids_rev,
9429 .capsrc_nids = alc883_capsrc_nids_rev,
9430 .dig_out_nid = ALC883_DIGOUT_NID,
9431 .dig_in_nid = ALC883_DIGIN_NID,
9432 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9433 .channel_mode = alc883_4ST_8ch_modes,
9434 .need_dac_fix = 1,
9435 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009436 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009437 .setup = alc882_targa_setup,
9438 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009439 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009440 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009441 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009442 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9443 * and the headphone jack. Turn this on and rely on the
9444 * standard mute methods whenever the user wants to turn
9445 * these outputs off.
9446 */
9447 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9448 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9449 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009450 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9451 .channel_mode = alc883_3ST_2ch_modes,
9452 .input_mux = &alc883_capture_source,
9453 },
Tobin Davis2880a862007-08-07 11:50:26 +02009454 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009455 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009456 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009457 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9458 .dac_nids = alc883_dac_nids,
9459 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009460 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9461 .channel_mode = alc883_3ST_2ch_modes,
9462 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009463 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009464 .setup = alc883_acer_aspire_setup,
9465 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009466 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009467 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009468 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009469 alc883_chmode_mixer },
9470 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9471 alc888_acer_aspire_4930g_verbs },
9472 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9473 .dac_nids = alc883_dac_nids,
9474 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9475 .adc_nids = alc883_adc_nids_rev,
9476 .capsrc_nids = alc883_capsrc_nids_rev,
9477 .dig_out_nid = ALC883_DIGOUT_NID,
9478 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9479 .channel_mode = alc883_3ST_6ch_modes,
9480 .need_dac_fix = 1,
9481 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009482 ARRAY_SIZE(alc888_2_capture_sources),
9483 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009484 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009485 .setup = alc888_acer_aspire_4930g_setup,
9486 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009487 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009488 [ALC888_ACER_ASPIRE_6530G] = {
9489 .mixers = { alc888_acer_aspire_6530_mixer },
9490 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9491 alc888_acer_aspire_6530g_verbs },
9492 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9493 .dac_nids = alc883_dac_nids,
9494 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9495 .adc_nids = alc883_adc_nids_rev,
9496 .capsrc_nids = alc883_capsrc_nids_rev,
9497 .dig_out_nid = ALC883_DIGOUT_NID,
9498 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9499 .channel_mode = alc883_3ST_2ch_modes,
9500 .num_mux_defs =
9501 ARRAY_SIZE(alc888_2_capture_sources),
9502 .input_mux = alc888_acer_aspire_6530_sources,
9503 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009504 .setup = alc888_acer_aspire_6530g_setup,
9505 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009506 },
Hector Martin3b315d72009-06-02 10:54:19 +02009507 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +01009508 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +02009509 alc883_chmode_mixer },
9510 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +01009511 alc889_acer_aspire_8930g_verbs,
9512 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +02009513 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9514 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009515 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9516 .adc_nids = alc889_adc_nids,
9517 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009518 .dig_out_nid = ALC883_DIGOUT_NID,
9519 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9520 .channel_mode = alc883_3ST_6ch_modes,
9521 .need_dac_fix = 1,
9522 .const_channel_count = 6,
9523 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009524 ARRAY_SIZE(alc889_capture_sources),
9525 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009526 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009527 .setup = alc889_acer_aspire_8930g_setup,
9528 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +01009529#ifdef CONFIG_SND_HDA_POWER_SAVE
9530 .power_hook = alc889_power_eapd,
9531#endif
Hector Martin3b315d72009-06-02 10:54:19 +02009532 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009533 [ALC888_ACER_ASPIRE_7730G] = {
9534 .mixers = { alc883_3ST_6ch_mixer,
9535 alc883_chmode_mixer },
9536 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9537 alc888_acer_aspire_7730G_verbs },
9538 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9539 .dac_nids = alc883_dac_nids,
9540 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9541 .adc_nids = alc883_adc_nids_rev,
9542 .capsrc_nids = alc883_capsrc_nids_rev,
9543 .dig_out_nid = ALC883_DIGOUT_NID,
9544 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9545 .channel_mode = alc883_3ST_6ch_modes,
9546 .need_dac_fix = 1,
9547 .const_channel_count = 6,
9548 .input_mux = &alc883_capture_source,
9549 .unsol_event = alc_automute_amp_unsol_event,
9550 .setup = alc888_acer_aspire_6530g_setup,
9551 .init_hook = alc_automute_amp,
9552 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009553 [ALC883_MEDION] = {
9554 .mixers = { alc883_fivestack_mixer,
9555 alc883_chmode_mixer },
9556 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009557 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009558 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9559 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009560 .adc_nids = alc883_adc_nids_alt,
9561 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009562 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02009563 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9564 .channel_mode = alc883_sixstack_modes,
9565 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009566 },
Kailang Yang272a5272007-05-14 11:00:38 +02009567 [ALC883_MEDION_MD2] = {
9568 .mixers = { alc883_medion_md2_mixer},
9569 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9570 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9571 .dac_nids = alc883_dac_nids,
9572 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009573 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9574 .channel_mode = alc883_3ST_2ch_modes,
9575 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009576 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009577 .setup = alc883_medion_md2_setup,
9578 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009579 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009580 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009581 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009582 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9583 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9584 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009585 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9586 .channel_mode = alc883_3ST_2ch_modes,
9587 .input_mux = &alc883_capture_source,
9588 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309589 [ALC883_CLEVO_M540R] = {
9590 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9591 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9592 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9593 .dac_nids = alc883_dac_nids,
9594 .dig_out_nid = ALC883_DIGOUT_NID,
9595 .dig_in_nid = ALC883_DIGIN_NID,
9596 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9597 .channel_mode = alc883_3ST_6ch_clevo_modes,
9598 .need_dac_fix = 1,
9599 .input_mux = &alc883_capture_source,
9600 /* This machine has the hardware HP auto-muting, thus
9601 * we need no software mute via unsol event
9602 */
9603 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009604 [ALC883_CLEVO_M720] = {
9605 .mixers = { alc883_clevo_m720_mixer },
9606 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009607 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9608 .dac_nids = alc883_dac_nids,
9609 .dig_out_nid = ALC883_DIGOUT_NID,
9610 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9611 .channel_mode = alc883_3ST_2ch_modes,
9612 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009613 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009614 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009615 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009616 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009617 [ALC883_LENOVO_101E_2ch] = {
9618 .mixers = { alc883_lenovo_101e_2ch_mixer},
9619 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9620 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9621 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009622 .adc_nids = alc883_adc_nids_alt,
9623 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009624 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009625 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9626 .channel_mode = alc883_3ST_2ch_modes,
9627 .input_mux = &alc883_lenovo_101e_capture_source,
9628 .unsol_event = alc883_lenovo_101e_unsol_event,
9629 .init_hook = alc883_lenovo_101e_all_automute,
9630 },
Kailang Yang272a5272007-05-14 11:00:38 +02009631 [ALC883_LENOVO_NB0763] = {
9632 .mixers = { alc883_lenovo_nb0763_mixer },
9633 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9634 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9635 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009636 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9637 .channel_mode = alc883_3ST_2ch_modes,
9638 .need_dac_fix = 1,
9639 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009640 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009641 .setup = alc883_medion_md2_setup,
9642 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009643 },
9644 [ALC888_LENOVO_MS7195_DIG] = {
9645 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9646 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9647 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9648 .dac_nids = alc883_dac_nids,
9649 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009650 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9651 .channel_mode = alc883_3ST_6ch_modes,
9652 .need_dac_fix = 1,
9653 .input_mux = &alc883_capture_source,
9654 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9655 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009656 },
9657 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009658 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009659 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9660 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9661 .dac_nids = alc883_dac_nids,
9662 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009663 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9664 .channel_mode = alc883_3ST_2ch_modes,
9665 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009666 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009667 .setup = alc883_haier_w66_setup,
9668 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009669 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009670 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009671 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009672 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009673 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9674 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009675 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9676 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009677 .need_dac_fix = 1,
9678 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009679 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009680 .setup = alc888_3st_hp_setup,
9681 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009682 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009683 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009684 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009685 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9686 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9687 .dac_nids = alc883_dac_nids,
9688 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009689 .dig_in_nid = ALC883_DIGIN_NID,
9690 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9691 .channel_mode = alc883_sixstack_modes,
9692 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009693 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009694 .setup = alc888_6st_dell_setup,
9695 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009696 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009697 [ALC883_MITAC] = {
9698 .mixers = { alc883_mitac_mixer },
9699 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9700 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9701 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009702 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9703 .channel_mode = alc883_3ST_2ch_modes,
9704 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009705 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009706 .setup = alc883_mitac_setup,
9707 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009708 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009709 [ALC883_FUJITSU_PI2515] = {
9710 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9711 .init_verbs = { alc883_init_verbs,
9712 alc883_2ch_fujitsu_pi2515_verbs},
9713 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9714 .dac_nids = alc883_dac_nids,
9715 .dig_out_nid = ALC883_DIGOUT_NID,
9716 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9717 .channel_mode = alc883_3ST_2ch_modes,
9718 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009719 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009720 .setup = alc883_2ch_fujitsu_pi2515_setup,
9721 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +01009722 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009723 [ALC888_FUJITSU_XA3530] = {
9724 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9725 .init_verbs = { alc883_init_verbs,
9726 alc888_fujitsu_xa3530_verbs },
9727 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9728 .dac_nids = alc883_dac_nids,
9729 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9730 .adc_nids = alc883_adc_nids_rev,
9731 .capsrc_nids = alc883_capsrc_nids_rev,
9732 .dig_out_nid = ALC883_DIGOUT_NID,
9733 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9734 .channel_mode = alc888_4ST_8ch_intel_modes,
9735 .num_mux_defs =
9736 ARRAY_SIZE(alc888_2_capture_sources),
9737 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009738 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009739 .setup = alc888_fujitsu_xa3530_setup,
9740 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009741 },
Kailang Yange2757d52008-08-26 13:17:46 +02009742 [ALC888_LENOVO_SKY] = {
9743 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9744 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9745 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9746 .dac_nids = alc883_dac_nids,
9747 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009748 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9749 .channel_mode = alc883_sixstack_modes,
9750 .need_dac_fix = 1,
9751 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009752 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009753 .setup = alc888_lenovo_sky_setup,
9754 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +02009755 },
9756 [ALC888_ASUS_M90V] = {
9757 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9758 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9759 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9760 .dac_nids = alc883_dac_nids,
9761 .dig_out_nid = ALC883_DIGOUT_NID,
9762 .dig_in_nid = ALC883_DIGIN_NID,
9763 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9764 .channel_mode = alc883_3ST_6ch_modes,
9765 .need_dac_fix = 1,
9766 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009767 .unsol_event = alc_sku_unsol_event,
9768 .setup = alc883_mode2_setup,
9769 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +02009770 },
9771 [ALC888_ASUS_EEE1601] = {
9772 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009773 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009774 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9775 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9776 .dac_nids = alc883_dac_nids,
9777 .dig_out_nid = ALC883_DIGOUT_NID,
9778 .dig_in_nid = ALC883_DIGIN_NID,
9779 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9780 .channel_mode = alc883_3ST_2ch_modes,
9781 .need_dac_fix = 1,
9782 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009783 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009784 .init_hook = alc883_eee1601_inithook,
9785 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009786 [ALC1200_ASUS_P5Q] = {
9787 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9788 .init_verbs = { alc883_init_verbs },
9789 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9790 .dac_nids = alc883_dac_nids,
9791 .dig_out_nid = ALC1200_DIGOUT_NID,
9792 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009793 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009794 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9795 .channel_mode = alc883_sixstack_modes,
9796 .input_mux = &alc883_capture_source,
9797 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009798 [ALC889A_MB31] = {
9799 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9800 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9801 alc880_gpio1_init_verbs },
9802 .adc_nids = alc883_adc_nids,
9803 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009804 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009805 .dac_nids = alc883_dac_nids,
9806 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9807 .channel_mode = alc889A_mb31_6ch_modes,
9808 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9809 .input_mux = &alc889A_mb31_capture_source,
9810 .dig_out_nid = ALC883_DIGOUT_NID,
9811 .unsol_event = alc889A_mb31_unsol_event,
9812 .init_hook = alc889A_mb31_automute,
9813 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009814 [ALC883_SONY_VAIO_TT] = {
9815 .mixers = { alc883_vaiott_mixer },
9816 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9817 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9818 .dac_nids = alc883_dac_nids,
9819 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9820 .channel_mode = alc883_3ST_2ch_modes,
9821 .input_mux = &alc883_capture_source,
9822 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009823 .setup = alc883_vaiott_setup,
9824 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +02009825 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009826};
9827
9828
9829/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02009830 * Pin config fixes
9831 */
9832enum {
9833 PINFIX_ABIT_AW9D_MAX
9834};
9835
9836static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9837 { 0x15, 0x01080104 }, /* side */
9838 { 0x16, 0x01011012 }, /* rear */
9839 { 0x17, 0x01016011 }, /* clfe */
9840 { }
9841};
9842
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009843static const struct alc_fixup alc882_fixups[] = {
9844 [PINFIX_ABIT_AW9D_MAX] = {
9845 .pins = alc882_abit_aw9d_pinfix
9846 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009847};
9848
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009849static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009850 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9851 {}
9852};
9853
9854/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009855 * BIOS auto configuration
9856 */
Takashi Iwai05f5f472009-08-25 13:10:18 +02009857static int alc882_auto_create_input_ctls(struct hda_codec *codec,
9858 const struct auto_pin_cfg *cfg)
9859{
9860 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
9861}
9862
Takashi Iwai4953550a2009-06-30 15:28:30 +02009863static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009864 hda_nid_t nid, int pin_type,
9865 int dac_idx)
9866{
9867 /* set as output */
9868 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009869 int idx;
9870
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009871 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009872 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9873 idx = 4;
9874 else
9875 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009876 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9877
9878}
9879
Takashi Iwai4953550a2009-06-30 15:28:30 +02009880static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009881{
9882 struct alc_spec *spec = codec->spec;
9883 int i;
9884
9885 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009886 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009887 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009888 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009889 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009890 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009891 }
9892}
9893
Takashi Iwai4953550a2009-06-30 15:28:30 +02009894static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009895{
9896 struct alc_spec *spec = codec->spec;
9897 hda_nid_t pin;
9898
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009899 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009900 if (pin) /* connect to front */
9901 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009902 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009903 pin = spec->autocfg.speaker_pins[0];
9904 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009905 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009906}
9907
Takashi Iwai4953550a2009-06-30 15:28:30 +02009908static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009909{
9910 struct alc_spec *spec = codec->spec;
9911 int i;
9912
9913 for (i = 0; i < AUTO_PIN_LAST; i++) {
9914 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +02009915 if (!nid)
9916 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +02009917 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009918 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9919 snd_hda_codec_write(codec, nid, 0,
9920 AC_VERB_SET_AMP_GAIN_MUTE,
9921 AMP_OUT_MUTE);
9922 }
9923}
9924
9925static void alc882_auto_init_input_src(struct hda_codec *codec)
9926{
9927 struct alc_spec *spec = codec->spec;
9928 int c;
9929
9930 for (c = 0; c < spec->num_adc_nids; c++) {
9931 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9932 hda_nid_t nid = spec->capsrc_nids[c];
9933 unsigned int mux_idx;
9934 const struct hda_input_mux *imux;
9935 int conns, mute, idx, item;
9936
9937 conns = snd_hda_get_connections(codec, nid, conn_list,
9938 ARRAY_SIZE(conn_list));
9939 if (conns < 0)
9940 continue;
9941 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9942 imux = &spec->input_mux[mux_idx];
9943 for (idx = 0; idx < conns; idx++) {
9944 /* if the current connection is the selected one,
9945 * unmute it as default - otherwise mute it
9946 */
9947 mute = AMP_IN_MUTE(idx);
9948 for (item = 0; item < imux->num_items; item++) {
9949 if (imux->items[item].index == idx) {
9950 if (spec->cur_mux[c] == item)
9951 mute = AMP_IN_UNMUTE(idx);
9952 break;
9953 }
9954 }
9955 /* check if we have a selector or mixer
9956 * we could check for the widget type instead, but
9957 * just check for Amp-In presence (in case of mixer
9958 * without amp-in there is something wrong, this
9959 * function shouldn't be used or capsrc nid is wrong)
9960 */
9961 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009962 snd_hda_codec_write(codec, nid, 0,
9963 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009964 mute);
9965 else if (mute != AMP_IN_MUTE(idx))
9966 snd_hda_codec_write(codec, nid, 0,
9967 AC_VERB_SET_CONNECT_SEL,
9968 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009969 }
9970 }
9971}
9972
Takashi Iwai4953550a2009-06-30 15:28:30 +02009973/* add mic boosts if needed */
9974static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009975{
9976 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009977 int err;
9978 hda_nid_t nid;
9979
9980 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9981 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9982 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9983 "Mic Boost",
9984 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9985 if (err < 0)
9986 return err;
9987 }
9988 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9989 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9990 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9991 "Front Mic Boost",
9992 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9993 if (err < 0)
9994 return err;
9995 }
9996 return 0;
9997}
9998
9999/* almost identical with ALC880 parser... */
10000static int alc882_parse_auto_config(struct hda_codec *codec)
10001{
10002 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010003 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
10004 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010005
Takashi Iwai05f5f472009-08-25 13:10:18 +020010006 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10007 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010008 if (err < 0)
10009 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010010 if (!spec->autocfg.line_outs)
10011 return 0; /* can't find valid BIOS pin config */
10012
10013 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10014 if (err < 0)
10015 return err;
10016 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10017 if (err < 0)
10018 return err;
10019 err = alc880_auto_create_extra_out(spec,
10020 spec->autocfg.speaker_pins[0],
10021 "Speaker");
10022 if (err < 0)
10023 return err;
10024 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10025 "Headphone");
10026 if (err < 0)
10027 return err;
10028 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10029 if (err < 0)
10030 return err;
10031
10032 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10033
10034 /* check multiple SPDIF-out (for recent codecs) */
10035 for (i = 0; i < spec->autocfg.dig_outs; i++) {
10036 hda_nid_t dig_nid;
10037 err = snd_hda_get_connections(codec,
10038 spec->autocfg.dig_out_pins[i],
10039 &dig_nid, 1);
10040 if (err < 0)
10041 continue;
10042 if (!i)
10043 spec->multiout.dig_out_nid = dig_nid;
10044 else {
10045 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010046 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai05f5f472009-08-25 13:10:18 +020010047 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010048 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010049 }
10050 }
10051 if (spec->autocfg.dig_in_pin)
10052 spec->dig_in_nid = ALC880_DIGIN_NID;
10053
10054 if (spec->kctls.list)
10055 add_mixer(spec, spec->kctls.list);
10056
10057 add_verb(spec, alc883_auto_init_verbs);
10058 /* if ADC 0x07 is available, initialize it, too */
10059 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10060 add_verb(spec, alc882_adc1_init_verbs);
10061
10062 spec->num_mux_defs = 1;
10063 spec->input_mux = &spec->private_imux[0];
10064
10065 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
Takashi Iwai776e1842007-08-29 15:07:11 +020010066
10067 err = alc_auto_add_mic_boost(codec);
10068 if (err < 0)
10069 return err;
10070
Takashi Iwai776e1842007-08-29 15:07:11 +020010071 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010072}
10073
10074/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010075static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010076{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010077 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010078 alc882_auto_init_multi_out(codec);
10079 alc882_auto_init_hp_out(codec);
10080 alc882_auto_init_analog_input(codec);
10081 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010082 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010083 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010084}
10085
Takashi Iwai4953550a2009-06-30 15:28:30 +020010086static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010087{
10088 struct alc_spec *spec;
10089 int err, board_config;
10090
10091 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10092 if (spec == NULL)
10093 return -ENOMEM;
10094
10095 codec->spec = spec;
10096
Takashi Iwai4953550a2009-06-30 15:28:30 +020010097 switch (codec->vendor_id) {
10098 case 0x10ec0882:
10099 case 0x10ec0885:
10100 break;
10101 default:
10102 /* ALC883 and variants */
10103 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10104 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010105 }
10106
Takashi Iwai4953550a2009-06-30 15:28:30 +020010107 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10108 alc882_models,
10109 alc882_cfg_tbl);
10110
10111 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10112 board_config = snd_hda_check_board_codec_sid_config(codec,
10113 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10114
10115 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010116 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010117 codec->chip_name);
10118 board_config = ALC882_AUTO;
10119 }
10120
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010121 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010122
10123 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010124 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010125 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010126 if (err < 0) {
10127 alc_free(codec);
10128 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010129 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010130 printk(KERN_INFO
10131 "hda_codec: Cannot set up configuration "
10132 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010133 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010134 }
10135 }
10136
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010137 err = snd_hda_attach_beep_device(codec, 0x1);
10138 if (err < 0) {
10139 alc_free(codec);
10140 return err;
10141 }
10142
Takashi Iwai4953550a2009-06-30 15:28:30 +020010143 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010144 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010145
Takashi Iwai4953550a2009-06-30 15:28:30 +020010146 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10147 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10148 /* FIXME: setup DAC5 */
10149 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10150 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10151
10152 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10153 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10154
10155 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010156 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010157
10158 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010159 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010160 spec->num_adc_nids = 0;
10161 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010162 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010163 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010164 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010165 hda_nid_t nid = alc882_adc_nids[i];
10166 unsigned int wcap = get_wcaps(codec, nid);
10167 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010168 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010169 if (wcap != AC_WID_AUD_IN)
10170 continue;
10171 spec->private_adc_nids[spec->num_adc_nids] = nid;
10172 err = snd_hda_get_connections(codec, nid, &cap, 1);
10173 if (err < 0)
10174 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010175 err = snd_hda_get_connections(codec, cap, items,
10176 ARRAY_SIZE(items));
10177 if (err < 0)
10178 continue;
10179 for (j = 0; j < imux->num_items; j++)
10180 if (imux->items[j].index >= err)
10181 break;
10182 if (j < imux->num_items)
10183 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010184 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10185 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010186 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010187 spec->adc_nids = spec->private_adc_nids;
10188 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010189 }
10190
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010191 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010010192 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010193
Takashi Iwai2134ea42008-01-10 16:53:55 +010010194 spec->vmaster_nid = 0x0c;
10195
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010196 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010197 if (board_config == ALC882_AUTO)
10198 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010199#ifdef CONFIG_SND_HDA_POWER_SAVE
10200 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010201 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010202#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010010203 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010204
10205 return 0;
10206}
10207
Takashi Iwai4953550a2009-06-30 15:28:30 +020010208
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010209/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010210 * ALC262 support
10211 */
10212
10213#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10214#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10215
10216#define alc262_dac_nids alc260_dac_nids
10217#define alc262_adc_nids alc882_adc_nids
10218#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010219#define alc262_capsrc_nids alc882_capsrc_nids
10220#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010221
10222#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010223#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010224
Kailang Yang4e555fe2008-08-26 13:05:55 +020010225static hda_nid_t alc262_dmic_adc_nids[1] = {
10226 /* ADC0 */
10227 0x09
10228};
10229
10230static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10231
Kailang Yangdf694da2005-12-05 19:42:22 +010010232static struct snd_kcontrol_new alc262_base_mixer[] = {
10233 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10234 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10235 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10236 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10237 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10238 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10239 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10240 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010241 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010242 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10243 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010244 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010245 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10246 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10247 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10248 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010249 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010250};
10251
Takashi Iwaice875f02008-01-28 18:17:43 +010010252/* update HP, line and mono-out pins according to the master switch */
10253static void alc262_hp_master_update(struct hda_codec *codec)
10254{
10255 struct alc_spec *spec = codec->spec;
10256 int val = spec->master_sw;
10257
10258 /* HP & line-out */
10259 snd_hda_codec_write_cache(codec, 0x1b, 0,
10260 AC_VERB_SET_PIN_WIDGET_CONTROL,
10261 val ? PIN_HP : 0);
10262 snd_hda_codec_write_cache(codec, 0x15, 0,
10263 AC_VERB_SET_PIN_WIDGET_CONTROL,
10264 val ? PIN_HP : 0);
10265 /* mono (speaker) depending on the HP jack sense */
10266 val = val && !spec->jack_present;
10267 snd_hda_codec_write_cache(codec, 0x16, 0,
10268 AC_VERB_SET_PIN_WIDGET_CONTROL,
10269 val ? PIN_OUT : 0);
10270}
10271
10272static void alc262_hp_bpc_automute(struct hda_codec *codec)
10273{
10274 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010275
10276 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010277 alc262_hp_master_update(codec);
10278}
10279
10280static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10281{
10282 if ((res >> 26) != ALC880_HP_EVENT)
10283 return;
10284 alc262_hp_bpc_automute(codec);
10285}
10286
10287static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10288{
10289 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010290
10291 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010292 alc262_hp_master_update(codec);
10293}
10294
10295static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10296 unsigned int res)
10297{
10298 if ((res >> 26) != ALC880_HP_EVENT)
10299 return;
10300 alc262_hp_wildwest_automute(codec);
10301}
10302
Takashi Iwaib72519b2009-05-08 14:31:55 +020010303#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010304
10305static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10306 struct snd_ctl_elem_value *ucontrol)
10307{
10308 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10309 struct alc_spec *spec = codec->spec;
10310 int val = !!*ucontrol->value.integer.value;
10311
10312 if (val == spec->master_sw)
10313 return 0;
10314 spec->master_sw = val;
10315 alc262_hp_master_update(codec);
10316 return 1;
10317}
10318
Takashi Iwaib72519b2009-05-08 14:31:55 +020010319#define ALC262_HP_MASTER_SWITCH \
10320 { \
10321 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10322 .name = "Master Playback Switch", \
10323 .info = snd_ctl_boolean_mono_info, \
10324 .get = alc262_hp_master_sw_get, \
10325 .put = alc262_hp_master_sw_put, \
10326 }
10327
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010328static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010329 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010330 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10331 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10332 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010333 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10334 HDA_OUTPUT),
10335 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10336 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010337 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10338 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010339 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010340 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10341 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010342 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010343 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10344 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10345 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10346 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010347 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10348 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10349 { } /* end */
10350};
10351
Kailang Yangcd7509a2007-01-26 18:33:17 +010010352static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010353 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010354 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10355 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10356 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10357 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010358 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10359 HDA_OUTPUT),
10360 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10361 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010362 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10363 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010364 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010365 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10366 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10367 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10368 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010369 { } /* end */
10370};
10371
10372static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10373 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10374 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010375 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010376 { } /* end */
10377};
10378
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010379/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010380static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010381{
10382 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010383
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010384 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010010385 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010386}
10387
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010388static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010389 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10390 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010391 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10392 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10393 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10394 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10395 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10396 { } /* end */
10397};
10398
10399static struct hda_verb alc262_hp_t5735_verbs[] = {
10400 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10401 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10402
10403 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10404 { }
10405};
10406
Kailang Yang8c427222008-01-10 13:03:59 +010010407static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010408 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10409 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010410 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10411 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010412 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10413 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10414 { } /* end */
10415};
10416
10417static struct hda_verb alc262_hp_rp5700_verbs[] = {
10418 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10419 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10420 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10421 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10422 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10423 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10424 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10425 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10426 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10427 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10428 {}
10429};
10430
10431static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10432 .num_items = 1,
10433 .items = {
10434 { "Line", 0x1 },
10435 },
10436};
10437
Takashi Iwai42171c12009-05-08 14:11:43 +020010438/* bind hp and internal speaker mute (with plug check) as master switch */
10439static void alc262_hippo_master_update(struct hda_codec *codec)
10440{
10441 struct alc_spec *spec = codec->spec;
10442 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10443 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10444 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10445 unsigned int mute;
10446
10447 /* HP */
10448 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10449 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10450 HDA_AMP_MUTE, mute);
10451 /* mute internal speaker per jack sense */
10452 if (spec->jack_present)
10453 mute = HDA_AMP_MUTE;
10454 if (line_nid)
10455 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10456 HDA_AMP_MUTE, mute);
10457 if (speaker_nid && speaker_nid != line_nid)
10458 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10459 HDA_AMP_MUTE, mute);
10460}
10461
10462#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10463
10464static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10465 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010466{
10467 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010468 struct alc_spec *spec = codec->spec;
10469 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010470
Takashi Iwai42171c12009-05-08 14:11:43 +020010471 if (val == spec->master_sw)
10472 return 0;
10473 spec->master_sw = val;
10474 alc262_hippo_master_update(codec);
10475 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010476}
Takashi Iwai5b319542007-07-26 11:49:22 +020010477
Takashi Iwai42171c12009-05-08 14:11:43 +020010478#define ALC262_HIPPO_MASTER_SWITCH \
10479 { \
10480 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10481 .name = "Master Playback Switch", \
10482 .info = snd_ctl_boolean_mono_info, \
10483 .get = alc262_hippo_master_sw_get, \
10484 .put = alc262_hippo_master_sw_put, \
10485 }
10486
10487static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10488 ALC262_HIPPO_MASTER_SWITCH,
10489 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10490 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10491 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10492 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10493 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10494 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10495 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10496 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10497 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10498 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10499 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10500 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10501 { } /* end */
10502};
10503
10504static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10505 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10506 ALC262_HIPPO_MASTER_SWITCH,
10507 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10508 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10509 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10510 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10511 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10512 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10513 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10514 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10515 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10516 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10517 { } /* end */
10518};
10519
10520/* mute/unmute internal speaker according to the hp jack and mute state */
10521static void alc262_hippo_automute(struct hda_codec *codec)
10522{
10523 struct alc_spec *spec = codec->spec;
10524 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020010525
Wu Fengguang864f92b2009-11-18 12:38:02 +080010526 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020010527 alc262_hippo_master_update(codec);
10528}
10529
10530static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10531{
10532 if ((res >> 26) != ALC880_HP_EVENT)
10533 return;
10534 alc262_hippo_automute(codec);
10535}
10536
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010537static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010538{
10539 struct alc_spec *spec = codec->spec;
10540
10541 spec->autocfg.hp_pins[0] = 0x15;
10542 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010543}
10544
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010545static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010546{
10547 struct alc_spec *spec = codec->spec;
10548
10549 spec->autocfg.hp_pins[0] = 0x1b;
10550 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010551}
10552
10553
Kailang Yang272a5272007-05-14 11:00:38 +020010554static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010555 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010556 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010557 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10558 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10559 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10560 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10561 { } /* end */
10562};
10563
Kailang Yang83c34212007-07-05 11:43:05 +020010564static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010565 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10566 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010567 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10568 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10569 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10570 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10571 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10572 { } /* end */
10573};
Kailang Yang272a5272007-05-14 11:00:38 +020010574
Tony Vroonba340e82009-02-02 19:01:30 +000010575static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10576 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10577 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10578 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10579 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10580 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10581 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10582 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10583 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10584 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10585 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10586 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10587 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10588 { } /* end */
10589};
10590
10591static struct hda_verb alc262_tyan_verbs[] = {
10592 /* Headphone automute */
10593 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10594 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10595 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10596
10597 /* P11 AUX_IN, white 4-pin connector */
10598 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10599 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10600 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10601 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10602
10603 {}
10604};
10605
10606/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010607static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010608{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010609 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010610
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010611 spec->autocfg.hp_pins[0] = 0x1b;
10612 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010613}
10614
Tony Vroonba340e82009-02-02 19:01:30 +000010615
Kailang Yangdf694da2005-12-05 19:42:22 +010010616#define alc262_capture_mixer alc882_capture_mixer
10617#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10618
10619/*
10620 * generic initialization of ADC, input mixers and output mixers
10621 */
10622static struct hda_verb alc262_init_verbs[] = {
10623 /*
10624 * Unmute ADC0-2 and set the default input to mic-in
10625 */
10626 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10627 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10628 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10629 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10630 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10631 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10632
Takashi Iwaicb53c622007-08-10 17:21:45 +020010633 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010634 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010635 * Note: PASD motherboards uses the Line In 2 as the input for
10636 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010637 */
10638 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010639 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010644
10645 /*
10646 * Set up output mixers (0x0c - 0x0e)
10647 */
10648 /* set vol=0 to output mixers */
10649 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10650 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10651 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10652 /* set up input amps for analog loopback */
10653 /* Amp Indices: DAC = 0, mixer = 1 */
10654 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10655 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10656 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10657 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10658 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10659 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10660
10661 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10662 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10663 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10664 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10665 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10666 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10667
10668 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10669 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10670 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10671 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10672 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010673
Kailang Yangdf694da2005-12-05 19:42:22 +010010674 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10675 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010676
Kailang Yangdf694da2005-12-05 19:42:22 +010010677 /* FIXME: use matrix-type input source selection */
10678 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10679 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10680 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10681 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10682 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10683 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10684 /* Input mixer2 */
10685 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10686 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10687 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10688 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10689 /* Input mixer3 */
10690 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10691 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10692 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010693 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010694
10695 { }
10696};
10697
Kailang Yang4e555fe2008-08-26 13:05:55 +020010698static struct hda_verb alc262_eapd_verbs[] = {
10699 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10700 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10701 { }
10702};
10703
Kailang Yangccc656c2006-10-17 12:32:26 +020010704static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10705 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10706 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10707 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10708
10709 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10710 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10711 {}
10712};
10713
Kailang Yang272a5272007-05-14 11:00:38 +020010714static struct hda_verb alc262_sony_unsol_verbs[] = {
10715 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10716 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10717 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10718
10719 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10720 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010721 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010722};
10723
Kailang Yang4e555fe2008-08-26 13:05:55 +020010724static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10725 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10726 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10727 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10728 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10729 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010730 { } /* end */
10731};
10732
10733static struct hda_verb alc262_toshiba_s06_verbs[] = {
10734 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10735 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10736 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10737 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10738 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10739 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10740 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10741 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10742 {}
10743};
10744
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010745static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020010746{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010747 struct alc_spec *spec = codec->spec;
10748
10749 spec->autocfg.hp_pins[0] = 0x15;
10750 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010751 spec->ext_mic.pin = 0x18;
10752 spec->ext_mic.mux_idx = 0;
10753 spec->int_mic.pin = 0x12;
10754 spec->int_mic.mux_idx = 9;
10755 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020010756}
10757
Takashi Iwai834be882006-03-01 14:16:17 +010010758/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010759 * nec model
10760 * 0x15 = headphone
10761 * 0x16 = internal speaker
10762 * 0x18 = external mic
10763 */
10764
10765static struct snd_kcontrol_new alc262_nec_mixer[] = {
10766 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10767 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10768
10769 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10770 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10771 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10772
10773 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10774 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10775 { } /* end */
10776};
10777
10778static struct hda_verb alc262_nec_verbs[] = {
10779 /* Unmute Speaker */
10780 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10781
10782 /* Headphone */
10783 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10784 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10785
10786 /* External mic to headphone */
10787 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10788 /* External mic to speaker */
10789 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10790 {}
10791};
10792
10793/*
Takashi Iwai834be882006-03-01 14:16:17 +010010794 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010795 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10796 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010797 */
10798
10799#define ALC_HP_EVENT 0x37
10800
10801static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10802 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10803 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010804 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10805 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010806 {}
10807};
10808
Jiang zhe0e31daf2008-03-20 12:12:39 +010010809static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10810 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10811 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10812 {}
10813};
10814
Daniel T Chene2595322009-12-19 18:19:02 -050010815static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
10816 /* Front Mic pin: input vref at 50% */
10817 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10818 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10819 {}
10820};
10821
Takashi Iwai834be882006-03-01 14:16:17 +010010822static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010823 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010824 .items = {
10825 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010826 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010827 { "CD", 0x4 },
10828 },
10829};
10830
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010831static struct hda_input_mux alc262_HP_capture_source = {
10832 .num_items = 5,
10833 .items = {
10834 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010835 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010836 { "Line", 0x2 },
10837 { "CD", 0x4 },
10838 { "AUX IN", 0x6 },
10839 },
10840};
10841
zhejiangaccbe492007-08-31 12:36:05 +020010842static struct hda_input_mux alc262_HP_D7000_capture_source = {
10843 .num_items = 4,
10844 .items = {
10845 { "Mic", 0x0 },
10846 { "Front Mic", 0x2 },
10847 { "Line", 0x1 },
10848 { "CD", 0x4 },
10849 },
10850};
10851
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010852/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010853static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10854{
10855 struct alc_spec *spec = codec->spec;
10856 unsigned int mute;
10857
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010858 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080010859 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
10860 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010010861 spec->sense_updated = 1;
10862 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010863 /* unmute internal speaker only if both HPs are unplugged and
10864 * master switch is on
10865 */
10866 if (spec->jack_present)
10867 mute = HDA_AMP_MUTE;
10868 else
Takashi Iwai834be882006-03-01 14:16:17 +010010869 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010870 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10871 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010872}
10873
10874/* unsolicited event for HP jack sensing */
10875static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10876 unsigned int res)
10877{
10878 if ((res >> 26) != ALC_HP_EVENT)
10879 return;
10880 alc262_fujitsu_automute(codec, 1);
10881}
10882
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010883static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10884{
10885 alc262_fujitsu_automute(codec, 1);
10886}
10887
Takashi Iwai834be882006-03-01 14:16:17 +010010888/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010889static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10890 .ops = &snd_hda_bind_vol,
10891 .values = {
10892 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10893 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10894 0
10895 },
10896};
Takashi Iwai834be882006-03-01 14:16:17 +010010897
Jiang zhe0e31daf2008-03-20 12:12:39 +010010898/* mute/unmute internal speaker according to the hp jack and mute state */
10899static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10900{
10901 struct alc_spec *spec = codec->spec;
10902 unsigned int mute;
10903
10904 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080010905 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010906 spec->sense_updated = 1;
10907 }
10908 if (spec->jack_present) {
10909 /* mute internal speaker */
10910 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10911 HDA_AMP_MUTE, HDA_AMP_MUTE);
10912 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10913 HDA_AMP_MUTE, HDA_AMP_MUTE);
10914 } else {
10915 /* unmute internal speaker if necessary */
10916 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10917 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10918 HDA_AMP_MUTE, mute);
10919 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10920 HDA_AMP_MUTE, mute);
10921 }
10922}
10923
10924/* unsolicited event for HP jack sensing */
10925static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10926 unsigned int res)
10927{
10928 if ((res >> 26) != ALC_HP_EVENT)
10929 return;
10930 alc262_lenovo_3000_automute(codec, 1);
10931}
10932
Takashi Iwai8de56b72009-07-24 16:51:47 +020010933static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10934 int dir, int idx, long *valp)
10935{
10936 int i, change = 0;
10937
10938 for (i = 0; i < 2; i++, valp++)
10939 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10940 HDA_AMP_MUTE,
10941 *valp ? 0 : HDA_AMP_MUTE);
10942 return change;
10943}
10944
Takashi Iwai834be882006-03-01 14:16:17 +010010945/* bind hp and internal speaker mute (with plug check) */
10946static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10947 struct snd_ctl_elem_value *ucontrol)
10948{
10949 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10950 long *valp = ucontrol->value.integer.value;
10951 int change;
10952
Takashi Iwai8de56b72009-07-24 16:51:47 +020010953 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10954 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010955 if (change)
10956 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010957 return change;
10958}
10959
10960static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010961 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010962 {
10963 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10964 .name = "Master Playback Switch",
10965 .info = snd_hda_mixer_amp_switch_info,
10966 .get = snd_hda_mixer_amp_switch_get,
10967 .put = alc262_fujitsu_master_sw_put,
10968 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10969 },
10970 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10971 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10972 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10973 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10974 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010975 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10976 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10977 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010978 { } /* end */
10979};
10980
Jiang zhe0e31daf2008-03-20 12:12:39 +010010981/* bind hp and internal speaker mute (with plug check) */
10982static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10983 struct snd_ctl_elem_value *ucontrol)
10984{
10985 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10986 long *valp = ucontrol->value.integer.value;
10987 int change;
10988
Takashi Iwai8de56b72009-07-24 16:51:47 +020010989 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010990 if (change)
10991 alc262_lenovo_3000_automute(codec, 0);
10992 return change;
10993}
10994
10995static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10996 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10997 {
10998 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10999 .name = "Master Playback Switch",
11000 .info = snd_hda_mixer_amp_switch_info,
11001 .get = snd_hda_mixer_amp_switch_get,
11002 .put = alc262_lenovo_3000_master_sw_put,
11003 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11004 },
11005 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11006 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11007 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11008 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11009 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11010 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11011 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11012 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11013 { } /* end */
11014};
11015
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011016static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11017 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011018 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011019 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11020 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11021 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11022 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11023 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11024 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11025 { } /* end */
11026};
11027
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011028/* additional init verbs for Benq laptops */
11029static struct hda_verb alc262_EAPD_verbs[] = {
11030 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11031 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11032 {}
11033};
11034
Kailang Yang83c34212007-07-05 11:43:05 +020011035static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11036 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11037 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11038
11039 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11040 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11041 {}
11042};
11043
Tobin Davisf651b502007-10-26 12:40:47 +020011044/* Samsung Q1 Ultra Vista model setup */
11045static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011046 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11047 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011048 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11049 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11050 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011051 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011052 { } /* end */
11053};
11054
11055static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011056 /* output mixer */
11057 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11058 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11059 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11060 /* speaker */
11061 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11062 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11063 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11064 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11065 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011066 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011067 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11068 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11069 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11070 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11071 /* internal mic */
11072 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11073 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11074 /* ADC, choose mic */
11075 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11076 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11077 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11078 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11079 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11080 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11081 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11082 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11083 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11084 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011085 {}
11086};
11087
Tobin Davisf651b502007-10-26 12:40:47 +020011088/* mute/unmute internal speaker according to the hp jack and mute state */
11089static void alc262_ultra_automute(struct hda_codec *codec)
11090{
11091 struct alc_spec *spec = codec->spec;
11092 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011093
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011094 mute = 0;
11095 /* auto-mute only when HP is used as HP */
11096 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011097 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011098 if (spec->jack_present)
11099 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011100 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011101 /* mute/unmute internal speaker */
11102 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11103 HDA_AMP_MUTE, mute);
11104 /* mute/unmute HP */
11105 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11106 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011107}
11108
11109/* unsolicited event for HP jack sensing */
11110static void alc262_ultra_unsol_event(struct hda_codec *codec,
11111 unsigned int res)
11112{
11113 if ((res >> 26) != ALC880_HP_EVENT)
11114 return;
11115 alc262_ultra_automute(codec);
11116}
11117
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011118static struct hda_input_mux alc262_ultra_capture_source = {
11119 .num_items = 2,
11120 .items = {
11121 { "Mic", 0x1 },
11122 { "Headphone", 0x7 },
11123 },
11124};
11125
11126static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11127 struct snd_ctl_elem_value *ucontrol)
11128{
11129 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11130 struct alc_spec *spec = codec->spec;
11131 int ret;
11132
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011133 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011134 if (!ret)
11135 return 0;
11136 /* reprogram the HP pin as mic or HP according to the input source */
11137 snd_hda_codec_write_cache(codec, 0x15, 0,
11138 AC_VERB_SET_PIN_WIDGET_CONTROL,
11139 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11140 alc262_ultra_automute(codec); /* mute/unmute HP */
11141 return ret;
11142}
11143
11144static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11145 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11146 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11147 {
11148 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11149 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011150 .info = alc_mux_enum_info,
11151 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011152 .put = alc262_ultra_mux_enum_put,
11153 },
11154 { } /* end */
11155};
11156
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011157/* We use two mixers depending on the output pin; 0x16 is a mono output
11158 * and thus it's bound with a different mixer.
11159 * This function returns which mixer amp should be used.
11160 */
11161static int alc262_check_volbit(hda_nid_t nid)
11162{
11163 if (!nid)
11164 return 0;
11165 else if (nid == 0x16)
11166 return 2;
11167 else
11168 return 1;
11169}
11170
11171static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
11172 const char *pfx, int *vbits)
11173{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011174 unsigned long val;
11175 int vbit;
11176
11177 vbit = alc262_check_volbit(nid);
11178 if (!vbit)
11179 return 0;
11180 if (*vbits & vbit) /* a volume control for this mixer already there */
11181 return 0;
11182 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011183 if (vbit == 2)
11184 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11185 else
11186 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011187 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011188}
11189
11190static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
11191 const char *pfx)
11192{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011193 unsigned long val;
11194
11195 if (!nid)
11196 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011197 if (nid == 0x16)
11198 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11199 else
11200 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011201 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011202}
11203
Kailang Yangdf694da2005-12-05 19:42:22 +010011204/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011205static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11206 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011207{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011208 const char *pfx;
11209 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010011210 int err;
11211
11212 spec->multiout.num_dacs = 1; /* only use one dac */
11213 spec->multiout.dac_nids = spec->private_dac_nids;
11214 spec->multiout.dac_nids[0] = 2;
11215
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011216 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11217 pfx = "Master";
11218 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11219 pfx = "Speaker";
11220 else
11221 pfx = "Front";
11222 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11223 if (err < 0)
11224 return err;
11225 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11226 if (err < 0)
11227 return err;
11228 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11229 if (err < 0)
11230 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011231
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011232 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11233 alc262_check_volbit(cfg->speaker_pins[0]) |
11234 alc262_check_volbit(cfg->hp_pins[0]);
11235 if (vbits == 1 || vbits == 2)
11236 pfx = "Master"; /* only one mixer is used */
11237 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11238 pfx = "Speaker";
11239 else
11240 pfx = "Front";
11241 vbits = 0;
11242 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11243 if (err < 0)
11244 return err;
11245 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11246 &vbits);
11247 if (err < 0)
11248 return err;
11249 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11250 &vbits);
11251 if (err < 0)
11252 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011253 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011254}
11255
Takashi Iwai05f5f472009-08-25 13:10:18 +020011256#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010011257 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011258
11259/*
11260 * generic initialization of ADC, input mixers and output mixers
11261 */
11262static struct hda_verb alc262_volume_init_verbs[] = {
11263 /*
11264 * Unmute ADC0-2 and set the default input to mic-in
11265 */
11266 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11267 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11268 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11269 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11270 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11271 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11272
Takashi Iwaicb53c622007-08-10 17:21:45 +020011273 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011274 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011275 * Note: PASD motherboards uses the Line In 2 as the input for
11276 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011277 */
11278 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011279 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11280 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11281 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11282 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11283 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011284
11285 /*
11286 * Set up output mixers (0x0c - 0x0f)
11287 */
11288 /* set vol=0 to output mixers */
11289 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11290 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11291 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011292
Kailang Yangdf694da2005-12-05 19:42:22 +010011293 /* set up input amps for analog loopback */
11294 /* Amp Indices: DAC = 0, mixer = 1 */
11295 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11296 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11297 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11298 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11299 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11300 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11301
11302 /* FIXME: use matrix-type input source selection */
11303 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11304 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11305 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11306 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11307 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11308 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11309 /* Input mixer2 */
11310 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11311 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11312 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11313 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11314 /* Input mixer3 */
11315 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11316 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11317 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11318 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11319
11320 { }
11321};
11322
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011323static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11324 /*
11325 * Unmute ADC0-2 and set the default input to mic-in
11326 */
11327 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11328 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11329 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11330 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11331 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11332 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11333
Takashi Iwaicb53c622007-08-10 17:21:45 +020011334 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011335 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011336 * Note: PASD motherboards uses the Line In 2 as the input for
11337 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011338 */
11339 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011340 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11341 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11342 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11343 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11344 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11345 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11346 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011347
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011348 /*
11349 * Set up output mixers (0x0c - 0x0e)
11350 */
11351 /* set vol=0 to output mixers */
11352 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11353 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11354 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11355
11356 /* set up input amps for analog loopback */
11357 /* Amp Indices: DAC = 0, mixer = 1 */
11358 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11359 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11360 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11361 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11362 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11363 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11364
Takashi Iwaice875f02008-01-28 18:17:43 +010011365 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011366 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11367 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11368
11369 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11370 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11371
11372 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11373 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11374
11375 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11376 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11377 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11378 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11379 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11380
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011381 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011382 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11383 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011384 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011385 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11386 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11387
11388
11389 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011390 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11391 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011392 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011393 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11394 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11395 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11396 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11397 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11398 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11399 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11400 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011401 /* Input mixer2 */
11402 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011403 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11404 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11405 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11406 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11407 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11408 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11409 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11410 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011411 /* Input mixer3 */
11412 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011413 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11414 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11415 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11416 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11417 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11418 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11419 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11420 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011421
Takashi Iwaice875f02008-01-28 18:17:43 +010011422 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11423
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011424 { }
11425};
11426
Kailang Yangcd7509a2007-01-26 18:33:17 +010011427static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11428 /*
11429 * Unmute ADC0-2 and set the default input to mic-in
11430 */
11431 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11432 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11433 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11434 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11435 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11436 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11437
Takashi Iwaicb53c622007-08-10 17:21:45 +020011438 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011439 * mixer widget
11440 * Note: PASD motherboards uses the Line In 2 as the input for front
11441 * panel mic (mic 2)
11442 */
11443 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011444 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11445 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11446 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11447 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11448 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11449 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11450 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11451 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011452 /*
11453 * Set up output mixers (0x0c - 0x0e)
11454 */
11455 /* set vol=0 to output mixers */
11456 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11457 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11458 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11459
11460 /* set up input amps for analog loopback */
11461 /* Amp Indices: DAC = 0, mixer = 1 */
11462 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11463 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11464 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11465 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11466 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11467 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11468
11469
11470 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11471 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11472 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11473 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11474 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11475 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11476 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11477
11478 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11479 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11480
11481 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11482 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11483
11484 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11485 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11486 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11487 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11488 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11489 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11490
11491 /* FIXME: use matrix-type input source selection */
11492 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11493 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11494 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11495 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11496 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11497 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11498 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11499 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11500 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11501 /* Input mixer2 */
11502 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11503 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11504 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11505 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11506 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11507 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11508 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11509 /* Input mixer3 */
11510 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11511 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11512 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11513 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11514 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11515 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11516 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11517
Takashi Iwaice875f02008-01-28 18:17:43 +010011518 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11519
Kailang Yangcd7509a2007-01-26 18:33:17 +010011520 { }
11521};
11522
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011523static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11524
11525 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11526 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11527 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11528
11529 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11530 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11531 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11532 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11533
11534 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11535 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11536 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11537 {}
11538};
11539
11540
Takashi Iwaicb53c622007-08-10 17:21:45 +020011541#ifdef CONFIG_SND_HDA_POWER_SAVE
11542#define alc262_loopbacks alc880_loopbacks
11543#endif
11544
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011545/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011546#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11547#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11548#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11549#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11550
11551/*
11552 * BIOS auto configuration
11553 */
11554static int alc262_parse_auto_config(struct hda_codec *codec)
11555{
11556 struct alc_spec *spec = codec->spec;
11557 int err;
11558 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11559
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011560 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11561 alc262_ignore);
11562 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011563 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011564 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011565 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011566 spec->multiout.max_channels = 2;
11567 spec->no_analog = 1;
11568 goto dig_only;
11569 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011570 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011571 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011572 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11573 if (err < 0)
11574 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011575 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011576 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011577 return err;
11578
11579 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11580
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011581 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011582 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011583 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011584 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011585 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011586 if (spec->autocfg.dig_in_pin)
11587 spec->dig_in_nid = ALC262_DIGIN_NID;
11588
Takashi Iwai603c4012008-07-30 15:01:44 +020011589 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011590 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011591
Takashi Iwaid88897e2008-10-31 15:01:37 +010011592 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011593 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011594 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011595
Takashi Iwai776e1842007-08-29 15:07:11 +020011596 err = alc_auto_add_mic_boost(codec);
11597 if (err < 0)
11598 return err;
11599
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011600 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11601
Kailang Yangdf694da2005-12-05 19:42:22 +010011602 return 1;
11603}
11604
11605#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11606#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11607#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011608#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011609
11610
11611/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011612static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011613{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011614 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011615 alc262_auto_init_multi_out(codec);
11616 alc262_auto_init_hp_out(codec);
11617 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011618 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011619 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011620 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011621}
11622
11623/*
11624 * configuration and preset
11625 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011626static const char *alc262_models[ALC262_MODEL_LAST] = {
11627 [ALC262_BASIC] = "basic",
11628 [ALC262_HIPPO] = "hippo",
11629 [ALC262_HIPPO_1] = "hippo_1",
11630 [ALC262_FUJITSU] = "fujitsu",
11631 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011632 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011633 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011634 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011635 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011636 [ALC262_BENQ_T31] = "benq-t31",
11637 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011638 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011639 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011640 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011641 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011642 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011643 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011644 [ALC262_AUTO] = "auto",
11645};
11646
11647static struct snd_pci_quirk alc262_cfg_tbl[] = {
11648 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011649 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011650 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11651 ALC262_HP_BPC),
11652 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11653 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011654 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11655 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011656 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011657 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011658 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011659 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011660 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011661 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011662 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011663 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011664 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11665 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11666 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011667 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11668 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011669 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011670 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011671 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011672 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011673 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011674 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050011675 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010011676 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011677#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010011678 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11679 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011680#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090011681 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011682 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011683 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011684 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011685 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011686 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011687 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11688 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011689 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011690 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011691 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011692 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011693 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011694 {}
11695};
11696
11697static struct alc_config_preset alc262_presets[] = {
11698 [ALC262_BASIC] = {
11699 .mixers = { alc262_base_mixer },
11700 .init_verbs = { alc262_init_verbs },
11701 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11702 .dac_nids = alc262_dac_nids,
11703 .hp_nid = 0x03,
11704 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11705 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011706 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011707 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011708 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011709 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011710 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011711 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11712 .dac_nids = alc262_dac_nids,
11713 .hp_nid = 0x03,
11714 .dig_out_nid = ALC262_DIGOUT_NID,
11715 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11716 .channel_mode = alc262_modes,
11717 .input_mux = &alc262_capture_source,
11718 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011719 .setup = alc262_hippo_setup,
11720 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011721 },
11722 [ALC262_HIPPO_1] = {
11723 .mixers = { alc262_hippo1_mixer },
11724 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11725 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11726 .dac_nids = alc262_dac_nids,
11727 .hp_nid = 0x02,
11728 .dig_out_nid = ALC262_DIGOUT_NID,
11729 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11730 .channel_mode = alc262_modes,
11731 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011732 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011733 .setup = alc262_hippo1_setup,
11734 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011735 },
Takashi Iwai834be882006-03-01 14:16:17 +010011736 [ALC262_FUJITSU] = {
11737 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011738 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11739 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011740 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11741 .dac_nids = alc262_dac_nids,
11742 .hp_nid = 0x03,
11743 .dig_out_nid = ALC262_DIGOUT_NID,
11744 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11745 .channel_mode = alc262_modes,
11746 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011747 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011748 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011749 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011750 [ALC262_HP_BPC] = {
11751 .mixers = { alc262_HP_BPC_mixer },
11752 .init_verbs = { alc262_HP_BPC_init_verbs },
11753 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11754 .dac_nids = alc262_dac_nids,
11755 .hp_nid = 0x03,
11756 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11757 .channel_mode = alc262_modes,
11758 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011759 .unsol_event = alc262_hp_bpc_unsol_event,
11760 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011761 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011762 [ALC262_HP_BPC_D7000_WF] = {
11763 .mixers = { alc262_HP_BPC_WildWest_mixer },
11764 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11765 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11766 .dac_nids = alc262_dac_nids,
11767 .hp_nid = 0x03,
11768 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11769 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011770 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011771 .unsol_event = alc262_hp_wildwest_unsol_event,
11772 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011773 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011774 [ALC262_HP_BPC_D7000_WL] = {
11775 .mixers = { alc262_HP_BPC_WildWest_mixer,
11776 alc262_HP_BPC_WildWest_option_mixer },
11777 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11778 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11779 .dac_nids = alc262_dac_nids,
11780 .hp_nid = 0x03,
11781 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11782 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011783 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011784 .unsol_event = alc262_hp_wildwest_unsol_event,
11785 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011786 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011787 [ALC262_HP_TC_T5735] = {
11788 .mixers = { alc262_hp_t5735_mixer },
11789 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11790 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11791 .dac_nids = alc262_dac_nids,
11792 .hp_nid = 0x03,
11793 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11794 .channel_mode = alc262_modes,
11795 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010011796 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011797 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010011798 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010011799 },
11800 [ALC262_HP_RP5700] = {
11801 .mixers = { alc262_hp_rp5700_mixer },
11802 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11803 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11804 .dac_nids = alc262_dac_nids,
11805 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11806 .channel_mode = alc262_modes,
11807 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011808 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011809 [ALC262_BENQ_ED8] = {
11810 .mixers = { alc262_base_mixer },
11811 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11812 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11813 .dac_nids = alc262_dac_nids,
11814 .hp_nid = 0x03,
11815 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11816 .channel_mode = alc262_modes,
11817 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011818 },
Kailang Yang272a5272007-05-14 11:00:38 +020011819 [ALC262_SONY_ASSAMD] = {
11820 .mixers = { alc262_sony_mixer },
11821 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11822 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11823 .dac_nids = alc262_dac_nids,
11824 .hp_nid = 0x02,
11825 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11826 .channel_mode = alc262_modes,
11827 .input_mux = &alc262_capture_source,
11828 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011829 .setup = alc262_hippo_setup,
11830 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020011831 },
11832 [ALC262_BENQ_T31] = {
11833 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011834 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
11835 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020011836 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11837 .dac_nids = alc262_dac_nids,
11838 .hp_nid = 0x03,
11839 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11840 .channel_mode = alc262_modes,
11841 .input_mux = &alc262_capture_source,
11842 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011843 .setup = alc262_hippo_setup,
11844 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020011845 },
Tobin Davisf651b502007-10-26 12:40:47 +020011846 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011847 .mixers = { alc262_ultra_mixer },
11848 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011849 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011850 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11851 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011852 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11853 .channel_mode = alc262_modes,
11854 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011855 .adc_nids = alc262_adc_nids, /* ADC0 */
11856 .capsrc_nids = alc262_capsrc_nids,
11857 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011858 .unsol_event = alc262_ultra_unsol_event,
11859 .init_hook = alc262_ultra_automute,
11860 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011861 [ALC262_LENOVO_3000] = {
11862 .mixers = { alc262_lenovo_3000_mixer },
11863 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050011864 alc262_lenovo_3000_unsol_verbs,
11865 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011866 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11867 .dac_nids = alc262_dac_nids,
11868 .hp_nid = 0x03,
11869 .dig_out_nid = ALC262_DIGOUT_NID,
11870 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11871 .channel_mode = alc262_modes,
11872 .input_mux = &alc262_fujitsu_capture_source,
11873 .unsol_event = alc262_lenovo_3000_unsol_event,
11874 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011875 [ALC262_NEC] = {
11876 .mixers = { alc262_nec_mixer },
11877 .init_verbs = { alc262_nec_verbs },
11878 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11879 .dac_nids = alc262_dac_nids,
11880 .hp_nid = 0x03,
11881 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11882 .channel_mode = alc262_modes,
11883 .input_mux = &alc262_capture_source,
11884 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011885 [ALC262_TOSHIBA_S06] = {
11886 .mixers = { alc262_toshiba_s06_mixer },
11887 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11888 alc262_eapd_verbs },
11889 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11890 .capsrc_nids = alc262_dmic_capsrc_nids,
11891 .dac_nids = alc262_dac_nids,
11892 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011893 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011894 .dig_out_nid = ALC262_DIGOUT_NID,
11895 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11896 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011897 .unsol_event = alc_sku_unsol_event,
11898 .setup = alc262_toshiba_s06_setup,
11899 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020011900 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011901 [ALC262_TOSHIBA_RX1] = {
11902 .mixers = { alc262_toshiba_rx1_mixer },
11903 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11904 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11905 .dac_nids = alc262_dac_nids,
11906 .hp_nid = 0x03,
11907 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11908 .channel_mode = alc262_modes,
11909 .input_mux = &alc262_capture_source,
11910 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011911 .setup = alc262_hippo_setup,
11912 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011913 },
Tony Vroonba340e82009-02-02 19:01:30 +000011914 [ALC262_TYAN] = {
11915 .mixers = { alc262_tyan_mixer },
11916 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11917 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11918 .dac_nids = alc262_dac_nids,
11919 .hp_nid = 0x02,
11920 .dig_out_nid = ALC262_DIGOUT_NID,
11921 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11922 .channel_mode = alc262_modes,
11923 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011924 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011925 .setup = alc262_tyan_setup,
11926 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000011927 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011928};
11929
11930static int patch_alc262(struct hda_codec *codec)
11931{
11932 struct alc_spec *spec;
11933 int board_config;
11934 int err;
11935
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011936 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011937 if (spec == NULL)
11938 return -ENOMEM;
11939
11940 codec->spec = spec;
11941#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011942 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11943 * under-run
11944 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011945 {
11946 int tmp;
11947 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11948 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11949 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11950 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11951 }
11952#endif
11953
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011954 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11955
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011956 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11957 alc262_models,
11958 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011959
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011960 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011961 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11962 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011963 board_config = ALC262_AUTO;
11964 }
11965
11966 if (board_config == ALC262_AUTO) {
11967 /* automatic parse from the BIOS config */
11968 err = alc262_parse_auto_config(codec);
11969 if (err < 0) {
11970 alc_free(codec);
11971 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011972 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011973 printk(KERN_INFO
11974 "hda_codec: Cannot set up configuration "
11975 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011976 board_config = ALC262_BASIC;
11977 }
11978 }
11979
Takashi Iwai07eba612009-02-19 08:06:35 +010011980 if (!spec->no_analog) {
11981 err = snd_hda_attach_beep_device(codec, 0x1);
11982 if (err < 0) {
11983 alc_free(codec);
11984 return err;
11985 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011986 }
11987
Kailang Yangdf694da2005-12-05 19:42:22 +010011988 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011989 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011990
Kailang Yangdf694da2005-12-05 19:42:22 +010011991 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11992 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011993
Kailang Yangdf694da2005-12-05 19:42:22 +010011994 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11995 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11996
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011997 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011998 int i;
11999 /* check whether the digital-mic has to be supported */
12000 for (i = 0; i < spec->input_mux->num_items; i++) {
12001 if (spec->input_mux->items[i].index >= 9)
12002 break;
12003 }
12004 if (i < spec->input_mux->num_items) {
12005 /* use only ADC0 */
12006 spec->adc_nids = alc262_dmic_adc_nids;
12007 spec->num_adc_nids = 1;
12008 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012009 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012010 /* all analog inputs */
12011 /* check whether NID 0x07 is valid */
12012 unsigned int wcap = get_wcaps(codec, 0x07);
12013
12014 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012015 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012016 if (wcap != AC_WID_AUD_IN) {
12017 spec->adc_nids = alc262_adc_nids_alt;
12018 spec->num_adc_nids =
12019 ARRAY_SIZE(alc262_adc_nids_alt);
12020 spec->capsrc_nids = alc262_capsrc_nids_alt;
12021 } else {
12022 spec->adc_nids = alc262_adc_nids;
12023 spec->num_adc_nids =
12024 ARRAY_SIZE(alc262_adc_nids);
12025 spec->capsrc_nids = alc262_capsrc_nids;
12026 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012027 }
12028 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012029 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012030 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010012031 if (!spec->no_analog)
12032 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012033
Takashi Iwai2134ea42008-01-10 16:53:55 +010012034 spec->vmaster_nid = 0x0c;
12035
Kailang Yangdf694da2005-12-05 19:42:22 +010012036 codec->patch_ops = alc_patch_ops;
12037 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012038 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012039#ifdef CONFIG_SND_HDA_POWER_SAVE
12040 if (!spec->loopback.amplist)
12041 spec->loopback.amplist = alc262_loopbacks;
12042#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010012043 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020012044
Kailang Yangdf694da2005-12-05 19:42:22 +010012045 return 0;
12046}
12047
Kailang Yangdf694da2005-12-05 19:42:22 +010012048/*
Kailang Yanga361d842007-06-05 12:30:55 +020012049 * ALC268 channel source setting (2 channel)
12050 */
12051#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12052#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012053
Kailang Yanga361d842007-06-05 12:30:55 +020012054static hda_nid_t alc268_dac_nids[2] = {
12055 /* front, hp */
12056 0x02, 0x03
12057};
12058
12059static hda_nid_t alc268_adc_nids[2] = {
12060 /* ADC0-1 */
12061 0x08, 0x07
12062};
12063
12064static hda_nid_t alc268_adc_nids_alt[1] = {
12065 /* ADC0 */
12066 0x08
12067};
12068
Takashi Iwaie1406342008-02-11 18:32:32 +010012069static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12070
Kailang Yanga361d842007-06-05 12:30:55 +020012071static struct snd_kcontrol_new alc268_base_mixer[] = {
12072 /* output mixer control */
12073 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12074 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12075 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12076 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012077 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12078 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12079 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012080 { }
12081};
12082
Takashi Iwai42171c12009-05-08 14:11:43 +020012083static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12084 /* output mixer control */
12085 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12086 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12087 ALC262_HIPPO_MASTER_SWITCH,
12088 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12089 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12090 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12091 { }
12092};
12093
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012094/* bind Beep switches of both NID 0x0f and 0x10 */
12095static struct hda_bind_ctls alc268_bind_beep_sw = {
12096 .ops = &snd_hda_bind_sw,
12097 .values = {
12098 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12099 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12100 0
12101 },
12102};
12103
12104static struct snd_kcontrol_new alc268_beep_mixer[] = {
12105 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12106 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12107 { }
12108};
12109
Kailang Yangd1a991a2007-08-15 16:21:59 +020012110static struct hda_verb alc268_eapd_verbs[] = {
12111 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12112 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12113 { }
12114};
12115
Takashi Iwaid2738092007-08-16 14:59:45 +020012116/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012117static struct hda_verb alc268_toshiba_verbs[] = {
12118 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12119 { } /* end */
12120};
12121
12122/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012123/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012124static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12125 .ops = &snd_hda_bind_vol,
12126 .values = {
12127 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12128 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12129 0
12130 },
12131};
12132
Takashi Iwai889c4392007-08-23 18:56:52 +020012133/* mute/unmute internal speaker according to the hp jack and mute state */
12134static void alc268_acer_automute(struct hda_codec *codec, int force)
12135{
12136 struct alc_spec *spec = codec->spec;
12137 unsigned int mute;
12138
12139 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012140 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012141 spec->sense_updated = 1;
12142 }
12143 if (spec->jack_present)
12144 mute = HDA_AMP_MUTE; /* mute internal speaker */
12145 else /* unmute internal speaker if necessary */
12146 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12147 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12148 HDA_AMP_MUTE, mute);
12149}
12150
12151
12152/* bind hp and internal speaker mute (with plug check) */
12153static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12154 struct snd_ctl_elem_value *ucontrol)
12155{
12156 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12157 long *valp = ucontrol->value.integer.value;
12158 int change;
12159
Takashi Iwai8de56b72009-07-24 16:51:47 +020012160 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012161 if (change)
12162 alc268_acer_automute(codec, 0);
12163 return change;
12164}
Takashi Iwaid2738092007-08-16 14:59:45 +020012165
Kailang Yang8ef355d2008-08-26 13:10:22 +020012166static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12167 /* output mixer control */
12168 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12169 {
12170 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12171 .name = "Master Playback Switch",
12172 .info = snd_hda_mixer_amp_switch_info,
12173 .get = snd_hda_mixer_amp_switch_get,
12174 .put = alc268_acer_master_sw_put,
12175 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12176 },
12177 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12178 { }
12179};
12180
Takashi Iwaid2738092007-08-16 14:59:45 +020012181static struct snd_kcontrol_new alc268_acer_mixer[] = {
12182 /* output mixer control */
12183 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12184 {
12185 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12186 .name = "Master Playback Switch",
12187 .info = snd_hda_mixer_amp_switch_info,
12188 .get = snd_hda_mixer_amp_switch_get,
12189 .put = alc268_acer_master_sw_put,
12190 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12191 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012192 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12193 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12194 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012195 { }
12196};
12197
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012198static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12199 /* output mixer control */
12200 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12201 {
12202 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12203 .name = "Master Playback Switch",
12204 .info = snd_hda_mixer_amp_switch_info,
12205 .get = snd_hda_mixer_amp_switch_get,
12206 .put = alc268_acer_master_sw_put,
12207 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12208 },
12209 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12210 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12211 { }
12212};
12213
Kailang Yang8ef355d2008-08-26 13:10:22 +020012214static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12215 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12216 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12217 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12218 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12219 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12220 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12221 { }
12222};
12223
Takashi Iwaid2738092007-08-16 14:59:45 +020012224static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012225 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12226 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012227 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12228 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012229 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12230 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012231 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12232 { }
12233};
12234
12235/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012236#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012237#define alc268_toshiba_setup alc262_hippo_setup
12238#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012239
12240static void alc268_acer_unsol_event(struct hda_codec *codec,
12241 unsigned int res)
12242{
Takashi Iwai889c4392007-08-23 18:56:52 +020012243 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012244 return;
12245 alc268_acer_automute(codec, 1);
12246}
12247
Takashi Iwai889c4392007-08-23 18:56:52 +020012248static void alc268_acer_init_hook(struct hda_codec *codec)
12249{
12250 alc268_acer_automute(codec, 1);
12251}
12252
Kailang Yang8ef355d2008-08-26 13:10:22 +020012253/* toggle speaker-output according to the hp-jack state */
12254static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12255{
12256 unsigned int present;
12257 unsigned char bits;
12258
Wu Fengguang864f92b2009-11-18 12:38:02 +080012259 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012260 bits = present ? AMP_IN_MUTE(0) : 0;
12261 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
12262 AMP_IN_MUTE(0), bits);
12263 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
12264 AMP_IN_MUTE(0), bits);
12265}
12266
Kailang Yang8ef355d2008-08-26 13:10:22 +020012267static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12268 unsigned int res)
12269{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012270 switch (res >> 26) {
12271 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012272 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012273 break;
12274 case ALC880_MIC_EVENT:
12275 alc_mic_automute(codec);
12276 break;
12277 }
12278}
12279
12280static void alc268_acer_lc_setup(struct hda_codec *codec)
12281{
12282 struct alc_spec *spec = codec->spec;
12283 spec->ext_mic.pin = 0x18;
12284 spec->ext_mic.mux_idx = 0;
12285 spec->int_mic.pin = 0x12;
12286 spec->int_mic.mux_idx = 6;
12287 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012288}
12289
12290static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12291{
12292 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012293 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012294}
12295
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012296static struct snd_kcontrol_new alc268_dell_mixer[] = {
12297 /* output mixer control */
12298 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12299 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12300 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12301 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12302 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12303 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12304 { }
12305};
12306
12307static struct hda_verb alc268_dell_verbs[] = {
12308 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12309 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12310 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012311 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012312 { }
12313};
12314
12315/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012316static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012317{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012318 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012319
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012320 spec->autocfg.hp_pins[0] = 0x15;
12321 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012322 spec->ext_mic.pin = 0x18;
12323 spec->ext_mic.mux_idx = 0;
12324 spec->int_mic.pin = 0x19;
12325 spec->int_mic.mux_idx = 1;
12326 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012327}
12328
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012329static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12330 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12331 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12332 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12333 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12334 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12335 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12336 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12337 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12338 { }
12339};
12340
12341static struct hda_verb alc267_quanta_il1_verbs[] = {
12342 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12343 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12344 { }
12345};
12346
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012347static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012348{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012349 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012350 spec->autocfg.hp_pins[0] = 0x15;
12351 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012352 spec->ext_mic.pin = 0x18;
12353 spec->ext_mic.mux_idx = 0;
12354 spec->int_mic.pin = 0x19;
12355 spec->int_mic.mux_idx = 1;
12356 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012357}
12358
Kailang Yanga361d842007-06-05 12:30:55 +020012359/*
12360 * generic initialization of ADC, input mixers and output mixers
12361 */
12362static struct hda_verb alc268_base_init_verbs[] = {
12363 /* Unmute DAC0-1 and set vol = 0 */
12364 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012365 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012366
12367 /*
12368 * Set up output mixers (0x0c - 0x0e)
12369 */
12370 /* set vol=0 to output mixers */
12371 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012372 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12373
12374 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12375 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12376
12377 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12378 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12379 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12380 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12381 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12382 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12383 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12384 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12385
12386 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12387 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12388 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12389 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012390 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012391
12392 /* set PCBEEP vol = 0, mute connections */
12393 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12394 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12395 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012396
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012397 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012398
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012399 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12400 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12401 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12402 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012403
Kailang Yanga361d842007-06-05 12:30:55 +020012404 { }
12405};
12406
12407/*
12408 * generic initialization of ADC, input mixers and output mixers
12409 */
12410static struct hda_verb alc268_volume_init_verbs[] = {
12411 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012412 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12413 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012414
12415 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12416 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12417 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12418 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12419 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12420
Kailang Yanga361d842007-06-05 12:30:55 +020012421 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012422 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12423 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12424
12425 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012426 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012427
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012428 /* set PCBEEP vol = 0, mute connections */
12429 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12430 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12431 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012432
12433 { }
12434};
12435
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012436static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12437 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12438 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12439 { } /* end */
12440};
12441
Kailang Yanga361d842007-06-05 12:30:55 +020012442static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12443 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12444 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012445 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012446 { } /* end */
12447};
12448
12449static struct snd_kcontrol_new alc268_capture_mixer[] = {
12450 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12451 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12452 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12453 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012454 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012455 { } /* end */
12456};
12457
12458static struct hda_input_mux alc268_capture_source = {
12459 .num_items = 4,
12460 .items = {
12461 { "Mic", 0x0 },
12462 { "Front Mic", 0x1 },
12463 { "Line", 0x2 },
12464 { "CD", 0x3 },
12465 },
12466};
12467
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012468static struct hda_input_mux alc268_acer_capture_source = {
12469 .num_items = 3,
12470 .items = {
12471 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012472 { "Internal Mic", 0x1 },
12473 { "Line", 0x2 },
12474 },
12475};
12476
12477static struct hda_input_mux alc268_acer_dmic_capture_source = {
12478 .num_items = 3,
12479 .items = {
12480 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012481 { "Internal Mic", 0x6 },
12482 { "Line", 0x2 },
12483 },
12484};
12485
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012486#ifdef CONFIG_SND_DEBUG
12487static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012488 /* Volume widgets */
12489 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12490 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12491 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12492 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12493 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12494 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12495 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12496 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12497 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12498 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12499 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12500 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12501 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012502 /* The below appears problematic on some hardwares */
12503 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012504 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12505 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12506 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12507 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12508
12509 /* Modes for retasking pin widgets */
12510 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12511 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12512 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12513 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12514
12515 /* Controls for GPIO pins, assuming they are configured as outputs */
12516 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12517 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12518 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12519 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12520
12521 /* Switches to allow the digital SPDIF output pin to be enabled.
12522 * The ALC268 does not have an SPDIF input.
12523 */
12524 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12525
12526 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12527 * this output to turn on an external amplifier.
12528 */
12529 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12530 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12531
12532 { } /* end */
12533};
12534#endif
12535
Kailang Yanga361d842007-06-05 12:30:55 +020012536/* create input playback/capture controls for the given pin */
12537static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12538 const char *ctlname, int idx)
12539{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012540 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012541 int err;
12542
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012543 switch (nid) {
12544 case 0x14:
12545 case 0x16:
12546 dac = 0x02;
12547 break;
12548 case 0x15:
Takashi Iwai4feabef2010-01-19 15:38:44 +010012549 case 0x21:
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012550 dac = 0x03;
12551 break;
12552 default:
12553 return 0;
12554 }
12555 if (spec->multiout.dac_nids[0] != dac &&
12556 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012557 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012558 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012559 HDA_OUTPUT));
12560 if (err < 0)
12561 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012562 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12563 }
12564
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012565 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012566 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020012567 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012568 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012569 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012570 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012571 if (err < 0)
12572 return err;
12573 return 0;
12574}
12575
12576/* add playback controls from the parsed DAC table */
12577static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12578 const struct auto_pin_cfg *cfg)
12579{
12580 hda_nid_t nid;
12581 int err;
12582
Kailang Yanga361d842007-06-05 12:30:55 +020012583 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012584
12585 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012586 if (nid) {
12587 const char *name;
12588 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12589 name = "Speaker";
12590 else
12591 name = "Front";
12592 err = alc268_new_analog_output(spec, nid, name, 0);
12593 if (err < 0)
12594 return err;
12595 }
Kailang Yanga361d842007-06-05 12:30:55 +020012596
12597 nid = cfg->speaker_pins[0];
12598 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012599 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020012600 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12601 if (err < 0)
12602 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012603 } else {
12604 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12605 if (err < 0)
12606 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012607 }
12608 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012609 if (nid) {
12610 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12611 if (err < 0)
12612 return err;
12613 }
Kailang Yanga361d842007-06-05 12:30:55 +020012614
12615 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12616 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012617 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012618 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012619 if (err < 0)
12620 return err;
12621 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012622 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012623}
12624
12625/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020012626static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020012627 const struct auto_pin_cfg *cfg)
12628{
Takashi Iwai05f5f472009-08-25 13:10:18 +020012629 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020012630}
12631
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012632static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12633 hda_nid_t nid, int pin_type)
12634{
12635 int idx;
12636
12637 alc_set_pin_output(codec, nid, pin_type);
12638 if (nid == 0x14 || nid == 0x16)
12639 idx = 0;
12640 else
12641 idx = 1;
12642 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12643}
12644
12645static void alc268_auto_init_multi_out(struct hda_codec *codec)
12646{
12647 struct alc_spec *spec = codec->spec;
12648 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12649 if (nid) {
12650 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12651 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12652 }
12653}
12654
12655static void alc268_auto_init_hp_out(struct hda_codec *codec)
12656{
12657 struct alc_spec *spec = codec->spec;
12658 hda_nid_t pin;
12659
12660 pin = spec->autocfg.hp_pins[0];
12661 if (pin)
12662 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12663 pin = spec->autocfg.speaker_pins[0];
12664 if (pin)
12665 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12666}
12667
Kailang Yanga361d842007-06-05 12:30:55 +020012668static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12669{
12670 struct alc_spec *spec = codec->spec;
12671 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12672 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12673 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12674 unsigned int dac_vol1, dac_vol2;
12675
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012676 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020012677 snd_hda_codec_write(codec, speaker_nid, 0,
12678 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012679 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012680 snd_hda_codec_write(codec, 0x0f, 0,
12681 AC_VERB_SET_AMP_GAIN_MUTE,
12682 AMP_IN_UNMUTE(1));
12683 snd_hda_codec_write(codec, 0x10, 0,
12684 AC_VERB_SET_AMP_GAIN_MUTE,
12685 AMP_IN_UNMUTE(1));
12686 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012687 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012688 snd_hda_codec_write(codec, 0x0f, 0,
12689 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12690 snd_hda_codec_write(codec, 0x10, 0,
12691 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12692 }
12693
12694 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012695 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012696 dac_vol2 = AMP_OUT_ZERO;
12697 else if (line_nid == 0x15)
12698 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012699 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012700 dac_vol2 = AMP_OUT_ZERO;
12701 else if (hp_nid == 0x15)
12702 dac_vol1 = AMP_OUT_ZERO;
12703 if (line_nid != 0x16 || hp_nid != 0x16 ||
12704 spec->autocfg.line_out_pins[1] != 0x16 ||
12705 spec->autocfg.line_out_pins[2] != 0x16)
12706 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12707
12708 snd_hda_codec_write(codec, 0x02, 0,
12709 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12710 snd_hda_codec_write(codec, 0x03, 0,
12711 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12712}
12713
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012714/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012715#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12716#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012717#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012718#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12719
12720/*
12721 * BIOS auto configuration
12722 */
12723static int alc268_parse_auto_config(struct hda_codec *codec)
12724{
12725 struct alc_spec *spec = codec->spec;
12726 int err;
12727 static hda_nid_t alc268_ignore[] = { 0 };
12728
12729 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12730 alc268_ignore);
12731 if (err < 0)
12732 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012733 if (!spec->autocfg.line_outs) {
12734 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12735 spec->multiout.max_channels = 2;
12736 spec->no_analog = 1;
12737 goto dig_only;
12738 }
Kailang Yanga361d842007-06-05 12:30:55 +020012739 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012740 }
Kailang Yanga361d842007-06-05 12:30:55 +020012741 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12742 if (err < 0)
12743 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012744 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020012745 if (err < 0)
12746 return err;
12747
12748 spec->multiout.max_channels = 2;
12749
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012750 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012751 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012752 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012753 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012754 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12755 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012756 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012757 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012758
Takashi Iwai892981f2009-03-02 08:04:35 +010012759 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012760 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012761
Takashi Iwaid88897e2008-10-31 15:01:37 +010012762 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012763 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012764 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012765
Takashi Iwai776e1842007-08-29 15:07:11 +020012766 err = alc_auto_add_mic_boost(codec);
12767 if (err < 0)
12768 return err;
12769
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012770 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12771
Kailang Yanga361d842007-06-05 12:30:55 +020012772 return 1;
12773}
12774
Kailang Yanga361d842007-06-05 12:30:55 +020012775#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12776
12777/* init callback for auto-configuration model -- overriding the default init */
12778static void alc268_auto_init(struct hda_codec *codec)
12779{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012780 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012781 alc268_auto_init_multi_out(codec);
12782 alc268_auto_init_hp_out(codec);
12783 alc268_auto_init_mono_speaker_out(codec);
12784 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012785 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012786 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012787}
12788
12789/*
12790 * configuration and preset
12791 */
12792static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012793 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012794 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012795 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012796 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012797 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012798 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012799 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012800 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012801#ifdef CONFIG_SND_DEBUG
12802 [ALC268_TEST] = "test",
12803#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012804 [ALC268_AUTO] = "auto",
12805};
12806
12807static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012808 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012809 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012810 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012811 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012812 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012813 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12814 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012815 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050012816 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
12817 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020012818 /* almost compatible with toshiba but with optional digital outs;
12819 * auto-probing seems working fine
12820 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012821 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020012822 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020012823 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012824 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012825 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012826 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012827 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012828 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012829 {}
12830};
12831
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012832/* Toshiba laptops have no unique PCI SSID but only codec SSID */
12833static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
12834 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
12835 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
12836 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12837 ALC268_TOSHIBA),
12838 {}
12839};
12840
Kailang Yanga361d842007-06-05 12:30:55 +020012841static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012842 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012843 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
12844 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012845 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12846 alc267_quanta_il1_verbs },
12847 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12848 .dac_nids = alc268_dac_nids,
12849 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12850 .adc_nids = alc268_adc_nids_alt,
12851 .hp_nid = 0x03,
12852 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12853 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012854 .unsol_event = alc_sku_unsol_event,
12855 .setup = alc267_quanta_il1_setup,
12856 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012857 },
Kailang Yanga361d842007-06-05 12:30:55 +020012858 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012859 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12860 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012861 .init_verbs = { alc268_base_init_verbs },
12862 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12863 .dac_nids = alc268_dac_nids,
12864 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12865 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012866 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012867 .hp_nid = 0x03,
12868 .dig_out_nid = ALC268_DIGOUT_NID,
12869 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12870 .channel_mode = alc268_modes,
12871 .input_mux = &alc268_capture_source,
12872 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012873 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012874 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012875 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012876 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12877 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012878 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12879 .dac_nids = alc268_dac_nids,
12880 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12881 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012882 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012883 .hp_nid = 0x03,
12884 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12885 .channel_mode = alc268_modes,
12886 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012887 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012888 .setup = alc268_toshiba_setup,
12889 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020012890 },
12891 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020012892 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012893 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012894 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12895 alc268_acer_verbs },
12896 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12897 .dac_nids = alc268_dac_nids,
12898 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12899 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012900 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012901 .hp_nid = 0x02,
12902 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12903 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012904 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012905 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012906 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012907 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012908 [ALC268_ACER_DMIC] = {
12909 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12910 alc268_beep_mixer },
12911 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12912 alc268_acer_verbs },
12913 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12914 .dac_nids = alc268_dac_nids,
12915 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12916 .adc_nids = alc268_adc_nids_alt,
12917 .capsrc_nids = alc268_capsrc_nids,
12918 .hp_nid = 0x02,
12919 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12920 .channel_mode = alc268_modes,
12921 .input_mux = &alc268_acer_dmic_capture_source,
12922 .unsol_event = alc268_acer_unsol_event,
12923 .init_hook = alc268_acer_init_hook,
12924 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012925 [ALC268_ACER_ASPIRE_ONE] = {
12926 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012927 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012928 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012929 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12930 alc268_acer_aspire_one_verbs },
12931 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12932 .dac_nids = alc268_dac_nids,
12933 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12934 .adc_nids = alc268_adc_nids_alt,
12935 .capsrc_nids = alc268_capsrc_nids,
12936 .hp_nid = 0x03,
12937 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12938 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012939 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012940 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012941 .init_hook = alc268_acer_lc_init_hook,
12942 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012943 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012944 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
12945 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012946 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12947 alc268_dell_verbs },
12948 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12949 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012950 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12951 .adc_nids = alc268_adc_nids_alt,
12952 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012953 .hp_nid = 0x02,
12954 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12955 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012956 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012957 .setup = alc268_dell_setup,
12958 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012959 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012960 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012961 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12962 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012963 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12964 alc268_toshiba_verbs },
12965 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12966 .dac_nids = alc268_dac_nids,
12967 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12968 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012969 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012970 .hp_nid = 0x03,
12971 .dig_out_nid = ALC268_DIGOUT_NID,
12972 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12973 .channel_mode = alc268_modes,
12974 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012975 .setup = alc268_toshiba_setup,
12976 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012977 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012978#ifdef CONFIG_SND_DEBUG
12979 [ALC268_TEST] = {
12980 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12981 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12982 alc268_volume_init_verbs },
12983 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12984 .dac_nids = alc268_dac_nids,
12985 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12986 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012987 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012988 .hp_nid = 0x03,
12989 .dig_out_nid = ALC268_DIGOUT_NID,
12990 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12991 .channel_mode = alc268_modes,
12992 .input_mux = &alc268_capture_source,
12993 },
12994#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012995};
12996
12997static int patch_alc268(struct hda_codec *codec)
12998{
12999 struct alc_spec *spec;
13000 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013001 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013002
Julia Lawallef86f582009-12-19 08:18:03 +010013003 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013004 if (spec == NULL)
13005 return -ENOMEM;
13006
13007 codec->spec = spec;
13008
13009 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13010 alc268_models,
13011 alc268_cfg_tbl);
13012
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013013 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13014 board_config = snd_hda_check_board_codec_sid_config(codec,
13015 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
13016
Kailang Yanga361d842007-06-05 12:30:55 +020013017 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013018 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13019 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013020 board_config = ALC268_AUTO;
13021 }
13022
13023 if (board_config == ALC268_AUTO) {
13024 /* automatic parse from the BIOS config */
13025 err = alc268_parse_auto_config(codec);
13026 if (err < 0) {
13027 alc_free(codec);
13028 return err;
13029 } else if (!err) {
13030 printk(KERN_INFO
13031 "hda_codec: Cannot set up configuration "
13032 "from BIOS. Using base mode...\n");
13033 board_config = ALC268_3ST;
13034 }
13035 }
13036
13037 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013038 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013039
Kailang Yanga361d842007-06-05 12:30:55 +020013040 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13041 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013042 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013043
Kailang Yanga361d842007-06-05 12:30:55 +020013044 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13045
Takashi Iwai22971e32009-02-10 11:56:44 +010013046 has_beep = 0;
13047 for (i = 0; i < spec->num_mixers; i++) {
13048 if (spec->mixers[i] == alc268_beep_mixer) {
13049 has_beep = 1;
13050 break;
13051 }
13052 }
13053
13054 if (has_beep) {
13055 err = snd_hda_attach_beep_device(codec, 0x1);
13056 if (err < 0) {
13057 alc_free(codec);
13058 return err;
13059 }
13060 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13061 /* override the amp caps for beep generator */
13062 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013063 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13064 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13065 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13066 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013067 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013068
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013069 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013070 /* check whether NID 0x07 is valid */
13071 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013072 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013073
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013074 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013075 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013076 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013077 if (spec->auto_mic ||
13078 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013079 spec->adc_nids = alc268_adc_nids_alt;
13080 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013081 if (spec->auto_mic)
13082 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013083 if (spec->auto_mic || spec->input_mux->num_items == 1)
13084 add_mixer(spec, alc268_capture_nosrc_mixer);
13085 else
13086 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013087 } else {
13088 spec->adc_nids = alc268_adc_nids;
13089 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013090 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013091 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013092 /* set default input source */
13093 for (i = 0; i < spec->num_adc_nids; i++)
13094 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13095 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013096 i < spec->num_mux_defs ?
13097 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013098 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013099 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013100
13101 spec->vmaster_nid = 0x02;
13102
Kailang Yanga361d842007-06-05 12:30:55 +020013103 codec->patch_ops = alc_patch_ops;
13104 if (board_config == ALC268_AUTO)
13105 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013106
Takashi Iwaidaead532008-11-28 12:55:36 +010013107 codec->proc_widget_hook = print_realtek_coef;
13108
Kailang Yanga361d842007-06-05 12:30:55 +020013109 return 0;
13110}
13111
13112/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013113 * ALC269 channel source setting (2 channel)
13114 */
13115#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13116
13117#define alc269_dac_nids alc260_dac_nids
13118
13119static hda_nid_t alc269_adc_nids[1] = {
13120 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013121 0x08,
13122};
13123
Takashi Iwaie01bf502008-08-21 16:25:07 +020013124static hda_nid_t alc269_capsrc_nids[1] = {
13125 0x23,
13126};
13127
13128/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
13129 * not a mux!
13130 */
13131
Kailang Yangf6a92242007-12-13 16:52:54 +010013132#define alc269_modes alc260_modes
13133#define alc269_capture_source alc880_lg_lw_capture_source
13134
13135static struct snd_kcontrol_new alc269_base_mixer[] = {
13136 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13137 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13138 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13139 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13140 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13141 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13142 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13143 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13144 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13145 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13146 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13147 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13148 { } /* end */
13149};
13150
Kailang Yang60db6b52008-08-26 13:13:00 +020013151static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13152 /* output mixer control */
13153 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13154 {
13155 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13156 .name = "Master Playback Switch",
13157 .info = snd_hda_mixer_amp_switch_info,
13158 .get = snd_hda_mixer_amp_switch_get,
13159 .put = alc268_acer_master_sw_put,
13160 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13161 },
13162 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13163 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13164 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13165 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13166 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13167 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013168 { }
13169};
13170
Tony Vroon64154832008-11-06 15:08:49 +000013171static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13172 /* output mixer control */
13173 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13174 {
13175 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13176 .name = "Master Playback Switch",
13177 .info = snd_hda_mixer_amp_switch_info,
13178 .get = snd_hda_mixer_amp_switch_get,
13179 .put = alc268_acer_master_sw_put,
13180 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13181 },
13182 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13183 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13184 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13185 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13186 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13187 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13188 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13189 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13190 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013191 { }
13192};
13193
Kailang Yangf53281e2008-07-18 12:36:43 +020013194static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013195 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013196 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013197 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013198 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013199 { } /* end */
13200};
13201
Kailang Yangf6a92242007-12-13 16:52:54 +010013202/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020013203static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
13204 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13205 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013206 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13207 { } /* end */
13208};
13209
13210/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020013211#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013212
Kailang Yang60db6b52008-08-26 13:13:00 +020013213static struct hda_verb alc269_quanta_fl1_verbs[] = {
13214 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13215 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13216 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13217 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13218 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13219 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13220 { }
13221};
13222
Tony Vroon64154832008-11-06 15:08:49 +000013223static struct hda_verb alc269_lifebook_verbs[] = {
13224 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13225 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13226 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13227 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13228 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13229 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13230 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13231 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13232 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13233 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13234 { }
13235};
13236
Kailang Yang60db6b52008-08-26 13:13:00 +020013237/* toggle speaker-output according to the hp-jack state */
13238static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13239{
13240 unsigned int present;
13241 unsigned char bits;
13242
Wu Fengguang864f92b2009-11-18 12:38:02 +080013243 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang60db6b52008-08-26 13:13:00 +020013244 bits = present ? AMP_IN_MUTE(0) : 0;
13245 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13246 AMP_IN_MUTE(0), bits);
13247 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13248 AMP_IN_MUTE(0), bits);
13249
13250 snd_hda_codec_write(codec, 0x20, 0,
13251 AC_VERB_SET_COEF_INDEX, 0x0c);
13252 snd_hda_codec_write(codec, 0x20, 0,
13253 AC_VERB_SET_PROC_COEF, 0x680);
13254
13255 snd_hda_codec_write(codec, 0x20, 0,
13256 AC_VERB_SET_COEF_INDEX, 0x0c);
13257 snd_hda_codec_write(codec, 0x20, 0,
13258 AC_VERB_SET_PROC_COEF, 0x480);
13259}
13260
Tony Vroon64154832008-11-06 15:08:49 +000013261/* toggle speaker-output according to the hp-jacks state */
13262static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13263{
13264 unsigned int present;
13265 unsigned char bits;
13266
13267 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013268 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013269
13270 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013271 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013272
13273 bits = present ? AMP_IN_MUTE(0) : 0;
13274 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13275 AMP_IN_MUTE(0), bits);
13276 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13277 AMP_IN_MUTE(0), bits);
13278
13279 snd_hda_codec_write(codec, 0x20, 0,
13280 AC_VERB_SET_COEF_INDEX, 0x0c);
13281 snd_hda_codec_write(codec, 0x20, 0,
13282 AC_VERB_SET_PROC_COEF, 0x680);
13283
13284 snd_hda_codec_write(codec, 0x20, 0,
13285 AC_VERB_SET_COEF_INDEX, 0x0c);
13286 snd_hda_codec_write(codec, 0x20, 0,
13287 AC_VERB_SET_PROC_COEF, 0x480);
13288}
13289
Tony Vroon64154832008-11-06 15:08:49 +000013290static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13291{
13292 unsigned int present_laptop;
13293 unsigned int present_dock;
13294
Wu Fengguang864f92b2009-11-18 12:38:02 +080013295 present_laptop = snd_hda_jack_detect(codec, 0x18);
13296 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000013297
13298 /* Laptop mic port overrides dock mic port, design decision */
13299 if (present_dock)
13300 snd_hda_codec_write(codec, 0x23, 0,
13301 AC_VERB_SET_CONNECT_SEL, 0x3);
13302 if (present_laptop)
13303 snd_hda_codec_write(codec, 0x23, 0,
13304 AC_VERB_SET_CONNECT_SEL, 0x0);
13305 if (!present_dock && !present_laptop)
13306 snd_hda_codec_write(codec, 0x23, 0,
13307 AC_VERB_SET_CONNECT_SEL, 0x1);
13308}
13309
Kailang Yang60db6b52008-08-26 13:13:00 +020013310static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13311 unsigned int res)
13312{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013313 switch (res >> 26) {
13314 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013315 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013316 break;
13317 case ALC880_MIC_EVENT:
13318 alc_mic_automute(codec);
13319 break;
13320 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013321}
13322
Tony Vroon64154832008-11-06 15:08:49 +000013323static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13324 unsigned int res)
13325{
13326 if ((res >> 26) == ALC880_HP_EVENT)
13327 alc269_lifebook_speaker_automute(codec);
13328 if ((res >> 26) == ALC880_MIC_EVENT)
13329 alc269_lifebook_mic_autoswitch(codec);
13330}
13331
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013332static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13333{
13334 struct alc_spec *spec = codec->spec;
13335 spec->ext_mic.pin = 0x18;
13336 spec->ext_mic.mux_idx = 0;
13337 spec->int_mic.pin = 0x19;
13338 spec->int_mic.mux_idx = 1;
13339 spec->auto_mic = 1;
13340}
13341
Kailang Yang60db6b52008-08-26 13:13:00 +020013342static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13343{
13344 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013345 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013346}
13347
Tony Vroon64154832008-11-06 15:08:49 +000013348static void alc269_lifebook_init_hook(struct hda_codec *codec)
13349{
13350 alc269_lifebook_speaker_automute(codec);
13351 alc269_lifebook_mic_autoswitch(codec);
13352}
13353
Kailang Yang60db6b52008-08-26 13:13:00 +020013354static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
13355 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13356 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13357 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13358 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13359 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13360 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13361 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13362 {}
13363};
13364
13365static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
13366 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13367 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13368 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13369 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13370 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13371 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13372 {}
13373};
13374
13375/* toggle speaker-output according to the hp-jack state */
13376static void alc269_speaker_automute(struct hda_codec *codec)
13377{
Kailang Yangebb83ee2009-12-17 12:23:00 +010013378 struct alc_spec *spec = codec->spec;
13379 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020013380 unsigned int present;
13381 unsigned char bits;
13382
Kailang Yangebb83ee2009-12-17 12:23:00 +010013383 present = snd_hda_jack_detect(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020013384 bits = present ? AMP_IN_MUTE(0) : 0;
13385 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13386 AMP_IN_MUTE(0), bits);
13387 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13388 AMP_IN_MUTE(0), bits);
13389}
13390
Kailang Yang60db6b52008-08-26 13:13:00 +020013391/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013392static void alc269_eeepc_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013393 unsigned int res)
13394{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013395 switch (res >> 26) {
13396 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013397 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013398 break;
13399 case ALC880_MIC_EVENT:
13400 alc_mic_automute(codec);
13401 break;
13402 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013403}
13404
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013405static void alc269_eeepc_dmic_setup(struct hda_codec *codec)
13406{
13407 struct alc_spec *spec = codec->spec;
13408 spec->ext_mic.pin = 0x18;
13409 spec->ext_mic.mux_idx = 0;
13410 spec->int_mic.pin = 0x12;
13411 spec->int_mic.mux_idx = 5;
13412 spec->auto_mic = 1;
13413}
13414
13415static void alc269_eeepc_amic_setup(struct hda_codec *codec)
13416{
13417 struct alc_spec *spec = codec->spec;
13418 spec->ext_mic.pin = 0x18;
13419 spec->ext_mic.mux_idx = 0;
13420 spec->int_mic.pin = 0x19;
13421 spec->int_mic.mux_idx = 1;
13422 spec->auto_mic = 1;
13423}
13424
13425static void alc269_eeepc_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013426{
13427 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013428 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013429}
13430
Kailang Yangf6a92242007-12-13 16:52:54 +010013431/*
13432 * generic initialization of ADC, input mixers and output mixers
13433 */
13434static struct hda_verb alc269_init_verbs[] = {
13435 /*
13436 * Unmute ADC0 and set the default input to mic-in
13437 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013438 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013439
13440 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13441 * analog-loopback mixer widget
13442 * Note: PASD motherboards uses the Line In 2 as the input for
13443 * front panel mic (mic 2)
13444 */
13445 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13446 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13447 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13448 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13449 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13450 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13451
13452 /*
13453 * Set up output mixers (0x0c - 0x0e)
13454 */
13455 /* set vol=0 to output mixers */
13456 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13457 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13458
13459 /* set up input amps for analog loopback */
13460 /* Amp Indices: DAC = 0, mixer = 1 */
13461 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13462 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13463 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13464 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13465 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13466 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13467
13468 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13469 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13470 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13471 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13472 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13473 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13474 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13475
13476 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13477 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13478 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13479 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13480 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13481 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13482 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13483
13484 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13485 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13486
13487 /* FIXME: use matrix-type input source selection */
13488 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13489 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013490 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13491 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013492 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13493 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13494
13495 /* set EAPD */
13496 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13497 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13498 { }
13499};
13500
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013501#define alc269_auto_create_multi_out_ctls \
13502 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020013503#define alc269_auto_create_input_ctls \
13504 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013505
13506#ifdef CONFIG_SND_HDA_POWER_SAVE
13507#define alc269_loopbacks alc880_loopbacks
13508#endif
13509
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013510/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013511#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13512#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13513#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13514#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13515
Takashi Iwaif03d3112009-03-05 14:18:16 +010013516static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13517 .substreams = 1,
13518 .channels_min = 2,
13519 .channels_max = 8,
13520 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13521 /* NID is set in alc_build_pcms */
13522 .ops = {
13523 .open = alc880_playback_pcm_open,
13524 .prepare = alc880_playback_pcm_prepare,
13525 .cleanup = alc880_playback_pcm_cleanup
13526 },
13527};
13528
13529static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13530 .substreams = 1,
13531 .channels_min = 2,
13532 .channels_max = 2,
13533 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13534 /* NID is set in alc_build_pcms */
13535};
13536
Kailang Yangf6a92242007-12-13 16:52:54 +010013537/*
13538 * BIOS auto configuration
13539 */
13540static int alc269_parse_auto_config(struct hda_codec *codec)
13541{
13542 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013543 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013544 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13545
13546 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13547 alc269_ignore);
13548 if (err < 0)
13549 return err;
13550
13551 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13552 if (err < 0)
13553 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013554 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010013555 if (err < 0)
13556 return err;
13557
13558 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13559
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013560 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013561 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13562
Takashi Iwai603c4012008-07-30 15:01:44 +020013563 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013564 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013565
Takashi Iwaid88897e2008-10-31 15:01:37 +010013566 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013567 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013568 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013569 /* set default input source */
13570 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13571 0, AC_VERB_SET_CONNECT_SEL,
13572 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013573
13574 err = alc_auto_add_mic_boost(codec);
13575 if (err < 0)
13576 return err;
13577
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013578 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013579 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013580
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013581 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13582
Kailang Yangf6a92242007-12-13 16:52:54 +010013583 return 1;
13584}
13585
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013586#define alc269_auto_init_multi_out alc268_auto_init_multi_out
13587#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010013588#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13589
13590
13591/* init callback for auto-configuration model -- overriding the default init */
13592static void alc269_auto_init(struct hda_codec *codec)
13593{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013594 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013595 alc269_auto_init_multi_out(codec);
13596 alc269_auto_init_hp_out(codec);
13597 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013598 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013599 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013600}
13601
13602/*
13603 * configuration and preset
13604 */
13605static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013606 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013607 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013608 [ALC269_ASUS_AMIC] = "asus-amic",
13609 [ALC269_ASUS_DMIC] = "asus-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000013610 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020013611 [ALC269_LIFEBOOK] = "lifebook",
13612 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010013613};
13614
13615static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013616 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013617 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013618 ALC269_ASUS_AMIC),
13619 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_ASUS_AMIC),
13620 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80JT", ALC269_ASUS_AMIC),
13621 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_ASUS_AMIC),
13622 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_ASUS_AMIC),
13623 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_ASUS_AMIC),
13624 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_ASUS_AMIC),
13625 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_ASUS_AMIC),
13626 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_ASUS_AMIC),
13627 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_ASUS_AMIC),
13628 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_ASUS_AMIC),
13629 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_ASUS_AMIC),
13630 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_ASUS_AMIC),
13631 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_ASUS_AMIC),
13632 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_ASUS_AMIC),
13633 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_ASUS_AMIC),
13634 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_ASUS_AMIC),
13635 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_ASUS_AMIC),
13636 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_ASUS_AMIC),
13637 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_ASUS_AMIC),
13638 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_ASUS_AMIC),
13639 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_AMIC),
13640 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_ASUS_AMIC),
13641 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_AMIC),
13642 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_DMIC),
13643 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_AMIC),
13644 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_AMIC),
13645 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_AMIC),
13646 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020013647 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013648 ALC269_ASUS_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020013649 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013650 ALC269_ASUS_DMIC),
13651 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_ASUS_DMIC),
13652 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_ASUS_DMIC),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013653 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013654 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013655 {}
13656};
13657
13658static struct alc_config_preset alc269_presets[] = {
13659 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013660 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013661 .init_verbs = { alc269_init_verbs },
13662 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13663 .dac_nids = alc269_dac_nids,
13664 .hp_nid = 0x03,
13665 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13666 .channel_mode = alc269_modes,
13667 .input_mux = &alc269_capture_source,
13668 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013669 [ALC269_QUANTA_FL1] = {
13670 .mixers = { alc269_quanta_fl1_mixer },
13671 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13672 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13673 .dac_nids = alc269_dac_nids,
13674 .hp_nid = 0x03,
13675 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13676 .channel_mode = alc269_modes,
13677 .input_mux = &alc269_capture_source,
13678 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013679 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020013680 .init_hook = alc269_quanta_fl1_init_hook,
13681 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010013682 [ALC269_ASUS_AMIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013683 .mixers = { alc269_eeepc_mixer },
13684 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013685 .init_verbs = { alc269_init_verbs,
13686 alc269_eeepc_amic_init_verbs },
13687 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13688 .dac_nids = alc269_dac_nids,
13689 .hp_nid = 0x03,
13690 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13691 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013692 .unsol_event = alc269_eeepc_unsol_event,
13693 .setup = alc269_eeepc_amic_setup,
13694 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013695 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010013696 [ALC269_ASUS_DMIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013697 .mixers = { alc269_eeepc_mixer },
13698 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013699 .init_verbs = { alc269_init_verbs,
13700 alc269_eeepc_dmic_init_verbs },
13701 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13702 .dac_nids = alc269_dac_nids,
13703 .hp_nid = 0x03,
13704 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13705 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013706 .unsol_event = alc269_eeepc_unsol_event,
13707 .setup = alc269_eeepc_dmic_setup,
13708 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013709 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013710 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013711 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013712 .cap_mixer = alc269_epc_capture_mixer,
13713 .init_verbs = { alc269_init_verbs,
13714 alc269_eeepc_dmic_init_verbs },
13715 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13716 .dac_nids = alc269_dac_nids,
13717 .hp_nid = 0x03,
13718 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13719 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013720 .unsol_event = alc269_eeepc_unsol_event,
13721 .setup = alc269_eeepc_dmic_setup,
13722 .init_hook = alc269_eeepc_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010013723 },
Tony Vroon64154832008-11-06 15:08:49 +000013724 [ALC269_LIFEBOOK] = {
13725 .mixers = { alc269_lifebook_mixer },
13726 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13727 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13728 .dac_nids = alc269_dac_nids,
13729 .hp_nid = 0x03,
13730 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13731 .channel_mode = alc269_modes,
13732 .input_mux = &alc269_capture_source,
13733 .unsol_event = alc269_lifebook_unsol_event,
13734 .init_hook = alc269_lifebook_init_hook,
13735 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013736};
13737
13738static int patch_alc269(struct hda_codec *codec)
13739{
13740 struct alc_spec *spec;
13741 int board_config;
13742 int err;
13743
13744 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13745 if (spec == NULL)
13746 return -ENOMEM;
13747
13748 codec->spec = spec;
13749
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013750 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13751
Kailang Yang274693f2009-12-03 10:07:50 +010013752 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
13753 kfree(codec->chip_name);
13754 codec->chip_name = kstrdup("ALC259", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010013755 if (!codec->chip_name) {
13756 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010013757 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010013758 }
Kailang Yang274693f2009-12-03 10:07:50 +010013759 }
13760
Kailang Yangf6a92242007-12-13 16:52:54 +010013761 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13762 alc269_models,
13763 alc269_cfg_tbl);
13764
13765 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013766 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13767 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013768 board_config = ALC269_AUTO;
13769 }
13770
13771 if (board_config == ALC269_AUTO) {
13772 /* automatic parse from the BIOS config */
13773 err = alc269_parse_auto_config(codec);
13774 if (err < 0) {
13775 alc_free(codec);
13776 return err;
13777 } else if (!err) {
13778 printk(KERN_INFO
13779 "hda_codec: Cannot set up configuration "
13780 "from BIOS. Using base mode...\n");
13781 board_config = ALC269_BASIC;
13782 }
13783 }
13784
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013785 err = snd_hda_attach_beep_device(codec, 0x1);
13786 if (err < 0) {
13787 alc_free(codec);
13788 return err;
13789 }
13790
Kailang Yangf6a92242007-12-13 16:52:54 +010013791 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013792 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010013793
Takashi Iwaif03d3112009-03-05 14:18:16 +010013794 if (codec->subsystem_id == 0x17aa3bf8) {
13795 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13796 * fix the sample rate of analog I/O to 44.1kHz
13797 */
13798 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13799 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13800 } else {
13801 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13802 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13803 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013804 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13805 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13806
13807 spec->adc_nids = alc269_adc_nids;
13808 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013809 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013810 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013811 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013812 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013813
Takashi Iwai100d5eb2009-08-10 11:55:51 +020013814 spec->vmaster_nid = 0x02;
13815
Kailang Yangf6a92242007-12-13 16:52:54 +010013816 codec->patch_ops = alc_patch_ops;
13817 if (board_config == ALC269_AUTO)
13818 spec->init_hook = alc269_auto_init;
13819#ifdef CONFIG_SND_HDA_POWER_SAVE
13820 if (!spec->loopback.amplist)
13821 spec->loopback.amplist = alc269_loopbacks;
13822#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013823 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013824
13825 return 0;
13826}
13827
13828/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013829 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13830 */
13831
13832/*
13833 * set the path ways for 2 channel output
13834 * need to set the codec line out and mic 1 pin widgets to inputs
13835 */
13836static struct hda_verb alc861_threestack_ch2_init[] = {
13837 /* set pin widget 1Ah (line in) for input */
13838 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013839 /* set pin widget 18h (mic1/2) for input, for mic also enable
13840 * the vref
13841 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013842 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13843
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013844 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13845#if 0
13846 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13847 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13848#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013849 { } /* end */
13850};
13851/*
13852 * 6ch mode
13853 * need to set the codec line out and mic 1 pin widgets to outputs
13854 */
13855static struct hda_verb alc861_threestack_ch6_init[] = {
13856 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13857 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13858 /* set pin widget 18h (mic1) for output (CLFE)*/
13859 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13860
13861 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013862 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013863
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013864 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13865#if 0
13866 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13867 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13868#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013869 { } /* end */
13870};
13871
13872static struct hda_channel_mode alc861_threestack_modes[2] = {
13873 { 2, alc861_threestack_ch2_init },
13874 { 6, alc861_threestack_ch6_init },
13875};
Takashi Iwai22309c32006-08-09 16:57:28 +020013876/* Set mic1 as input and unmute the mixer */
13877static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13878 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13879 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13880 { } /* end */
13881};
13882/* Set mic1 as output and mute mixer */
13883static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13884 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13885 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13886 { } /* end */
13887};
13888
13889static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13890 { 2, alc861_uniwill_m31_ch2_init },
13891 { 4, alc861_uniwill_m31_ch4_init },
13892};
Kailang Yangdf694da2005-12-05 19:42:22 +010013893
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013894/* Set mic1 and line-in as input and unmute the mixer */
13895static struct hda_verb alc861_asus_ch2_init[] = {
13896 /* set pin widget 1Ah (line in) for input */
13897 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013898 /* set pin widget 18h (mic1/2) for input, for mic also enable
13899 * the vref
13900 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013901 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13902
13903 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13904#if 0
13905 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13906 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13907#endif
13908 { } /* end */
13909};
13910/* Set mic1 nad line-in as output and mute mixer */
13911static struct hda_verb alc861_asus_ch6_init[] = {
13912 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13913 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13914 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13915 /* set pin widget 18h (mic1) for output (CLFE)*/
13916 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13917 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13918 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13919 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13920
13921 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13922#if 0
13923 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13924 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13925#endif
13926 { } /* end */
13927};
13928
13929static struct hda_channel_mode alc861_asus_modes[2] = {
13930 { 2, alc861_asus_ch2_init },
13931 { 6, alc861_asus_ch6_init },
13932};
13933
Kailang Yangdf694da2005-12-05 19:42:22 +010013934/* patch-ALC861 */
13935
13936static struct snd_kcontrol_new alc861_base_mixer[] = {
13937 /* output mixer control */
13938 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13939 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13940 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13941 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13942 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13943
13944 /*Input mixer control */
13945 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13946 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13947 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13948 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13949 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13950 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13951 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13952 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13953 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13954 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013955
Kailang Yangdf694da2005-12-05 19:42:22 +010013956 { } /* end */
13957};
13958
13959static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13960 /* output mixer control */
13961 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13962 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13963 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13964 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13965 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13966
13967 /* Input mixer control */
13968 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13969 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13970 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13971 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13972 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13973 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13974 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13975 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13976 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13977 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013978
Kailang Yangdf694da2005-12-05 19:42:22 +010013979 {
13980 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13981 .name = "Channel Mode",
13982 .info = alc_ch_mode_info,
13983 .get = alc_ch_mode_get,
13984 .put = alc_ch_mode_put,
13985 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13986 },
13987 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013988};
13989
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013990static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013991 /* output mixer control */
13992 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13993 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13994 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013995
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013996 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013997};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013998
Takashi Iwai22309c32006-08-09 16:57:28 +020013999static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
14000 /* output mixer control */
14001 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14002 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14003 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14004 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14005 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14006
14007 /* Input mixer control */
14008 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14009 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14010 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14011 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14012 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14013 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14014 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14015 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14016 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14017 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014018
Takashi Iwai22309c32006-08-09 16:57:28 +020014019 {
14020 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14021 .name = "Channel Mode",
14022 .info = alc_ch_mode_info,
14023 .get = alc_ch_mode_get,
14024 .put = alc_ch_mode_put,
14025 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
14026 },
14027 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014028};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014029
14030static struct snd_kcontrol_new alc861_asus_mixer[] = {
14031 /* output mixer control */
14032 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14033 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14034 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14035 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14036 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14037
14038 /* Input mixer control */
14039 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14040 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14041 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14042 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14043 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14044 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14045 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14046 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14047 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014048 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
14049
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014050 {
14051 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14052 .name = "Channel Mode",
14053 .info = alc_ch_mode_info,
14054 .get = alc_ch_mode_get,
14055 .put = alc_ch_mode_put,
14056 .private_value = ARRAY_SIZE(alc861_asus_modes),
14057 },
14058 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014059};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014060
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014061/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014062static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014063 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14064 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014065 { }
14066};
14067
Kailang Yangdf694da2005-12-05 19:42:22 +010014068/*
14069 * generic initialization of ADC, input mixers and output mixers
14070 */
14071static struct hda_verb alc861_base_init_verbs[] = {
14072 /*
14073 * Unmute ADC0 and set the default input to mic-in
14074 */
14075 /* port-A for surround (rear panel) */
14076 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14077 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
14078 /* port-B for mic-in (rear panel) with vref */
14079 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14080 /* port-C for line-in (rear panel) */
14081 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14082 /* port-D for Front */
14083 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14084 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14085 /* port-E for HP out (front panel) */
14086 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14087 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014088 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014089 /* port-F for mic-in (front panel) with vref */
14090 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14091 /* port-G for CLFE (rear panel) */
14092 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14093 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
14094 /* port-H for side (rear panel) */
14095 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14096 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
14097 /* CD-in */
14098 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14099 /* route front mic to ADC1*/
14100 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14101 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014102
Kailang Yangdf694da2005-12-05 19:42:22 +010014103 /* Unmute DAC0~3 & spdif out*/
14104 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14105 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14106 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14107 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14108 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014109
Kailang Yangdf694da2005-12-05 19:42:22 +010014110 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14111 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14112 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14113 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14114 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014115
Kailang Yangdf694da2005-12-05 19:42:22 +010014116 /* Unmute Stereo Mixer 15 */
14117 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14118 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14119 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014120 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014121
14122 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14123 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14124 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14125 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14126 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14127 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14128 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14129 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014130 /* hp used DAC 3 (Front) */
14131 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014132 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14133
14134 { }
14135};
14136
14137static struct hda_verb alc861_threestack_init_verbs[] = {
14138 /*
14139 * Unmute ADC0 and set the default input to mic-in
14140 */
14141 /* port-A for surround (rear panel) */
14142 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14143 /* port-B for mic-in (rear panel) with vref */
14144 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14145 /* port-C for line-in (rear panel) */
14146 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14147 /* port-D for Front */
14148 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14149 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14150 /* port-E for HP out (front panel) */
14151 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14152 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014153 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014154 /* port-F for mic-in (front panel) with vref */
14155 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14156 /* port-G for CLFE (rear panel) */
14157 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14158 /* port-H for side (rear panel) */
14159 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14160 /* CD-in */
14161 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14162 /* route front mic to ADC1*/
14163 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14164 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14165 /* Unmute DAC0~3 & spdif out*/
14166 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14167 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14168 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14169 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14170 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014171
Kailang Yangdf694da2005-12-05 19:42:22 +010014172 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14173 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14174 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14175 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14176 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014177
Kailang Yangdf694da2005-12-05 19:42:22 +010014178 /* Unmute Stereo Mixer 15 */
14179 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14180 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14181 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014182 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014183
14184 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14185 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14186 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14187 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14188 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14189 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14190 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14191 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014192 /* hp used DAC 3 (Front) */
14193 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014194 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14195 { }
14196};
Takashi Iwai22309c32006-08-09 16:57:28 +020014197
14198static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
14199 /*
14200 * Unmute ADC0 and set the default input to mic-in
14201 */
14202 /* port-A for surround (rear panel) */
14203 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14204 /* port-B for mic-in (rear panel) with vref */
14205 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14206 /* port-C for line-in (rear panel) */
14207 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14208 /* port-D for Front */
14209 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14210 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14211 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014212 /* this has to be set to VREF80 */
14213 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014214 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014215 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014216 /* port-F for mic-in (front panel) with vref */
14217 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14218 /* port-G for CLFE (rear panel) */
14219 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14220 /* port-H for side (rear panel) */
14221 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14222 /* CD-in */
14223 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14224 /* route front mic to ADC1*/
14225 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14226 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14227 /* Unmute DAC0~3 & spdif out*/
14228 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14229 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14230 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14231 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14232 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014233
Takashi Iwai22309c32006-08-09 16:57:28 +020014234 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14235 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14236 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14237 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14238 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014239
Takashi Iwai22309c32006-08-09 16:57:28 +020014240 /* Unmute Stereo Mixer 15 */
14241 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14242 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14243 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014244 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014245
14246 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14247 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14248 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14249 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14250 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14251 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14252 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14253 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014254 /* hp used DAC 3 (Front) */
14255 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014256 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14257 { }
14258};
14259
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014260static struct hda_verb alc861_asus_init_verbs[] = {
14261 /*
14262 * Unmute ADC0 and set the default input to mic-in
14263 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014264 /* port-A for surround (rear panel)
14265 * according to codec#0 this is the HP jack
14266 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014267 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14268 /* route front PCM to HP */
14269 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14270 /* port-B for mic-in (rear panel) with vref */
14271 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14272 /* port-C for line-in (rear panel) */
14273 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14274 /* port-D for Front */
14275 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14276 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14277 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014278 /* this has to be set to VREF80 */
14279 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014280 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014281 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014282 /* port-F for mic-in (front panel) with vref */
14283 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14284 /* port-G for CLFE (rear panel) */
14285 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14286 /* port-H for side (rear panel) */
14287 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14288 /* CD-in */
14289 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14290 /* route front mic to ADC1*/
14291 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14292 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14293 /* Unmute DAC0~3 & spdif out*/
14294 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14295 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14296 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14297 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14298 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14299 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14300 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14301 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14302 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14303 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014304
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014305 /* Unmute Stereo Mixer 15 */
14306 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14307 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14308 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014309 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014310
14311 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14312 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14313 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14314 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14315 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14316 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14317 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14318 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014319 /* hp used DAC 3 (Front) */
14320 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014321 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14322 { }
14323};
14324
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014325/* additional init verbs for ASUS laptops */
14326static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14327 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14328 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14329 { }
14330};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014331
Kailang Yangdf694da2005-12-05 19:42:22 +010014332/*
14333 * generic initialization of ADC, input mixers and output mixers
14334 */
14335static struct hda_verb alc861_auto_init_verbs[] = {
14336 /*
14337 * Unmute ADC0 and set the default input to mic-in
14338 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014339 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014340 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014341
Kailang Yangdf694da2005-12-05 19:42:22 +010014342 /* Unmute DAC0~3 & spdif out*/
14343 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14344 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14345 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14346 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14347 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014348
Kailang Yangdf694da2005-12-05 19:42:22 +010014349 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14350 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14351 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14352 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14353 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014354
Kailang Yangdf694da2005-12-05 19:42:22 +010014355 /* Unmute Stereo Mixer 15 */
14356 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14357 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14358 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14359 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14360
Takashi Iwai1c209302009-07-22 15:17:45 +020014361 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14362 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14363 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14364 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14365 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14366 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14367 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14368 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014369
14370 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14371 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014372 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14373 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014374 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14375 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014376 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14377 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014378
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014379 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014380
14381 { }
14382};
14383
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014384static struct hda_verb alc861_toshiba_init_verbs[] = {
14385 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014386
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014387 { }
14388};
14389
14390/* toggle speaker-output according to the hp-jack state */
14391static void alc861_toshiba_automute(struct hda_codec *codec)
14392{
Wu Fengguang864f92b2009-11-18 12:38:02 +080014393 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014394
Takashi Iwai47fd8302007-08-10 17:11:07 +020014395 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14396 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14397 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14398 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014399}
14400
14401static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14402 unsigned int res)
14403{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014404 if ((res >> 26) == ALC880_HP_EVENT)
14405 alc861_toshiba_automute(codec);
14406}
14407
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014408/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014409#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14410#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14411#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14412#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14413
14414
14415#define ALC861_DIGOUT_NID 0x07
14416
14417static struct hda_channel_mode alc861_8ch_modes[1] = {
14418 { 8, NULL }
14419};
14420
14421static hda_nid_t alc861_dac_nids[4] = {
14422 /* front, surround, clfe, side */
14423 0x03, 0x06, 0x05, 0x04
14424};
14425
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014426static hda_nid_t alc660_dac_nids[3] = {
14427 /* front, clfe, surround */
14428 0x03, 0x05, 0x06
14429};
14430
Kailang Yangdf694da2005-12-05 19:42:22 +010014431static hda_nid_t alc861_adc_nids[1] = {
14432 /* ADC0-2 */
14433 0x08,
14434};
14435
14436static struct hda_input_mux alc861_capture_source = {
14437 .num_items = 5,
14438 .items = {
14439 { "Mic", 0x0 },
14440 { "Front Mic", 0x3 },
14441 { "Line", 0x1 },
14442 { "CD", 0x4 },
14443 { "Mixer", 0x5 },
14444 },
14445};
14446
Takashi Iwai1c209302009-07-22 15:17:45 +020014447static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14448{
14449 struct alc_spec *spec = codec->spec;
14450 hda_nid_t mix, srcs[5];
14451 int i, j, num;
14452
14453 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14454 return 0;
14455 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14456 if (num < 0)
14457 return 0;
14458 for (i = 0; i < num; i++) {
14459 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014460 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014461 if (type != AC_WID_AUD_OUT)
14462 continue;
14463 for (j = 0; j < spec->multiout.num_dacs; j++)
14464 if (spec->multiout.dac_nids[j] == srcs[i])
14465 break;
14466 if (j >= spec->multiout.num_dacs)
14467 return srcs[i];
14468 }
14469 return 0;
14470}
14471
Kailang Yangdf694da2005-12-05 19:42:22 +010014472/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014473static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014474 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014475{
Takashi Iwai1c209302009-07-22 15:17:45 +020014476 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014477 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014478 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014479
14480 spec->multiout.dac_nids = spec->private_dac_nids;
14481 for (i = 0; i < cfg->line_outs; i++) {
14482 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014483 dac = alc861_look_for_dac(codec, nid);
14484 if (!dac)
14485 continue;
14486 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014487 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014488 return 0;
14489}
14490
Takashi Iwai1c209302009-07-22 15:17:45 +020014491static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14492 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014493{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020014494 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020014495 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14496}
14497
14498/* add playback controls from the parsed DAC table */
14499static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14500 const struct auto_pin_cfg *cfg)
14501{
14502 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014503 static const char *chname[4] = {
14504 "Front", "Surround", NULL /*CLFE*/, "Side"
14505 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014506 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014507 int i, err;
14508
14509 if (cfg->line_outs == 1) {
14510 const char *pfx = NULL;
14511 if (!cfg->hp_outs)
14512 pfx = "Master";
14513 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14514 pfx = "Speaker";
14515 if (pfx) {
14516 nid = spec->multiout.dac_nids[0];
14517 return alc861_create_out_sw(codec, pfx, nid, 3);
14518 }
14519 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014520
14521 for (i = 0; i < cfg->line_outs; i++) {
14522 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014523 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014524 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014525 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014526 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014527 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014528 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014529 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014530 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014531 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014532 return err;
14533 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014534 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014535 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014536 return err;
14537 }
14538 }
14539 return 0;
14540}
14541
Takashi Iwai1c209302009-07-22 15:17:45 +020014542static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014543{
Takashi Iwai1c209302009-07-22 15:17:45 +020014544 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014545 int err;
14546 hda_nid_t nid;
14547
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014548 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014549 return 0;
14550
14551 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014552 nid = alc861_look_for_dac(codec, pin);
14553 if (nid) {
14554 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14555 if (err < 0)
14556 return err;
14557 spec->multiout.hp_nid = nid;
14558 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014559 }
14560 return 0;
14561}
14562
14563/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020014564static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014565 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014566{
Takashi Iwai05f5f472009-08-25 13:10:18 +020014567 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014568}
14569
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014570static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14571 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014572 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014573{
Takashi Iwai1c209302009-07-22 15:17:45 +020014574 hda_nid_t mix, srcs[5];
14575 int i, num;
14576
Jacek Luczak564c5be2008-05-03 18:41:23 +020014577 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14578 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014579 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014580 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014581 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14582 return;
14583 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14584 if (num < 0)
14585 return;
14586 for (i = 0; i < num; i++) {
14587 unsigned int mute;
14588 if (srcs[i] == dac || srcs[i] == 0x15)
14589 mute = AMP_IN_UNMUTE(i);
14590 else
14591 mute = AMP_IN_MUTE(i);
14592 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14593 mute);
14594 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014595}
14596
14597static void alc861_auto_init_multi_out(struct hda_codec *codec)
14598{
14599 struct alc_spec *spec = codec->spec;
14600 int i;
14601
14602 for (i = 0; i < spec->autocfg.line_outs; i++) {
14603 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014604 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014605 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014606 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014607 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014608 }
14609}
14610
14611static void alc861_auto_init_hp_out(struct hda_codec *codec)
14612{
14613 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014614
Takashi Iwai15870f02009-10-05 08:25:13 +020014615 if (spec->autocfg.hp_outs)
14616 alc861_auto_set_output_and_unmute(codec,
14617 spec->autocfg.hp_pins[0],
14618 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014619 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020014620 if (spec->autocfg.speaker_outs)
14621 alc861_auto_set_output_and_unmute(codec,
14622 spec->autocfg.speaker_pins[0],
14623 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020014624 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014625}
14626
14627static void alc861_auto_init_analog_input(struct hda_codec *codec)
14628{
14629 struct alc_spec *spec = codec->spec;
14630 int i;
14631
14632 for (i = 0; i < AUTO_PIN_LAST; i++) {
14633 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014634 if (nid >= 0x0c && nid <= 0x11)
14635 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014636 }
14637}
14638
14639/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014640/* return 1 if successful, 0 if the proper config is not found,
14641 * or a negative error code
14642 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014643static int alc861_parse_auto_config(struct hda_codec *codec)
14644{
14645 struct alc_spec *spec = codec->spec;
14646 int err;
14647 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14648
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014649 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14650 alc861_ignore);
14651 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014652 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014653 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014654 return 0; /* can't find valid BIOS pin config */
14655
Takashi Iwai1c209302009-07-22 15:17:45 +020014656 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014657 if (err < 0)
14658 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014659 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014660 if (err < 0)
14661 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014662 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014663 if (err < 0)
14664 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014665 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014666 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014667 return err;
14668
14669 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14670
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014671 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014672 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14673
Takashi Iwai603c4012008-07-30 15:01:44 +020014674 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014675 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014676
Takashi Iwaid88897e2008-10-31 15:01:37 +010014677 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014678
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014679 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014680 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014681
14682 spec->adc_nids = alc861_adc_nids;
14683 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014684 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014685
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014686 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14687
Kailang Yangdf694da2005-12-05 19:42:22 +010014688 return 1;
14689}
14690
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014691/* additional initialization for auto-configuration model */
14692static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014693{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014694 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014695 alc861_auto_init_multi_out(codec);
14696 alc861_auto_init_hp_out(codec);
14697 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014698 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014699 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014700}
14701
Takashi Iwaicb53c622007-08-10 17:21:45 +020014702#ifdef CONFIG_SND_HDA_POWER_SAVE
14703static struct hda_amp_list alc861_loopbacks[] = {
14704 { 0x15, HDA_INPUT, 0 },
14705 { 0x15, HDA_INPUT, 1 },
14706 { 0x15, HDA_INPUT, 2 },
14707 { 0x15, HDA_INPUT, 3 },
14708 { } /* end */
14709};
14710#endif
14711
Kailang Yangdf694da2005-12-05 19:42:22 +010014712
14713/*
14714 * configuration and preset
14715 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014716static const char *alc861_models[ALC861_MODEL_LAST] = {
14717 [ALC861_3ST] = "3stack",
14718 [ALC660_3ST] = "3stack-660",
14719 [ALC861_3ST_DIG] = "3stack-dig",
14720 [ALC861_6ST_DIG] = "6stack-dig",
14721 [ALC861_UNIWILL_M31] = "uniwill-m31",
14722 [ALC861_TOSHIBA] = "toshiba",
14723 [ALC861_ASUS] = "asus",
14724 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14725 [ALC861_AUTO] = "auto",
14726};
14727
14728static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014729 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014730 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14731 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14732 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014733 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014734 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014735 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014736 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14737 * Any other models that need this preset?
14738 */
14739 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014740 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14741 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014742 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14743 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14744 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14745 /* FIXME: the below seems conflict */
14746 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14747 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14748 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014749 {}
14750};
14751
14752static struct alc_config_preset alc861_presets[] = {
14753 [ALC861_3ST] = {
14754 .mixers = { alc861_3ST_mixer },
14755 .init_verbs = { alc861_threestack_init_verbs },
14756 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14757 .dac_nids = alc861_dac_nids,
14758 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14759 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014760 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014761 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14762 .adc_nids = alc861_adc_nids,
14763 .input_mux = &alc861_capture_source,
14764 },
14765 [ALC861_3ST_DIG] = {
14766 .mixers = { alc861_base_mixer },
14767 .init_verbs = { alc861_threestack_init_verbs },
14768 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14769 .dac_nids = alc861_dac_nids,
14770 .dig_out_nid = ALC861_DIGOUT_NID,
14771 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14772 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014773 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014774 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14775 .adc_nids = alc861_adc_nids,
14776 .input_mux = &alc861_capture_source,
14777 },
14778 [ALC861_6ST_DIG] = {
14779 .mixers = { alc861_base_mixer },
14780 .init_verbs = { alc861_base_init_verbs },
14781 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14782 .dac_nids = alc861_dac_nids,
14783 .dig_out_nid = ALC861_DIGOUT_NID,
14784 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14785 .channel_mode = alc861_8ch_modes,
14786 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14787 .adc_nids = alc861_adc_nids,
14788 .input_mux = &alc861_capture_source,
14789 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014790 [ALC660_3ST] = {
14791 .mixers = { alc861_3ST_mixer },
14792 .init_verbs = { alc861_threestack_init_verbs },
14793 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14794 .dac_nids = alc660_dac_nids,
14795 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14796 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014797 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014798 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14799 .adc_nids = alc861_adc_nids,
14800 .input_mux = &alc861_capture_source,
14801 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014802 [ALC861_UNIWILL_M31] = {
14803 .mixers = { alc861_uniwill_m31_mixer },
14804 .init_verbs = { alc861_uniwill_m31_init_verbs },
14805 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14806 .dac_nids = alc861_dac_nids,
14807 .dig_out_nid = ALC861_DIGOUT_NID,
14808 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14809 .channel_mode = alc861_uniwill_m31_modes,
14810 .need_dac_fix = 1,
14811 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14812 .adc_nids = alc861_adc_nids,
14813 .input_mux = &alc861_capture_source,
14814 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014815 [ALC861_TOSHIBA] = {
14816 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014817 .init_verbs = { alc861_base_init_verbs,
14818 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014819 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14820 .dac_nids = alc861_dac_nids,
14821 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14822 .channel_mode = alc883_3ST_2ch_modes,
14823 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14824 .adc_nids = alc861_adc_nids,
14825 .input_mux = &alc861_capture_source,
14826 .unsol_event = alc861_toshiba_unsol_event,
14827 .init_hook = alc861_toshiba_automute,
14828 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014829 [ALC861_ASUS] = {
14830 .mixers = { alc861_asus_mixer },
14831 .init_verbs = { alc861_asus_init_verbs },
14832 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14833 .dac_nids = alc861_dac_nids,
14834 .dig_out_nid = ALC861_DIGOUT_NID,
14835 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14836 .channel_mode = alc861_asus_modes,
14837 .need_dac_fix = 1,
14838 .hp_nid = 0x06,
14839 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14840 .adc_nids = alc861_adc_nids,
14841 .input_mux = &alc861_capture_source,
14842 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014843 [ALC861_ASUS_LAPTOP] = {
14844 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14845 .init_verbs = { alc861_asus_init_verbs,
14846 alc861_asus_laptop_init_verbs },
14847 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14848 .dac_nids = alc861_dac_nids,
14849 .dig_out_nid = ALC861_DIGOUT_NID,
14850 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14851 .channel_mode = alc883_3ST_2ch_modes,
14852 .need_dac_fix = 1,
14853 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14854 .adc_nids = alc861_adc_nids,
14855 .input_mux = &alc861_capture_source,
14856 },
14857};
Kailang Yangdf694da2005-12-05 19:42:22 +010014858
Takashi Iwaicfc9b062009-12-01 12:19:37 +010014859/* Pin config fixes */
14860enum {
14861 PINFIX_FSC_AMILO_PI1505,
14862};
14863
14864static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = {
14865 { 0x0b, 0x0221101f }, /* HP */
14866 { 0x0f, 0x90170310 }, /* speaker */
14867 { }
14868};
14869
14870static const struct alc_fixup alc861_fixups[] = {
14871 [PINFIX_FSC_AMILO_PI1505] = {
14872 .pins = alc861_fsc_amilo_pi1505_pinfix
14873 },
14874};
14875
14876static struct snd_pci_quirk alc861_fixup_tbl[] = {
14877 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
14878 {}
14879};
Kailang Yangdf694da2005-12-05 19:42:22 +010014880
14881static int patch_alc861(struct hda_codec *codec)
14882{
14883 struct alc_spec *spec;
14884 int board_config;
14885 int err;
14886
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014887 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014888 if (spec == NULL)
14889 return -ENOMEM;
14890
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014891 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014892
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014893 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14894 alc861_models,
14895 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014896
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014897 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014898 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14899 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014900 board_config = ALC861_AUTO;
14901 }
14902
Takashi Iwaicfc9b062009-12-01 12:19:37 +010014903 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups);
14904
Kailang Yangdf694da2005-12-05 19:42:22 +010014905 if (board_config == ALC861_AUTO) {
14906 /* automatic parse from the BIOS config */
14907 err = alc861_parse_auto_config(codec);
14908 if (err < 0) {
14909 alc_free(codec);
14910 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014911 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014912 printk(KERN_INFO
14913 "hda_codec: Cannot set up configuration "
14914 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014915 board_config = ALC861_3ST_DIG;
14916 }
14917 }
14918
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014919 err = snd_hda_attach_beep_device(codec, 0x23);
14920 if (err < 0) {
14921 alc_free(codec);
14922 return err;
14923 }
14924
Kailang Yangdf694da2005-12-05 19:42:22 +010014925 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014926 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014927
Kailang Yangdf694da2005-12-05 19:42:22 +010014928 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14929 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14930
Kailang Yangdf694da2005-12-05 19:42:22 +010014931 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14932 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14933
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010014934 if (!spec->cap_mixer)
14935 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014936 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14937
Takashi Iwai2134ea42008-01-10 16:53:55 +010014938 spec->vmaster_nid = 0x03;
14939
Kailang Yangdf694da2005-12-05 19:42:22 +010014940 codec->patch_ops = alc_patch_ops;
14941 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014942 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014943#ifdef CONFIG_SND_HDA_POWER_SAVE
14944 if (!spec->loopback.amplist)
14945 spec->loopback.amplist = alc861_loopbacks;
14946#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014947 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014948
Kailang Yangdf694da2005-12-05 19:42:22 +010014949 return 0;
14950}
14951
14952/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014953 * ALC861-VD support
14954 *
14955 * Based on ALC882
14956 *
14957 * In addition, an independent DAC
14958 */
14959#define ALC861VD_DIGOUT_NID 0x06
14960
14961static hda_nid_t alc861vd_dac_nids[4] = {
14962 /* front, surr, clfe, side surr */
14963 0x02, 0x03, 0x04, 0x05
14964};
14965
14966/* dac_nids for ALC660vd are in a different order - according to
14967 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014968 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014969 * of ALC660vd codecs, but for now there is only 3stack mixer
14970 * - and it is the same as in 861vd.
14971 * adc_nids in ALC660vd are (is) the same as in 861vd
14972 */
14973static hda_nid_t alc660vd_dac_nids[3] = {
14974 /* front, rear, clfe, rear_surr */
14975 0x02, 0x04, 0x03
14976};
14977
14978static hda_nid_t alc861vd_adc_nids[1] = {
14979 /* ADC0 */
14980 0x09,
14981};
14982
Takashi Iwaie1406342008-02-11 18:32:32 +010014983static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14984
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014985/* input MUX */
14986/* FIXME: should be a matrix-type input source selection */
14987static struct hda_input_mux alc861vd_capture_source = {
14988 .num_items = 4,
14989 .items = {
14990 { "Mic", 0x0 },
14991 { "Front Mic", 0x1 },
14992 { "Line", 0x2 },
14993 { "CD", 0x4 },
14994 },
14995};
14996
Kailang Yang272a5272007-05-14 11:00:38 +020014997static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014998 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014999 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010015000 { "Ext Mic", 0x0 },
15001 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020015002 },
15003};
15004
Kailang Yangd1a991a2007-08-15 16:21:59 +020015005static struct hda_input_mux alc861vd_hp_capture_source = {
15006 .num_items = 2,
15007 .items = {
15008 { "Front Mic", 0x0 },
15009 { "ATAPI Mic", 0x1 },
15010 },
15011};
15012
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015013/*
15014 * 2ch mode
15015 */
15016static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
15017 { 2, NULL }
15018};
15019
15020/*
15021 * 6ch mode
15022 */
15023static struct hda_verb alc861vd_6stack_ch6_init[] = {
15024 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15025 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15026 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15027 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15028 { } /* end */
15029};
15030
15031/*
15032 * 8ch mode
15033 */
15034static struct hda_verb alc861vd_6stack_ch8_init[] = {
15035 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15036 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15037 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15038 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15039 { } /* end */
15040};
15041
15042static struct hda_channel_mode alc861vd_6stack_modes[2] = {
15043 { 6, alc861vd_6stack_ch6_init },
15044 { 8, alc861vd_6stack_ch8_init },
15045};
15046
15047static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
15048 {
15049 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15050 .name = "Channel Mode",
15051 .info = alc_ch_mode_info,
15052 .get = alc_ch_mode_get,
15053 .put = alc_ch_mode_put,
15054 },
15055 { } /* end */
15056};
15057
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015058/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15059 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15060 */
15061static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
15062 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15063 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15064
15065 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15066 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
15067
15068 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
15069 HDA_OUTPUT),
15070 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
15071 HDA_OUTPUT),
15072 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
15073 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
15074
15075 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
15076 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
15077
15078 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15079
15080 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15081 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15082 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15083
15084 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15085 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15086 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15087
15088 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15089 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15090
15091 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15092 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15093
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015094 { } /* end */
15095};
15096
15097static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
15098 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15099 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15100
15101 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15102
15103 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15104 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15105 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15106
15107 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15108 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15109 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15110
15111 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15112 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15113
15114 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15115 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15116
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015117 { } /* end */
15118};
15119
Kailang Yangbdd148a2007-05-08 15:19:08 +020015120static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
15121 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15122 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
15123 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15124
15125 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15126
15127 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15128 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15129 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15130
15131 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15132 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15133 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15134
15135 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15136 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15137
15138 { } /* end */
15139};
15140
Tobin Davisb419f342008-03-07 11:57:51 +010015141/* Pin assignment: Speaker=0x14, HP = 0x15,
15142 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020015143 */
15144static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010015145 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15146 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015147 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15148 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010015149 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
15150 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15151 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15152 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
15153 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15154 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015155 { } /* end */
15156};
15157
Kailang Yangd1a991a2007-08-15 16:21:59 +020015158/* Pin assignment: Speaker=0x14, Line-out = 0x15,
15159 * Front Mic=0x18, ATAPI Mic = 0x19,
15160 */
15161static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
15162 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15163 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15164 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15165 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
15166 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15167 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15168 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15169 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015170
Kailang Yangd1a991a2007-08-15 16:21:59 +020015171 { } /* end */
15172};
15173
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015174/*
15175 * generic initialization of ADC, input mixers and output mixers
15176 */
15177static struct hda_verb alc861vd_volume_init_verbs[] = {
15178 /*
15179 * Unmute ADC0 and set the default input to mic-in
15180 */
15181 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15182 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15183
15184 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
15185 * the analog-loopback mixer widget
15186 */
15187 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015188 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15189 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15190 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15191 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15192 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015193
15194 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020015195 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15196 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15197 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015198 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015199
15200 /*
15201 * Set up output mixers (0x02 - 0x05)
15202 */
15203 /* set vol=0 to output mixers */
15204 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15205 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15206 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15207 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15208
15209 /* set up input amps for analog loopback */
15210 /* Amp Indices: DAC = 0, mixer = 1 */
15211 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15212 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15213 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15214 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15215 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15216 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15217 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15218 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15219
15220 { }
15221};
15222
15223/*
15224 * 3-stack pin configuration:
15225 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
15226 */
15227static struct hda_verb alc861vd_3stack_init_verbs[] = {
15228 /*
15229 * Set pin mode and muting
15230 */
15231 /* set front pin widgets 0x14 for output */
15232 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15233 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15234 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15235
15236 /* Mic (rear) pin: input vref at 80% */
15237 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15238 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15239 /* Front Mic pin: input vref at 80% */
15240 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15241 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15242 /* Line In pin: input */
15243 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15244 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15245 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15246 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15247 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15248 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15249 /* CD pin widget for input */
15250 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15251
15252 { }
15253};
15254
15255/*
15256 * 6-stack pin configuration:
15257 */
15258static struct hda_verb alc861vd_6stack_init_verbs[] = {
15259 /*
15260 * Set pin mode and muting
15261 */
15262 /* set front pin widgets 0x14 for output */
15263 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15264 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15265 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15266
15267 /* Rear Pin: output 1 (0x0d) */
15268 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15269 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15270 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15271 /* CLFE Pin: output 2 (0x0e) */
15272 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15273 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15274 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15275 /* Side Pin: output 3 (0x0f) */
15276 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15277 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15278 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15279
15280 /* Mic (rear) pin: input vref at 80% */
15281 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15282 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15283 /* Front Mic pin: input vref at 80% */
15284 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15285 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15286 /* Line In pin: input */
15287 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15288 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15289 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15290 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15291 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15292 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15293 /* CD pin widget for input */
15294 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15295
15296 { }
15297};
15298
Kailang Yangbdd148a2007-05-08 15:19:08 +020015299static struct hda_verb alc861vd_eapd_verbs[] = {
15300 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15301 { }
15302};
15303
Kailang Yangf9423e72008-05-27 12:32:25 +020015304static struct hda_verb alc660vd_eapd_verbs[] = {
15305 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15306 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15307 { }
15308};
15309
Kailang Yangbdd148a2007-05-08 15:19:08 +020015310static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15311 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15312 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15313 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15314 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015315 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015316 {}
15317};
15318
Kailang Yangbdd148a2007-05-08 15:19:08 +020015319static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15320{
15321 unsigned int present;
15322 unsigned char bits;
15323
Wu Fengguang864f92b2009-11-18 12:38:02 +080015324 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020015325 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080015326
Takashi Iwai47fd8302007-08-10 17:11:07 +020015327 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15328 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015329}
15330
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015331static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015332{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015333 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015334 spec->autocfg.hp_pins[0] = 0x1b;
15335 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015336}
15337
15338static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15339{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015340 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015341 alc861vd_lenovo_mic_automute(codec);
15342}
15343
15344static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15345 unsigned int res)
15346{
15347 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015348 case ALC880_MIC_EVENT:
15349 alc861vd_lenovo_mic_automute(codec);
15350 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015351 default:
15352 alc_automute_amp_unsol_event(codec, res);
15353 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015354 }
15355}
15356
Kailang Yang272a5272007-05-14 11:00:38 +020015357static struct hda_verb alc861vd_dallas_verbs[] = {
15358 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15359 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15360 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15361 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15362
15363 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15364 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15365 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15366 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15367 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15368 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15369 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15370 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015371
Kailang Yang272a5272007-05-14 11:00:38 +020015372 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15373 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15374 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15375 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15376 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15377 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15378 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15379 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15380
15381 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15382 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15383 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15384 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15385 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15386 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15387 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15388 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15389
15390 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15391 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15392 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15393 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15394
15395 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015396 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015397 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15398
15399 { } /* end */
15400};
15401
15402/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015403static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015404{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015405 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015406
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015407 spec->autocfg.hp_pins[0] = 0x15;
15408 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020015409}
15410
Takashi Iwaicb53c622007-08-10 17:21:45 +020015411#ifdef CONFIG_SND_HDA_POWER_SAVE
15412#define alc861vd_loopbacks alc880_loopbacks
15413#endif
15414
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015415/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015416#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15417#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15418#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15419#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15420
15421/*
15422 * configuration and preset
15423 */
15424static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15425 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015426 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015427 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015428 [ALC861VD_3ST] = "3stack",
15429 [ALC861VD_3ST_DIG] = "3stack-digout",
15430 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015431 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015432 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015433 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015434 [ALC861VD_AUTO] = "auto",
15435};
15436
15437static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015438 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15439 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015440 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015441 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010015442 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015443 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015444 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015445 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015446 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015447 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015448 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015449 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015450 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015451 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015452 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015453 {}
15454};
15455
15456static struct alc_config_preset alc861vd_presets[] = {
15457 [ALC660VD_3ST] = {
15458 .mixers = { alc861vd_3st_mixer },
15459 .init_verbs = { alc861vd_volume_init_verbs,
15460 alc861vd_3stack_init_verbs },
15461 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15462 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015463 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15464 .channel_mode = alc861vd_3stack_2ch_modes,
15465 .input_mux = &alc861vd_capture_source,
15466 },
Mike Crash6963f842007-06-25 12:12:51 +020015467 [ALC660VD_3ST_DIG] = {
15468 .mixers = { alc861vd_3st_mixer },
15469 .init_verbs = { alc861vd_volume_init_verbs,
15470 alc861vd_3stack_init_verbs },
15471 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15472 .dac_nids = alc660vd_dac_nids,
15473 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015474 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15475 .channel_mode = alc861vd_3stack_2ch_modes,
15476 .input_mux = &alc861vd_capture_source,
15477 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015478 [ALC861VD_3ST] = {
15479 .mixers = { alc861vd_3st_mixer },
15480 .init_verbs = { alc861vd_volume_init_verbs,
15481 alc861vd_3stack_init_verbs },
15482 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15483 .dac_nids = alc861vd_dac_nids,
15484 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15485 .channel_mode = alc861vd_3stack_2ch_modes,
15486 .input_mux = &alc861vd_capture_source,
15487 },
15488 [ALC861VD_3ST_DIG] = {
15489 .mixers = { alc861vd_3st_mixer },
15490 .init_verbs = { alc861vd_volume_init_verbs,
15491 alc861vd_3stack_init_verbs },
15492 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15493 .dac_nids = alc861vd_dac_nids,
15494 .dig_out_nid = ALC861VD_DIGOUT_NID,
15495 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15496 .channel_mode = alc861vd_3stack_2ch_modes,
15497 .input_mux = &alc861vd_capture_source,
15498 },
15499 [ALC861VD_6ST_DIG] = {
15500 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15501 .init_verbs = { alc861vd_volume_init_verbs,
15502 alc861vd_6stack_init_verbs },
15503 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15504 .dac_nids = alc861vd_dac_nids,
15505 .dig_out_nid = ALC861VD_DIGOUT_NID,
15506 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15507 .channel_mode = alc861vd_6stack_modes,
15508 .input_mux = &alc861vd_capture_source,
15509 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015510 [ALC861VD_LENOVO] = {
15511 .mixers = { alc861vd_lenovo_mixer },
15512 .init_verbs = { alc861vd_volume_init_verbs,
15513 alc861vd_3stack_init_verbs,
15514 alc861vd_eapd_verbs,
15515 alc861vd_lenovo_unsol_verbs },
15516 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15517 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015518 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15519 .channel_mode = alc861vd_3stack_2ch_modes,
15520 .input_mux = &alc861vd_capture_source,
15521 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015522 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015523 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015524 },
Kailang Yang272a5272007-05-14 11:00:38 +020015525 [ALC861VD_DALLAS] = {
15526 .mixers = { alc861vd_dallas_mixer },
15527 .init_verbs = { alc861vd_dallas_verbs },
15528 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15529 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015530 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15531 .channel_mode = alc861vd_3stack_2ch_modes,
15532 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015533 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015534 .setup = alc861vd_dallas_setup,
15535 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015536 },
15537 [ALC861VD_HP] = {
15538 .mixers = { alc861vd_hp_mixer },
15539 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15540 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15541 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015542 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015543 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15544 .channel_mode = alc861vd_3stack_2ch_modes,
15545 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015546 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015547 .setup = alc861vd_dallas_setup,
15548 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020015549 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015550 [ALC660VD_ASUS_V1S] = {
15551 .mixers = { alc861vd_lenovo_mixer },
15552 .init_verbs = { alc861vd_volume_init_verbs,
15553 alc861vd_3stack_init_verbs,
15554 alc861vd_eapd_verbs,
15555 alc861vd_lenovo_unsol_verbs },
15556 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15557 .dac_nids = alc660vd_dac_nids,
15558 .dig_out_nid = ALC861VD_DIGOUT_NID,
15559 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15560 .channel_mode = alc861vd_3stack_2ch_modes,
15561 .input_mux = &alc861vd_capture_source,
15562 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015563 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015564 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015565 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015566};
15567
15568/*
15569 * BIOS auto configuration
15570 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015571static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15572 const struct auto_pin_cfg *cfg)
15573{
Takashi Iwai9c0afc82010-01-12 14:00:11 +010015574 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x22, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020015575}
15576
15577
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015578static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15579 hda_nid_t nid, int pin_type, int dac_idx)
15580{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015581 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015582}
15583
15584static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15585{
15586 struct alc_spec *spec = codec->spec;
15587 int i;
15588
15589 for (i = 0; i <= HDA_SIDE; i++) {
15590 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015591 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015592 if (nid)
15593 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015594 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015595 }
15596}
15597
15598
15599static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15600{
15601 struct alc_spec *spec = codec->spec;
15602 hda_nid_t pin;
15603
15604 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015605 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015606 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015607 pin = spec->autocfg.speaker_pins[0];
15608 if (pin)
15609 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015610}
15611
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015612#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15613
15614static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15615{
15616 struct alc_spec *spec = codec->spec;
15617 int i;
15618
15619 for (i = 0; i < AUTO_PIN_LAST; i++) {
15620 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020015621 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015622 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015623 if (nid != ALC861VD_PIN_CD_NID &&
15624 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015625 snd_hda_codec_write(codec, nid, 0,
15626 AC_VERB_SET_AMP_GAIN_MUTE,
15627 AMP_OUT_MUTE);
15628 }
15629 }
15630}
15631
Takashi Iwaif511b012008-08-15 16:46:42 +020015632#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15633
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015634#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15635#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15636
15637/* add playback controls from the parsed DAC table */
15638/* Based on ALC880 version. But ALC861VD has separate,
15639 * different NIDs for mute/unmute switch and volume control */
15640static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15641 const struct auto_pin_cfg *cfg)
15642{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015643 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15644 hda_nid_t nid_v, nid_s;
15645 int i, err;
15646
15647 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015648 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015649 continue;
15650 nid_v = alc861vd_idx_to_mixer_vol(
15651 alc880_dac_to_idx(
15652 spec->multiout.dac_nids[i]));
15653 nid_s = alc861vd_idx_to_mixer_switch(
15654 alc880_dac_to_idx(
15655 spec->multiout.dac_nids[i]));
15656
15657 if (i == 2) {
15658 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015659 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
15660 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015661 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15662 HDA_OUTPUT));
15663 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015664 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015665 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
15666 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015667 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15668 HDA_OUTPUT));
15669 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015670 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015671 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
15672 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015673 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15674 HDA_INPUT));
15675 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015676 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015677 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
15678 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015679 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15680 HDA_INPUT));
15681 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015682 return err;
15683 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015684 const char *pfx;
15685 if (cfg->line_outs == 1 &&
15686 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
15687 if (!cfg->hp_pins)
15688 pfx = "Speaker";
15689 else
15690 pfx = "PCM";
15691 } else
15692 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015693 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015694 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15695 HDA_OUTPUT));
15696 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015697 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015698 if (cfg->line_outs == 1 &&
15699 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15700 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015701 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015702 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015703 HDA_INPUT));
15704 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015705 return err;
15706 }
15707 }
15708 return 0;
15709}
15710
15711/* add playback controls for speaker and HP outputs */
15712/* Based on ALC880 version. But ALC861VD has separate,
15713 * different NIDs for mute/unmute switch and volume control */
15714static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15715 hda_nid_t pin, const char *pfx)
15716{
15717 hda_nid_t nid_v, nid_s;
15718 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015719
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015720 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015721 return 0;
15722
15723 if (alc880_is_fixed_pin(pin)) {
15724 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15725 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015726 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015727 spec->multiout.hp_nid = nid_v;
15728 else
15729 spec->multiout.extra_out_nid[0] = nid_v;
15730 /* control HP volume/switch on the output mixer amp */
15731 nid_v = alc861vd_idx_to_mixer_vol(
15732 alc880_fixed_pin_idx(pin));
15733 nid_s = alc861vd_idx_to_mixer_switch(
15734 alc880_fixed_pin_idx(pin));
15735
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015736 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015737 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15738 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015739 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015740 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015741 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15742 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015743 return err;
15744 } else if (alc880_is_multi_pin(pin)) {
15745 /* set manual connection */
15746 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015747 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015748 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15749 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015750 return err;
15751 }
15752 return 0;
15753}
15754
15755/* parse the BIOS configuration and set up the alc_spec
15756 * return 1 if successful, 0 if the proper config is not found,
15757 * or a negative error code
15758 * Based on ALC880 version - had to change it to override
15759 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15760static int alc861vd_parse_auto_config(struct hda_codec *codec)
15761{
15762 struct alc_spec *spec = codec->spec;
15763 int err;
15764 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15765
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015766 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15767 alc861vd_ignore);
15768 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015769 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015770 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015771 return 0; /* can't find valid BIOS pin config */
15772
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015773 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15774 if (err < 0)
15775 return err;
15776 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15777 if (err < 0)
15778 return err;
15779 err = alc861vd_auto_create_extra_out(spec,
15780 spec->autocfg.speaker_pins[0],
15781 "Speaker");
15782 if (err < 0)
15783 return err;
15784 err = alc861vd_auto_create_extra_out(spec,
15785 spec->autocfg.hp_pins[0],
15786 "Headphone");
15787 if (err < 0)
15788 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015789 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015790 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015791 return err;
15792
15793 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15794
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015795 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015796 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15797
Takashi Iwai603c4012008-07-30 15:01:44 +020015798 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015799 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015800
Takashi Iwaid88897e2008-10-31 15:01:37 +010015801 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015802
15803 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015804 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015805
Takashi Iwai776e1842007-08-29 15:07:11 +020015806 err = alc_auto_add_mic_boost(codec);
15807 if (err < 0)
15808 return err;
15809
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015810 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15811
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015812 return 1;
15813}
15814
15815/* additional initialization for auto-configuration model */
15816static void alc861vd_auto_init(struct hda_codec *codec)
15817{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015818 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015819 alc861vd_auto_init_multi_out(codec);
15820 alc861vd_auto_init_hp_out(codec);
15821 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015822 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015823 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015824 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015825}
15826
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015827enum {
15828 ALC660VD_FIX_ASUS_GPIO1
15829};
15830
15831/* reset GPIO1 */
15832static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
15833 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
15834 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
15835 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
15836 { }
15837};
15838
15839static const struct alc_fixup alc861vd_fixups[] = {
15840 [ALC660VD_FIX_ASUS_GPIO1] = {
15841 .verbs = alc660vd_fix_asus_gpio1_verbs,
15842 },
15843};
15844
15845static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
15846 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
15847 {}
15848};
15849
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015850static int patch_alc861vd(struct hda_codec *codec)
15851{
15852 struct alc_spec *spec;
15853 int err, board_config;
15854
15855 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15856 if (spec == NULL)
15857 return -ENOMEM;
15858
15859 codec->spec = spec;
15860
15861 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15862 alc861vd_models,
15863 alc861vd_cfg_tbl);
15864
15865 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015866 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15867 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015868 board_config = ALC861VD_AUTO;
15869 }
15870
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015871 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups);
15872
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015873 if (board_config == ALC861VD_AUTO) {
15874 /* automatic parse from the BIOS config */
15875 err = alc861vd_parse_auto_config(codec);
15876 if (err < 0) {
15877 alc_free(codec);
15878 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015879 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015880 printk(KERN_INFO
15881 "hda_codec: Cannot set up configuration "
15882 "from BIOS. Using base mode...\n");
15883 board_config = ALC861VD_3ST;
15884 }
15885 }
15886
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015887 err = snd_hda_attach_beep_device(codec, 0x23);
15888 if (err < 0) {
15889 alc_free(codec);
15890 return err;
15891 }
15892
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015893 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015894 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015895
Kailang Yang2f893282008-05-27 12:14:47 +020015896 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015897 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015898 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015899 }
15900
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015901 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15902 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15903
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015904 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15905 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15906
Takashi Iwaidd704692009-08-11 08:45:11 +020015907 if (!spec->adc_nids) {
15908 spec->adc_nids = alc861vd_adc_nids;
15909 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15910 }
15911 if (!spec->capsrc_nids)
15912 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015913
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015914 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015915 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015916
Takashi Iwai2134ea42008-01-10 16:53:55 +010015917 spec->vmaster_nid = 0x02;
15918
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015919 codec->patch_ops = alc_patch_ops;
15920
15921 if (board_config == ALC861VD_AUTO)
15922 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015923#ifdef CONFIG_SND_HDA_POWER_SAVE
15924 if (!spec->loopback.amplist)
15925 spec->loopback.amplist = alc861vd_loopbacks;
15926#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015927 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015928
15929 return 0;
15930}
15931
15932/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015933 * ALC662 support
15934 *
15935 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15936 * configuration. Each pin widget can choose any input DACs and a mixer.
15937 * Each ADC is connected from a mixer of all inputs. This makes possible
15938 * 6-channel independent captures.
15939 *
15940 * In addition, an independent DAC for the multi-playback (not used in this
15941 * driver yet).
15942 */
15943#define ALC662_DIGOUT_NID 0x06
15944#define ALC662_DIGIN_NID 0x0a
15945
15946static hda_nid_t alc662_dac_nids[4] = {
15947 /* front, rear, clfe, rear_surr */
15948 0x02, 0x03, 0x04
15949};
15950
Kailang Yang622e84c2009-04-21 07:39:04 +020015951static hda_nid_t alc272_dac_nids[2] = {
15952 0x02, 0x03
15953};
15954
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015955static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015956 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015957 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015958};
Takashi Iwaie1406342008-02-11 18:32:32 +010015959
Kailang Yang622e84c2009-04-21 07:39:04 +020015960static hda_nid_t alc272_adc_nids[1] = {
15961 /* ADC1-2 */
15962 0x08,
15963};
15964
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015965static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015966static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15967
Takashi Iwaie1406342008-02-11 18:32:32 +010015968
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015969/* input MUX */
15970/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015971static struct hda_input_mux alc662_capture_source = {
15972 .num_items = 4,
15973 .items = {
15974 { "Mic", 0x0 },
15975 { "Front Mic", 0x1 },
15976 { "Line", 0x2 },
15977 { "CD", 0x4 },
15978 },
15979};
15980
15981static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15982 .num_items = 2,
15983 .items = {
15984 { "Mic", 0x1 },
15985 { "Line", 0x2 },
15986 },
15987};
Kailang Yang291702f2007-10-16 14:28:03 +020015988
Kailang Yang6dda9f42008-05-27 12:05:31 +020015989static struct hda_input_mux alc663_capture_source = {
15990 .num_items = 3,
15991 .items = {
15992 { "Mic", 0x0 },
15993 { "Front Mic", 0x1 },
15994 { "Line", 0x2 },
15995 },
15996};
15997
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015998#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020015999static struct hda_input_mux alc272_nc10_capture_source = {
16000 .num_items = 16,
16001 .items = {
16002 { "Autoselect Mic", 0x0 },
16003 { "Internal Mic", 0x1 },
16004 { "In-0x02", 0x2 },
16005 { "In-0x03", 0x3 },
16006 { "In-0x04", 0x4 },
16007 { "In-0x05", 0x5 },
16008 { "In-0x06", 0x6 },
16009 { "In-0x07", 0x7 },
16010 { "In-0x08", 0x8 },
16011 { "In-0x09", 0x9 },
16012 { "In-0x0a", 0x0a },
16013 { "In-0x0b", 0x0b },
16014 { "In-0x0c", 0x0c },
16015 { "In-0x0d", 0x0d },
16016 { "In-0x0e", 0x0e },
16017 { "In-0x0f", 0x0f },
16018 },
16019};
16020#endif
16021
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016022/*
16023 * 2ch mode
16024 */
16025static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
16026 { 2, NULL }
16027};
16028
16029/*
16030 * 2ch mode
16031 */
16032static struct hda_verb alc662_3ST_ch2_init[] = {
16033 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
16034 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16035 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
16036 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16037 { } /* end */
16038};
16039
16040/*
16041 * 6ch mode
16042 */
16043static struct hda_verb alc662_3ST_ch6_init[] = {
16044 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16045 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16046 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
16047 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16048 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16049 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
16050 { } /* end */
16051};
16052
16053static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
16054 { 2, alc662_3ST_ch2_init },
16055 { 6, alc662_3ST_ch6_init },
16056};
16057
16058/*
16059 * 2ch mode
16060 */
16061static struct hda_verb alc662_sixstack_ch6_init[] = {
16062 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16063 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16064 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16065 { } /* end */
16066};
16067
16068/*
16069 * 6ch mode
16070 */
16071static struct hda_verb alc662_sixstack_ch8_init[] = {
16072 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16073 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16074 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16075 { } /* end */
16076};
16077
16078static struct hda_channel_mode alc662_5stack_modes[2] = {
16079 { 2, alc662_sixstack_ch6_init },
16080 { 6, alc662_sixstack_ch8_init },
16081};
16082
16083/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16084 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16085 */
16086
16087static struct snd_kcontrol_new alc662_base_mixer[] = {
16088 /* output mixer control */
16089 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016090 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016091 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016092 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016093 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16094 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016095 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16096 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016097 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16098
16099 /*Input mixer control */
16100 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
16101 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
16102 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
16103 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
16104 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
16105 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
16106 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
16107 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016108 { } /* end */
16109};
16110
16111static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
16112 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016113 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016114 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16115 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16116 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16117 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16118 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16119 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16120 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16121 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16122 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016123 { } /* end */
16124};
16125
16126static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
16127 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016128 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016129 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016130 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016131 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16132 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016133 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16134 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016135 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16136 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16137 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16138 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16139 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16140 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16141 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16142 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16143 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016144 { } /* end */
16145};
16146
16147static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
16148 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16149 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010016150 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16151 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016152 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16153 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16154 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16155 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16156 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016157 { } /* end */
16158};
16159
Kailang Yang291702f2007-10-16 14:28:03 +020016160static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016161 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16162 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020016163
16164 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
16165 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16166 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16167
16168 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16169 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16170 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16171 { } /* end */
16172};
16173
Kailang Yang8c427222008-01-10 13:03:59 +010016174static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016175 ALC262_HIPPO_MASTER_SWITCH,
16176 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016177 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016178 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16179 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016180 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
16181 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16182 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16183 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16184 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16185 { } /* end */
16186};
16187
Kailang Yangf1d4e282008-08-26 14:03:29 +020016188static struct hda_bind_ctls alc663_asus_bind_master_vol = {
16189 .ops = &snd_hda_bind_vol,
16190 .values = {
16191 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16192 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
16193 0
16194 },
16195};
16196
16197static struct hda_bind_ctls alc663_asus_one_bind_switch = {
16198 .ops = &snd_hda_bind_sw,
16199 .values = {
16200 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16201 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16202 0
16203 },
16204};
16205
Kailang Yang6dda9f42008-05-27 12:05:31 +020016206static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016207 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16208 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
16209 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16210 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16211 { } /* end */
16212};
16213
16214static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
16215 .ops = &snd_hda_bind_sw,
16216 .values = {
16217 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16218 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16219 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16220 0
16221 },
16222};
16223
16224static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
16225 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16226 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
16227 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16228 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16229 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16230 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16231
16232 { } /* end */
16233};
16234
16235static struct hda_bind_ctls alc663_asus_four_bind_switch = {
16236 .ops = &snd_hda_bind_sw,
16237 .values = {
16238 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16239 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16240 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16241 0
16242 },
16243};
16244
16245static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
16246 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16247 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
16248 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16249 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16250 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16251 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16252 { } /* end */
16253};
16254
16255static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016256 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16257 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016258 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16259 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16260 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16261 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16262 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16263 { } /* end */
16264};
16265
16266static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
16267 .ops = &snd_hda_bind_vol,
16268 .values = {
16269 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16270 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16271 0
16272 },
16273};
16274
16275static struct hda_bind_ctls alc663_asus_two_bind_switch = {
16276 .ops = &snd_hda_bind_sw,
16277 .values = {
16278 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16279 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
16280 0
16281 },
16282};
16283
16284static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16285 HDA_BIND_VOL("Master Playback Volume",
16286 &alc663_asus_two_bind_master_vol),
16287 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16288 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016289 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16290 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16291 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016292 { } /* end */
16293};
16294
16295static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16296 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16297 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16298 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16299 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16300 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16301 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016302 { } /* end */
16303};
16304
16305static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16306 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16307 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16308 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16309 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16310 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16311
16312 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16313 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16314 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16315 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16316 { } /* end */
16317};
16318
16319static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16320 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16321 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16322 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16323
16324 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16325 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16326 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16327 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16328 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16329 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16330 { } /* end */
16331};
16332
Kailang Yangebb83ee2009-12-17 12:23:00 +010016333static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
16334 .ops = &snd_hda_bind_sw,
16335 .values = {
16336 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16337 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16338 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16339 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16340 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16341 0
16342 },
16343};
16344
16345static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
16346 .ops = &snd_hda_bind_sw,
16347 .values = {
16348 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16349 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16350 0
16351 },
16352};
16353
16354static struct snd_kcontrol_new alc663_mode7_mixer[] = {
16355 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16356 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16357 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16358 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16359 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16360 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16361 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16362 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16363 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16364 { } /* end */
16365};
16366
16367static struct snd_kcontrol_new alc663_mode8_mixer[] = {
16368 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16369 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16370 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16371 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16372 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16373 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16374 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16375 { } /* end */
16376};
16377
16378
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016379static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16380 {
16381 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16382 .name = "Channel Mode",
16383 .info = alc_ch_mode_info,
16384 .get = alc_ch_mode_get,
16385 .put = alc_ch_mode_put,
16386 },
16387 { } /* end */
16388};
16389
16390static struct hda_verb alc662_init_verbs[] = {
16391 /* ADC: mute amp left and right */
16392 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16393 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16394 /* Front mixer: unmute input/output amp left and right (volume = 0) */
16395
Takashi Iwaicb53c622007-08-10 17:21:45 +020016396 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16397 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16398 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16399 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16400 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016401
Kailang Yangb60dd392007-09-20 12:50:29 +020016402 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16403 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16404 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16405 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16406 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16407 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016408
16409 /* Front Pin: output 0 (0x0c) */
16410 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16411 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16412
16413 /* Rear Pin: output 1 (0x0d) */
16414 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16415 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16416
16417 /* CLFE Pin: output 2 (0x0e) */
16418 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16419 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16420
16421 /* Mic (rear) pin: input vref at 80% */
16422 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16423 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16424 /* Front Mic pin: input vref at 80% */
16425 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16426 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16427 /* Line In pin: input */
16428 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16429 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16430 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16431 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16432 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16433 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16434 /* CD pin widget for input */
16435 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16436
16437 /* FIXME: use matrix-type input source selection */
16438 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16439 /* Input mixer */
16440 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016441 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016442
16443 /* always trun on EAPD */
16444 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16445 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16446
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016447 { }
16448};
16449
16450static struct hda_verb alc662_sue_init_verbs[] = {
16451 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16452 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016453 {}
16454};
16455
16456static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16457 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16458 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16459 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016460};
16461
Kailang Yang8c427222008-01-10 13:03:59 +010016462/* Set Unsolicited Event*/
16463static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16464 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16465 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16466 {}
16467};
16468
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016469/*
16470 * generic initialization of ADC, input mixers and output mixers
16471 */
16472static struct hda_verb alc662_auto_init_verbs[] = {
16473 /*
16474 * Unmute ADC and set the default input to mic-in
16475 */
16476 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16477 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16478
16479 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16480 * mixer widget
16481 * Note: PASD motherboards uses the Line In 2 as the input for front
16482 * panel mic (mic 2)
16483 */
16484 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016485 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16486 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16487 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16488 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16489 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016490
16491 /*
16492 * Set up output mixers (0x0c - 0x0f)
16493 */
16494 /* set vol=0 to output mixers */
16495 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16496 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16497 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16498
16499 /* set up input amps for analog loopback */
16500 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020016501 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16502 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16503 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16504 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16505 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16506 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016507
16508
16509 /* FIXME: use matrix-type input source selection */
16510 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16511 /* Input mixer */
16512 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016513 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016514 { }
16515};
16516
Takashi Iwai24fb9172008-09-02 14:48:20 +020016517/* additional verbs for ALC663 */
16518static struct hda_verb alc663_auto_init_verbs[] = {
16519 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16520 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16521 { }
16522};
16523
Kailang Yang6dda9f42008-05-27 12:05:31 +020016524static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016525 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16526 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016527 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16528 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016529 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16530 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16531 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016532 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16533 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16534 {}
16535};
16536
Kailang Yangf1d4e282008-08-26 14:03:29 +020016537static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16538 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16539 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16540 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16541 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16542 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16543 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16544 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16545 {}
16546};
16547
16548static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16549 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16550 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16551 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16552 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16553 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16554 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16555 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16556 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16557 {}
16558};
16559
16560static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16561 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16562 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16563 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16564 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16565 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16566 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16567 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16568 {}
16569};
16570
16571static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16572 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16573 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16574 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16575 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16576 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16577 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16578 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16579 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16580 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16581 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16582 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16583 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16584 {}
16585};
16586
16587static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16588 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16589 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16590 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16591 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16592 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16593 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16594 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16595 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16596 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16597 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16598 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16599 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16600 {}
16601};
16602
Kailang Yang6dda9f42008-05-27 12:05:31 +020016603static struct hda_verb alc663_g71v_init_verbs[] = {
16604 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16605 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16606 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16607
16608 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16609 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16610 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16611
16612 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16613 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16614 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16615 {}
16616};
16617
16618static struct hda_verb alc663_g50v_init_verbs[] = {
16619 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16620 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16621 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16622
16623 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16624 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16625 {}
16626};
16627
Kailang Yangf1d4e282008-08-26 14:03:29 +020016628static struct hda_verb alc662_ecs_init_verbs[] = {
16629 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16630 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16631 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16632 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16633 {}
16634};
16635
Kailang Yang622e84c2009-04-21 07:39:04 +020016636static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16637 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16638 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16639 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16640 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16641 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16642 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16643 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16644 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16645 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16646 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16647 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16648 {}
16649};
16650
16651static struct hda_verb alc272_dell_init_verbs[] = {
16652 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16653 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16654 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16655 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16656 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16657 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16658 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16659 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16660 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16661 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16662 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16663 {}
16664};
16665
Kailang Yangebb83ee2009-12-17 12:23:00 +010016666static struct hda_verb alc663_mode7_init_verbs[] = {
16667 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16668 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16669 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16670 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16671 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16672 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16673 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
16674 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16675 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16676 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16677 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16678 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16679 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16680 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16681 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16682 {}
16683};
16684
16685static struct hda_verb alc663_mode8_init_verbs[] = {
16686 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16687 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16688 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16689 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16690 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16691 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16692 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16693 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16694 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16695 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16696 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16697 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16698 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16699 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16700 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16701 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16702 {}
16703};
16704
Kailang Yangf1d4e282008-08-26 14:03:29 +020016705static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16706 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16707 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16708 { } /* end */
16709};
16710
Kailang Yang622e84c2009-04-21 07:39:04 +020016711static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16712 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16713 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16714 { } /* end */
16715};
16716
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016717static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16718{
16719 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016720 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016721
Wu Fengguang864f92b2009-11-18 12:38:02 +080016722 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016723 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016724
Takashi Iwai47fd8302007-08-10 17:11:07 +020016725 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16726 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016727}
16728
16729static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16730{
16731 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016732 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016733
Wu Fengguang864f92b2009-11-18 12:38:02 +080016734 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016735 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016736
Takashi Iwai47fd8302007-08-10 17:11:07 +020016737 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16738 HDA_AMP_MUTE, bits);
16739 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16740 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016741}
16742
16743static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16744 unsigned int res)
16745{
16746 if ((res >> 26) == ALC880_HP_EVENT)
16747 alc662_lenovo_101e_all_automute(codec);
16748 if ((res >> 26) == ALC880_FRONT_EVENT)
16749 alc662_lenovo_101e_ispeaker_automute(codec);
16750}
16751
Kailang Yang291702f2007-10-16 14:28:03 +020016752/* unsolicited event for HP jack sensing */
16753static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16754 unsigned int res)
16755{
Kailang Yang291702f2007-10-16 14:28:03 +020016756 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016757 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016758 else
16759 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016760}
16761
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016762static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020016763{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016764 struct alc_spec *spec = codec->spec;
16765
16766 alc262_hippo1_setup(codec);
16767 spec->ext_mic.pin = 0x18;
16768 spec->ext_mic.mux_idx = 0;
16769 spec->int_mic.pin = 0x19;
16770 spec->int_mic.mux_idx = 1;
16771 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020016772}
16773
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016774static void alc662_eeepc_inithook(struct hda_codec *codec)
16775{
16776 alc262_hippo_automute(codec);
16777 alc_mic_automute(codec);
16778}
16779
16780static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010016781{
Takashi Iwai42171c12009-05-08 14:11:43 +020016782 struct alc_spec *spec = codec->spec;
16783
16784 spec->autocfg.hp_pins[0] = 0x14;
16785 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010016786}
16787
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016788#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
16789
Kailang Yang6dda9f42008-05-27 12:05:31 +020016790static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16791{
16792 unsigned int present;
16793 unsigned char bits;
16794
Wu Fengguang864f92b2009-11-18 12:38:02 +080016795 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016796 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016797 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16798 AMP_IN_MUTE(0), bits);
16799 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16800 AMP_IN_MUTE(0), bits);
16801}
16802
16803static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16804{
16805 unsigned int present;
16806 unsigned char bits;
16807
Wu Fengguang864f92b2009-11-18 12:38:02 +080016808 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016809 bits = present ? HDA_AMP_MUTE : 0;
16810 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16811 AMP_IN_MUTE(0), bits);
16812 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16813 AMP_IN_MUTE(0), bits);
16814 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16815 AMP_IN_MUTE(0), bits);
16816 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16817 AMP_IN_MUTE(0), bits);
16818}
16819
16820static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16821{
16822 unsigned int present;
16823 unsigned char bits;
16824
Wu Fengguang864f92b2009-11-18 12:38:02 +080016825 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016826 bits = present ? HDA_AMP_MUTE : 0;
16827 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16828 AMP_IN_MUTE(0), bits);
16829 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16830 AMP_IN_MUTE(0), bits);
16831 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16832 AMP_IN_MUTE(0), bits);
16833 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16834 AMP_IN_MUTE(0), bits);
16835}
16836
16837static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16838{
16839 unsigned int present;
16840 unsigned char bits;
16841
Wu Fengguang864f92b2009-11-18 12:38:02 +080016842 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016843 bits = present ? 0 : PIN_OUT;
16844 snd_hda_codec_write(codec, 0x14, 0,
16845 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16846}
16847
16848static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16849{
16850 unsigned int present1, present2;
16851
Wu Fengguang864f92b2009-11-18 12:38:02 +080016852 present1 = snd_hda_jack_detect(codec, 0x21);
16853 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016854
16855 if (present1 || present2) {
16856 snd_hda_codec_write_cache(codec, 0x14, 0,
16857 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16858 } else {
16859 snd_hda_codec_write_cache(codec, 0x14, 0,
16860 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16861 }
16862}
16863
16864static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16865{
16866 unsigned int present1, present2;
16867
Wu Fengguang864f92b2009-11-18 12:38:02 +080016868 present1 = snd_hda_jack_detect(codec, 0x1b);
16869 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016870
16871 if (present1 || present2) {
16872 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16873 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16874 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16875 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16876 } else {
16877 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16878 AMP_IN_MUTE(0), 0);
16879 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16880 AMP_IN_MUTE(0), 0);
16881 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016882}
16883
Kailang Yangebb83ee2009-12-17 12:23:00 +010016884static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
16885{
16886 unsigned int present1, present2;
16887
16888 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16889 AC_VERB_GET_PIN_SENSE, 0)
16890 & AC_PINSENSE_PRESENCE;
16891 present2 = snd_hda_codec_read(codec, 0x21, 0,
16892 AC_VERB_GET_PIN_SENSE, 0)
16893 & AC_PINSENSE_PRESENCE;
16894
16895 if (present1 || present2) {
16896 snd_hda_codec_write_cache(codec, 0x14, 0,
16897 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16898 snd_hda_codec_write_cache(codec, 0x17, 0,
16899 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16900 } else {
16901 snd_hda_codec_write_cache(codec, 0x14, 0,
16902 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16903 snd_hda_codec_write_cache(codec, 0x17, 0,
16904 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16905 }
16906}
16907
16908static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
16909{
16910 unsigned int present1, present2;
16911
16912 present1 = snd_hda_codec_read(codec, 0x21, 0,
16913 AC_VERB_GET_PIN_SENSE, 0)
16914 & AC_PINSENSE_PRESENCE;
16915 present2 = snd_hda_codec_read(codec, 0x15, 0,
16916 AC_VERB_GET_PIN_SENSE, 0)
16917 & AC_PINSENSE_PRESENCE;
16918
16919 if (present1 || present2) {
16920 snd_hda_codec_write_cache(codec, 0x14, 0,
16921 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16922 snd_hda_codec_write_cache(codec, 0x17, 0,
16923 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16924 } else {
16925 snd_hda_codec_write_cache(codec, 0x14, 0,
16926 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16927 snd_hda_codec_write_cache(codec, 0x17, 0,
16928 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16929 }
16930}
16931
Kailang Yang6dda9f42008-05-27 12:05:31 +020016932static void alc663_m51va_unsol_event(struct hda_codec *codec,
16933 unsigned int res)
16934{
16935 switch (res >> 26) {
16936 case ALC880_HP_EVENT:
16937 alc663_m51va_speaker_automute(codec);
16938 break;
16939 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016940 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016941 break;
16942 }
16943}
16944
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016945static void alc663_m51va_setup(struct hda_codec *codec)
16946{
16947 struct alc_spec *spec = codec->spec;
16948 spec->ext_mic.pin = 0x18;
16949 spec->ext_mic.mux_idx = 0;
16950 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010016951 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016952 spec->auto_mic = 1;
16953}
16954
Kailang Yang6dda9f42008-05-27 12:05:31 +020016955static void alc663_m51va_inithook(struct hda_codec *codec)
16956{
16957 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016958 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016959}
16960
Kailang Yangf1d4e282008-08-26 14:03:29 +020016961/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016962#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010016963
16964static void alc663_mode1_setup(struct hda_codec *codec)
16965{
16966 struct alc_spec *spec = codec->spec;
16967 spec->ext_mic.pin = 0x18;
16968 spec->ext_mic.mux_idx = 0;
16969 spec->int_mic.pin = 0x19;
16970 spec->int_mic.mux_idx = 1;
16971 spec->auto_mic = 1;
16972}
16973
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016974#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020016975
Kailang Yangf1d4e282008-08-26 14:03:29 +020016976/* ***************** Mode2 ******************************/
16977static void alc662_mode2_unsol_event(struct hda_codec *codec,
16978 unsigned int res)
16979{
16980 switch (res >> 26) {
16981 case ALC880_HP_EVENT:
16982 alc662_f5z_speaker_automute(codec);
16983 break;
16984 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016985 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016986 break;
16987 }
16988}
16989
Kailang Yangebb83ee2009-12-17 12:23:00 +010016990#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016991
Kailang Yangf1d4e282008-08-26 14:03:29 +020016992static void alc662_mode2_inithook(struct hda_codec *codec)
16993{
16994 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016995 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016996}
16997/* ***************** Mode3 ******************************/
16998static void alc663_mode3_unsol_event(struct hda_codec *codec,
16999 unsigned int res)
17000{
17001 switch (res >> 26) {
17002 case ALC880_HP_EVENT:
17003 alc663_two_hp_m1_speaker_automute(codec);
17004 break;
17005 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017006 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017007 break;
17008 }
17009}
17010
Kailang Yangebb83ee2009-12-17 12:23:00 +010017011#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017012
Kailang Yangf1d4e282008-08-26 14:03:29 +020017013static void alc663_mode3_inithook(struct hda_codec *codec)
17014{
17015 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017016 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017017}
17018/* ***************** Mode4 ******************************/
17019static void alc663_mode4_unsol_event(struct hda_codec *codec,
17020 unsigned int res)
17021{
17022 switch (res >> 26) {
17023 case ALC880_HP_EVENT:
17024 alc663_21jd_two_speaker_automute(codec);
17025 break;
17026 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017027 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017028 break;
17029 }
17030}
17031
Kailang Yangebb83ee2009-12-17 12:23:00 +010017032#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017033
Kailang Yangf1d4e282008-08-26 14:03:29 +020017034static void alc663_mode4_inithook(struct hda_codec *codec)
17035{
17036 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017037 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017038}
17039/* ***************** Mode5 ******************************/
17040static void alc663_mode5_unsol_event(struct hda_codec *codec,
17041 unsigned int res)
17042{
17043 switch (res >> 26) {
17044 case ALC880_HP_EVENT:
17045 alc663_15jd_two_speaker_automute(codec);
17046 break;
17047 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017048 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017049 break;
17050 }
17051}
17052
Kailang Yangebb83ee2009-12-17 12:23:00 +010017053#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017054
Kailang Yangf1d4e282008-08-26 14:03:29 +020017055static void alc663_mode5_inithook(struct hda_codec *codec)
17056{
17057 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017058 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017059}
17060/* ***************** Mode6 ******************************/
17061static void alc663_mode6_unsol_event(struct hda_codec *codec,
17062 unsigned int res)
17063{
17064 switch (res >> 26) {
17065 case ALC880_HP_EVENT:
17066 alc663_two_hp_m2_speaker_automute(codec);
17067 break;
17068 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017069 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017070 break;
17071 }
17072}
17073
Kailang Yangebb83ee2009-12-17 12:23:00 +010017074#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017075
Kailang Yangf1d4e282008-08-26 14:03:29 +020017076static void alc663_mode6_inithook(struct hda_codec *codec)
17077{
17078 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017079 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017080}
17081
Kailang Yangebb83ee2009-12-17 12:23:00 +010017082/* ***************** Mode7 ******************************/
17083static void alc663_mode7_unsol_event(struct hda_codec *codec,
17084 unsigned int res)
17085{
17086 switch (res >> 26) {
17087 case ALC880_HP_EVENT:
17088 alc663_two_hp_m7_speaker_automute(codec);
17089 break;
17090 case ALC880_MIC_EVENT:
17091 alc_mic_automute(codec);
17092 break;
17093 }
17094}
17095
17096#define alc663_mode7_setup alc663_mode1_setup
17097
17098static void alc663_mode7_inithook(struct hda_codec *codec)
17099{
17100 alc663_two_hp_m7_speaker_automute(codec);
17101 alc_mic_automute(codec);
17102}
17103
17104/* ***************** Mode8 ******************************/
17105static void alc663_mode8_unsol_event(struct hda_codec *codec,
17106 unsigned int res)
17107{
17108 switch (res >> 26) {
17109 case ALC880_HP_EVENT:
17110 alc663_two_hp_m8_speaker_automute(codec);
17111 break;
17112 case ALC880_MIC_EVENT:
17113 alc_mic_automute(codec);
17114 break;
17115 }
17116}
17117
17118#define alc663_mode8_setup alc663_m51va_setup
17119
17120static void alc663_mode8_inithook(struct hda_codec *codec)
17121{
17122 alc663_two_hp_m8_speaker_automute(codec);
17123 alc_mic_automute(codec);
17124}
17125
Kailang Yang6dda9f42008-05-27 12:05:31 +020017126static void alc663_g71v_hp_automute(struct hda_codec *codec)
17127{
17128 unsigned int present;
17129 unsigned char bits;
17130
Wu Fengguang864f92b2009-11-18 12:38:02 +080017131 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017132 bits = present ? HDA_AMP_MUTE : 0;
17133 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17134 HDA_AMP_MUTE, bits);
17135 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17136 HDA_AMP_MUTE, bits);
17137}
17138
17139static void alc663_g71v_front_automute(struct hda_codec *codec)
17140{
17141 unsigned int present;
17142 unsigned char bits;
17143
Wu Fengguang864f92b2009-11-18 12:38:02 +080017144 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017145 bits = present ? HDA_AMP_MUTE : 0;
17146 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17147 HDA_AMP_MUTE, bits);
17148}
17149
17150static void alc663_g71v_unsol_event(struct hda_codec *codec,
17151 unsigned int res)
17152{
17153 switch (res >> 26) {
17154 case ALC880_HP_EVENT:
17155 alc663_g71v_hp_automute(codec);
17156 break;
17157 case ALC880_FRONT_EVENT:
17158 alc663_g71v_front_automute(codec);
17159 break;
17160 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017161 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017162 break;
17163 }
17164}
17165
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017166#define alc663_g71v_setup alc663_m51va_setup
17167
Kailang Yang6dda9f42008-05-27 12:05:31 +020017168static void alc663_g71v_inithook(struct hda_codec *codec)
17169{
17170 alc663_g71v_front_automute(codec);
17171 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017172 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017173}
17174
17175static void alc663_g50v_unsol_event(struct hda_codec *codec,
17176 unsigned int res)
17177{
17178 switch (res >> 26) {
17179 case ALC880_HP_EVENT:
17180 alc663_m51va_speaker_automute(codec);
17181 break;
17182 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017183 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017184 break;
17185 }
17186}
17187
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017188#define alc663_g50v_setup alc663_m51va_setup
17189
Kailang Yang6dda9f42008-05-27 12:05:31 +020017190static void alc663_g50v_inithook(struct hda_codec *codec)
17191{
17192 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017193 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017194}
17195
Kailang Yangf1d4e282008-08-26 14:03:29 +020017196static struct snd_kcontrol_new alc662_ecs_mixer[] = {
17197 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020017198 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017199
17200 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
17201 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
17202 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
17203
17204 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17205 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17206 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17207 { } /* end */
17208};
17209
Chris Pockelé9541ba12009-05-12 08:08:53 +020017210static struct snd_kcontrol_new alc272_nc10_mixer[] = {
17211 /* Master Playback automatically created from Speaker and Headphone */
17212 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17213 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17214 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17215 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17216
17217 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17218 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17219 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
17220
17221 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17222 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17223 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
17224 { } /* end */
17225};
17226
Takashi Iwaicb53c622007-08-10 17:21:45 +020017227#ifdef CONFIG_SND_HDA_POWER_SAVE
17228#define alc662_loopbacks alc880_loopbacks
17229#endif
17230
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017231
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017232/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017233#define alc662_pcm_analog_playback alc880_pcm_analog_playback
17234#define alc662_pcm_analog_capture alc880_pcm_analog_capture
17235#define alc662_pcm_digital_playback alc880_pcm_digital_playback
17236#define alc662_pcm_digital_capture alc880_pcm_digital_capture
17237
17238/*
17239 * configuration and preset
17240 */
17241static const char *alc662_models[ALC662_MODEL_LAST] = {
17242 [ALC662_3ST_2ch_DIG] = "3stack-dig",
17243 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
17244 [ALC662_3ST_6ch] = "3stack-6ch",
17245 [ALC662_5ST_DIG] = "6stack-dig",
17246 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020017247 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010017248 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017249 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020017250 [ALC663_ASUS_M51VA] = "m51va",
17251 [ALC663_ASUS_G71V] = "g71v",
17252 [ALC663_ASUS_H13] = "h13",
17253 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017254 [ALC663_ASUS_MODE1] = "asus-mode1",
17255 [ALC662_ASUS_MODE2] = "asus-mode2",
17256 [ALC663_ASUS_MODE3] = "asus-mode3",
17257 [ALC663_ASUS_MODE4] = "asus-mode4",
17258 [ALC663_ASUS_MODE5] = "asus-mode5",
17259 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010017260 [ALC663_ASUS_MODE7] = "asus-mode7",
17261 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020017262 [ALC272_DELL] = "dell",
17263 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020017264 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017265 [ALC662_AUTO] = "auto",
17266};
17267
17268static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010017269 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020017270 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
17271 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017272 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
17273 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
17274 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
17275 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
17276 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
17277 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017278 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
17279 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017280 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017281 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
17282 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
17283 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
17284 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
17285 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017286 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017287 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
17288 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017289 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
17290 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
17291 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
17292 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017293 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017294 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
17295 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
17296 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017297 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
17298 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
17299 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
17300 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017301 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017302 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
17303 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017304 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017305 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
17306 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
17307 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017308 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
17309 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
17310 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017311 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
17312 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
17313 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017314 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017315 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
17316 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017317 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017318 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020017319 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017320 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
17321 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
17322 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017323 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017324 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
17325 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010017326 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020017327 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010017328 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017329 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030017330 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
17331 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010017332 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020017333 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030017334 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
17335 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020017336 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020017337 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017338 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020017339 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020017340 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017341 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
17342 ALC663_ASUS_H13),
David Santinoli7aee6742009-12-09 12:34:26 +010017343 SND_PCI_QUIRK(0x8086, 0xd604, "Intel mobo", ALC662_3ST_2ch_DIG),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017344 {}
17345};
17346
17347static struct alc_config_preset alc662_presets[] = {
17348 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017349 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017350 .init_verbs = { alc662_init_verbs },
17351 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17352 .dac_nids = alc662_dac_nids,
17353 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017354 .dig_in_nid = ALC662_DIGIN_NID,
17355 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17356 .channel_mode = alc662_3ST_2ch_modes,
17357 .input_mux = &alc662_capture_source,
17358 },
17359 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017360 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017361 .init_verbs = { alc662_init_verbs },
17362 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17363 .dac_nids = alc662_dac_nids,
17364 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017365 .dig_in_nid = ALC662_DIGIN_NID,
17366 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17367 .channel_mode = alc662_3ST_6ch_modes,
17368 .need_dac_fix = 1,
17369 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017370 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017371 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017372 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017373 .init_verbs = { alc662_init_verbs },
17374 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17375 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017376 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17377 .channel_mode = alc662_3ST_6ch_modes,
17378 .need_dac_fix = 1,
17379 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017380 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017381 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017382 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017383 .init_verbs = { alc662_init_verbs },
17384 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17385 .dac_nids = alc662_dac_nids,
17386 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017387 .dig_in_nid = ALC662_DIGIN_NID,
17388 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
17389 .channel_mode = alc662_5stack_modes,
17390 .input_mux = &alc662_capture_source,
17391 },
17392 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017393 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017394 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
17395 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17396 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017397 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17398 .channel_mode = alc662_3ST_2ch_modes,
17399 .input_mux = &alc662_lenovo_101e_capture_source,
17400 .unsol_event = alc662_lenovo_101e_unsol_event,
17401 .init_hook = alc662_lenovo_101e_all_automute,
17402 },
Kailang Yang291702f2007-10-16 14:28:03 +020017403 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017404 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020017405 .init_verbs = { alc662_init_verbs,
17406 alc662_eeepc_sue_init_verbs },
17407 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17408 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020017409 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17410 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020017411 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017412 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020017413 .init_hook = alc662_eeepc_inithook,
17414 },
Kailang Yang8c427222008-01-10 13:03:59 +010017415 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017416 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010017417 alc662_chmode_mixer },
17418 .init_verbs = { alc662_init_verbs,
17419 alc662_eeepc_ep20_sue_init_verbs },
17420 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17421 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010017422 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17423 .channel_mode = alc662_3ST_6ch_modes,
17424 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020017425 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017426 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010017427 .init_hook = alc662_eeepc_ep20_inithook,
17428 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017429 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017430 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017431 .init_verbs = { alc662_init_verbs,
17432 alc662_ecs_init_verbs },
17433 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17434 .dac_nids = alc662_dac_nids,
17435 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17436 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017437 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017438 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017439 .init_hook = alc662_eeepc_inithook,
17440 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017441 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017442 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017443 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17444 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17445 .dac_nids = alc662_dac_nids,
17446 .dig_out_nid = ALC662_DIGOUT_NID,
17447 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17448 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017449 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017450 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017451 .init_hook = alc663_m51va_inithook,
17452 },
17453 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017454 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017455 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
17456 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17457 .dac_nids = alc662_dac_nids,
17458 .dig_out_nid = ALC662_DIGOUT_NID,
17459 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17460 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017461 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017462 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017463 .init_hook = alc663_g71v_inithook,
17464 },
17465 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017466 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017467 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17468 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17469 .dac_nids = alc662_dac_nids,
17470 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17471 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017472 .unsol_event = alc663_m51va_unsol_event,
17473 .init_hook = alc663_m51va_inithook,
17474 },
17475 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017476 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017477 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17478 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17479 .dac_nids = alc662_dac_nids,
17480 .dig_out_nid = ALC662_DIGOUT_NID,
17481 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17482 .channel_mode = alc662_3ST_6ch_modes,
17483 .input_mux = &alc663_capture_source,
17484 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017485 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017486 .init_hook = alc663_g50v_inithook,
17487 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017488 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017489 .mixers = { alc663_m51va_mixer },
17490 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017491 .init_verbs = { alc662_init_verbs,
17492 alc663_21jd_amic_init_verbs },
17493 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17494 .hp_nid = 0x03,
17495 .dac_nids = alc662_dac_nids,
17496 .dig_out_nid = ALC662_DIGOUT_NID,
17497 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17498 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017499 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017500 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017501 .init_hook = alc663_mode1_inithook,
17502 },
17503 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017504 .mixers = { alc662_1bjd_mixer },
17505 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017506 .init_verbs = { alc662_init_verbs,
17507 alc662_1bjd_amic_init_verbs },
17508 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17509 .dac_nids = alc662_dac_nids,
17510 .dig_out_nid = ALC662_DIGOUT_NID,
17511 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17512 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017513 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017514 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017515 .init_hook = alc662_mode2_inithook,
17516 },
17517 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017518 .mixers = { alc663_two_hp_m1_mixer },
17519 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017520 .init_verbs = { alc662_init_verbs,
17521 alc663_two_hp_amic_m1_init_verbs },
17522 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17523 .hp_nid = 0x03,
17524 .dac_nids = alc662_dac_nids,
17525 .dig_out_nid = ALC662_DIGOUT_NID,
17526 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17527 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017528 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017529 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017530 .init_hook = alc663_mode3_inithook,
17531 },
17532 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017533 .mixers = { alc663_asus_21jd_clfe_mixer },
17534 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017535 .init_verbs = { alc662_init_verbs,
17536 alc663_21jd_amic_init_verbs},
17537 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17538 .hp_nid = 0x03,
17539 .dac_nids = alc662_dac_nids,
17540 .dig_out_nid = ALC662_DIGOUT_NID,
17541 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17542 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017543 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017544 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017545 .init_hook = alc663_mode4_inithook,
17546 },
17547 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017548 .mixers = { alc663_asus_15jd_clfe_mixer },
17549 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017550 .init_verbs = { alc662_init_verbs,
17551 alc663_15jd_amic_init_verbs },
17552 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17553 .hp_nid = 0x03,
17554 .dac_nids = alc662_dac_nids,
17555 .dig_out_nid = ALC662_DIGOUT_NID,
17556 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17557 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017558 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017559 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017560 .init_hook = alc663_mode5_inithook,
17561 },
17562 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017563 .mixers = { alc663_two_hp_m2_mixer },
17564 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017565 .init_verbs = { alc662_init_verbs,
17566 alc663_two_hp_amic_m2_init_verbs },
17567 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17568 .hp_nid = 0x03,
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 = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017574 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017575 .init_hook = alc663_mode6_inithook,
17576 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010017577 [ALC663_ASUS_MODE7] = {
17578 .mixers = { alc663_mode7_mixer },
17579 .cap_mixer = alc662_auto_capture_mixer,
17580 .init_verbs = { alc662_init_verbs,
17581 alc663_mode7_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,
17588 .unsol_event = alc663_mode7_unsol_event,
17589 .setup = alc663_mode7_setup,
17590 .init_hook = alc663_mode7_inithook,
17591 },
17592 [ALC663_ASUS_MODE8] = {
17593 .mixers = { alc663_mode8_mixer },
17594 .cap_mixer = alc662_auto_capture_mixer,
17595 .init_verbs = { alc662_init_verbs,
17596 alc663_mode8_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,
17603 .unsol_event = alc663_mode8_unsol_event,
17604 .setup = alc663_mode8_setup,
17605 .init_hook = alc663_mode8_inithook,
17606 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017607 [ALC272_DELL] = {
17608 .mixers = { alc663_m51va_mixer },
17609 .cap_mixer = alc272_auto_capture_mixer,
17610 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17611 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17612 .dac_nids = alc662_dac_nids,
17613 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17614 .adc_nids = alc272_adc_nids,
17615 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17616 .capsrc_nids = alc272_capsrc_nids,
17617 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017618 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017619 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017620 .init_hook = alc663_m51va_inithook,
17621 },
17622 [ALC272_DELL_ZM1] = {
17623 .mixers = { alc663_m51va_mixer },
17624 .cap_mixer = alc662_auto_capture_mixer,
17625 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17626 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17627 .dac_nids = alc662_dac_nids,
17628 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17629 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017630 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020017631 .capsrc_nids = alc662_capsrc_nids,
17632 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017633 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017634 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017635 .init_hook = alc663_m51va_inithook,
17636 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017637 [ALC272_SAMSUNG_NC10] = {
17638 .mixers = { alc272_nc10_mixer },
17639 .init_verbs = { alc662_init_verbs,
17640 alc663_21jd_amic_init_verbs },
17641 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17642 .dac_nids = alc272_dac_nids,
17643 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17644 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017645 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020017646 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017647 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020017648 .init_hook = alc663_mode4_inithook,
17649 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017650};
17651
17652
17653/*
17654 * BIOS auto configuration
17655 */
17656
Takashi Iwai7085ec12009-10-02 09:03:58 +020017657/* convert from MIX nid to DAC */
17658static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
17659{
17660 if (nid == 0x0f)
17661 return 0x02;
17662 else if (nid >= 0x0c && nid <= 0x0e)
17663 return nid - 0x0c + 0x02;
17664 else
17665 return 0;
17666}
17667
17668/* get MIX nid connected to the given pin targeted to DAC */
17669static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
17670 hda_nid_t dac)
17671{
17672 hda_nid_t mix[4];
17673 int i, num;
17674
17675 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
17676 for (i = 0; i < num; i++) {
17677 if (alc662_mix_to_dac(mix[i]) == dac)
17678 return mix[i];
17679 }
17680 return 0;
17681}
17682
17683/* look for an empty DAC slot */
17684static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
17685{
17686 struct alc_spec *spec = codec->spec;
17687 hda_nid_t srcs[5];
17688 int i, j, num;
17689
17690 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
17691 if (num < 0)
17692 return 0;
17693 for (i = 0; i < num; i++) {
17694 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
17695 if (!nid)
17696 continue;
17697 for (j = 0; j < spec->multiout.num_dacs; j++)
17698 if (spec->multiout.dac_nids[j] == nid)
17699 break;
17700 if (j >= spec->multiout.num_dacs)
17701 return nid;
17702 }
17703 return 0;
17704}
17705
17706/* fill in the dac_nids table from the parsed pin configuration */
17707static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
17708 const struct auto_pin_cfg *cfg)
17709{
17710 struct alc_spec *spec = codec->spec;
17711 int i;
17712 hda_nid_t dac;
17713
17714 spec->multiout.dac_nids = spec->private_dac_nids;
17715 for (i = 0; i < cfg->line_outs; i++) {
17716 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
17717 if (!dac)
17718 continue;
17719 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
17720 }
17721 return 0;
17722}
17723
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017724static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017725 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017726{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017727 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017728 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
17729}
17730
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017731static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017732 hda_nid_t nid, unsigned int chs)
17733{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017734 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017735 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
17736}
17737
17738#define alc662_add_stereo_vol(spec, pfx, nid) \
17739 alc662_add_vol_ctl(spec, pfx, nid, 3)
17740#define alc662_add_stereo_sw(spec, pfx, nid) \
17741 alc662_add_sw_ctl(spec, pfx, nid, 3)
17742
17743/* add playback controls from the parsed DAC table */
17744static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
17745 const struct auto_pin_cfg *cfg)
17746{
17747 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017748 static const char *chname[4] = {
17749 "Front", "Surround", NULL /*CLFE*/, "Side"
17750 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020017751 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017752 int i, err;
17753
17754 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017755 nid = spec->multiout.dac_nids[i];
17756 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017757 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017758 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
17759 if (!mix)
17760 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017761 if (i == 2) {
17762 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017763 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017764 if (err < 0)
17765 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017766 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017767 if (err < 0)
17768 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017769 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017770 if (err < 0)
17771 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017772 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017773 if (err < 0)
17774 return err;
17775 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017776 const char *pfx;
17777 if (cfg->line_outs == 1 &&
17778 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017779 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017780 pfx = "Speaker";
17781 else
17782 pfx = "PCM";
17783 } else
17784 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017785 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017786 if (err < 0)
17787 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017788 if (cfg->line_outs == 1 &&
17789 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
17790 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020017791 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017792 if (err < 0)
17793 return err;
17794 }
17795 }
17796 return 0;
17797}
17798
17799/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017800/* return DAC nid if any new DAC is assigned */
17801static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017802 const char *pfx)
17803{
Takashi Iwai7085ec12009-10-02 09:03:58 +020017804 struct alc_spec *spec = codec->spec;
17805 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017806 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017807
17808 if (!pin)
17809 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017810 nid = alc662_look_for_dac(codec, pin);
17811 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017812 /* the corresponding DAC is already occupied */
17813 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
17814 return 0; /* no way */
17815 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017816 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017817 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17818 }
17819
17820 mix = alc662_dac_to_mix(codec, pin, nid);
17821 if (!mix)
17822 return 0;
17823 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
17824 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020017825 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017826 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
17827 if (err < 0)
17828 return err;
17829 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017830}
17831
17832/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017833#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020017834 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017835
17836static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17837 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017838 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017839{
Takashi Iwai7085ec12009-10-02 09:03:58 +020017840 int i, num;
17841 hda_nid_t srcs[4];
17842
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017843 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017844 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017845 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
17846 if (num <= 1)
17847 return;
17848 for (i = 0; i < num; i++) {
17849 if (alc662_mix_to_dac(srcs[i]) != dac)
17850 continue;
17851 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
17852 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017853 }
17854}
17855
17856static void alc662_auto_init_multi_out(struct hda_codec *codec)
17857{
17858 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017859 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017860 int i;
17861
17862 for (i = 0; i <= HDA_SIDE; i++) {
17863 hda_nid_t nid = spec->autocfg.line_out_pins[i];
17864 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017865 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017866 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017867 }
17868}
17869
17870static void alc662_auto_init_hp_out(struct hda_codec *codec)
17871{
17872 struct alc_spec *spec = codec->spec;
17873 hda_nid_t pin;
17874
17875 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017876 if (pin)
17877 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
17878 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017879 pin = spec->autocfg.speaker_pins[0];
17880 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020017881 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
17882 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017883}
17884
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017885#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17886
17887static void alc662_auto_init_analog_input(struct hda_codec *codec)
17888{
17889 struct alc_spec *spec = codec->spec;
17890 int i;
17891
17892 for (i = 0; i < AUTO_PIN_LAST; i++) {
17893 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020017894 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017895 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017896 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017897 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017898 snd_hda_codec_write(codec, nid, 0,
17899 AC_VERB_SET_AMP_GAIN_MUTE,
17900 AMP_OUT_MUTE);
17901 }
17902 }
17903}
17904
Takashi Iwaif511b012008-08-15 16:46:42 +020017905#define alc662_auto_init_input_src alc882_auto_init_input_src
17906
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017907static int alc662_parse_auto_config(struct hda_codec *codec)
17908{
17909 struct alc_spec *spec = codec->spec;
17910 int err;
17911 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17912
17913 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17914 alc662_ignore);
17915 if (err < 0)
17916 return err;
17917 if (!spec->autocfg.line_outs)
17918 return 0; /* can't find valid BIOS pin config */
17919
Takashi Iwai7085ec12009-10-02 09:03:58 +020017920 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017921 if (err < 0)
17922 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017923 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017924 if (err < 0)
17925 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017926 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017927 spec->autocfg.speaker_pins[0],
17928 "Speaker");
17929 if (err < 0)
17930 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017931 if (err)
17932 spec->multiout.extra_out_nid[0] = err;
17933 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017934 "Headphone");
17935 if (err < 0)
17936 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017937 if (err)
17938 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017939 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017940 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017941 return err;
17942
17943 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17944
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017945 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017946 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17947
Takashi Iwai603c4012008-07-30 15:01:44 +020017948 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017949 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017950
17951 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017952 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017953
Takashi Iwaid88897e2008-10-31 15:01:37 +010017954 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017955 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017956 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017957
17958 err = alc_auto_add_mic_boost(codec);
17959 if (err < 0)
17960 return err;
17961
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017962 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17963
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017964 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017965}
17966
17967/* additional initialization for auto-configuration model */
17968static void alc662_auto_init(struct hda_codec *codec)
17969{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017970 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017971 alc662_auto_init_multi_out(codec);
17972 alc662_auto_init_hp_out(codec);
17973 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017974 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017975 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017976 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017977}
17978
17979static int patch_alc662(struct hda_codec *codec)
17980{
17981 struct alc_spec *spec;
17982 int err, board_config;
17983
17984 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17985 if (!spec)
17986 return -ENOMEM;
17987
17988 codec->spec = spec;
17989
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017990 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17991
Kailang Yang274693f2009-12-03 10:07:50 +010017992 if (alc_read_coef_idx(codec, 0)==0x8020){
17993 kfree(codec->chip_name);
17994 codec->chip_name = kstrdup("ALC661", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017995 if (!codec->chip_name) {
17996 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010017997 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017998 }
Kailang Yang274693f2009-12-03 10:07:50 +010017999 }
18000
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018001 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
18002 alc662_models,
18003 alc662_cfg_tbl);
18004 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020018005 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
18006 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018007 board_config = ALC662_AUTO;
18008 }
18009
18010 if (board_config == ALC662_AUTO) {
18011 /* automatic parse from the BIOS config */
18012 err = alc662_parse_auto_config(codec);
18013 if (err < 0) {
18014 alc_free(codec);
18015 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018016 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018017 printk(KERN_INFO
18018 "hda_codec: Cannot set up configuration "
18019 "from BIOS. Using base mode...\n");
18020 board_config = ALC662_3ST_2ch_DIG;
18021 }
18022 }
18023
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090018024 err = snd_hda_attach_beep_device(codec, 0x1);
18025 if (err < 0) {
18026 alc_free(codec);
18027 return err;
18028 }
18029
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018030 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020018031 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018032
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018033 spec->stream_analog_playback = &alc662_pcm_analog_playback;
18034 spec->stream_analog_capture = &alc662_pcm_analog_capture;
18035
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018036 spec->stream_digital_playback = &alc662_pcm_digital_playback;
18037 spec->stream_digital_capture = &alc662_pcm_digital_capture;
18038
Takashi Iwaidd704692009-08-11 08:45:11 +020018039 if (!spec->adc_nids) {
18040 spec->adc_nids = alc662_adc_nids;
18041 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
18042 }
18043 if (!spec->capsrc_nids)
18044 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018045
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018046 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018047 set_capture_mixer(codec);
Takashi Iwaib9591442009-03-16 15:25:00 +010018048 if (codec->vendor_id == 0x10ec0662)
18049 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
18050 else
18051 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018052
Takashi Iwai2134ea42008-01-10 16:53:55 +010018053 spec->vmaster_nid = 0x02;
18054
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018055 codec->patch_ops = alc_patch_ops;
18056 if (board_config == ALC662_AUTO)
18057 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020018058#ifdef CONFIG_SND_HDA_POWER_SAVE
18059 if (!spec->loopback.amplist)
18060 spec->loopback.amplist = alc662_loopbacks;
18061#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010018062 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018063
18064 return 0;
18065}
18066
Kailang Yang274693f2009-12-03 10:07:50 +010018067static int patch_alc888(struct hda_codec *codec)
18068{
18069 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
18070 kfree(codec->chip_name);
18071 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018072 if (!codec->chip_name) {
18073 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018074 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018075 }
18076 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018077 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018078 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018079}
18080
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018081/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070018082 * patch entries
18083 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018084static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070018085 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018086 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018087 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020018088 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018089 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018090 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020018091 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018092 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018093 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018094 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018095 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
18096 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
18097 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018098 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018099 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018100 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
18101 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018102 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018103 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018104 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018105 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020018106 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018107 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020018108 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018109 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018110 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018111 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020018112 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018113 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018114 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018115 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018116 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018117 {} /* terminator */
18118};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018119
18120MODULE_ALIAS("snd-hda-codec-id:10ec*");
18121
18122MODULE_LICENSE("GPL");
18123MODULE_DESCRIPTION("Realtek HD-audio codec");
18124
18125static struct hda_codec_preset_list realtek_list = {
18126 .preset = snd_hda_preset_realtek,
18127 .owner = THIS_MODULE,
18128};
18129
18130static int __init patch_realtek_init(void)
18131{
18132 return snd_hda_add_codec_preset(&realtek_list);
18133}
18134
18135static void __exit patch_realtek_exit(void)
18136{
18137 snd_hda_delete_codec_preset(&realtek_list);
18138}
18139
18140module_init(patch_realtek_init)
18141module_exit(patch_realtek_exit)