blob: faeb74f28207b71c44b27040c69a1d5f5b18345e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090033#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020075 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010076 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010078 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020079 ALC260_WILL,
80 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010081 ALC260_FAVORIT100,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010082#ifdef CONFIG_SND_DEBUG
83 ALC260_TEST,
84#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010085 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020086 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087};
88
Kailang Yangdf694da2005-12-05 19:42:22 +010089/* ALC262 models */
90enum {
91 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020092 ALC262_HIPPO,
93 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010094 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020095 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010096 ALC262_HP_BPC_D7000_WL,
97 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010098 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010099 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200100 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200101 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200102 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200103 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100104 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200105 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200106 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200107 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000108 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100109 ALC262_AUTO,
110 ALC262_MODEL_LAST /* last tag */
111};
112
Kailang Yanga361d842007-06-05 12:30:55 +0200113/* ALC268 models */
114enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200115 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200116 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200117 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200118 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100119 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200120 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100121 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100122 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100123#ifdef CONFIG_SND_DEBUG
124 ALC268_TEST,
125#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200126 ALC268_AUTO,
127 ALC268_MODEL_LAST /* last tag */
128};
129
Kailang Yangf6a92242007-12-13 16:52:54 +0100130/* ALC269 models */
131enum {
132 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200133 ALC269_QUANTA_FL1,
Kailang Yangebb83ee2009-12-17 12:23:00 +0100134 ALC269_ASUS_AMIC,
135 ALC269_ASUS_DMIC,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100136 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000137 ALC269_LIFEBOOK,
Kailang Yangf6a92242007-12-13 16:52:54 +0100138 ALC269_AUTO,
139 ALC269_MODEL_LAST /* last tag */
140};
141
Kailang Yangdf694da2005-12-05 19:42:22 +0100142/* ALC861 models */
143enum {
144 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200145 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100146 ALC861_3ST_DIG,
147 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200148 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200149 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200150 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100151 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100152 ALC861_AUTO,
153 ALC861_MODEL_LAST,
154};
155
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100156/* ALC861-VD models */
157enum {
158 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200159 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100160 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100161 ALC861VD_3ST,
162 ALC861VD_3ST_DIG,
163 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200164 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200165 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200166 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100167 ALC861VD_AUTO,
168 ALC861VD_MODEL_LAST,
169};
170
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200171/* ALC662 models */
172enum {
173 ALC662_3ST_2ch_DIG,
174 ALC662_3ST_6ch_DIG,
175 ALC662_3ST_6ch,
176 ALC662_5ST_DIG,
177 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200178 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100179 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200180 ALC663_ASUS_M51VA,
181 ALC663_ASUS_G71V,
182 ALC663_ASUS_H13,
183 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200184 ALC662_ECS,
185 ALC663_ASUS_MODE1,
186 ALC662_ASUS_MODE2,
187 ALC663_ASUS_MODE3,
188 ALC663_ASUS_MODE4,
189 ALC663_ASUS_MODE5,
190 ALC663_ASUS_MODE6,
Kailang Yangebb83ee2009-12-17 12:23:00 +0100191 ALC663_ASUS_MODE7,
192 ALC663_ASUS_MODE8,
Kailang Yang622e84c2009-04-21 07:39:04 +0200193 ALC272_DELL,
194 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200195 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200196 ALC662_AUTO,
197 ALC662_MODEL_LAST,
198};
199
Kailang Yangdf694da2005-12-05 19:42:22 +0100200/* ALC882 models */
201enum {
202 ALC882_3ST_DIG,
203 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200204 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200205 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200206 ALC882_TARGA,
207 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200208 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100209 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200210 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200211 ALC885_MB5,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200212 ALC885_IMAC24,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -0800213 ALC885_IMAC91,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200214 ALC883_3ST_2ch_DIG,
215 ALC883_3ST_6ch_DIG,
216 ALC883_3ST_6ch,
217 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200218 ALC883_TARGA_DIG,
219 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200220 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200221 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200222 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800223 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100224 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200225 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200226 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200227 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200228 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100229 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200230 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200231 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200232 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200233 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200234 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200235 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100236 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100237 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430238 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100239 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100240 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800241 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200242 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200243 ALC889A_INTEL,
244 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200245 ALC888_ASUS_M90V,
246 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200247 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100248 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200249 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200250 ALC882_AUTO,
251 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200252};
253
Kailang Yangdf694da2005-12-05 19:42:22 +0100254/* for GPIO Poll */
255#define GPIO_MASK 0x03
256
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200257/* extra amp-initialization sequence types */
258enum {
259 ALC_INIT_NONE,
260 ALC_INIT_DEFAULT,
261 ALC_INIT_GPIO1,
262 ALC_INIT_GPIO2,
263 ALC_INIT_GPIO3,
264};
265
Takashi Iwai6c819492009-08-10 18:47:44 +0200266struct alc_mic_route {
267 hda_nid_t pin;
268 unsigned char mux_idx;
269 unsigned char amix_idx;
270};
271
272#define MUX_IDX_UNDEF ((unsigned char)-1)
273
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274struct alc_spec {
275 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100276 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100278 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100279 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200281 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200282 * don't forget NULL
283 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200284 */
285 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200287 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 struct hda_pcm_stream *stream_analog_playback;
289 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100290 struct hda_pcm_stream *stream_analog_alt_playback;
291 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200293 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 struct hda_pcm_stream *stream_digital_playback;
295 struct hda_pcm_stream *stream_digital_capture;
296
297 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200298 struct hda_multi_out multiout; /* playback set-up
299 * max_channels, dacs must be set
300 * dig_out_nid and hp_nid are optional
301 */
Takashi Iwai63300792008-01-24 15:31:36 +0100302 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100303 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100304 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305
306 /* capture */
307 unsigned int num_adc_nids;
308 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100309 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200310 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311
312 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200313 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314 const struct hda_input_mux *input_mux;
315 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200316 struct alc_mic_route ext_mic;
317 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318
319 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100320 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200322 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200323 int const_channel_count;
324 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325
326 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100327 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200328
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200329 /* dynamic controls, init_verbs and input_mux */
330 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200331 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200332 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200333 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200334 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
335 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100336
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100337 /* hooks */
338 void (*init_hook)(struct hda_codec *codec);
339 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
340
Takashi Iwai834be882006-03-01 14:16:17 +0100341 /* for pin sensing */
342 unsigned int sense_updated: 1;
343 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100344 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200345 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200346
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100347 /* other flags */
348 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200349 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100350
Takashi Iwai2134ea42008-01-10 16:53:55 +0100351 /* for virtual master */
352 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200353#ifdef CONFIG_SND_HDA_POWER_SAVE
354 struct hda_loopback_check loopback;
355#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200356
357 /* for PLL fix */
358 hda_nid_t pll_nid;
359 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100360};
361
362/*
363 * configuration template - to be copied to the spec instance
364 */
365struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200366 struct snd_kcontrol_new *mixers[5]; /* should be identical size
367 * with spec
368 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100369 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100370 const struct hda_verb *init_verbs[5];
371 unsigned int num_dacs;
372 hda_nid_t *dac_nids;
373 hda_nid_t dig_out_nid; /* optional */
374 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800375 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100376 unsigned int num_adc_nids;
377 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100378 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100379 hda_nid_t dig_in_nid;
380 unsigned int num_channel_mode;
381 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200382 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200383 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200384 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100385 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100386 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200387 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100388 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200389#ifdef CONFIG_SND_HDA_POWER_SAVE
390 struct hda_amp_list *loopbacks;
391#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392};
393
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394
395/*
396 * input MUX handling
397 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200398static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
399 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400{
401 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
402 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200403 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
404 if (mux_idx >= spec->num_mux_defs)
405 mux_idx = 0;
406 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407}
408
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200409static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
410 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411{
412 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
413 struct alc_spec *spec = codec->spec;
414 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
415
416 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
417 return 0;
418}
419
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200420static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
421 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422{
423 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
424 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100425 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100427 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100428 hda_nid_t nid = spec->capsrc_nids ?
429 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200430 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431
Takashi Iwaicd896c32008-11-18 12:36:33 +0100432 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
433 imux = &spec->input_mux[mux_idx];
434
Takashi Iwaia22d5432009-07-27 12:54:26 +0200435 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200436 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100437 /* Matrix-mixer style (e.g. ALC882) */
438 unsigned int *cur_val = &spec->cur_mux[adc_idx];
439 unsigned int i, idx;
440
441 idx = ucontrol->value.enumerated.item[0];
442 if (idx >= imux->num_items)
443 idx = imux->num_items - 1;
444 if (*cur_val == idx)
445 return 0;
446 for (i = 0; i < imux->num_items; i++) {
447 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
448 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
449 imux->items[i].index,
450 HDA_AMP_MUTE, v);
451 }
452 *cur_val = idx;
453 return 1;
454 } else {
455 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100456 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100457 &spec->cur_mux[adc_idx]);
458 }
459}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200460
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461/*
462 * channel mode setting
463 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200464static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
465 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466{
467 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
468 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100469 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
470 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471}
472
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200473static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
474 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475{
476 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
477 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100478 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200479 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200480 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481}
482
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200483static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
484 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485{
486 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
487 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200488 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
489 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200490 &spec->ext_channel_count);
491 if (err >= 0 && !spec->const_channel_count) {
492 spec->multiout.max_channels = spec->ext_channel_count;
493 if (spec->need_dac_fix)
494 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
495 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200496 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497}
498
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100500 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200501 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100502 * being part of a format specifier. Maximum allowed length of a value is
503 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100504 *
505 * Note: some retasking pin complexes seem to ignore requests for input
506 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
507 * are requested. Therefore order this list so that this behaviour will not
508 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200509 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
510 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200511 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100512static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100513 "Mic 50pc bias", "Mic 80pc bias",
514 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100515};
516static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100517 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100518};
519/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200520 * in the pin being assumed to be exclusively an input or an output pin. In
521 * addition, "input" pins may or may not process the mic bias option
522 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
523 * accept requests for bias as of chip versions up to March 2006) and/or
524 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100525 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200526#define ALC_PIN_DIR_IN 0x00
527#define ALC_PIN_DIR_OUT 0x01
528#define ALC_PIN_DIR_INOUT 0x02
529#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
530#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100531
Kailang Yangea1fb292008-08-26 12:58:38 +0200532/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100533 * For each direction the minimum and maximum values are given.
534 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200535static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100536 { 0, 2 }, /* ALC_PIN_DIR_IN */
537 { 3, 4 }, /* ALC_PIN_DIR_OUT */
538 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200539 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
540 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100541};
542#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
543#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
544#define alc_pin_mode_n_items(_dir) \
545 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
546
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200547static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
548 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200549{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100550 unsigned int item_num = uinfo->value.enumerated.item;
551 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
552
553 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200554 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100555 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
556
557 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
558 item_num = alc_pin_mode_min(dir);
559 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200560 return 0;
561}
562
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200563static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
564 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200565{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100566 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200567 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
568 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100569 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200570 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200571 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
572 AC_VERB_GET_PIN_WIDGET_CONTROL,
573 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200574
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100575 /* Find enumerated value for current pinctl setting */
576 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200577 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100578 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200579 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100580 return 0;
581}
582
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200583static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
584 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100585{
586 signed int change;
587 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
588 hda_nid_t nid = kcontrol->private_value & 0xffff;
589 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
590 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200591 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
592 AC_VERB_GET_PIN_WIDGET_CONTROL,
593 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100594
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200595 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100596 val = alc_pin_mode_min(dir);
597
598 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100599 if (change) {
600 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200601 snd_hda_codec_write_cache(codec, nid, 0,
602 AC_VERB_SET_PIN_WIDGET_CONTROL,
603 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100604
Kailang Yangea1fb292008-08-26 12:58:38 +0200605 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100606 * for the requested pin mode. Enum values of 2 or less are
607 * input modes.
608 *
609 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200610 * reduces noise slightly (particularly on input) so we'll
611 * do it. However, having both input and output buffers
612 * enabled simultaneously doesn't seem to be problematic if
613 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100614 */
615 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200616 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
617 HDA_AMP_MUTE, HDA_AMP_MUTE);
618 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
619 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100620 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200621 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
622 HDA_AMP_MUTE, HDA_AMP_MUTE);
623 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
624 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100625 }
626 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200627 return change;
628}
629
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100630#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200631 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100632 .info = alc_pin_mode_info, \
633 .get = alc_pin_mode_get, \
634 .put = alc_pin_mode_put, \
635 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100636
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100637/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
638 * together using a mask with more than one bit set. This control is
639 * currently used only by the ALC260 test model. At this stage they are not
640 * needed for any "production" models.
641 */
642#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200643#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200644
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200645static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
646 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100647{
648 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
649 hda_nid_t nid = kcontrol->private_value & 0xffff;
650 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
651 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200652 unsigned int val = snd_hda_codec_read(codec, nid, 0,
653 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100654
655 *valp = (val & mask) != 0;
656 return 0;
657}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200658static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
659 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100660{
661 signed int change;
662 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
663 hda_nid_t nid = kcontrol->private_value & 0xffff;
664 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
665 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200666 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
667 AC_VERB_GET_GPIO_DATA,
668 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100669
670 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200671 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
672 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100673 gpio_data &= ~mask;
674 else
675 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200676 snd_hda_codec_write_cache(codec, nid, 0,
677 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100678
679 return change;
680}
681#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
682 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
683 .info = alc_gpio_data_info, \
684 .get = alc_gpio_data_get, \
685 .put = alc_gpio_data_put, \
686 .private_value = nid | (mask<<16) }
687#endif /* CONFIG_SND_DEBUG */
688
Jonathan Woithe92621f12006-02-28 11:47:47 +0100689/* A switch control to allow the enabling of the digital IO pins on the
690 * ALC260. This is incredibly simplistic; the intention of this control is
691 * to provide something in the test model allowing digital outputs to be
692 * identified if present. If models are found which can utilise these
693 * outputs a more complete mixer control can be devised for those models if
694 * necessary.
695 */
696#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200697#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200698
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200699static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
700 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100701{
702 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
703 hda_nid_t nid = kcontrol->private_value & 0xffff;
704 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
705 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200706 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100707 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100708
709 *valp = (val & mask) != 0;
710 return 0;
711}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200712static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
713 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100714{
715 signed int change;
716 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
717 hda_nid_t nid = kcontrol->private_value & 0xffff;
718 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
719 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200720 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100721 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200722 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100723
724 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200725 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100726 if (val==0)
727 ctrl_data &= ~mask;
728 else
729 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200730 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
731 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100732
733 return change;
734}
735#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
736 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
737 .info = alc_spdif_ctrl_info, \
738 .get = alc_spdif_ctrl_get, \
739 .put = alc_spdif_ctrl_put, \
740 .private_value = nid | (mask<<16) }
741#endif /* CONFIG_SND_DEBUG */
742
Jonathan Woithef8225f62008-01-08 12:16:54 +0100743/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
744 * Again, this is only used in the ALC26x test models to help identify when
745 * the EAPD line must be asserted for features to work.
746 */
747#ifdef CONFIG_SND_DEBUG
748#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
749
750static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
751 struct snd_ctl_elem_value *ucontrol)
752{
753 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
754 hda_nid_t nid = kcontrol->private_value & 0xffff;
755 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
756 long *valp = ucontrol->value.integer.value;
757 unsigned int val = snd_hda_codec_read(codec, nid, 0,
758 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
759
760 *valp = (val & mask) != 0;
761 return 0;
762}
763
764static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
765 struct snd_ctl_elem_value *ucontrol)
766{
767 int change;
768 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
769 hda_nid_t nid = kcontrol->private_value & 0xffff;
770 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
771 long val = *ucontrol->value.integer.value;
772 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
773 AC_VERB_GET_EAPD_BTLENABLE,
774 0x00);
775
776 /* Set/unset the masked control bit(s) as needed */
777 change = (!val ? 0 : mask) != (ctrl_data & mask);
778 if (!val)
779 ctrl_data &= ~mask;
780 else
781 ctrl_data |= mask;
782 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
783 ctrl_data);
784
785 return change;
786}
787
788#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
789 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
790 .info = alc_eapd_ctrl_info, \
791 .get = alc_eapd_ctrl_get, \
792 .put = alc_eapd_ctrl_put, \
793 .private_value = nid | (mask<<16) }
794#endif /* CONFIG_SND_DEBUG */
795
Kailang Yangdf694da2005-12-05 19:42:22 +0100796/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100797 * set up the input pin config (depending on the given auto-pin type)
798 */
799static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
800 int auto_pin_type)
801{
802 unsigned int val = PIN_IN;
803
804 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
805 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100806 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100807 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
808 if (pincap & AC_PINCAP_VREF_80)
809 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200810 else if (pincap & AC_PINCAP_VREF_50)
811 val = PIN_VREF50;
812 else if (pincap & AC_PINCAP_VREF_100)
813 val = PIN_VREF100;
814 else if (pincap & AC_PINCAP_VREF_GRD)
815 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100816 }
817 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
818}
819
820/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100821 */
822static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
823{
824 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
825 return;
826 spec->mixers[spec->num_mixers++] = mix;
827}
828
829static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
830{
831 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
832 return;
833 spec->init_verbs[spec->num_init_verbs++] = verb;
834}
835
Takashi Iwaidaead532008-11-28 12:55:36 +0100836#ifdef CONFIG_PROC_FS
837/*
838 * hook for proc
839 */
840static void print_realtek_coef(struct snd_info_buffer *buffer,
841 struct hda_codec *codec, hda_nid_t nid)
842{
843 int coeff;
844
845 if (nid != 0x20)
846 return;
847 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
848 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
849 coeff = snd_hda_codec_read(codec, nid, 0,
850 AC_VERB_GET_COEF_INDEX, 0);
851 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
852}
853#else
854#define print_realtek_coef NULL
855#endif
856
Takashi Iwaid88897e2008-10-31 15:01:37 +0100857/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100858 * set up from the preset table
859 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200860static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200861 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100862{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200863 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100864 int i;
865
866 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100867 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100868 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200869 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
870 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100871 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200872
Kailang Yangdf694da2005-12-05 19:42:22 +0100873 spec->channel_mode = preset->channel_mode;
874 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200875 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200876 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100877
Hector Martin3b315d72009-06-02 10:54:19 +0200878 if (preset->const_channel_count)
879 spec->multiout.max_channels = preset->const_channel_count;
880 else
881 spec->multiout.max_channels = spec->channel_mode[0].channels;
882 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100883
884 spec->multiout.num_dacs = preset->num_dacs;
885 spec->multiout.dac_nids = preset->dac_nids;
886 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800887 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100888 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200889
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200890 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200891 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200892 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100893 spec->input_mux = preset->input_mux;
894
895 spec->num_adc_nids = preset->num_adc_nids;
896 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100897 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100898 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100899
900 spec->unsol_event = preset->unsol_event;
901 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200902#ifdef CONFIG_SND_HDA_POWER_SAVE
903 spec->loopback.amplist = preset->loopbacks;
904#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200905
906 if (preset->setup)
907 preset->setup(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100908}
909
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200910/* Enable GPIO mask and set output */
911static struct hda_verb alc_gpio1_init_verbs[] = {
912 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
913 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
914 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
915 { }
916};
917
918static struct hda_verb alc_gpio2_init_verbs[] = {
919 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
920 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
921 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
922 { }
923};
924
Kailang Yangbdd148a2007-05-08 15:19:08 +0200925static struct hda_verb alc_gpio3_init_verbs[] = {
926 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
927 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
928 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
929 { }
930};
931
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200932/*
933 * Fix hardware PLL issue
934 * On some codecs, the analog PLL gating control must be off while
935 * the default value is 1.
936 */
937static void alc_fix_pll(struct hda_codec *codec)
938{
939 struct alc_spec *spec = codec->spec;
940 unsigned int val;
941
942 if (!spec->pll_nid)
943 return;
944 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
945 spec->pll_coef_idx);
946 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
947 AC_VERB_GET_PROC_COEF, 0);
948 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
949 spec->pll_coef_idx);
950 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
951 val & ~(1 << spec->pll_coef_bit));
952}
953
954static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
955 unsigned int coef_idx, unsigned int coef_bit)
956{
957 struct alc_spec *spec = codec->spec;
958 spec->pll_nid = nid;
959 spec->pll_coef_idx = coef_idx;
960 spec->pll_coef_bit = coef_bit;
961 alc_fix_pll(codec);
962}
963
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200964static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200965{
966 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200967 unsigned int nid = spec->autocfg.hp_pins[0];
968 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200969
Takashi Iwaiad87c642009-11-02 14:23:15 +0100970 if (!nid)
971 return;
Wu Fengguang864f92b2009-11-18 12:38:02 +0800972 spec->jack_present = snd_hda_jack_detect(codec, nid);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200973 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
974 nid = spec->autocfg.speaker_pins[i];
975 if (!nid)
976 break;
977 snd_hda_codec_write(codec, nid, 0,
978 AC_VERB_SET_PIN_WIDGET_CONTROL,
979 spec->jack_present ? 0 : PIN_OUT);
980 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200981}
982
Takashi Iwai6c819492009-08-10 18:47:44 +0200983static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
984 hda_nid_t nid)
985{
986 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
987 int i, nums;
988
989 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
990 for (i = 0; i < nums; i++)
991 if (conn[i] == nid)
992 return i;
993 return -1;
994}
995
Kailang Yang7fb0d782008-10-15 11:12:35 +0200996static void alc_mic_automute(struct hda_codec *codec)
997{
998 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +0200999 struct alc_mic_route *dead, *alive;
1000 unsigned int present, type;
1001 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001002
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001003 if (!spec->auto_mic)
1004 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001005 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1006 return;
1007 if (snd_BUG_ON(!spec->adc_nids))
1008 return;
1009
1010 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1011
Wu Fengguang864f92b2009-11-18 12:38:02 +08001012 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001013 if (present) {
1014 alive = &spec->ext_mic;
1015 dead = &spec->int_mic;
1016 } else {
1017 alive = &spec->int_mic;
1018 dead = &spec->ext_mic;
1019 }
1020
Takashi Iwai6c819492009-08-10 18:47:44 +02001021 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1022 if (type == AC_WID_AUD_MIX) {
1023 /* Matrix-mixer style (e.g. ALC882) */
1024 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1025 alive->mux_idx,
1026 HDA_AMP_MUTE, 0);
1027 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1028 dead->mux_idx,
1029 HDA_AMP_MUTE, HDA_AMP_MUTE);
1030 } else {
1031 /* MUX style (e.g. ALC880) */
1032 snd_hda_codec_write_cache(codec, cap_nid, 0,
1033 AC_VERB_SET_CONNECT_SEL,
1034 alive->mux_idx);
1035 }
1036
1037 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001038}
1039
Kailang Yangc9b58002007-10-16 14:30:01 +02001040/* unsolicited event for HP jack sensing */
1041static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1042{
1043 if (codec->vendor_id == 0x10ec0880)
1044 res >>= 28;
1045 else
1046 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001047 switch (res) {
1048 case ALC880_HP_EVENT:
1049 alc_automute_pin(codec);
1050 break;
1051 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001052 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001053 break;
1054 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001055}
1056
1057static void alc_inithook(struct hda_codec *codec)
1058{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001059 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001060 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001061}
1062
Kailang Yangf9423e72008-05-27 12:32:25 +02001063/* additional initialization for ALC888 variants */
1064static void alc888_coef_init(struct hda_codec *codec)
1065{
1066 unsigned int tmp;
1067
1068 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1069 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1070 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001071 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001072 /* alc888S-VC */
1073 snd_hda_codec_read(codec, 0x20, 0,
1074 AC_VERB_SET_PROC_COEF, 0x830);
1075 else
1076 /* alc888-VB */
1077 snd_hda_codec_read(codec, 0x20, 0,
1078 AC_VERB_SET_PROC_COEF, 0x3030);
1079}
1080
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001081static void alc889_coef_init(struct hda_codec *codec)
1082{
1083 unsigned int tmp;
1084
1085 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1086 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1087 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1088 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1089}
1090
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001091static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001092{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001093 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001094
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001095 switch (type) {
1096 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001097 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1098 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001099 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001100 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1101 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001102 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001103 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1104 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001105 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001106 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001107 case 0x10ec0260:
1108 snd_hda_codec_write(codec, 0x0f, 0,
1109 AC_VERB_SET_EAPD_BTLENABLE, 2);
1110 snd_hda_codec_write(codec, 0x10, 0,
1111 AC_VERB_SET_EAPD_BTLENABLE, 2);
1112 break;
1113 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001114 case 0x10ec0267:
1115 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001116 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001117 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001118 case 0x10ec0660:
1119 case 0x10ec0662:
1120 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001121 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001122 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001123 snd_hda_codec_write(codec, 0x14, 0,
1124 AC_VERB_SET_EAPD_BTLENABLE, 2);
1125 snd_hda_codec_write(codec, 0x15, 0,
1126 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001127 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001128 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001129 switch (codec->vendor_id) {
1130 case 0x10ec0260:
1131 snd_hda_codec_write(codec, 0x1a, 0,
1132 AC_VERB_SET_COEF_INDEX, 7);
1133 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1134 AC_VERB_GET_PROC_COEF, 0);
1135 snd_hda_codec_write(codec, 0x1a, 0,
1136 AC_VERB_SET_COEF_INDEX, 7);
1137 snd_hda_codec_write(codec, 0x1a, 0,
1138 AC_VERB_SET_PROC_COEF,
1139 tmp | 0x2010);
1140 break;
1141 case 0x10ec0262:
1142 case 0x10ec0880:
1143 case 0x10ec0882:
1144 case 0x10ec0883:
1145 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001146 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001147 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001148 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001149 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001150 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001151 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001152 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001153 case 0x10ec0267:
1154 case 0x10ec0268:
1155 snd_hda_codec_write(codec, 0x20, 0,
1156 AC_VERB_SET_COEF_INDEX, 7);
1157 tmp = snd_hda_codec_read(codec, 0x20, 0,
1158 AC_VERB_GET_PROC_COEF, 0);
1159 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001160 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001161 snd_hda_codec_write(codec, 0x20, 0,
1162 AC_VERB_SET_PROC_COEF,
1163 tmp | 0x3000);
1164 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001165 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001166 break;
1167 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001168}
Kailang Yangea1fb292008-08-26 12:58:38 +02001169
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001170static void alc_init_auto_hp(struct hda_codec *codec)
1171{
1172 struct alc_spec *spec = codec->spec;
1173
1174 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001175 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001176
Kailang Yangc9b58002007-10-16 14:30:01 +02001177 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001178 if (spec->autocfg.line_out_pins[0] &&
1179 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001180 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001181 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001182 else
1183 return;
1184 }
1185
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001186 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1187 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001188 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1189 AC_VERB_SET_UNSOLICITED_ENABLE,
1190 AC_USRSP_EN | ALC880_HP_EVENT);
1191 spec->unsol_event = alc_sku_unsol_event;
1192}
1193
Takashi Iwai6c819492009-08-10 18:47:44 +02001194static void alc_init_auto_mic(struct hda_codec *codec)
1195{
1196 struct alc_spec *spec = codec->spec;
1197 struct auto_pin_cfg *cfg = &spec->autocfg;
1198 hda_nid_t fixed, ext;
1199 int i;
1200
1201 /* there must be only two mic inputs exclusively */
1202 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1203 if (cfg->input_pins[i])
1204 return;
1205
1206 fixed = ext = 0;
1207 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1208 hda_nid_t nid = cfg->input_pins[i];
1209 unsigned int defcfg;
1210 if (!nid)
1211 return;
1212 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1213 switch (get_defcfg_connect(defcfg)) {
1214 case AC_JACK_PORT_FIXED:
1215 if (fixed)
1216 return; /* already occupied */
1217 fixed = nid;
1218 break;
1219 case AC_JACK_PORT_COMPLEX:
1220 if (ext)
1221 return; /* already occupied */
1222 ext = nid;
1223 break;
1224 default:
1225 return; /* invalid entry */
1226 }
1227 }
1228 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1229 return; /* no unsol support */
1230 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1231 ext, fixed);
1232 spec->ext_mic.pin = ext;
1233 spec->int_mic.pin = fixed;
1234 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1235 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1236 spec->auto_mic = 1;
1237 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1238 AC_VERB_SET_UNSOLICITED_ENABLE,
1239 AC_USRSP_EN | ALC880_MIC_EVENT);
1240 spec->unsol_event = alc_sku_unsol_event;
1241}
1242
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001243/* check subsystem ID and set up device-specific initialization;
1244 * return 1 if initialized, 0 if invalid SSID
1245 */
1246/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1247 * 31 ~ 16 : Manufacture ID
1248 * 15 ~ 8 : SKU ID
1249 * 7 ~ 0 : Assembly ID
1250 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1251 */
1252static int alc_subsystem_id(struct hda_codec *codec,
1253 hda_nid_t porta, hda_nid_t porte,
1254 hda_nid_t portd)
1255{
1256 unsigned int ass, tmp, i;
1257 unsigned nid;
1258 struct alc_spec *spec = codec->spec;
1259
1260 ass = codec->subsystem_id & 0xffff;
1261 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1262 goto do_sku;
1263
1264 /* invalid SSID, check the special NID pin defcfg instead */
1265 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001266 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001267 * 29~21 : reserve
1268 * 20 : PCBEEP input
1269 * 19~16 : Check sum (15:1)
1270 * 15~1 : Custom
1271 * 0 : override
1272 */
1273 nid = 0x1d;
1274 if (codec->vendor_id == 0x10ec0260)
1275 nid = 0x17;
1276 ass = snd_hda_codec_get_pincfg(codec, nid);
1277 snd_printd("realtek: No valid SSID, "
1278 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001279 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001280 if (!(ass & 1) && !(ass & 0x100000))
1281 return 0;
1282 if ((ass >> 30) != 1) /* no physical connection */
1283 return 0;
1284
1285 /* check sum */
1286 tmp = 0;
1287 for (i = 1; i < 16; i++) {
1288 if ((ass >> i) & 1)
1289 tmp++;
1290 }
1291 if (((ass >> 16) & 0xf) != tmp)
1292 return 0;
1293do_sku:
1294 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1295 ass & 0xffff, codec->vendor_id);
1296 /*
1297 * 0 : override
1298 * 1 : Swap Jack
1299 * 2 : 0 --> Desktop, 1 --> Laptop
1300 * 3~5 : External Amplifier control
1301 * 7~6 : Reserved
1302 */
1303 tmp = (ass & 0x38) >> 3; /* external Amp control */
1304 switch (tmp) {
1305 case 1:
1306 spec->init_amp = ALC_INIT_GPIO1;
1307 break;
1308 case 3:
1309 spec->init_amp = ALC_INIT_GPIO2;
1310 break;
1311 case 7:
1312 spec->init_amp = ALC_INIT_GPIO3;
1313 break;
1314 case 5:
1315 spec->init_amp = ALC_INIT_DEFAULT;
1316 break;
1317 }
1318
1319 /* is laptop or Desktop and enable the function "Mute internal speaker
1320 * when the external headphone out jack is plugged"
1321 */
1322 if (!(ass & 0x8000))
1323 return 1;
1324 /*
1325 * 10~8 : Jack location
1326 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1327 * 14~13: Resvered
1328 * 15 : 1 --> enable the function "Mute internal speaker
1329 * when the external headphone out jack is plugged"
1330 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001331 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001332 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001333 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1334 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001335 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001336 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001337 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001338 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001339 nid = portd;
Kailang Yangc9b58002007-10-16 14:30:01 +02001340 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001341 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001342 for (i = 0; i < spec->autocfg.line_outs; i++)
1343 if (spec->autocfg.line_out_pins[i] == nid)
1344 return 1;
1345 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001346 }
1347
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001348 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001349 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001350 return 1;
1351}
Kailang Yangea1fb292008-08-26 12:58:38 +02001352
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001353static void alc_ssid_check(struct hda_codec *codec,
1354 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1355{
1356 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1357 struct alc_spec *spec = codec->spec;
1358 snd_printd("realtek: "
1359 "Enable default setup for auto mode as fallback\n");
1360 spec->init_amp = ALC_INIT_DEFAULT;
1361 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001362 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001363 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001364}
1365
Takashi Iwai41e41f12005-06-08 14:48:49 +02001366/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001367 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001368 */
1369
1370struct alc_pincfg {
1371 hda_nid_t nid;
1372 u32 val;
1373};
1374
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001375struct alc_fixup {
1376 const struct alc_pincfg *pins;
1377 const struct hda_verb *verbs;
1378};
1379
1380static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001381 const struct snd_pci_quirk *quirk,
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001382 const struct alc_fixup *fix)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001383{
1384 const struct alc_pincfg *cfg;
1385
1386 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1387 if (!quirk)
1388 return;
1389
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001390 fix += quirk->value;
1391 cfg = fix->pins;
1392 if (cfg) {
1393 for (; cfg->nid; cfg++)
1394 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1395 }
1396 if (fix->verbs)
1397 add_verb(codec->spec, fix->verbs);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001398}
1399
Kailang Yang274693f2009-12-03 10:07:50 +01001400static int alc_read_coef_idx(struct hda_codec *codec,
1401 unsigned int coef_idx)
1402{
1403 unsigned int val;
1404 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1405 coef_idx);
1406 val = snd_hda_codec_read(codec, 0x20, 0,
1407 AC_VERB_GET_PROC_COEF, 0);
1408 return val;
1409}
1410
Takashi Iwaif95474e2007-07-10 00:47:43 +02001411/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001412 * ALC888
1413 */
1414
1415/*
1416 * 2ch mode
1417 */
1418static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1419/* Mic-in jack as mic in */
1420 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1421 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1422/* Line-in jack as Line in */
1423 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1424 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1425/* Line-Out as Front */
1426 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1427 { } /* end */
1428};
1429
1430/*
1431 * 4ch mode
1432 */
1433static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1434/* Mic-in jack as mic in */
1435 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1436 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1437/* Line-in jack as Surround */
1438 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1439 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1440/* Line-Out as Front */
1441 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1442 { } /* end */
1443};
1444
1445/*
1446 * 6ch mode
1447 */
1448static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1449/* Mic-in jack as CLFE */
1450 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1451 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1452/* Line-in jack as Surround */
1453 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1454 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1455/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1456 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1457 { } /* end */
1458};
1459
1460/*
1461 * 8ch mode
1462 */
1463static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1464/* Mic-in jack as CLFE */
1465 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1466 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1467/* Line-in jack as Surround */
1468 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1469 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1470/* Line-Out as Side */
1471 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1472 { } /* end */
1473};
1474
1475static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1476 { 2, alc888_4ST_ch2_intel_init },
1477 { 4, alc888_4ST_ch4_intel_init },
1478 { 6, alc888_4ST_ch6_intel_init },
1479 { 8, alc888_4ST_ch8_intel_init },
1480};
1481
1482/*
1483 * ALC888 Fujitsu Siemens Amillo xa3530
1484 */
1485
1486static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1487/* Front Mic: set to PIN_IN (empty by default) */
1488 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1489/* Connect Internal HP to Front */
1490 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1491 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1492 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1493/* Connect Bass HP to Front */
1494 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1495 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1496 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1497/* Connect Line-Out side jack (SPDIF) to Side */
1498 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1499 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1500 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1501/* Connect Mic jack to CLFE */
1502 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1503 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1504 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1505/* Connect Line-in jack to Surround */
1506 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1507 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1508 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1509/* Connect HP out jack to Front */
1510 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1511 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1512 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1513/* Enable unsolicited event for HP jack and Line-out jack */
1514 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1515 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1516 {}
1517};
1518
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001519static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001520{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001521 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001522 unsigned int mute;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001523 hda_nid_t nid;
1524 int i;
1525
1526 spec->jack_present = 0;
1527 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1528 nid = spec->autocfg.hp_pins[i];
1529 if (!nid)
1530 break;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001531 if (snd_hda_jack_detect(codec, nid)) {
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001532 spec->jack_present = 1;
1533 break;
1534 }
1535 }
1536
1537 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001538 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001539 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1540 nid = spec->autocfg.speaker_pins[i];
1541 if (!nid)
1542 break;
1543 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1544 HDA_AMP_MUTE, mute);
1545 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001546}
1547
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001548static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1549 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001550{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001551 if (codec->vendor_id == 0x10ec0880)
1552 res >>= 28;
1553 else
1554 res >>= 26;
1555 if (res == ALC880_HP_EVENT)
1556 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001557}
1558
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001559static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001560{
1561 struct alc_spec *spec = codec->spec;
1562
1563 spec->autocfg.hp_pins[0] = 0x15;
1564 spec->autocfg.speaker_pins[0] = 0x14;
1565 spec->autocfg.speaker_pins[1] = 0x16;
1566 spec->autocfg.speaker_pins[2] = 0x17;
1567 spec->autocfg.speaker_pins[3] = 0x19;
1568 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001569}
1570
1571static void alc889_intel_init_hook(struct hda_codec *codec)
1572{
1573 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001574 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001575}
1576
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001577static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001578{
1579 struct alc_spec *spec = codec->spec;
1580
1581 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1582 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1583 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1584 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001585}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001586
1587/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001588 * ALC888 Acer Aspire 4930G model
1589 */
1590
1591static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1592/* Front Mic: set to PIN_IN (empty by default) */
1593 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1594/* Unselect Front Mic by default in input mixer 3 */
1595 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001596/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001597 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1598/* Connect Internal HP to front */
1599 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1600 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1601 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1602/* Connect HP out to front */
1603 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1604 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1605 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1606 { }
1607};
1608
Hector Martin3b315d72009-06-02 10:54:19 +02001609/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001610 * ALC888 Acer Aspire 6530G model
1611 */
1612
1613static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1614/* Bias voltage on for external mic port */
1615 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001616/* Front Mic: set to PIN_IN (empty by default) */
1617 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1618/* Unselect Front Mic by default in input mixer 3 */
1619 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001620/* Enable unsolicited event for HP jack */
1621 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1622/* Enable speaker output */
1623 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1624 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1625/* Enable headphone output */
1626 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1627 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1628 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1629 { }
1630};
1631
1632/*
Hector Martin018df412009-06-04 00:13:40 +02001633 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001634 */
1635
Hector Martin018df412009-06-04 00:13:40 +02001636static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001637/* Front Mic: set to PIN_IN (empty by default) */
1638 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1639/* Unselect Front Mic by default in input mixer 3 */
1640 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1641/* Enable unsolicited event for HP jack */
1642 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1643/* Connect Internal Front to Front */
1644 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1645 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1646 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1647/* Connect Internal Rear to Rear */
1648 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1649 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1650 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1651/* Connect Internal CLFE to CLFE */
1652 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1653 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1654 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1655/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001656 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001657 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1658 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1659/* Enable all DACs */
1660/* DAC DISABLE/MUTE 1? */
1661/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1662 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1663 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1664/* DAC DISABLE/MUTE 2? */
1665/* some bit here disables the other DACs. Init=0x4900 */
1666 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1667 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02001668/* DMIC fix
1669 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1670 * which makes the stereo useless. However, either the mic or the ALC889
1671 * makes the signal become a difference/sum signal instead of standard
1672 * stereo, which is annoying. So instead we flip this bit which makes the
1673 * codec replicate the sum signal to both channels, turning it into a
1674 * normal mono mic.
1675 */
1676/* DMIC_CONTROL? Init value = 0x0001 */
1677 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1678 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001679 { }
1680};
1681
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001682static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001683 /* Front mic only available on one ADC */
1684 {
1685 .num_items = 4,
1686 .items = {
1687 { "Mic", 0x0 },
1688 { "Line", 0x2 },
1689 { "CD", 0x4 },
1690 { "Front Mic", 0xb },
1691 },
1692 },
1693 {
1694 .num_items = 3,
1695 .items = {
1696 { "Mic", 0x0 },
1697 { "Line", 0x2 },
1698 { "CD", 0x4 },
1699 },
1700 }
1701};
1702
Tony Vroond2fd4b02009-06-21 00:40:10 +01001703static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1704 /* Interal mic only available on one ADC */
1705 {
Tony Vroon684a8842009-06-26 09:27:50 +01001706 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001707 .items = {
1708 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001709 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001710 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001711 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001712 { "Int Mic", 0xb },
1713 },
1714 },
1715 {
Tony Vroon684a8842009-06-26 09:27:50 +01001716 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001717 .items = {
1718 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001719 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001720 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001721 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001722 },
1723 }
1724};
1725
Hector Martin018df412009-06-04 00:13:40 +02001726static struct hda_input_mux alc889_capture_sources[3] = {
1727 /* Digital mic only available on first "ADC" */
1728 {
1729 .num_items = 5,
1730 .items = {
1731 { "Mic", 0x0 },
1732 { "Line", 0x2 },
1733 { "CD", 0x4 },
1734 { "Front Mic", 0xb },
1735 { "Input Mix", 0xa },
1736 },
1737 },
1738 {
1739 .num_items = 4,
1740 .items = {
1741 { "Mic", 0x0 },
1742 { "Line", 0x2 },
1743 { "CD", 0x4 },
1744 { "Input Mix", 0xa },
1745 },
1746 },
1747 {
1748 .num_items = 4,
1749 .items = {
1750 { "Mic", 0x0 },
1751 { "Line", 0x2 },
1752 { "CD", 0x4 },
1753 { "Input Mix", 0xa },
1754 },
1755 }
1756};
1757
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001758static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001759 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1760 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1761 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1762 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1763 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1764 HDA_OUTPUT),
1765 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1766 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1767 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1768 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1769 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1770 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1771 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1772 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1773 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1774 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1775 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1776 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001777 { } /* end */
1778};
1779
Hector Martin556eea92009-12-20 22:51:23 +01001780static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
1781 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1782 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1783 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1784 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1785 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1786 HDA_OUTPUT),
1787 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1788 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1789 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1790 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1791 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1792 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1793 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1794 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1795 { } /* end */
1796};
1797
1798
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001799static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001800{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001801 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001802
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001803 spec->autocfg.hp_pins[0] = 0x15;
1804 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01001805 spec->autocfg.speaker_pins[1] = 0x16;
1806 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001807}
1808
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001809static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001810{
1811 struct alc_spec *spec = codec->spec;
1812
1813 spec->autocfg.hp_pins[0] = 0x15;
1814 spec->autocfg.speaker_pins[0] = 0x14;
1815 spec->autocfg.speaker_pins[1] = 0x16;
1816 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001817}
1818
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001819static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001820{
1821 struct alc_spec *spec = codec->spec;
1822
1823 spec->autocfg.hp_pins[0] = 0x15;
1824 spec->autocfg.speaker_pins[0] = 0x14;
1825 spec->autocfg.speaker_pins[1] = 0x16;
1826 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001827}
1828
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001829/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001830 * ALC880 3-stack model
1831 *
1832 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001833 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1834 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001835 */
1836
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001837static hda_nid_t alc880_dac_nids[4] = {
1838 /* front, rear, clfe, rear_surr */
1839 0x02, 0x05, 0x04, 0x03
1840};
1841
1842static hda_nid_t alc880_adc_nids[3] = {
1843 /* ADC0-2 */
1844 0x07, 0x08, 0x09,
1845};
1846
1847/* The datasheet says the node 0x07 is connected from inputs,
1848 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001849 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001850 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001851static hda_nid_t alc880_adc_nids_alt[2] = {
1852 /* ADC1-2 */
1853 0x08, 0x09,
1854};
1855
1856#define ALC880_DIGOUT_NID 0x06
1857#define ALC880_DIGIN_NID 0x0a
1858
1859static struct hda_input_mux alc880_capture_source = {
1860 .num_items = 4,
1861 .items = {
1862 { "Mic", 0x0 },
1863 { "Front Mic", 0x3 },
1864 { "Line", 0x2 },
1865 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001866 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001867};
1868
1869/* channel source setting (2/6 channel selection for 3-stack) */
1870/* 2ch mode */
1871static struct hda_verb alc880_threestack_ch2_init[] = {
1872 /* set line-in to input, mute it */
1873 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1874 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1875 /* set mic-in to input vref 80%, mute it */
1876 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1877 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001878 { } /* end */
1879};
1880
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001881/* 6ch mode */
1882static struct hda_verb alc880_threestack_ch6_init[] = {
1883 /* set line-in to output, unmute it */
1884 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1885 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1886 /* set mic-in to output, unmute it */
1887 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1888 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1889 { } /* end */
1890};
1891
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001892static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001893 { 2, alc880_threestack_ch2_init },
1894 { 6, alc880_threestack_ch6_init },
1895};
1896
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001897static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001898 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001899 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001900 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001901 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001902 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1903 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001904 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1905 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001906 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1907 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1908 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1909 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1910 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1911 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1912 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1913 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001914 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001915 {
1916 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1917 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001918 .info = alc_ch_mode_info,
1919 .get = alc_ch_mode_get,
1920 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001921 },
1922 { } /* end */
1923};
1924
1925/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001926static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1927 struct snd_ctl_elem_info *uinfo)
1928{
1929 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1930 struct alc_spec *spec = codec->spec;
1931 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001932
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001933 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001934 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1935 HDA_INPUT);
1936 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001937 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001938 return err;
1939}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001940
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001941static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1942 unsigned int size, unsigned int __user *tlv)
1943{
1944 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1945 struct alc_spec *spec = codec->spec;
1946 int err;
1947
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001948 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001949 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1950 HDA_INPUT);
1951 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001952 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001953 return err;
1954}
1955
1956typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1957 struct snd_ctl_elem_value *ucontrol);
1958
1959static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1960 struct snd_ctl_elem_value *ucontrol,
1961 getput_call_t func)
1962{
1963 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1964 struct alc_spec *spec = codec->spec;
1965 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1966 int err;
1967
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001968 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001969 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1970 3, 0, HDA_INPUT);
1971 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001972 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001973 return err;
1974}
1975
1976static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1977 struct snd_ctl_elem_value *ucontrol)
1978{
1979 return alc_cap_getput_caller(kcontrol, ucontrol,
1980 snd_hda_mixer_amp_volume_get);
1981}
1982
1983static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1984 struct snd_ctl_elem_value *ucontrol)
1985{
1986 return alc_cap_getput_caller(kcontrol, ucontrol,
1987 snd_hda_mixer_amp_volume_put);
1988}
1989
1990/* capture mixer elements */
1991#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1992
1993static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1994 struct snd_ctl_elem_value *ucontrol)
1995{
1996 return alc_cap_getput_caller(kcontrol, ucontrol,
1997 snd_hda_mixer_amp_switch_get);
1998}
1999
2000static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2001 struct snd_ctl_elem_value *ucontrol)
2002{
2003 return alc_cap_getput_caller(kcontrol, ucontrol,
2004 snd_hda_mixer_amp_switch_put);
2005}
2006
Takashi Iwaia23b6882009-03-23 15:21:36 +01002007#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002008 { \
2009 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2010 .name = "Capture Switch", \
2011 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2012 .count = num, \
2013 .info = alc_cap_sw_info, \
2014 .get = alc_cap_sw_get, \
2015 .put = alc_cap_sw_put, \
2016 }, \
2017 { \
2018 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2019 .name = "Capture Volume", \
2020 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2021 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2022 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2023 .count = num, \
2024 .info = alc_cap_vol_info, \
2025 .get = alc_cap_vol_get, \
2026 .put = alc_cap_vol_put, \
2027 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002028 }
2029
2030#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002031 { \
2032 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2033 /* .name = "Capture Source", */ \
2034 .name = "Input Source", \
2035 .count = num, \
2036 .info = alc_mux_enum_info, \
2037 .get = alc_mux_enum_get, \
2038 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002039 }
2040
2041#define DEFINE_CAPMIX(num) \
2042static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2043 _DEFINE_CAPMIX(num), \
2044 _DEFINE_CAPSRC(num), \
2045 { } /* end */ \
2046}
2047
2048#define DEFINE_CAPMIX_NOSRC(num) \
2049static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2050 _DEFINE_CAPMIX(num), \
2051 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002052}
2053
2054/* up to three ADCs */
2055DEFINE_CAPMIX(1);
2056DEFINE_CAPMIX(2);
2057DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002058DEFINE_CAPMIX_NOSRC(1);
2059DEFINE_CAPMIX_NOSRC(2);
2060DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002061
2062/*
2063 * ALC880 5-stack model
2064 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002065 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2066 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002067 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2068 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2069 */
2070
2071/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002072static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002073 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002074 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002075 { } /* end */
2076};
2077
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002078/* channel source setting (6/8 channel selection for 5-stack) */
2079/* 6ch mode */
2080static struct hda_verb alc880_fivestack_ch6_init[] = {
2081 /* set line-in to input, mute it */
2082 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2083 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002084 { } /* end */
2085};
2086
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002087/* 8ch mode */
2088static struct hda_verb alc880_fivestack_ch8_init[] = {
2089 /* set line-in to output, unmute it */
2090 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2091 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2092 { } /* end */
2093};
2094
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002095static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002096 { 6, alc880_fivestack_ch6_init },
2097 { 8, alc880_fivestack_ch8_init },
2098};
2099
2100
2101/*
2102 * ALC880 6-stack model
2103 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002104 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2105 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002106 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2107 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2108 */
2109
2110static hda_nid_t alc880_6st_dac_nids[4] = {
2111 /* front, rear, clfe, rear_surr */
2112 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002113};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002114
2115static struct hda_input_mux alc880_6stack_capture_source = {
2116 .num_items = 4,
2117 .items = {
2118 { "Mic", 0x0 },
2119 { "Front Mic", 0x1 },
2120 { "Line", 0x2 },
2121 { "CD", 0x4 },
2122 },
2123};
2124
2125/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002126static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002127 { 8, NULL },
2128};
2129
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002130static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002131 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002132 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002133 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002134 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002135 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2136 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002137 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2138 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002139 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002140 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002141 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2142 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2143 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2144 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2145 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2146 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2147 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2148 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002149 {
2150 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2151 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002152 .info = alc_ch_mode_info,
2153 .get = alc_ch_mode_get,
2154 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002155 },
2156 { } /* end */
2157};
2158
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002159
2160/*
2161 * ALC880 W810 model
2162 *
2163 * W810 has rear IO for:
2164 * Front (DAC 02)
2165 * Surround (DAC 03)
2166 * Center/LFE (DAC 04)
2167 * Digital out (06)
2168 *
2169 * The system also has a pair of internal speakers, and a headphone jack.
2170 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002171 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002172 * There is a variable resistor to control the speaker or headphone
2173 * volume. This is a hardware-only device without a software API.
2174 *
2175 * Plugging headphones in will disable the internal speakers. This is
2176 * implemented in hardware, not via the driver using jack sense. In
2177 * a similar fashion, plugging into the rear socket marked "front" will
2178 * disable both the speakers and headphones.
2179 *
2180 * For input, there's a microphone jack, and an "audio in" jack.
2181 * These may not do anything useful with this driver yet, because I
2182 * haven't setup any initialization verbs for these yet...
2183 */
2184
2185static hda_nid_t alc880_w810_dac_nids[3] = {
2186 /* front, rear/surround, clfe */
2187 0x02, 0x03, 0x04
2188};
2189
2190/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002191static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002192 { 6, NULL }
2193};
2194
2195/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002196static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002197 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002198 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002199 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002200 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002201 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2202 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002203 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2204 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002205 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2206 { } /* end */
2207};
2208
2209
2210/*
2211 * Z710V model
2212 *
2213 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002214 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2215 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002216 */
2217
2218static hda_nid_t alc880_z71v_dac_nids[1] = {
2219 0x02
2220};
2221#define ALC880_Z71V_HP_DAC 0x03
2222
2223/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002224static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002225 { 2, NULL }
2226};
2227
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002228static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002229 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002230 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002231 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002232 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002233 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2234 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2235 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2236 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2237 { } /* end */
2238};
2239
2240
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002241/*
2242 * ALC880 F1734 model
2243 *
2244 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2245 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2246 */
2247
2248static hda_nid_t alc880_f1734_dac_nids[1] = {
2249 0x03
2250};
2251#define ALC880_F1734_HP_DAC 0x02
2252
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002253static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002254 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002255 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002256 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2257 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002258 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2259 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002260 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2261 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002262 { } /* end */
2263};
2264
Takashi Iwai937b4162008-02-11 14:52:36 +01002265static struct hda_input_mux alc880_f1734_capture_source = {
2266 .num_items = 2,
2267 .items = {
2268 { "Mic", 0x1 },
2269 { "CD", 0x4 },
2270 },
2271};
2272
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002273
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002274/*
2275 * ALC880 ASUS model
2276 *
2277 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2278 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2279 * Mic = 0x18, Line = 0x1a
2280 */
2281
2282#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2283#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2284
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002285static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002286 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002287 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002288 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002289 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002290 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2291 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002292 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2293 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002294 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2295 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2296 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2297 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2298 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2299 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002300 {
2301 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2302 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002303 .info = alc_ch_mode_info,
2304 .get = alc_ch_mode_get,
2305 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002306 },
2307 { } /* end */
2308};
2309
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002310/*
2311 * ALC880 ASUS W1V model
2312 *
2313 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2314 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2315 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2316 */
2317
2318/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002319static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002320 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2321 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002322 { } /* end */
2323};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002324
Kailang Yangdf694da2005-12-05 19:42:22 +01002325/* TCL S700 */
2326static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2327 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2328 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2329 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2330 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2331 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2332 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2333 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2334 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2335 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002336 { } /* end */
2337};
2338
Kailang Yangccc656c2006-10-17 12:32:26 +02002339/* Uniwill */
2340static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002341 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2342 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2343 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2344 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002345 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2346 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2347 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2348 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2349 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2350 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2351 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2352 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2353 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2354 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2355 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2356 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002357 {
2358 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2359 .name = "Channel Mode",
2360 .info = alc_ch_mode_info,
2361 .get = alc_ch_mode_get,
2362 .put = alc_ch_mode_put,
2363 },
2364 { } /* end */
2365};
2366
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002367static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2368 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2369 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2370 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2371 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2372 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2373 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2374 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2375 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2376 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2377 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2378 { } /* end */
2379};
2380
Kailang Yangccc656c2006-10-17 12:32:26 +02002381static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002382 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2383 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2384 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2385 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002386 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2387 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2388 { } /* end */
2389};
2390
Linus Torvalds1da177e2005-04-16 15:20:36 -07002391/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002392 * virtual master controls
2393 */
2394
2395/*
2396 * slave controls for virtual master
2397 */
2398static const char *alc_slave_vols[] = {
2399 "Front Playback Volume",
2400 "Surround Playback Volume",
2401 "Center Playback Volume",
2402 "LFE Playback Volume",
2403 "Side Playback Volume",
2404 "Headphone Playback Volume",
2405 "Speaker Playback Volume",
2406 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002407 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002408 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002409 NULL,
2410};
2411
2412static const char *alc_slave_sws[] = {
2413 "Front Playback Switch",
2414 "Surround Playback Switch",
2415 "Center Playback Switch",
2416 "LFE Playback Switch",
2417 "Side Playback Switch",
2418 "Headphone Playback Switch",
2419 "Speaker Playback Switch",
2420 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002421 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002422 "Line-Out Playback Switch",
2423 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002424 NULL,
2425};
2426
2427/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002428 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002429 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002430
2431static void alc_free_kctls(struct hda_codec *codec);
2432
Takashi Iwai67d634c2009-11-16 15:35:59 +01002433#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002434/* additional beep mixers; the actual parameters are overwritten at build */
2435static struct snd_kcontrol_new alc_beep_mixer[] = {
2436 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002437 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002438 { } /* end */
2439};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002440#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002441
Linus Torvalds1da177e2005-04-16 15:20:36 -07002442static int alc_build_controls(struct hda_codec *codec)
2443{
2444 struct alc_spec *spec = codec->spec;
2445 int err;
2446 int i;
2447
2448 for (i = 0; i < spec->num_mixers; i++) {
2449 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2450 if (err < 0)
2451 return err;
2452 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002453 if (spec->cap_mixer) {
2454 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2455 if (err < 0)
2456 return err;
2457 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002458 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002459 err = snd_hda_create_spdif_out_ctls(codec,
2460 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002461 if (err < 0)
2462 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002463 if (!spec->no_analog) {
2464 err = snd_hda_create_spdif_share_sw(codec,
2465 &spec->multiout);
2466 if (err < 0)
2467 return err;
2468 spec->multiout.share_spdif = 1;
2469 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002470 }
2471 if (spec->dig_in_nid) {
2472 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2473 if (err < 0)
2474 return err;
2475 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002476
Takashi Iwai67d634c2009-11-16 15:35:59 +01002477#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002478 /* create beep controls if needed */
2479 if (spec->beep_amp) {
2480 struct snd_kcontrol_new *knew;
2481 for (knew = alc_beep_mixer; knew->name; knew++) {
2482 struct snd_kcontrol *kctl;
2483 kctl = snd_ctl_new1(knew, codec);
2484 if (!kctl)
2485 return -ENOMEM;
2486 kctl->private_value = spec->beep_amp;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01002487 err = snd_hda_ctl_add(codec,
2488 get_amp_nid_(spec->beep_amp), kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002489 if (err < 0)
2490 return err;
2491 }
2492 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002493#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002494
Takashi Iwai2134ea42008-01-10 16:53:55 +01002495 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002496 if (!spec->no_analog &&
2497 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002498 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002499 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002500 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002501 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002502 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002503 if (err < 0)
2504 return err;
2505 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002506 if (!spec->no_analog &&
2507 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002508 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2509 NULL, alc_slave_sws);
2510 if (err < 0)
2511 return err;
2512 }
2513
Takashi Iwai603c4012008-07-30 15:01:44 +02002514 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002515 return 0;
2516}
2517
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002518
Linus Torvalds1da177e2005-04-16 15:20:36 -07002519/*
2520 * initialize the codec volumes, etc
2521 */
2522
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002523/*
2524 * generic initialization of ADC, input mixers and output mixers
2525 */
2526static struct hda_verb alc880_volume_init_verbs[] = {
2527 /*
2528 * Unmute ADC0-2 and set the default input to mic-in
2529 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002530 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002531 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002532 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002533 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002534 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002535 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002536
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002537 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2538 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002539 * Note: PASD motherboards uses the Line In 2 as the input for front
2540 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002541 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002542 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002543 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2544 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2545 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2546 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2547 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2548 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2549 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002550
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002551 /*
2552 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002553 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002554 /* set vol=0 to output mixers */
2555 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2556 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2557 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2558 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2559 /* set up input amps for analog loopback */
2560 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002561 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2562 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002563 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2564 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002565 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2566 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002567 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2568 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002569
2570 { }
2571};
2572
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002573/*
2574 * 3-stack pin configuration:
2575 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2576 */
2577static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2578 /*
2579 * preset connection lists of input pins
2580 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2581 */
2582 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2583 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2584 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2585
2586 /*
2587 * Set pin mode and muting
2588 */
2589 /* set front pin widgets 0x14 for output */
2590 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2591 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2592 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2593 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2594 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2595 /* Mic2 (as headphone out) for HP output */
2596 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2597 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2598 /* Line In pin widget for input */
2599 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2600 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2601 /* Line2 (as front mic) pin widget for input and vref at 80% */
2602 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2603 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2604 /* CD pin widget for input */
2605 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2606
2607 { }
2608};
2609
2610/*
2611 * 5-stack pin configuration:
2612 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2613 * line-in/side = 0x1a, f-mic = 0x1b
2614 */
2615static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2616 /*
2617 * preset connection lists of input pins
2618 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2619 */
2620 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2621 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2622
2623 /*
2624 * Set pin mode and muting
2625 */
2626 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002627 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2628 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2629 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2630 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002631 /* unmute pins for output (no gain on this amp) */
2632 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2633 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2634 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2635 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2636
Linus Torvalds1da177e2005-04-16 15:20:36 -07002637 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002638 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002639 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2640 /* Mic2 (as headphone out) for HP output */
2641 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002642 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002643 /* Line In pin widget for input */
2644 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2645 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2646 /* Line2 (as front mic) pin widget for input and vref at 80% */
2647 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2648 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2649 /* CD pin widget for input */
2650 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002651
2652 { }
2653};
2654
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002655/*
2656 * W810 pin configuration:
2657 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2658 */
2659static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002660 /* hphone/speaker input selector: front DAC */
2661 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2662
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002663 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2664 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2665 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2666 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2667 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2668 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2669
2670 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002671 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002672
Linus Torvalds1da177e2005-04-16 15:20:36 -07002673 { }
2674};
2675
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002676/*
2677 * Z71V pin configuration:
2678 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2679 */
2680static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002681 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002682 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002683 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002684 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002685
Takashi Iwai16ded522005-06-10 19:58:24 +02002686 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002687 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002688 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002689 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002690
2691 { }
2692};
2693
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002694/*
2695 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002696 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2697 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002698 */
2699static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2700 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2701
Takashi Iwai16ded522005-06-10 19:58:24 +02002702 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002703 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002704 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002705 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002706 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002707 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002708 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002709 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2710
Takashi Iwai16ded522005-06-10 19:58:24 +02002711 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002712 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002713 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002714 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002715 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002716 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002717 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002718 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002719 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002720
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002721 { }
2722};
Takashi Iwai16ded522005-06-10 19:58:24 +02002723
Kailang Yangccc656c2006-10-17 12:32:26 +02002724/*
2725 * Uniwill pin configuration:
2726 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2727 * line = 0x1a
2728 */
2729static struct hda_verb alc880_uniwill_init_verbs[] = {
2730 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2731
2732 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2733 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2734 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2735 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2736 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2737 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2738 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2739 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2740 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2741 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2742 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2743 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2744 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2745 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2746
2747 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2748 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2749 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2750 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2751 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2752 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2753 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2754 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2755 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2756
2757 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2758 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2759
2760 { }
2761};
2762
2763/*
2764* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002765* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002766 */
2767static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2768 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2769
2770 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2771 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2772 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2773 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2774 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2775 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2776 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2777 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2778 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2779 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2780 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2781 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2782
2783 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2784 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2785 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2786 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2787 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2788 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2789
2790 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2791 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2792
2793 { }
2794};
2795
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002796static struct hda_verb alc880_beep_init_verbs[] = {
2797 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2798 { }
2799};
2800
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002801/* auto-toggle front mic */
2802static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2803{
2804 unsigned int present;
2805 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002806
Wu Fengguang864f92b2009-11-18 12:38:02 +08002807 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002808 bits = present ? HDA_AMP_MUTE : 0;
2809 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002810}
2811
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002812static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002813{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002814 struct alc_spec *spec = codec->spec;
2815
2816 spec->autocfg.hp_pins[0] = 0x14;
2817 spec->autocfg.speaker_pins[0] = 0x15;
2818 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002819}
2820
2821static void alc880_uniwill_init_hook(struct hda_codec *codec)
2822{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002823 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002824 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002825}
2826
2827static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2828 unsigned int res)
2829{
2830 /* Looks like the unsol event is incompatible with the standard
2831 * definition. 4bit tag is placed at 28 bit!
2832 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002833 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002834 case ALC880_MIC_EVENT:
2835 alc880_uniwill_mic_automute(codec);
2836 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002837 default:
2838 alc_automute_amp_unsol_event(codec, res);
2839 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002840 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002841}
2842
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002843static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002844{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002845 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002846
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002847 spec->autocfg.hp_pins[0] = 0x14;
2848 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02002849}
2850
2851static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2852{
2853 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002854
Kailang Yangccc656c2006-10-17 12:32:26 +02002855 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002856 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2857 present &= HDA_AMP_VOLMASK;
2858 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2859 HDA_AMP_VOLMASK, present);
2860 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2861 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002862}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002863
Kailang Yangccc656c2006-10-17 12:32:26 +02002864static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2865 unsigned int res)
2866{
2867 /* Looks like the unsol event is incompatible with the standard
2868 * definition. 4bit tag is placed at 28 bit!
2869 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002870 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002871 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002872 else
2873 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002874}
2875
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002876/*
2877 * F1734 pin configuration:
2878 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2879 */
2880static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002881 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002882 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2883 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2884 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2885 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2886
2887 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2888 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2889 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2890 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2891
2892 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2893 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002894 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002895 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2896 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2897 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2898 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2899 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2900 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002901
Takashi Iwai937b4162008-02-11 14:52:36 +01002902 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2903 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2904
Takashi Iwai16ded522005-06-10 19:58:24 +02002905 { }
2906};
2907
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002908/*
2909 * ASUS pin configuration:
2910 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2911 */
2912static struct hda_verb alc880_pin_asus_init_verbs[] = {
2913 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2914 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2915 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2916 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2917
2918 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2919 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2920 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2921 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2922 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2923 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2924 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2925 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2926
2927 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2928 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2929 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2930 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2931 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2932 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2933 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2934 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2935 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002936
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002937 { }
2938};
2939
2940/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002941#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2942#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02002943#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002944
Kailang Yangdf694da2005-12-05 19:42:22 +01002945/* Clevo m520g init */
2946static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2947 /* headphone output */
2948 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2949 /* line-out */
2950 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2951 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2952 /* Line-in */
2953 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2954 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2955 /* CD */
2956 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2957 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2958 /* Mic1 (rear panel) */
2959 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2960 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2961 /* Mic2 (front panel) */
2962 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2963 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2964 /* headphone */
2965 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2966 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2967 /* change to EAPD mode */
2968 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2969 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2970
2971 { }
2972};
2973
2974static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002975 /* change to EAPD mode */
2976 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2977 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2978
Kailang Yangdf694da2005-12-05 19:42:22 +01002979 /* Headphone output */
2980 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2981 /* Front output*/
2982 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2983 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2984
2985 /* Line In pin widget for input */
2986 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2987 /* CD pin widget for input */
2988 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2989 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2990 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2991
2992 /* change to EAPD mode */
2993 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2994 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2995
2996 { }
2997};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002998
2999/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003000 * LG m1 express dual
3001 *
3002 * Pin assignment:
3003 * Rear Line-In/Out (blue): 0x14
3004 * Build-in Mic-In: 0x15
3005 * Speaker-out: 0x17
3006 * HP-Out (green): 0x1b
3007 * Mic-In/Out (red): 0x19
3008 * SPDIF-Out: 0x1e
3009 */
3010
3011/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3012static hda_nid_t alc880_lg_dac_nids[3] = {
3013 0x05, 0x02, 0x03
3014};
3015
3016/* seems analog CD is not working */
3017static struct hda_input_mux alc880_lg_capture_source = {
3018 .num_items = 3,
3019 .items = {
3020 { "Mic", 0x1 },
3021 { "Line", 0x5 },
3022 { "Internal Mic", 0x6 },
3023 },
3024};
3025
3026/* 2,4,6 channel modes */
3027static struct hda_verb alc880_lg_ch2_init[] = {
3028 /* set line-in and mic-in to input */
3029 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3030 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3031 { }
3032};
3033
3034static struct hda_verb alc880_lg_ch4_init[] = {
3035 /* set line-in to out and mic-in to input */
3036 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3037 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3038 { }
3039};
3040
3041static struct hda_verb alc880_lg_ch6_init[] = {
3042 /* set line-in and mic-in to output */
3043 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3044 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3045 { }
3046};
3047
3048static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3049 { 2, alc880_lg_ch2_init },
3050 { 4, alc880_lg_ch4_init },
3051 { 6, alc880_lg_ch6_init },
3052};
3053
3054static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003055 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3056 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003057 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3058 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3059 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3060 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3061 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3062 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3063 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3064 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3065 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3066 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3067 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3068 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3069 {
3070 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3071 .name = "Channel Mode",
3072 .info = alc_ch_mode_info,
3073 .get = alc_ch_mode_get,
3074 .put = alc_ch_mode_put,
3075 },
3076 { } /* end */
3077};
3078
3079static struct hda_verb alc880_lg_init_verbs[] = {
3080 /* set capture source to mic-in */
3081 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3082 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3083 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3084 /* mute all amp mixer inputs */
3085 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003086 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3087 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003088 /* line-in to input */
3089 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3090 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3091 /* built-in mic */
3092 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3093 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3094 /* speaker-out */
3095 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3096 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3097 /* mic-in to input */
3098 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3099 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3100 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3101 /* HP-out */
3102 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3103 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3104 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3105 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003106 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003107 { }
3108};
3109
3110/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003111static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003112{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003113 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003114
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003115 spec->autocfg.hp_pins[0] = 0x1b;
3116 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003117}
3118
3119/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003120 * LG LW20
3121 *
3122 * Pin assignment:
3123 * Speaker-out: 0x14
3124 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003125 * Built-in Mic-In: 0x19
3126 * Line-In: 0x1b
3127 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003128 * SPDIF-Out: 0x1e
3129 */
3130
Takashi Iwaid6815182006-03-23 16:06:23 +01003131static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003132 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003133 .items = {
3134 { "Mic", 0x0 },
3135 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003136 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003137 },
3138};
3139
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003140#define alc880_lg_lw_modes alc880_threestack_modes
3141
Takashi Iwaid6815182006-03-23 16:06:23 +01003142static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003143 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3144 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3145 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3146 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3147 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3148 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3149 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3150 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3151 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3152 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003153 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3154 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3155 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3156 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003157 {
3158 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3159 .name = "Channel Mode",
3160 .info = alc_ch_mode_info,
3161 .get = alc_ch_mode_get,
3162 .put = alc_ch_mode_put,
3163 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003164 { } /* end */
3165};
3166
3167static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003168 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3169 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3170 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3171
Takashi Iwaid6815182006-03-23 16:06:23 +01003172 /* set capture source to mic-in */
3173 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3174 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3175 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003176 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003177 /* speaker-out */
3178 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3179 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3180 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003181 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3182 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3183 /* mic-in to input */
3184 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3185 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3186 /* built-in mic */
3187 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3188 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3189 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003190 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003191 { }
3192};
3193
3194/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003195static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003196{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003197 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003198
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003199 spec->autocfg.hp_pins[0] = 0x1b;
3200 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003201}
3202
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003203static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3204 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3205 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3206 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3207 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3208 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3209 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3210 { } /* end */
3211};
3212
3213static struct hda_input_mux alc880_medion_rim_capture_source = {
3214 .num_items = 2,
3215 .items = {
3216 { "Mic", 0x0 },
3217 { "Internal Mic", 0x1 },
3218 },
3219};
3220
3221static struct hda_verb alc880_medion_rim_init_verbs[] = {
3222 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3223
3224 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3225 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3226
3227 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3228 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3229 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3230 /* Mic2 (as headphone out) for HP output */
3231 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3232 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3233 /* Internal Speaker */
3234 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3235 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3236
3237 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3238 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3239
3240 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3241 { }
3242};
3243
3244/* toggle speaker-output according to the hp-jack state */
3245static void alc880_medion_rim_automute(struct hda_codec *codec)
3246{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003247 struct alc_spec *spec = codec->spec;
3248 alc_automute_amp(codec);
3249 /* toggle EAPD */
3250 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003251 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3252 else
3253 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3254}
3255
3256static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3257 unsigned int res)
3258{
3259 /* Looks like the unsol event is incompatible with the standard
3260 * definition. 4bit tag is placed at 28 bit!
3261 */
3262 if ((res >> 28) == ALC880_HP_EVENT)
3263 alc880_medion_rim_automute(codec);
3264}
3265
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003266static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003267{
3268 struct alc_spec *spec = codec->spec;
3269
3270 spec->autocfg.hp_pins[0] = 0x14;
3271 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003272}
3273
Takashi Iwaicb53c622007-08-10 17:21:45 +02003274#ifdef CONFIG_SND_HDA_POWER_SAVE
3275static struct hda_amp_list alc880_loopbacks[] = {
3276 { 0x0b, HDA_INPUT, 0 },
3277 { 0x0b, HDA_INPUT, 1 },
3278 { 0x0b, HDA_INPUT, 2 },
3279 { 0x0b, HDA_INPUT, 3 },
3280 { 0x0b, HDA_INPUT, 4 },
3281 { } /* end */
3282};
3283
3284static struct hda_amp_list alc880_lg_loopbacks[] = {
3285 { 0x0b, HDA_INPUT, 1 },
3286 { 0x0b, HDA_INPUT, 6 },
3287 { 0x0b, HDA_INPUT, 7 },
3288 { } /* end */
3289};
3290#endif
3291
Takashi Iwaid6815182006-03-23 16:06:23 +01003292/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003293 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003294 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003295
Linus Torvalds1da177e2005-04-16 15:20:36 -07003296static int alc_init(struct hda_codec *codec)
3297{
3298 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003299 unsigned int i;
3300
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003301 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003302 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003303
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003304 for (i = 0; i < spec->num_init_verbs; i++)
3305 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003306
3307 if (spec->init_hook)
3308 spec->init_hook(codec);
3309
Linus Torvalds1da177e2005-04-16 15:20:36 -07003310 return 0;
3311}
3312
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003313static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3314{
3315 struct alc_spec *spec = codec->spec;
3316
3317 if (spec->unsol_event)
3318 spec->unsol_event(codec, res);
3319}
3320
Takashi Iwaicb53c622007-08-10 17:21:45 +02003321#ifdef CONFIG_SND_HDA_POWER_SAVE
3322static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3323{
3324 struct alc_spec *spec = codec->spec;
3325 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3326}
3327#endif
3328
Linus Torvalds1da177e2005-04-16 15:20:36 -07003329/*
3330 * Analog playback callbacks
3331 */
3332static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3333 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003334 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003335{
3336 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003337 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3338 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003339}
3340
3341static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3342 struct hda_codec *codec,
3343 unsigned int stream_tag,
3344 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003345 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003346{
3347 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003348 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3349 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003350}
3351
3352static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3353 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003354 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003355{
3356 struct alc_spec *spec = codec->spec;
3357 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3358}
3359
3360/*
3361 * Digital out
3362 */
3363static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3364 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003365 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003366{
3367 struct alc_spec *spec = codec->spec;
3368 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3369}
3370
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003371static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3372 struct hda_codec *codec,
3373 unsigned int stream_tag,
3374 unsigned int format,
3375 struct snd_pcm_substream *substream)
3376{
3377 struct alc_spec *spec = codec->spec;
3378 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3379 stream_tag, format, substream);
3380}
3381
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003382static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3383 struct hda_codec *codec,
3384 struct snd_pcm_substream *substream)
3385{
3386 struct alc_spec *spec = codec->spec;
3387 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3388}
3389
Linus Torvalds1da177e2005-04-16 15:20:36 -07003390static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3391 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003392 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003393{
3394 struct alc_spec *spec = codec->spec;
3395 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3396}
3397
3398/*
3399 * Analog capture
3400 */
Takashi Iwai63300792008-01-24 15:31:36 +01003401static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003402 struct hda_codec *codec,
3403 unsigned int stream_tag,
3404 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003405 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003406{
3407 struct alc_spec *spec = codec->spec;
3408
Takashi Iwai63300792008-01-24 15:31:36 +01003409 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003410 stream_tag, 0, format);
3411 return 0;
3412}
3413
Takashi Iwai63300792008-01-24 15:31:36 +01003414static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003415 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003416 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003417{
3418 struct alc_spec *spec = codec->spec;
3419
Takashi Iwai888afa12008-03-18 09:57:50 +01003420 snd_hda_codec_cleanup_stream(codec,
3421 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003422 return 0;
3423}
3424
3425
3426/*
3427 */
3428static struct hda_pcm_stream alc880_pcm_analog_playback = {
3429 .substreams = 1,
3430 .channels_min = 2,
3431 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003432 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003433 .ops = {
3434 .open = alc880_playback_pcm_open,
3435 .prepare = alc880_playback_pcm_prepare,
3436 .cleanup = alc880_playback_pcm_cleanup
3437 },
3438};
3439
3440static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003441 .substreams = 1,
3442 .channels_min = 2,
3443 .channels_max = 2,
3444 /* NID is set in alc_build_pcms */
3445};
3446
3447static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3448 .substreams = 1,
3449 .channels_min = 2,
3450 .channels_max = 2,
3451 /* NID is set in alc_build_pcms */
3452};
3453
3454static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3455 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003456 .channels_min = 2,
3457 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003458 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003459 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003460 .prepare = alc880_alt_capture_pcm_prepare,
3461 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003462 },
3463};
3464
3465static struct hda_pcm_stream alc880_pcm_digital_playback = {
3466 .substreams = 1,
3467 .channels_min = 2,
3468 .channels_max = 2,
3469 /* NID is set in alc_build_pcms */
3470 .ops = {
3471 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003472 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003473 .prepare = alc880_dig_playback_pcm_prepare,
3474 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003475 },
3476};
3477
3478static struct hda_pcm_stream alc880_pcm_digital_capture = {
3479 .substreams = 1,
3480 .channels_min = 2,
3481 .channels_max = 2,
3482 /* NID is set in alc_build_pcms */
3483};
3484
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003485/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003486static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003487 .substreams = 0,
3488 .channels_min = 0,
3489 .channels_max = 0,
3490};
3491
Linus Torvalds1da177e2005-04-16 15:20:36 -07003492static int alc_build_pcms(struct hda_codec *codec)
3493{
3494 struct alc_spec *spec = codec->spec;
3495 struct hda_pcm *info = spec->pcm_rec;
3496 int i;
3497
3498 codec->num_pcms = 1;
3499 codec->pcm_info = info;
3500
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003501 if (spec->no_analog)
3502 goto skip_analog;
3503
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003504 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3505 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003506 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003507
Takashi Iwai4a471b72005-12-07 13:56:29 +01003508 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003509 if (snd_BUG_ON(!spec->multiout.dac_nids))
3510 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003511 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3512 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3513 }
3514 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003515 if (snd_BUG_ON(!spec->adc_nids))
3516 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003517 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3518 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3519 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003520
Takashi Iwai4a471b72005-12-07 13:56:29 +01003521 if (spec->channel_mode) {
3522 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3523 for (i = 0; i < spec->num_channel_mode; i++) {
3524 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3525 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3526 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003527 }
3528 }
3529
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003530 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003531 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003532 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003533 snprintf(spec->stream_name_digital,
3534 sizeof(spec->stream_name_digital),
3535 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003536 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003537 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003538 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003539 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003540 if (spec->dig_out_type)
3541 info->pcm_type = spec->dig_out_type;
3542 else
3543 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003544 if (spec->multiout.dig_out_nid &&
3545 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003546 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3547 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3548 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003549 if (spec->dig_in_nid &&
3550 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003551 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3552 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3553 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003554 /* FIXME: do we need this for all Realtek codec models? */
3555 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003556 }
3557
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003558 if (spec->no_analog)
3559 return 0;
3560
Takashi Iwaie08a0072006-09-07 17:52:14 +02003561 /* If the use of more than one ADC is requested for the current
3562 * model, configure a second analog capture-only PCM.
3563 */
3564 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003565 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3566 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003567 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003568 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003569 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003570 if (spec->alt_dac_nid) {
3571 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3572 *spec->stream_analog_alt_playback;
3573 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3574 spec->alt_dac_nid;
3575 } else {
3576 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3577 alc_pcm_null_stream;
3578 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3579 }
3580 if (spec->num_adc_nids > 1) {
3581 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3582 *spec->stream_analog_alt_capture;
3583 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3584 spec->adc_nids[1];
3585 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3586 spec->num_adc_nids - 1;
3587 } else {
3588 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3589 alc_pcm_null_stream;
3590 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003591 }
3592 }
3593
Linus Torvalds1da177e2005-04-16 15:20:36 -07003594 return 0;
3595}
3596
Takashi Iwai603c4012008-07-30 15:01:44 +02003597static void alc_free_kctls(struct hda_codec *codec)
3598{
3599 struct alc_spec *spec = codec->spec;
3600
3601 if (spec->kctls.list) {
3602 struct snd_kcontrol_new *kctl = spec->kctls.list;
3603 int i;
3604 for (i = 0; i < spec->kctls.used; i++)
3605 kfree(kctl[i].name);
3606 }
3607 snd_array_free(&spec->kctls);
3608}
3609
Linus Torvalds1da177e2005-04-16 15:20:36 -07003610static void alc_free(struct hda_codec *codec)
3611{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003612 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003613
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003614 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003615 return;
3616
Takashi Iwai603c4012008-07-30 15:01:44 +02003617 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003618 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003619 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003620}
3621
Takashi Iwaie044c392008-10-27 16:56:24 +01003622#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003623static int alc_resume(struct hda_codec *codec)
3624{
Takashi Iwaie044c392008-10-27 16:56:24 +01003625 codec->patch_ops.init(codec);
3626 snd_hda_codec_resume_amp(codec);
3627 snd_hda_codec_resume_cache(codec);
3628 return 0;
3629}
Takashi Iwaie044c392008-10-27 16:56:24 +01003630#endif
3631
Linus Torvalds1da177e2005-04-16 15:20:36 -07003632/*
3633 */
3634static struct hda_codec_ops alc_patch_ops = {
3635 .build_controls = alc_build_controls,
3636 .build_pcms = alc_build_pcms,
3637 .init = alc_init,
3638 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003639 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003640#ifdef SND_HDA_NEEDS_RESUME
3641 .resume = alc_resume,
3642#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003643#ifdef CONFIG_SND_HDA_POWER_SAVE
3644 .check_power_status = alc_check_power_status,
3645#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003646};
3647
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003648
3649/*
3650 * Test configuration for debugging
3651 *
3652 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3653 * enum controls.
3654 */
3655#ifdef CONFIG_SND_DEBUG
3656static hda_nid_t alc880_test_dac_nids[4] = {
3657 0x02, 0x03, 0x04, 0x05
3658};
3659
3660static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003661 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003662 .items = {
3663 { "In-1", 0x0 },
3664 { "In-2", 0x1 },
3665 { "In-3", 0x2 },
3666 { "In-4", 0x3 },
3667 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003668 { "Front", 0x5 },
3669 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003670 },
3671};
3672
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003673static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003674 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003675 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003676 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003677 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003678};
3679
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003680static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3681 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003682{
3683 static char *texts[] = {
3684 "N/A", "Line Out", "HP Out",
3685 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3686 };
3687 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3688 uinfo->count = 1;
3689 uinfo->value.enumerated.items = 8;
3690 if (uinfo->value.enumerated.item >= 8)
3691 uinfo->value.enumerated.item = 7;
3692 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3693 return 0;
3694}
3695
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003696static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3697 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003698{
3699 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3700 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3701 unsigned int pin_ctl, item = 0;
3702
3703 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3704 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3705 if (pin_ctl & AC_PINCTL_OUT_EN) {
3706 if (pin_ctl & AC_PINCTL_HP_EN)
3707 item = 2;
3708 else
3709 item = 1;
3710 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3711 switch (pin_ctl & AC_PINCTL_VREFEN) {
3712 case AC_PINCTL_VREF_HIZ: item = 3; break;
3713 case AC_PINCTL_VREF_50: item = 4; break;
3714 case AC_PINCTL_VREF_GRD: item = 5; break;
3715 case AC_PINCTL_VREF_80: item = 6; break;
3716 case AC_PINCTL_VREF_100: item = 7; break;
3717 }
3718 }
3719 ucontrol->value.enumerated.item[0] = item;
3720 return 0;
3721}
3722
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003723static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3724 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003725{
3726 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3727 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3728 static unsigned int ctls[] = {
3729 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3730 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3731 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3732 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3733 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3734 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3735 };
3736 unsigned int old_ctl, new_ctl;
3737
3738 old_ctl = snd_hda_codec_read(codec, nid, 0,
3739 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3740 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3741 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003742 int val;
3743 snd_hda_codec_write_cache(codec, nid, 0,
3744 AC_VERB_SET_PIN_WIDGET_CONTROL,
3745 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003746 val = ucontrol->value.enumerated.item[0] >= 3 ?
3747 HDA_AMP_MUTE : 0;
3748 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3749 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003750 return 1;
3751 }
3752 return 0;
3753}
3754
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003755static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3756 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003757{
3758 static char *texts[] = {
3759 "Front", "Surround", "CLFE", "Side"
3760 };
3761 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3762 uinfo->count = 1;
3763 uinfo->value.enumerated.items = 4;
3764 if (uinfo->value.enumerated.item >= 4)
3765 uinfo->value.enumerated.item = 3;
3766 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3767 return 0;
3768}
3769
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003770static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3771 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003772{
3773 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3774 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3775 unsigned int sel;
3776
3777 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3778 ucontrol->value.enumerated.item[0] = sel & 3;
3779 return 0;
3780}
3781
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003782static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3783 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003784{
3785 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3786 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3787 unsigned int sel;
3788
3789 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3790 if (ucontrol->value.enumerated.item[0] != sel) {
3791 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003792 snd_hda_codec_write_cache(codec, nid, 0,
3793 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003794 return 1;
3795 }
3796 return 0;
3797}
3798
3799#define PIN_CTL_TEST(xname,nid) { \
3800 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3801 .name = xname, \
3802 .info = alc_test_pin_ctl_info, \
3803 .get = alc_test_pin_ctl_get, \
3804 .put = alc_test_pin_ctl_put, \
3805 .private_value = nid \
3806 }
3807
3808#define PIN_SRC_TEST(xname,nid) { \
3809 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3810 .name = xname, \
3811 .info = alc_test_pin_src_info, \
3812 .get = alc_test_pin_src_get, \
3813 .put = alc_test_pin_src_put, \
3814 .private_value = nid \
3815 }
3816
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003817static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003818 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3819 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3820 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3821 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003822 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3823 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3824 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3825 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003826 PIN_CTL_TEST("Front Pin Mode", 0x14),
3827 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3828 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3829 PIN_CTL_TEST("Side Pin Mode", 0x17),
3830 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3831 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3832 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3833 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3834 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3835 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3836 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3837 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3838 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3839 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3840 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3841 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3842 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3843 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3844 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3845 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3846 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3847 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003848 {
3849 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3850 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003851 .info = alc_ch_mode_info,
3852 .get = alc_ch_mode_get,
3853 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003854 },
3855 { } /* end */
3856};
3857
3858static struct hda_verb alc880_test_init_verbs[] = {
3859 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003860 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3861 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3862 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3863 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3864 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3865 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3866 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3867 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003868 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003869 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3870 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3871 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3872 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003873 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003874 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3875 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3876 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3877 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003878 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003879 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3880 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3881 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3882 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003883 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003884 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3885 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003886 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3887 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3888 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003889 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003890 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3891 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3892 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3893 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003894 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003895 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003896 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003897 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003898 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003899 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003900 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003901 /* Analog input/passthru */
3902 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3903 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3904 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3905 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3906 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003907 { }
3908};
3909#endif
3910
Linus Torvalds1da177e2005-04-16 15:20:36 -07003911/*
3912 */
3913
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003914static const char *alc880_models[ALC880_MODEL_LAST] = {
3915 [ALC880_3ST] = "3stack",
3916 [ALC880_TCL_S700] = "tcl",
3917 [ALC880_3ST_DIG] = "3stack-digout",
3918 [ALC880_CLEVO] = "clevo",
3919 [ALC880_5ST] = "5stack",
3920 [ALC880_5ST_DIG] = "5stack-digout",
3921 [ALC880_W810] = "w810",
3922 [ALC880_Z71V] = "z71v",
3923 [ALC880_6ST] = "6stack",
3924 [ALC880_6ST_DIG] = "6stack-digout",
3925 [ALC880_ASUS] = "asus",
3926 [ALC880_ASUS_W1V] = "asus-w1v",
3927 [ALC880_ASUS_DIG] = "asus-dig",
3928 [ALC880_ASUS_DIG2] = "asus-dig2",
3929 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003930 [ALC880_UNIWILL_P53] = "uniwill-p53",
3931 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003932 [ALC880_F1734] = "F1734",
3933 [ALC880_LG] = "lg",
3934 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003935 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003936#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003937 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003938#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003939 [ALC880_AUTO] = "auto",
3940};
3941
3942static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003943 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003944 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3945 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3946 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3947 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3948 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3949 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3950 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3951 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003952 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3953 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003954 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3955 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3956 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3957 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3958 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3959 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3960 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3961 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3962 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3963 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003964 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003965 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3966 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3967 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003968 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003969 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003970 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3971 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003972 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3973 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003974 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3975 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3976 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3977 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003978 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3979 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003980 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003981 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003982 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003983 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003984 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3985 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003986 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003987 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003988 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003989 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003990 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003991 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003992 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003993 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003994 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003995 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3996 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003997 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003998 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3999 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4000 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4001 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004002 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4003 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004004 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004005 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004006 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4007 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004008 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4009 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4010 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004011 /* default Intel */
4012 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004013 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4014 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004015 {}
4016};
4017
Takashi Iwai16ded522005-06-10 19:58:24 +02004018/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004019 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004020 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004021static struct alc_config_preset alc880_presets[] = {
4022 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004023 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004024 .init_verbs = { alc880_volume_init_verbs,
4025 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004026 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004027 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004028 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4029 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004030 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004031 .input_mux = &alc880_capture_source,
4032 },
4033 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004034 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004035 .init_verbs = { alc880_volume_init_verbs,
4036 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004037 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004038 .dac_nids = alc880_dac_nids,
4039 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004040 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4041 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004042 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004043 .input_mux = &alc880_capture_source,
4044 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004045 [ALC880_TCL_S700] = {
4046 .mixers = { alc880_tcl_s700_mixer },
4047 .init_verbs = { alc880_volume_init_verbs,
4048 alc880_pin_tcl_S700_init_verbs,
4049 alc880_gpio2_init_verbs },
4050 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4051 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004052 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4053 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004054 .hp_nid = 0x03,
4055 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4056 .channel_mode = alc880_2_jack_modes,
4057 .input_mux = &alc880_capture_source,
4058 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004059 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004060 .mixers = { alc880_three_stack_mixer,
4061 alc880_five_stack_mixer},
4062 .init_verbs = { alc880_volume_init_verbs,
4063 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004064 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4065 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004066 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4067 .channel_mode = alc880_fivestack_modes,
4068 .input_mux = &alc880_capture_source,
4069 },
4070 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004071 .mixers = { alc880_three_stack_mixer,
4072 alc880_five_stack_mixer },
4073 .init_verbs = { alc880_volume_init_verbs,
4074 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004075 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4076 .dac_nids = alc880_dac_nids,
4077 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004078 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4079 .channel_mode = alc880_fivestack_modes,
4080 .input_mux = &alc880_capture_source,
4081 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004082 [ALC880_6ST] = {
4083 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004084 .init_verbs = { alc880_volume_init_verbs,
4085 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004086 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4087 .dac_nids = alc880_6st_dac_nids,
4088 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4089 .channel_mode = alc880_sixstack_modes,
4090 .input_mux = &alc880_6stack_capture_source,
4091 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004092 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004093 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004094 .init_verbs = { alc880_volume_init_verbs,
4095 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004096 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4097 .dac_nids = alc880_6st_dac_nids,
4098 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004099 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4100 .channel_mode = alc880_sixstack_modes,
4101 .input_mux = &alc880_6stack_capture_source,
4102 },
4103 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004104 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004105 .init_verbs = { alc880_volume_init_verbs,
4106 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004107 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004108 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4109 .dac_nids = alc880_w810_dac_nids,
4110 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004111 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4112 .channel_mode = alc880_w810_modes,
4113 .input_mux = &alc880_capture_source,
4114 },
4115 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004116 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004117 .init_verbs = { alc880_volume_init_verbs,
4118 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004119 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4120 .dac_nids = alc880_z71v_dac_nids,
4121 .dig_out_nid = ALC880_DIGOUT_NID,
4122 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004123 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4124 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004125 .input_mux = &alc880_capture_source,
4126 },
4127 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004128 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004129 .init_verbs = { alc880_volume_init_verbs,
4130 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004131 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4132 .dac_nids = alc880_f1734_dac_nids,
4133 .hp_nid = 0x02,
4134 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4135 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004136 .input_mux = &alc880_f1734_capture_source,
4137 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004138 .setup = alc880_uniwill_p53_setup,
4139 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004140 },
4141 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004142 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004143 .init_verbs = { alc880_volume_init_verbs,
4144 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004145 alc880_gpio1_init_verbs },
4146 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4147 .dac_nids = alc880_asus_dac_nids,
4148 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4149 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004150 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004151 .input_mux = &alc880_capture_source,
4152 },
4153 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004154 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004155 .init_verbs = { alc880_volume_init_verbs,
4156 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004157 alc880_gpio1_init_verbs },
4158 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4159 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004160 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004161 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4162 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004163 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004164 .input_mux = &alc880_capture_source,
4165 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004166 [ALC880_ASUS_DIG2] = {
4167 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004168 .init_verbs = { alc880_volume_init_verbs,
4169 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004170 alc880_gpio2_init_verbs }, /* use GPIO2 */
4171 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4172 .dac_nids = alc880_asus_dac_nids,
4173 .dig_out_nid = ALC880_DIGOUT_NID,
4174 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4175 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004176 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004177 .input_mux = &alc880_capture_source,
4178 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004179 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004180 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004181 .init_verbs = { alc880_volume_init_verbs,
4182 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004183 alc880_gpio1_init_verbs },
4184 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4185 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004186 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004187 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4188 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004189 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004190 .input_mux = &alc880_capture_source,
4191 },
4192 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004193 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004194 .init_verbs = { alc880_volume_init_verbs,
4195 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004196 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4197 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004198 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004199 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4200 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004201 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004202 .input_mux = &alc880_capture_source,
4203 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004204 [ALC880_UNIWILL] = {
4205 .mixers = { alc880_uniwill_mixer },
4206 .init_verbs = { alc880_volume_init_verbs,
4207 alc880_uniwill_init_verbs },
4208 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4209 .dac_nids = alc880_asus_dac_nids,
4210 .dig_out_nid = ALC880_DIGOUT_NID,
4211 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4212 .channel_mode = alc880_threestack_modes,
4213 .need_dac_fix = 1,
4214 .input_mux = &alc880_capture_source,
4215 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004216 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004217 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004218 },
4219 [ALC880_UNIWILL_P53] = {
4220 .mixers = { alc880_uniwill_p53_mixer },
4221 .init_verbs = { alc880_volume_init_verbs,
4222 alc880_uniwill_p53_init_verbs },
4223 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4224 .dac_nids = alc880_asus_dac_nids,
4225 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004226 .channel_mode = alc880_threestack_modes,
4227 .input_mux = &alc880_capture_source,
4228 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004229 .setup = alc880_uniwill_p53_setup,
4230 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004231 },
4232 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004233 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004234 .init_verbs = { alc880_volume_init_verbs,
4235 alc880_uniwill_p53_init_verbs,
4236 alc880_beep_init_verbs },
4237 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4238 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004239 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004240 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4241 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004242 .input_mux = &alc880_capture_source,
4243 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004244 .setup = alc880_uniwill_p53_setup,
4245 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004246 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004247 [ALC880_CLEVO] = {
4248 .mixers = { alc880_three_stack_mixer },
4249 .init_verbs = { alc880_volume_init_verbs,
4250 alc880_pin_clevo_init_verbs },
4251 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4252 .dac_nids = alc880_dac_nids,
4253 .hp_nid = 0x03,
4254 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4255 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004256 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004257 .input_mux = &alc880_capture_source,
4258 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004259 [ALC880_LG] = {
4260 .mixers = { alc880_lg_mixer },
4261 .init_verbs = { alc880_volume_init_verbs,
4262 alc880_lg_init_verbs },
4263 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4264 .dac_nids = alc880_lg_dac_nids,
4265 .dig_out_nid = ALC880_DIGOUT_NID,
4266 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4267 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004268 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004269 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004270 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004271 .setup = alc880_lg_setup,
4272 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004273#ifdef CONFIG_SND_HDA_POWER_SAVE
4274 .loopbacks = alc880_lg_loopbacks,
4275#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004276 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004277 [ALC880_LG_LW] = {
4278 .mixers = { alc880_lg_lw_mixer },
4279 .init_verbs = { alc880_volume_init_verbs,
4280 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004281 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004282 .dac_nids = alc880_dac_nids,
4283 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004284 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4285 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004286 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004287 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004288 .setup = alc880_lg_lw_setup,
4289 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004290 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004291 [ALC880_MEDION_RIM] = {
4292 .mixers = { alc880_medion_rim_mixer },
4293 .init_verbs = { alc880_volume_init_verbs,
4294 alc880_medion_rim_init_verbs,
4295 alc_gpio2_init_verbs },
4296 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4297 .dac_nids = alc880_dac_nids,
4298 .dig_out_nid = ALC880_DIGOUT_NID,
4299 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4300 .channel_mode = alc880_2_jack_modes,
4301 .input_mux = &alc880_medion_rim_capture_source,
4302 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004303 .setup = alc880_medion_rim_setup,
4304 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004305 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004306#ifdef CONFIG_SND_DEBUG
4307 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004308 .mixers = { alc880_test_mixer },
4309 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004310 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4311 .dac_nids = alc880_test_dac_nids,
4312 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004313 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4314 .channel_mode = alc880_test_modes,
4315 .input_mux = &alc880_test_capture_source,
4316 },
4317#endif
4318};
4319
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004320/*
4321 * Automatic parse of I/O pins from the BIOS configuration
4322 */
4323
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004324enum {
4325 ALC_CTL_WIDGET_VOL,
4326 ALC_CTL_WIDGET_MUTE,
4327 ALC_CTL_BIND_MUTE,
4328};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004329static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004330 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4331 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004332 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004333};
4334
4335/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004336static int add_control(struct alc_spec *spec, int type, const char *name,
4337 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004338{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004339 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004340
Takashi Iwai603c4012008-07-30 15:01:44 +02004341 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4342 knew = snd_array_new(&spec->kctls);
4343 if (!knew)
4344 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004345 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004346 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004347 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004348 return -ENOMEM;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004349 if (get_amp_nid_(val))
Takashi Iwai9c96fa52009-11-16 11:25:33 +01004350 knew->subdevice = HDA_SUBDEV_NID_FLAG | get_amp_nid_(val);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004351 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004352 return 0;
4353}
4354
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004355static int add_control_with_pfx(struct alc_spec *spec, int type,
4356 const char *pfx, const char *dir,
4357 const char *sfx, unsigned long val)
4358{
4359 char name[32];
4360 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
4361 return add_control(spec, type, name, val);
4362}
4363
4364#define add_pb_vol_ctrl(spec, type, pfx, val) \
4365 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val)
4366#define add_pb_sw_ctrl(spec, type, pfx, val) \
4367 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val)
4368
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004369#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4370#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4371#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4372#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004373#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4374#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4375#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4376#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4377#define ALC880_PIN_CD_NID 0x1c
4378
4379/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004380static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4381 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004382{
4383 hda_nid_t nid;
4384 int assigned[4];
4385 int i, j;
4386
4387 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004388 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004389
4390 /* check the pins hardwired to audio widget */
4391 for (i = 0; i < cfg->line_outs; i++) {
4392 nid = cfg->line_out_pins[i];
4393 if (alc880_is_fixed_pin(nid)) {
4394 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004395 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004396 assigned[idx] = 1;
4397 }
4398 }
4399 /* left pins can be connect to any audio widget */
4400 for (i = 0; i < cfg->line_outs; i++) {
4401 nid = cfg->line_out_pins[i];
4402 if (alc880_is_fixed_pin(nid))
4403 continue;
4404 /* search for an empty channel */
4405 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004406 if (!assigned[j]) {
4407 spec->multiout.dac_nids[i] =
4408 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004409 assigned[j] = 1;
4410 break;
4411 }
4412 }
4413 }
4414 spec->multiout.num_dacs = cfg->line_outs;
4415 return 0;
4416}
4417
4418/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004419static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4420 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004421{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004422 static const char *chname[4] = {
4423 "Front", "Surround", NULL /*CLFE*/, "Side"
4424 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004425 hda_nid_t nid;
4426 int i, err;
4427
4428 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004429 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004430 continue;
4431 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4432 if (i == 2) {
4433 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004434 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4435 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004436 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4437 HDA_OUTPUT));
4438 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004439 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004440 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4441 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004442 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4443 HDA_OUTPUT));
4444 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004445 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004446 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4447 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004448 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4449 HDA_INPUT));
4450 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004451 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004452 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4453 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004454 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4455 HDA_INPUT));
4456 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004457 return err;
4458 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004459 const char *pfx;
4460 if (cfg->line_outs == 1 &&
4461 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4462 pfx = "Speaker";
4463 else
4464 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004465 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004466 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4467 HDA_OUTPUT));
4468 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004469 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004470 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004471 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4472 HDA_INPUT));
4473 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004474 return err;
4475 }
4476 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004477 return 0;
4478}
4479
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004480/* add playback controls for speaker and HP outputs */
4481static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4482 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004483{
4484 hda_nid_t nid;
4485 int err;
4486
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004487 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004488 return 0;
4489
4490 if (alc880_is_fixed_pin(pin)) {
4491 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004492 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004493 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004494 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004495 else
4496 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004497 /* control HP volume/switch on the output mixer amp */
4498 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004499 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004500 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4501 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004502 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004503 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004504 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4505 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004506 return err;
4507 } else if (alc880_is_multi_pin(pin)) {
4508 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004509 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004510 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004511 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4512 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004513 return err;
4514 }
4515 return 0;
4516}
4517
4518/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004519static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4520 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004521 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004522{
Kailang Yangdf694da2005-12-05 19:42:22 +01004523 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004524
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004525 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004526 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4527 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004528 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004529 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004530 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4531 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004532 return err;
4533 return 0;
4534}
4535
Takashi Iwai05f5f472009-08-25 13:10:18 +02004536static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004537{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004538 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4539 return (pincap & AC_PINCAP_IN) != 0;
4540}
4541
4542/* create playback/capture controls for input pins */
4543static int alc_auto_create_input_ctls(struct hda_codec *codec,
4544 const struct auto_pin_cfg *cfg,
4545 hda_nid_t mixer,
4546 hda_nid_t cap1, hda_nid_t cap2)
4547{
4548 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004549 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004550 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004551
4552 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004553 hda_nid_t pin;
4554
4555 pin = cfg->input_pins[i];
4556 if (!alc_is_input_pin(codec, pin))
4557 continue;
4558
4559 if (mixer) {
4560 idx = get_connection_index(codec, mixer, pin);
4561 if (idx >= 0) {
4562 err = new_analog_input(spec, pin,
4563 auto_pin_cfg_labels[i],
4564 idx, mixer);
4565 if (err < 0)
4566 return err;
4567 }
4568 }
4569
4570 if (!cap1)
4571 continue;
4572 idx = get_connection_index(codec, cap1, pin);
4573 if (idx < 0 && cap2)
4574 idx = get_connection_index(codec, cap2, pin);
4575 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004576 imux->items[imux->num_items].label =
4577 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004578 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004579 imux->num_items++;
4580 }
4581 }
4582 return 0;
4583}
4584
Takashi Iwai05f5f472009-08-25 13:10:18 +02004585static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4586 const struct auto_pin_cfg *cfg)
4587{
4588 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4589}
4590
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004591static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4592 unsigned int pin_type)
4593{
4594 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4595 pin_type);
4596 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004597 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4598 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004599}
4600
Kailang Yangdf694da2005-12-05 19:42:22 +01004601static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4602 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004603 int dac_idx)
4604{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004605 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004606 /* need the manual connection? */
4607 if (alc880_is_multi_pin(nid)) {
4608 struct alc_spec *spec = codec->spec;
4609 int idx = alc880_multi_pin_idx(nid);
4610 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4611 AC_VERB_SET_CONNECT_SEL,
4612 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4613 }
4614}
4615
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004616static int get_pin_type(int line_out_type)
4617{
4618 if (line_out_type == AUTO_PIN_HP_OUT)
4619 return PIN_HP;
4620 else
4621 return PIN_OUT;
4622}
4623
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004624static void alc880_auto_init_multi_out(struct hda_codec *codec)
4625{
4626 struct alc_spec *spec = codec->spec;
4627 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004628
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004629 for (i = 0; i < spec->autocfg.line_outs; i++) {
4630 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004631 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4632 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004633 }
4634}
4635
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004636static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004637{
4638 struct alc_spec *spec = codec->spec;
4639 hda_nid_t pin;
4640
Takashi Iwai82bc9552006-03-21 11:24:42 +01004641 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004642 if (pin) /* connect to front */
4643 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004644 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004645 if (pin) /* connect to front */
4646 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4647}
4648
4649static void alc880_auto_init_analog_input(struct hda_codec *codec)
4650{
4651 struct alc_spec *spec = codec->spec;
4652 int i;
4653
4654 for (i = 0; i < AUTO_PIN_LAST; i++) {
4655 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004656 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004657 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004658 if (nid != ALC880_PIN_CD_NID &&
4659 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004660 snd_hda_codec_write(codec, nid, 0,
4661 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004662 AMP_OUT_MUTE);
4663 }
4664 }
4665}
4666
4667/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004668/* return 1 if successful, 0 if the proper config is not found,
4669 * or a negative error code
4670 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004671static int alc880_parse_auto_config(struct hda_codec *codec)
4672{
4673 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004674 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004675 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004676
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004677 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4678 alc880_ignore);
4679 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004680 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004681 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004682 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004683
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004684 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4685 if (err < 0)
4686 return err;
4687 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4688 if (err < 0)
4689 return err;
4690 err = alc880_auto_create_extra_out(spec,
4691 spec->autocfg.speaker_pins[0],
4692 "Speaker");
4693 if (err < 0)
4694 return err;
4695 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4696 "Headphone");
4697 if (err < 0)
4698 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004699 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004700 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004701 return err;
4702
4703 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4704
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004705 /* check multiple SPDIF-out (for recent codecs) */
4706 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4707 hda_nid_t dig_nid;
4708 err = snd_hda_get_connections(codec,
4709 spec->autocfg.dig_out_pins[i],
4710 &dig_nid, 1);
4711 if (err < 0)
4712 continue;
4713 if (!i)
4714 spec->multiout.dig_out_nid = dig_nid;
4715 else {
4716 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004717 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004718 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004719 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004720 }
4721 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004722 if (spec->autocfg.dig_in_pin)
4723 spec->dig_in_nid = ALC880_DIGIN_NID;
4724
Takashi Iwai603c4012008-07-30 15:01:44 +02004725 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004726 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004727
Takashi Iwaid88897e2008-10-31 15:01:37 +01004728 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004729
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004730 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004731 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004732
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004733 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4734
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004735 return 1;
4736}
4737
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004738/* additional initialization for auto-configuration model */
4739static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004740{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004741 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004742 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004743 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004744 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004745 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004746 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004747}
4748
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004749/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4750 * one of two digital mic pins, e.g. on ALC272
4751 */
4752static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004753{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004754 struct alc_spec *spec = codec->spec;
4755 int i;
4756
4757 for (i = 0; i < spec->num_adc_nids; i++) {
4758 hda_nid_t cap = spec->capsrc_nids ?
4759 spec->capsrc_nids[i] : spec->adc_nids[i];
4760 int iidx, eidx;
4761
4762 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4763 if (iidx < 0)
4764 continue;
4765 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4766 if (eidx < 0)
4767 continue;
4768 spec->int_mic.mux_idx = iidx;
4769 spec->ext_mic.mux_idx = eidx;
4770 if (spec->capsrc_nids)
4771 spec->capsrc_nids += i;
4772 spec->adc_nids += i;
4773 spec->num_adc_nids = 1;
4774 return;
4775 }
4776 snd_printd(KERN_INFO "hda_codec: %s: "
4777 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4778 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4779 spec->auto_mic = 0; /* disable auto-mic to be sure */
4780}
4781
4782static void set_capture_mixer(struct hda_codec *codec)
4783{
4784 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01004785 static struct snd_kcontrol_new *caps[2][3] = {
4786 { alc_capture_mixer_nosrc1,
4787 alc_capture_mixer_nosrc2,
4788 alc_capture_mixer_nosrc3 },
4789 { alc_capture_mixer1,
4790 alc_capture_mixer2,
4791 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004792 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004793 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4794 int mux;
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004795 if (spec->auto_mic) {
4796 mux = 0;
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004797 fixup_automic_adc(codec);
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004798 } else if (spec->input_mux && spec->input_mux->num_items > 1)
Takashi Iwaia23b6882009-03-23 15:21:36 +01004799 mux = 1;
4800 else
4801 mux = 0;
4802 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4803 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004804}
4805
Takashi Iwai67d634c2009-11-16 15:35:59 +01004806#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004807#define set_beep_amp(spec, nid, idx, dir) \
4808 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwai67d634c2009-11-16 15:35:59 +01004809#else
4810#define set_beep_amp(spec, nid, idx, dir) /* NOP */
4811#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004812
4813/*
4814 * OK, here we have finally the patch for ALC880
4815 */
4816
Linus Torvalds1da177e2005-04-16 15:20:36 -07004817static int patch_alc880(struct hda_codec *codec)
4818{
4819 struct alc_spec *spec;
4820 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004821 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004822
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004823 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004824 if (spec == NULL)
4825 return -ENOMEM;
4826
4827 codec->spec = spec;
4828
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004829 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4830 alc880_models,
4831 alc880_cfg_tbl);
4832 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004833 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4834 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004835 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004836 }
4837
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004838 if (board_config == ALC880_AUTO) {
4839 /* automatic parse from the BIOS config */
4840 err = alc880_parse_auto_config(codec);
4841 if (err < 0) {
4842 alc_free(codec);
4843 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004844 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004845 printk(KERN_INFO
4846 "hda_codec: Cannot set up configuration "
4847 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004848 board_config = ALC880_3ST;
4849 }
4850 }
4851
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004852 err = snd_hda_attach_beep_device(codec, 0x1);
4853 if (err < 0) {
4854 alc_free(codec);
4855 return err;
4856 }
4857
Kailang Yangdf694da2005-12-05 19:42:22 +01004858 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02004859 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004860
Linus Torvalds1da177e2005-04-16 15:20:36 -07004861 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4862 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004863 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004864
Linus Torvalds1da177e2005-04-16 15:20:36 -07004865 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4866 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4867
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004868 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004869 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004870 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004871 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02004872 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004873 if (wcap != AC_WID_AUD_IN) {
4874 spec->adc_nids = alc880_adc_nids_alt;
4875 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004876 } else {
4877 spec->adc_nids = alc880_adc_nids;
4878 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004879 }
4880 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004881 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004882 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004883
Takashi Iwai2134ea42008-01-10 16:53:55 +01004884 spec->vmaster_nid = 0x0c;
4885
Linus Torvalds1da177e2005-04-16 15:20:36 -07004886 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004887 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004888 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004889#ifdef CONFIG_SND_HDA_POWER_SAVE
4890 if (!spec->loopback.amplist)
4891 spec->loopback.amplist = alc880_loopbacks;
4892#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004893 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004894
4895 return 0;
4896}
4897
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004898
Linus Torvalds1da177e2005-04-16 15:20:36 -07004899/*
4900 * ALC260 support
4901 */
4902
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004903static hda_nid_t alc260_dac_nids[1] = {
4904 /* front */
4905 0x02,
4906};
4907
4908static hda_nid_t alc260_adc_nids[1] = {
4909 /* ADC0 */
4910 0x04,
4911};
4912
Kailang Yangdf694da2005-12-05 19:42:22 +01004913static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004914 /* ADC1 */
4915 0x05,
4916};
4917
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004918/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4919 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4920 */
4921static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004922 /* ADC0, ADC1 */
4923 0x04, 0x05
4924};
4925
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004926#define ALC260_DIGOUT_NID 0x03
4927#define ALC260_DIGIN_NID 0x06
4928
4929static struct hda_input_mux alc260_capture_source = {
4930 .num_items = 4,
4931 .items = {
4932 { "Mic", 0x0 },
4933 { "Front Mic", 0x1 },
4934 { "Line", 0x2 },
4935 { "CD", 0x4 },
4936 },
4937};
4938
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004939/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004940 * headphone jack and the internal CD lines since these are the only pins at
4941 * which audio can appear. For flexibility, also allow the option of
4942 * recording the mixer output on the second ADC (ADC0 doesn't have a
4943 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004944 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004945static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4946 {
4947 .num_items = 3,
4948 .items = {
4949 { "Mic/Line", 0x0 },
4950 { "CD", 0x4 },
4951 { "Headphone", 0x2 },
4952 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004953 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004954 {
4955 .num_items = 4,
4956 .items = {
4957 { "Mic/Line", 0x0 },
4958 { "CD", 0x4 },
4959 { "Headphone", 0x2 },
4960 { "Mixer", 0x5 },
4961 },
4962 },
4963
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004964};
4965
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004966/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4967 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004968 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004969static struct hda_input_mux alc260_acer_capture_sources[2] = {
4970 {
4971 .num_items = 4,
4972 .items = {
4973 { "Mic", 0x0 },
4974 { "Line", 0x2 },
4975 { "CD", 0x4 },
4976 { "Headphone", 0x5 },
4977 },
4978 },
4979 {
4980 .num_items = 5,
4981 .items = {
4982 { "Mic", 0x0 },
4983 { "Line", 0x2 },
4984 { "CD", 0x4 },
4985 { "Headphone", 0x6 },
4986 { "Mixer", 0x5 },
4987 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004988 },
4989};
Michael Schwingencc959482009-02-22 18:58:45 +01004990
4991/* Maxdata Favorit 100XS */
4992static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4993 {
4994 .num_items = 2,
4995 .items = {
4996 { "Line/Mic", 0x0 },
4997 { "CD", 0x4 },
4998 },
4999 },
5000 {
5001 .num_items = 3,
5002 .items = {
5003 { "Line/Mic", 0x0 },
5004 { "CD", 0x4 },
5005 { "Mixer", 0x5 },
5006 },
5007 },
5008};
5009
Linus Torvalds1da177e2005-04-16 15:20:36 -07005010/*
5011 * This is just place-holder, so there's something for alc_build_pcms to look
5012 * at when it calculates the maximum number of channels. ALC260 has no mixer
5013 * element which allows changing the channel mode, so the verb list is
5014 * never used.
5015 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005016static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005017 { 2, NULL },
5018};
5019
Kailang Yangdf694da2005-12-05 19:42:22 +01005020
5021/* Mixer combinations
5022 *
5023 * basic: base_output + input + pc_beep + capture
5024 * HP: base_output + input + capture_alt
5025 * HP_3013: hp_3013 + input + capture
5026 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005027 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005028 */
5029
5030static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005031 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005032 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005033 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5034 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5035 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5036 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5037 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005038};
Kailang Yangdf694da2005-12-05 19:42:22 +01005039
5040static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005041 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5042 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5043 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5044 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5045 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5046 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5047 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5048 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005049 { } /* end */
5050};
5051
Takashi Iwaibec15c32008-01-28 18:16:30 +01005052/* update HP, line and mono out pins according to the master switch */
5053static void alc260_hp_master_update(struct hda_codec *codec,
5054 hda_nid_t hp, hda_nid_t line,
5055 hda_nid_t mono)
5056{
5057 struct alc_spec *spec = codec->spec;
5058 unsigned int val = spec->master_sw ? PIN_HP : 0;
5059 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005060 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005061 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005062 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005063 val);
5064 /* mono (speaker) depending on the HP jack sense */
5065 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005066 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005067 val);
5068}
5069
5070static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5071 struct snd_ctl_elem_value *ucontrol)
5072{
5073 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5074 struct alc_spec *spec = codec->spec;
5075 *ucontrol->value.integer.value = spec->master_sw;
5076 return 0;
5077}
5078
5079static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5080 struct snd_ctl_elem_value *ucontrol)
5081{
5082 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5083 struct alc_spec *spec = codec->spec;
5084 int val = !!*ucontrol->value.integer.value;
5085 hda_nid_t hp, line, mono;
5086
5087 if (val == spec->master_sw)
5088 return 0;
5089 spec->master_sw = val;
5090 hp = (kcontrol->private_value >> 16) & 0xff;
5091 line = (kcontrol->private_value >> 8) & 0xff;
5092 mono = kcontrol->private_value & 0xff;
5093 alc260_hp_master_update(codec, hp, line, mono);
5094 return 1;
5095}
5096
5097static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5098 {
5099 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5100 .name = "Master Playback Switch",
5101 .info = snd_ctl_boolean_mono_info,
5102 .get = alc260_hp_master_sw_get,
5103 .put = alc260_hp_master_sw_put,
5104 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5105 },
5106 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5107 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5108 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5109 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5110 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5111 HDA_OUTPUT),
5112 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5113 { } /* end */
5114};
5115
5116static struct hda_verb alc260_hp_unsol_verbs[] = {
5117 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5118 {},
5119};
5120
5121static void alc260_hp_automute(struct hda_codec *codec)
5122{
5123 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005124
Wu Fengguang864f92b2009-11-18 12:38:02 +08005125 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005126 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5127}
5128
5129static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5130{
5131 if ((res >> 26) == ALC880_HP_EVENT)
5132 alc260_hp_automute(codec);
5133}
5134
Kailang Yangdf694da2005-12-05 19:42:22 +01005135static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005136 {
5137 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5138 .name = "Master Playback Switch",
5139 .info = snd_ctl_boolean_mono_info,
5140 .get = alc260_hp_master_sw_get,
5141 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005142 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005143 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005144 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5145 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5146 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5147 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5148 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5149 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005150 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5151 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005152 { } /* end */
5153};
5154
Kailang Yang3f878302008-08-26 13:02:23 +02005155static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5156 .ops = &snd_hda_bind_vol,
5157 .values = {
5158 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5159 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5160 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5161 0
5162 },
5163};
5164
5165static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5166 .ops = &snd_hda_bind_sw,
5167 .values = {
5168 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5169 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5170 0
5171 },
5172};
5173
5174static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5175 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5176 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5177 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5178 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5179 { } /* end */
5180};
5181
Takashi Iwaibec15c32008-01-28 18:16:30 +01005182static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5183 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5184 {},
5185};
5186
5187static void alc260_hp_3013_automute(struct hda_codec *codec)
5188{
5189 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005190
Wu Fengguang864f92b2009-11-18 12:38:02 +08005191 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005192 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005193}
5194
5195static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5196 unsigned int res)
5197{
5198 if ((res >> 26) == ALC880_HP_EVENT)
5199 alc260_hp_3013_automute(codec);
5200}
5201
Kailang Yang3f878302008-08-26 13:02:23 +02005202static void alc260_hp_3012_automute(struct hda_codec *codec)
5203{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005204 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005205
Kailang Yang3f878302008-08-26 13:02:23 +02005206 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5207 bits);
5208 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5209 bits);
5210 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5211 bits);
5212}
5213
5214static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5215 unsigned int res)
5216{
5217 if ((res >> 26) == ALC880_HP_EVENT)
5218 alc260_hp_3012_automute(codec);
5219}
5220
5221/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005222 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5223 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005224static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005225 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005226 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005227 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005228 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5229 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5230 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5231 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005232 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005233 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5234 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005235 { } /* end */
5236};
5237
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005238/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5239 * versions of the ALC260 don't act on requests to enable mic bias from NID
5240 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5241 * datasheet doesn't mention this restriction. At this stage it's not clear
5242 * whether this behaviour is intentional or is a hardware bug in chip
5243 * revisions available in early 2006. Therefore for now allow the
5244 * "Headphone Jack Mode" control to span all choices, but if it turns out
5245 * that the lack of mic bias for this NID is intentional we could change the
5246 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5247 *
5248 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5249 * don't appear to make the mic bias available from the "line" jack, even
5250 * though the NID used for this jack (0x14) can supply it. The theory is
5251 * that perhaps Acer have included blocking capacitors between the ALC260
5252 * and the output jack. If this turns out to be the case for all such
5253 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5254 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005255 *
5256 * The C20x Tablet series have a mono internal speaker which is controlled
5257 * via the chip's Mono sum widget and pin complex, so include the necessary
5258 * controls for such models. On models without a "mono speaker" the control
5259 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005260 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005261static struct snd_kcontrol_new alc260_acer_mixer[] = {
5262 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5263 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005264 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005265 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005266 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005267 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005268 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005269 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5270 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5271 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5272 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5273 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5274 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5275 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5276 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005277 { } /* end */
5278};
5279
Michael Schwingencc959482009-02-22 18:58:45 +01005280/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5281 */
5282static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5283 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5284 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5285 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5286 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5287 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5288 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5289 { } /* end */
5290};
5291
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005292/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5293 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5294 */
5295static struct snd_kcontrol_new alc260_will_mixer[] = {
5296 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5297 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5298 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5299 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5300 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5301 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5302 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5303 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5304 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5305 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005306 { } /* end */
5307};
5308
5309/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5310 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5311 */
5312static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5313 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5314 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5315 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5316 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5317 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5318 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5319 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5320 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5321 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5322 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5323 { } /* end */
5324};
5325
Kailang Yangdf694da2005-12-05 19:42:22 +01005326/*
5327 * initialization verbs
5328 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005329static struct hda_verb alc260_init_verbs[] = {
5330 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005331 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005332 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005333 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005334 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005335 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005336 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005337 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005338 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005339 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005340 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005341 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005342 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005343 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005344 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005345 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005346 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005347 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5348 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005349 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005350 /* set connection select to line in (default select for this ADC) */
5351 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005352 /* mute capture amp left and right */
5353 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5354 /* set connection select to line in (default select for this ADC) */
5355 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005356 /* set vol=0 Line-Out mixer amp left and right */
5357 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5358 /* unmute pin widget amp left and right (no gain on this amp) */
5359 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5360 /* set vol=0 HP mixer amp left and right */
5361 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5362 /* unmute pin widget amp left and right (no gain on this amp) */
5363 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5364 /* set vol=0 Mono mixer amp left and right */
5365 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5366 /* unmute pin widget amp left and right (no gain on this amp) */
5367 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5368 /* unmute LINE-2 out pin */
5369 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005370 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5371 * Line In 2 = 0x03
5372 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005373 /* mute analog inputs */
5374 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5375 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5376 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5377 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5378 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005379 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005380 /* mute Front out path */
5381 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5382 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5383 /* mute Headphone out path */
5384 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5385 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5386 /* mute Mono out path */
5387 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5388 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005389 { }
5390};
5391
Takashi Iwai474167d2006-05-17 17:17:43 +02005392#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005393static struct hda_verb alc260_hp_init_verbs[] = {
5394 /* Headphone and output */
5395 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5396 /* mono output */
5397 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5398 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5399 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5400 /* Mic2 (front panel) pin widget for input and vref at 80% */
5401 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5402 /* Line In pin widget for input */
5403 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5404 /* Line-2 pin widget for output */
5405 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5406 /* CD pin widget for input */
5407 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5408 /* unmute amp left and right */
5409 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5410 /* set connection select to line in (default select for this ADC) */
5411 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5412 /* unmute Line-Out mixer amp left and right (volume = 0) */
5413 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5414 /* mute pin widget amp left and right (no gain on this amp) */
5415 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5416 /* unmute HP mixer amp left and right (volume = 0) */
5417 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5418 /* mute pin widget amp left and right (no gain on this amp) */
5419 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005420 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5421 * Line In 2 = 0x03
5422 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005423 /* mute analog inputs */
5424 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5425 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5426 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5427 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5428 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005429 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5430 /* Unmute Front out path */
5431 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5432 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5433 /* Unmute Headphone out path */
5434 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5435 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5436 /* Unmute Mono out path */
5437 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5438 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5439 { }
5440};
Takashi Iwai474167d2006-05-17 17:17:43 +02005441#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005442
5443static struct hda_verb alc260_hp_3013_init_verbs[] = {
5444 /* Line out and output */
5445 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5446 /* mono output */
5447 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5448 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5449 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5450 /* Mic2 (front panel) pin widget for input and vref at 80% */
5451 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5452 /* Line In pin widget for input */
5453 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5454 /* Headphone pin widget for output */
5455 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5456 /* CD pin widget for input */
5457 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5458 /* unmute amp left and right */
5459 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5460 /* set connection select to line in (default select for this ADC) */
5461 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5462 /* unmute Line-Out mixer amp left and right (volume = 0) */
5463 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5464 /* mute pin widget amp left and right (no gain on this amp) */
5465 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5466 /* unmute HP mixer amp left and right (volume = 0) */
5467 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5468 /* mute pin widget amp left and right (no gain on this amp) */
5469 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005470 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5471 * Line In 2 = 0x03
5472 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005473 /* mute analog inputs */
5474 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5475 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5476 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5477 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5478 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005479 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5480 /* Unmute Front out path */
5481 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5482 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5483 /* Unmute Headphone out path */
5484 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5485 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5486 /* Unmute Mono out path */
5487 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5488 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5489 { }
5490};
5491
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005492/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005493 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5494 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005495 */
5496static struct hda_verb alc260_fujitsu_init_verbs[] = {
5497 /* Disable all GPIOs */
5498 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5499 /* Internal speaker is connected to headphone pin */
5500 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5501 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5502 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005503 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5504 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5505 /* Ensure all other unused pins are disabled and muted. */
5506 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5507 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005508 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005509 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005510 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005511 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5512 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5513 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005514
Jonathan Woithef7ace402006-02-28 11:46:14 +01005515 /* Disable digital (SPDIF) pins */
5516 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5517 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005518
Kailang Yangea1fb292008-08-26 12:58:38 +02005519 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005520 * when acting as an output.
5521 */
5522 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5523
5524 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005525 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5526 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5527 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5528 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5529 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5530 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5531 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5532 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5533 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005534
Jonathan Woithef7ace402006-02-28 11:46:14 +01005535 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5536 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5537 /* Unmute Line1 pin widget output buffer since it starts as an output.
5538 * If the pin mode is changed by the user the pin mode control will
5539 * take care of enabling the pin's input/output buffers as needed.
5540 * Therefore there's no need to enable the input buffer at this
5541 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005542 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005543 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005544 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005545 * mixer ctrl)
5546 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005547 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005548
Jonathan Woithef7ace402006-02-28 11:46:14 +01005549 /* Mute capture amp left and right */
5550 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005551 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005552 * in (on mic1 pin)
5553 */
5554 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005555
Jonathan Woithef7ace402006-02-28 11:46:14 +01005556 /* Do the same for the second ADC: mute capture input amp and
5557 * set ADC connection to line in (on mic1 pin)
5558 */
5559 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5560 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005561
Jonathan Woithef7ace402006-02-28 11:46:14 +01005562 /* Mute all inputs to mixer widget (even unconnected ones) */
5563 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5564 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5565 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5566 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5567 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5568 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5569 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5570 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005571
5572 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005573};
5574
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005575/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5576 * similar laptops (adapted from Fujitsu init verbs).
5577 */
5578static struct hda_verb alc260_acer_init_verbs[] = {
5579 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5580 * the headphone jack. Turn this on and rely on the standard mute
5581 * methods whenever the user wants to turn these outputs off.
5582 */
5583 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5584 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5585 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5586 /* Internal speaker/Headphone jack is connected to Line-out pin */
5587 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5588 /* Internal microphone/Mic jack is connected to Mic1 pin */
5589 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5590 /* Line In jack is connected to Line1 pin */
5591 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005592 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5593 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005594 /* Ensure all other unused pins are disabled and muted. */
5595 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5596 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005597 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5598 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5599 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5600 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5601 /* Disable digital (SPDIF) pins */
5602 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5603 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5604
Kailang Yangea1fb292008-08-26 12:58:38 +02005605 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005606 * bus when acting as outputs.
5607 */
5608 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5609 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5610
5611 /* Start with output sum widgets muted and their output gains at min */
5612 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5613 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5614 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5615 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5616 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5617 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5618 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5619 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5620 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5621
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005622 /* Unmute Line-out pin widget amp left and right
5623 * (no equiv mixer ctrl)
5624 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005625 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005626 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5627 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005628 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5629 * inputs. If the pin mode is changed by the user the pin mode control
5630 * will take care of enabling the pin's input/output buffers as needed.
5631 * Therefore there's no need to enable the input buffer at this
5632 * stage.
5633 */
5634 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5635 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5636
5637 /* Mute capture amp left and right */
5638 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5639 /* Set ADC connection select to match default mixer setting - mic
5640 * (on mic1 pin)
5641 */
5642 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5643
5644 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005645 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005646 */
5647 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005648 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005649
5650 /* Mute all inputs to mixer widget (even unconnected ones) */
5651 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5652 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5653 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5654 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5655 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5656 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5657 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5658 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5659
5660 { }
5661};
5662
Michael Schwingencc959482009-02-22 18:58:45 +01005663/* Initialisation sequence for Maxdata Favorit 100XS
5664 * (adapted from Acer init verbs).
5665 */
5666static struct hda_verb alc260_favorit100_init_verbs[] = {
5667 /* GPIO 0 enables the output jack.
5668 * Turn this on and rely on the standard mute
5669 * methods whenever the user wants to turn these outputs off.
5670 */
5671 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5672 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5673 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5674 /* Line/Mic input jack is connected to Mic1 pin */
5675 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5676 /* Ensure all other unused pins are disabled and muted. */
5677 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5678 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5679 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5680 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5681 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5682 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5683 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5684 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5685 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5686 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5687 /* Disable digital (SPDIF) pins */
5688 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5689 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5690
5691 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5692 * bus when acting as outputs.
5693 */
5694 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5695 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5696
5697 /* Start with output sum widgets muted and their output gains at min */
5698 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5699 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5700 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5701 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5702 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5703 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5704 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5705 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5706 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5707
5708 /* Unmute Line-out pin widget amp left and right
5709 * (no equiv mixer ctrl)
5710 */
5711 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5712 /* 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
5720 /* Mute capture amp left and right */
5721 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5722 /* Set ADC connection select to match default mixer setting - mic
5723 * (on mic1 pin)
5724 */
5725 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5726
5727 /* Do similar with the second ADC: mute capture input amp and
5728 * set ADC connection to mic to match ALSA's default state.
5729 */
5730 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5731 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5732
5733 /* Mute all inputs to mixer widget (even unconnected ones) */
5734 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5735 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5736 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5737 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5738 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5739 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5740 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5741 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5742
5743 { }
5744};
5745
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005746static struct hda_verb alc260_will_verbs[] = {
5747 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5748 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5749 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5750 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5751 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5752 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5753 {}
5754};
5755
5756static struct hda_verb alc260_replacer_672v_verbs[] = {
5757 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5758 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5759 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5760
5761 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5762 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5763 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5764
5765 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5766 {}
5767};
5768
5769/* toggle speaker-output according to the hp-jack state */
5770static void alc260_replacer_672v_automute(struct hda_codec *codec)
5771{
5772 unsigned int present;
5773
5774 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08005775 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005776 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005777 snd_hda_codec_write_cache(codec, 0x01, 0,
5778 AC_VERB_SET_GPIO_DATA, 1);
5779 snd_hda_codec_write_cache(codec, 0x0f, 0,
5780 AC_VERB_SET_PIN_WIDGET_CONTROL,
5781 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005782 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005783 snd_hda_codec_write_cache(codec, 0x01, 0,
5784 AC_VERB_SET_GPIO_DATA, 0);
5785 snd_hda_codec_write_cache(codec, 0x0f, 0,
5786 AC_VERB_SET_PIN_WIDGET_CONTROL,
5787 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005788 }
5789}
5790
5791static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5792 unsigned int res)
5793{
5794 if ((res >> 26) == ALC880_HP_EVENT)
5795 alc260_replacer_672v_automute(codec);
5796}
5797
Kailang Yang3f878302008-08-26 13:02:23 +02005798static struct hda_verb alc260_hp_dc7600_verbs[] = {
5799 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5800 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5801 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5802 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5803 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5804 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5805 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5806 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5807 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5808 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5809 {}
5810};
5811
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005812/* Test configuration for debugging, modelled after the ALC880 test
5813 * configuration.
5814 */
5815#ifdef CONFIG_SND_DEBUG
5816static hda_nid_t alc260_test_dac_nids[1] = {
5817 0x02,
5818};
5819static hda_nid_t alc260_test_adc_nids[2] = {
5820 0x04, 0x05,
5821};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005822/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005823 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005824 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005825 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005826static struct hda_input_mux alc260_test_capture_sources[2] = {
5827 {
5828 .num_items = 7,
5829 .items = {
5830 { "MIC1 pin", 0x0 },
5831 { "MIC2 pin", 0x1 },
5832 { "LINE1 pin", 0x2 },
5833 { "LINE2 pin", 0x3 },
5834 { "CD pin", 0x4 },
5835 { "LINE-OUT pin", 0x5 },
5836 { "HP-OUT pin", 0x6 },
5837 },
5838 },
5839 {
5840 .num_items = 8,
5841 .items = {
5842 { "MIC1 pin", 0x0 },
5843 { "MIC2 pin", 0x1 },
5844 { "LINE1 pin", 0x2 },
5845 { "LINE2 pin", 0x3 },
5846 { "CD pin", 0x4 },
5847 { "Mixer", 0x5 },
5848 { "LINE-OUT pin", 0x6 },
5849 { "HP-OUT pin", 0x7 },
5850 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005851 },
5852};
5853static struct snd_kcontrol_new alc260_test_mixer[] = {
5854 /* Output driver widgets */
5855 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5856 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5857 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5858 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5859 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5860 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5861
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005862 /* Modes for retasking pin widgets
5863 * Note: the ALC260 doesn't seem to act on requests to enable mic
5864 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5865 * mention this restriction. At this stage it's not clear whether
5866 * this behaviour is intentional or is a hardware bug in chip
5867 * revisions available at least up until early 2006. Therefore for
5868 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5869 * choices, but if it turns out that the lack of mic bias for these
5870 * NIDs is intentional we could change their modes from
5871 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5872 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005873 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5874 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5875 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5876 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5877 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5878 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5879
5880 /* Loopback mixer controls */
5881 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5882 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5883 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5884 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5885 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5886 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5887 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5888 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5889 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5890 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005891 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5892 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5893 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5894 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005895
5896 /* Controls for GPIO pins, assuming they are configured as outputs */
5897 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5898 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5899 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5900 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5901
Jonathan Woithe92621f12006-02-28 11:47:47 +01005902 /* Switches to allow the digital IO pins to be enabled. The datasheet
5903 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005904 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005905 */
5906 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5907 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5908
Jonathan Woithef8225f62008-01-08 12:16:54 +01005909 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5910 * this output to turn on an external amplifier.
5911 */
5912 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5913 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5914
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005915 { } /* end */
5916};
5917static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005918 /* Enable all GPIOs as outputs with an initial value of 0 */
5919 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5920 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5921 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5922
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005923 /* Enable retasking pins as output, initially without power amp */
5924 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5925 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5926 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5927 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5928 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5929 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5930
Jonathan Woithe92621f12006-02-28 11:47:47 +01005931 /* Disable digital (SPDIF) pins initially, but users can enable
5932 * them via a mixer switch. In the case of SPDIF-out, this initverb
5933 * payload also sets the generation to 0, output to be in "consumer"
5934 * PCM format, copyright asserted, no pre-emphasis and no validity
5935 * control.
5936 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005937 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5938 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5939
Kailang Yangea1fb292008-08-26 12:58:38 +02005940 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005941 * OUT1 sum bus when acting as an output.
5942 */
5943 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5944 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5945 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5946 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5947
5948 /* Start with output sum widgets muted and their output gains at min */
5949 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5950 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5951 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5952 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5953 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5954 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5955 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5956 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5957 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5958
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005959 /* Unmute retasking pin widget output buffers since the default
5960 * state appears to be output. As the pin mode is changed by the
5961 * user the pin mode control will take care of enabling the pin's
5962 * input/output buffers as needed.
5963 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005964 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5965 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5966 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5967 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5968 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5969 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5970 /* Also unmute the mono-out pin widget */
5971 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5972
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005973 /* Mute capture amp left and right */
5974 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005975 /* Set ADC connection select to match default mixer setting (mic1
5976 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005977 */
5978 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5979
5980 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005981 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005982 */
5983 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5984 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5985
5986 /* Mute all inputs to mixer widget (even unconnected ones) */
5987 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5988 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5989 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5990 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5991 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5992 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5993 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5994 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5995
5996 { }
5997};
5998#endif
5999
Takashi Iwai63300792008-01-24 15:31:36 +01006000#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6001#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006002
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006003#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6004#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6005
Kailang Yangdf694da2005-12-05 19:42:22 +01006006/*
6007 * for BIOS auto-configuration
6008 */
6009
6010static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006011 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006012{
6013 hda_nid_t nid_vol;
6014 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006015 int err;
6016
6017 if (nid >= 0x0f && nid < 0x11) {
6018 nid_vol = nid - 0x7;
6019 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6020 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6021 } else if (nid == 0x11) {
6022 nid_vol = nid - 0x7;
6023 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6024 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6025 } else if (nid >= 0x12 && nid <= 0x15) {
6026 nid_vol = 0x08;
6027 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6028 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6029 } else
6030 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006031
Takashi Iwai863b4512008-10-21 17:01:47 +02006032 if (!(*vol_bits & (1 << nid_vol))) {
6033 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006034 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006035 if (err < 0)
6036 return err;
6037 *vol_bits |= (1 << nid_vol);
6038 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006039 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006040 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006041 return err;
6042 return 1;
6043}
6044
6045/* add playback controls from the parsed DAC table */
6046static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6047 const struct auto_pin_cfg *cfg)
6048{
6049 hda_nid_t nid;
6050 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006051 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006052
6053 spec->multiout.num_dacs = 1;
6054 spec->multiout.dac_nids = spec->private_dac_nids;
6055 spec->multiout.dac_nids[0] = 0x02;
6056
6057 nid = cfg->line_out_pins[0];
6058 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006059 const char *pfx;
6060 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6061 pfx = "Master";
6062 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6063 pfx = "Speaker";
6064 else
6065 pfx = "Front";
6066 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006067 if (err < 0)
6068 return err;
6069 }
6070
Takashi Iwai82bc9552006-03-21 11:24:42 +01006071 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006072 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006073 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006074 if (err < 0)
6075 return err;
6076 }
6077
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006078 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006079 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006080 err = alc260_add_playback_controls(spec, nid, "Headphone",
6081 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006082 if (err < 0)
6083 return err;
6084 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006085 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006086}
6087
6088/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006089static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006090 const struct auto_pin_cfg *cfg)
6091{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006092 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006093}
6094
6095static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6096 hda_nid_t nid, int pin_type,
6097 int sel_idx)
6098{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006099 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006100 /* need the manual connection? */
6101 if (nid >= 0x12) {
6102 int idx = nid - 0x12;
6103 snd_hda_codec_write(codec, idx + 0x0b, 0,
6104 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006105 }
6106}
6107
6108static void alc260_auto_init_multi_out(struct hda_codec *codec)
6109{
6110 struct alc_spec *spec = codec->spec;
6111 hda_nid_t nid;
6112
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006113 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006114 if (nid) {
6115 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6116 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6117 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006118
Takashi Iwai82bc9552006-03-21 11:24:42 +01006119 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006120 if (nid)
6121 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6122
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006123 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006124 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006125 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006126}
Kailang Yangdf694da2005-12-05 19:42:22 +01006127
6128#define ALC260_PIN_CD_NID 0x16
6129static void alc260_auto_init_analog_input(struct hda_codec *codec)
6130{
6131 struct alc_spec *spec = codec->spec;
6132 int i;
6133
6134 for (i = 0; i < AUTO_PIN_LAST; i++) {
6135 hda_nid_t nid = spec->autocfg.input_pins[i];
6136 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006137 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006138 if (nid != ALC260_PIN_CD_NID &&
6139 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006140 snd_hda_codec_write(codec, nid, 0,
6141 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006142 AMP_OUT_MUTE);
6143 }
6144 }
6145}
6146
6147/*
6148 * generic initialization of ADC, input mixers and output mixers
6149 */
6150static struct hda_verb alc260_volume_init_verbs[] = {
6151 /*
6152 * Unmute ADC0-1 and set the default input to mic-in
6153 */
6154 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6155 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6156 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6157 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006158
Kailang Yangdf694da2005-12-05 19:42:22 +01006159 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6160 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006161 * Note: PASD motherboards uses the Line In 2 as the input for
6162 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006163 */
6164 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006165 /* mute analog inputs */
6166 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6167 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6168 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6169 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6170 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006171
6172 /*
6173 * Set up output mixers (0x08 - 0x0a)
6174 */
6175 /* set vol=0 to output mixers */
6176 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6177 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6178 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6179 /* set up input amps for analog loopback */
6180 /* Amp Indices: DAC = 0, mixer = 1 */
6181 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6182 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6183 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6184 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6185 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6186 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006187
Kailang Yangdf694da2005-12-05 19:42:22 +01006188 { }
6189};
6190
6191static int alc260_parse_auto_config(struct hda_codec *codec)
6192{
6193 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006194 int err;
6195 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6196
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006197 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6198 alc260_ignore);
6199 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006200 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006201 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6202 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006203 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006204 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006205 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006206 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006207 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006208 return err;
6209
6210 spec->multiout.max_channels = 2;
6211
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006212 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006213 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006214 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006215 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006216
Takashi Iwaid88897e2008-10-31 15:01:37 +01006217 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006218
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006219 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006220 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006221
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006222 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6223
Kailang Yangdf694da2005-12-05 19:42:22 +01006224 return 1;
6225}
6226
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006227/* additional initialization for auto-configuration model */
6228static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006229{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006230 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006231 alc260_auto_init_multi_out(codec);
6232 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006233 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006234 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006235}
6236
Takashi Iwaicb53c622007-08-10 17:21:45 +02006237#ifdef CONFIG_SND_HDA_POWER_SAVE
6238static struct hda_amp_list alc260_loopbacks[] = {
6239 { 0x07, HDA_INPUT, 0 },
6240 { 0x07, HDA_INPUT, 1 },
6241 { 0x07, HDA_INPUT, 2 },
6242 { 0x07, HDA_INPUT, 3 },
6243 { 0x07, HDA_INPUT, 4 },
6244 { } /* end */
6245};
6246#endif
6247
Kailang Yangdf694da2005-12-05 19:42:22 +01006248/*
6249 * ALC260 configurations
6250 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006251static const char *alc260_models[ALC260_MODEL_LAST] = {
6252 [ALC260_BASIC] = "basic",
6253 [ALC260_HP] = "hp",
6254 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006255 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006256 [ALC260_FUJITSU_S702X] = "fujitsu",
6257 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006258 [ALC260_WILL] = "will",
6259 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006260 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006261#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006262 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006263#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006264 [ALC260_AUTO] = "auto",
6265};
6266
6267static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006268 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006269 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006270 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006271 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006272 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006273 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006274 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006275 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006276 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006277 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6278 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6279 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6280 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6281 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6282 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6283 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6284 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6285 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006286 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006287 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006288 {}
6289};
6290
Kailang Yangdf694da2005-12-05 19:42:22 +01006291static struct alc_config_preset alc260_presets[] = {
6292 [ALC260_BASIC] = {
6293 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006294 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006295 .init_verbs = { alc260_init_verbs },
6296 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6297 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006298 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006299 .adc_nids = alc260_adc_nids,
6300 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6301 .channel_mode = alc260_modes,
6302 .input_mux = &alc260_capture_source,
6303 },
6304 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006305 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006306 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006307 .init_verbs = { alc260_init_verbs,
6308 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006309 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6310 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006311 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6312 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006313 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6314 .channel_mode = alc260_modes,
6315 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006316 .unsol_event = alc260_hp_unsol_event,
6317 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006318 },
Kailang Yang3f878302008-08-26 13:02:23 +02006319 [ALC260_HP_DC7600] = {
6320 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006321 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006322 .init_verbs = { alc260_init_verbs,
6323 alc260_hp_dc7600_verbs },
6324 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6325 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006326 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6327 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006328 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6329 .channel_mode = alc260_modes,
6330 .input_mux = &alc260_capture_source,
6331 .unsol_event = alc260_hp_3012_unsol_event,
6332 .init_hook = alc260_hp_3012_automute,
6333 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006334 [ALC260_HP_3013] = {
6335 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006336 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006337 .init_verbs = { alc260_hp_3013_init_verbs,
6338 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006339 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6340 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006341 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6342 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006343 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6344 .channel_mode = alc260_modes,
6345 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006346 .unsol_event = alc260_hp_3013_unsol_event,
6347 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006348 },
6349 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006350 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006351 .init_verbs = { alc260_fujitsu_init_verbs },
6352 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6353 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006354 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6355 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006356 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6357 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006358 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6359 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006360 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006361 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006362 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006363 .init_verbs = { alc260_acer_init_verbs },
6364 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6365 .dac_nids = alc260_dac_nids,
6366 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6367 .adc_nids = alc260_dual_adc_nids,
6368 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6369 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006370 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6371 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006372 },
Michael Schwingencc959482009-02-22 18:58:45 +01006373 [ALC260_FAVORIT100] = {
6374 .mixers = { alc260_favorit100_mixer },
6375 .init_verbs = { alc260_favorit100_init_verbs },
6376 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6377 .dac_nids = alc260_dac_nids,
6378 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6379 .adc_nids = alc260_dual_adc_nids,
6380 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6381 .channel_mode = alc260_modes,
6382 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6383 .input_mux = alc260_favorit100_capture_sources,
6384 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006385 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006386 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006387 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6388 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6389 .dac_nids = alc260_dac_nids,
6390 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6391 .adc_nids = alc260_adc_nids,
6392 .dig_out_nid = ALC260_DIGOUT_NID,
6393 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6394 .channel_mode = alc260_modes,
6395 .input_mux = &alc260_capture_source,
6396 },
6397 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006398 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006399 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6400 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6401 .dac_nids = alc260_dac_nids,
6402 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6403 .adc_nids = alc260_adc_nids,
6404 .dig_out_nid = ALC260_DIGOUT_NID,
6405 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6406 .channel_mode = alc260_modes,
6407 .input_mux = &alc260_capture_source,
6408 .unsol_event = alc260_replacer_672v_unsol_event,
6409 .init_hook = alc260_replacer_672v_automute,
6410 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006411#ifdef CONFIG_SND_DEBUG
6412 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006413 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006414 .init_verbs = { alc260_test_init_verbs },
6415 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6416 .dac_nids = alc260_test_dac_nids,
6417 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6418 .adc_nids = alc260_test_adc_nids,
6419 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6420 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006421 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6422 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006423 },
6424#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006425};
6426
Linus Torvalds1da177e2005-04-16 15:20:36 -07006427static int patch_alc260(struct hda_codec *codec)
6428{
6429 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006430 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006431
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006432 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006433 if (spec == NULL)
6434 return -ENOMEM;
6435
6436 codec->spec = spec;
6437
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006438 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6439 alc260_models,
6440 alc260_cfg_tbl);
6441 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006442 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006443 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006444 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006445 }
6446
Kailang Yangdf694da2005-12-05 19:42:22 +01006447 if (board_config == ALC260_AUTO) {
6448 /* automatic parse from the BIOS config */
6449 err = alc260_parse_auto_config(codec);
6450 if (err < 0) {
6451 alc_free(codec);
6452 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006453 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006454 printk(KERN_INFO
6455 "hda_codec: Cannot set up configuration "
6456 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006457 board_config = ALC260_BASIC;
6458 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006459 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006460
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006461 err = snd_hda_attach_beep_device(codec, 0x1);
6462 if (err < 0) {
6463 alc_free(codec);
6464 return err;
6465 }
6466
Kailang Yangdf694da2005-12-05 19:42:22 +01006467 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006468 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006469
Linus Torvalds1da177e2005-04-16 15:20:36 -07006470 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6471 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6472
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006473 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6474 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6475
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006476 if (!spec->adc_nids && spec->input_mux) {
6477 /* check whether NID 0x04 is valid */
6478 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006479 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006480 /* get type */
6481 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6482 spec->adc_nids = alc260_adc_nids_alt;
6483 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6484 } else {
6485 spec->adc_nids = alc260_adc_nids;
6486 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6487 }
6488 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006489 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006490 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006491
Takashi Iwai2134ea42008-01-10 16:53:55 +01006492 spec->vmaster_nid = 0x08;
6493
Linus Torvalds1da177e2005-04-16 15:20:36 -07006494 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006495 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006496 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006497#ifdef CONFIG_SND_HDA_POWER_SAVE
6498 if (!spec->loopback.amplist)
6499 spec->loopback.amplist = alc260_loopbacks;
6500#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006501 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006502
6503 return 0;
6504}
6505
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006506
Linus Torvalds1da177e2005-04-16 15:20:36 -07006507/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006508 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006509 *
6510 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6511 * configuration. Each pin widget can choose any input DACs and a mixer.
6512 * Each ADC is connected from a mixer of all inputs. This makes possible
6513 * 6-channel independent captures.
6514 *
6515 * In addition, an independent DAC for the multi-playback (not used in this
6516 * driver yet).
6517 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006518#define ALC882_DIGOUT_NID 0x06
6519#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006520#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6521#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6522#define ALC1200_DIGOUT_NID 0x10
6523
Linus Torvalds1da177e2005-04-16 15:20:36 -07006524
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006525static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006526 { 8, NULL }
6527};
6528
Takashi Iwai4953550a2009-06-30 15:28:30 +02006529/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006530static hda_nid_t alc882_dac_nids[4] = {
6531 /* front, rear, clfe, rear_surr */
6532 0x02, 0x03, 0x04, 0x05
6533};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006534#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006535
Takashi Iwai4953550a2009-06-30 15:28:30 +02006536/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006537#define alc882_adc_nids alc880_adc_nids
6538#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006539#define alc883_adc_nids alc882_adc_nids_alt
6540static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6541static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6542#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006543
Takashi Iwaie1406342008-02-11 18:32:32 +01006544static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6545static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006546#define alc883_capsrc_nids alc882_capsrc_nids_alt
6547static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6548#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006549
Linus Torvalds1da177e2005-04-16 15:20:36 -07006550/* input MUX */
6551/* FIXME: should be a matrix-type input source selection */
6552
6553static struct hda_input_mux alc882_capture_source = {
6554 .num_items = 4,
6555 .items = {
6556 { "Mic", 0x0 },
6557 { "Front Mic", 0x1 },
6558 { "Line", 0x2 },
6559 { "CD", 0x4 },
6560 },
6561};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006562
Takashi Iwai4953550a2009-06-30 15:28:30 +02006563#define alc883_capture_source alc882_capture_source
6564
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006565static struct hda_input_mux alc889_capture_source = {
6566 .num_items = 3,
6567 .items = {
6568 { "Front Mic", 0x0 },
6569 { "Mic", 0x3 },
6570 { "Line", 0x2 },
6571 },
6572};
6573
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006574static struct hda_input_mux mb5_capture_source = {
6575 .num_items = 3,
6576 .items = {
6577 { "Mic", 0x1 },
6578 { "Line", 0x2 },
6579 { "CD", 0x4 },
6580 },
6581};
6582
Takashi Iwai4953550a2009-06-30 15:28:30 +02006583static struct hda_input_mux alc883_3stack_6ch_intel = {
6584 .num_items = 4,
6585 .items = {
6586 { "Mic", 0x1 },
6587 { "Front Mic", 0x0 },
6588 { "Line", 0x2 },
6589 { "CD", 0x4 },
6590 },
6591};
6592
6593static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6594 .num_items = 2,
6595 .items = {
6596 { "Mic", 0x1 },
6597 { "Line", 0x2 },
6598 },
6599};
6600
6601static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6602 .num_items = 4,
6603 .items = {
6604 { "Mic", 0x0 },
6605 { "iMic", 0x1 },
6606 { "Line", 0x2 },
6607 { "CD", 0x4 },
6608 },
6609};
6610
6611static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6612 .num_items = 2,
6613 .items = {
6614 { "Mic", 0x0 },
6615 { "Int Mic", 0x1 },
6616 },
6617};
6618
6619static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6620 .num_items = 3,
6621 .items = {
6622 { "Mic", 0x0 },
6623 { "Front Mic", 0x1 },
6624 { "Line", 0x4 },
6625 },
6626};
6627
6628static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6629 .num_items = 2,
6630 .items = {
6631 { "Mic", 0x0 },
6632 { "Line", 0x2 },
6633 },
6634};
6635
6636static struct hda_input_mux alc889A_mb31_capture_source = {
6637 .num_items = 2,
6638 .items = {
6639 { "Mic", 0x0 },
6640 /* Front Mic (0x01) unused */
6641 { "Line", 0x2 },
6642 /* Line 2 (0x03) unused */
6643 /* CD (0x04) unsused? */
6644 },
6645};
6646
6647/*
6648 * 2ch mode
6649 */
6650static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6651 { 2, NULL }
6652};
6653
Kailang Yangdf694da2005-12-05 19:42:22 +01006654/*
Kailang Yang272a5272007-05-14 11:00:38 +02006655 * 2ch mode
6656 */
6657static struct hda_verb alc882_3ST_ch2_init[] = {
6658 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6659 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6660 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6661 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6662 { } /* end */
6663};
6664
6665/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006666 * 4ch mode
6667 */
6668static struct hda_verb alc882_3ST_ch4_init[] = {
6669 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6670 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6671 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6672 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6673 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6674 { } /* end */
6675};
6676
6677/*
Kailang Yang272a5272007-05-14 11:00:38 +02006678 * 6ch mode
6679 */
6680static struct hda_verb alc882_3ST_ch6_init[] = {
6681 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6682 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6683 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6684 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6685 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6686 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6687 { } /* end */
6688};
6689
Takashi Iwai4953550a2009-06-30 15:28:30 +02006690static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006691 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006692 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006693 { 6, alc882_3ST_ch6_init },
6694};
6695
Takashi Iwai4953550a2009-06-30 15:28:30 +02006696#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6697
Kailang Yang272a5272007-05-14 11:00:38 +02006698/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04306699 * 2ch mode
6700 */
6701static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6702 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6703 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6704 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6705 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6706 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6707 { } /* end */
6708};
6709
6710/*
6711 * 4ch mode
6712 */
6713static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
6714 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6715 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6716 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6717 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6718 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6719 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6720 { } /* end */
6721};
6722
6723/*
6724 * 6ch mode
6725 */
6726static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
6727 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6728 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6729 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6730 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6731 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6732 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6733 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6734 { } /* end */
6735};
6736
6737static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
6738 { 2, alc883_3ST_ch2_clevo_init },
6739 { 4, alc883_3ST_ch4_clevo_init },
6740 { 6, alc883_3ST_ch6_clevo_init },
6741};
6742
6743
6744/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006745 * 6ch mode
6746 */
6747static struct hda_verb alc882_sixstack_ch6_init[] = {
6748 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6749 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6750 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6751 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6752 { } /* end */
6753};
6754
6755/*
6756 * 8ch mode
6757 */
6758static struct hda_verb alc882_sixstack_ch8_init[] = {
6759 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6760 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6761 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6762 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6763 { } /* end */
6764};
6765
6766static struct hda_channel_mode alc882_sixstack_modes[2] = {
6767 { 6, alc882_sixstack_ch6_init },
6768 { 8, alc882_sixstack_ch8_init },
6769};
6770
Takashi Iwai87350ad2007-08-16 18:19:38 +02006771/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006772 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006773 */
6774
6775/*
6776 * 2ch mode
6777 */
6778static struct hda_verb alc885_mbp_ch2_init[] = {
6779 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6780 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6781 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6782 { } /* end */
6783};
6784
6785/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006786 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02006787 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006788static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006789 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6790 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6791 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6792 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6793 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6794 { } /* end */
6795};
6796
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006797static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006798 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006799 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006800};
6801
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006802/*
6803 * 2ch
6804 * Speakers/Woofer/HP = Front
6805 * LineIn = Input
6806 */
6807static struct hda_verb alc885_mb5_ch2_init[] = {
6808 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6809 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6810 { } /* end */
6811};
6812
6813/*
6814 * 6ch mode
6815 * Speakers/HP = Front
6816 * Woofer = LFE
6817 * LineIn = Surround
6818 */
6819static struct hda_verb alc885_mb5_ch6_init[] = {
6820 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6821 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6822 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6823 { } /* end */
6824};
6825
6826static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6827 { 2, alc885_mb5_ch2_init },
6828 { 6, alc885_mb5_ch6_init },
6829};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006830
Takashi Iwai4953550a2009-06-30 15:28:30 +02006831
6832/*
6833 * 2ch mode
6834 */
6835static struct hda_verb alc883_4ST_ch2_init[] = {
6836 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6837 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6838 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6839 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6840 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6841 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6842 { } /* end */
6843};
6844
6845/*
6846 * 4ch mode
6847 */
6848static struct hda_verb alc883_4ST_ch4_init[] = {
6849 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6850 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6851 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6852 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6853 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6854 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6855 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6856 { } /* end */
6857};
6858
6859/*
6860 * 6ch mode
6861 */
6862static struct hda_verb alc883_4ST_ch6_init[] = {
6863 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6864 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6865 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6866 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6867 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6868 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6869 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6870 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6871 { } /* end */
6872};
6873
6874/*
6875 * 8ch mode
6876 */
6877static struct hda_verb alc883_4ST_ch8_init[] = {
6878 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6879 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6880 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6881 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6882 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6883 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6884 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6885 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6886 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6887 { } /* end */
6888};
6889
6890static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6891 { 2, alc883_4ST_ch2_init },
6892 { 4, alc883_4ST_ch4_init },
6893 { 6, alc883_4ST_ch6_init },
6894 { 8, alc883_4ST_ch8_init },
6895};
6896
6897
6898/*
6899 * 2ch mode
6900 */
6901static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6902 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6903 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6904 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6905 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6906 { } /* end */
6907};
6908
6909/*
6910 * 4ch mode
6911 */
6912static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6913 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6914 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6915 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6916 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6917 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6918 { } /* end */
6919};
6920
6921/*
6922 * 6ch mode
6923 */
6924static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6925 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6926 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6927 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6928 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6929 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6930 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6931 { } /* end */
6932};
6933
6934static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6935 { 2, alc883_3ST_ch2_intel_init },
6936 { 4, alc883_3ST_ch4_intel_init },
6937 { 6, alc883_3ST_ch6_intel_init },
6938};
6939
6940/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006941 * 2ch mode
6942 */
6943static struct hda_verb alc889_ch2_intel_init[] = {
6944 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6945 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
6946 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
6947 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
6948 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6949 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6950 { } /* end */
6951};
6952
6953/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006954 * 6ch mode
6955 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006956static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006957 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6958 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6959 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6960 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6961 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006962 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6963 { } /* end */
6964};
6965
6966/*
6967 * 8ch mode
6968 */
6969static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006970 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6971 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6972 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6973 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6974 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006975 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6976 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006977 { } /* end */
6978};
6979
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006980static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
6981 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006982 { 6, alc889_ch6_intel_init },
6983 { 8, alc889_ch8_intel_init },
6984};
6985
6986/*
6987 * 6ch mode
6988 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006989static struct hda_verb alc883_sixstack_ch6_init[] = {
6990 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6991 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6992 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6993 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6994 { } /* end */
6995};
6996
6997/*
6998 * 8ch mode
6999 */
7000static struct hda_verb alc883_sixstack_ch8_init[] = {
7001 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7002 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7003 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7004 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7005 { } /* end */
7006};
7007
7008static struct hda_channel_mode alc883_sixstack_modes[2] = {
7009 { 6, alc883_sixstack_ch6_init },
7010 { 8, alc883_sixstack_ch8_init },
7011};
7012
7013
Linus Torvalds1da177e2005-04-16 15:20:36 -07007014/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7015 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7016 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007017static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007018 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007019 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007020 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007021 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007022 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7023 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007024 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7025 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007026 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007027 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007028 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7029 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7030 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7031 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7032 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7033 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007034 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007035 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7036 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007037 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007038 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007039 { } /* end */
7040};
7041
Takashi Iwai87350ad2007-08-16 18:19:38 +02007042static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007043 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7044 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7045 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7046 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7047 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007048 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7049 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007050 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7051 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007052 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007053 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7054 { } /* end */
7055};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007056
7057static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007058 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7059 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7060 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7061 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7062 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7063 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7064 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7065 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007066 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7067 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7068 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7069 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7070 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7071 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7072 { } /* end */
7073};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007074
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007075static struct snd_kcontrol_new alc885_imac91_mixer[] = {
7076 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7077 HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
7078 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
7079 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7080 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7081 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7082 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7083 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7084 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7085 { } /* end */
7086};
7087
7088
Kailang Yangbdd148a2007-05-08 15:19:08 +02007089static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7090 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7091 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7092 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7093 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7094 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7095 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7096 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7097 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7098 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007099 { } /* end */
7100};
7101
Kailang Yang272a5272007-05-14 11:00:38 +02007102static struct snd_kcontrol_new alc882_targa_mixer[] = {
7103 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7104 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7105 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7106 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7107 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7108 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7109 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7110 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7111 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007112 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007113 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7114 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007115 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007116 { } /* end */
7117};
7118
7119/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7120 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7121 */
7122static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7123 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7124 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7125 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7126 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7127 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7128 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7129 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7130 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7131 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7132 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7133 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7134 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007135 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007136 { } /* end */
7137};
7138
Takashi Iwai914759b2007-09-06 14:52:04 +02007139static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7140 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7141 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7142 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7143 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7144 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7145 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7146 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7147 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7148 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7149 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007150 { } /* end */
7151};
7152
Kailang Yangdf694da2005-12-05 19:42:22 +01007153static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7154 {
7155 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7156 .name = "Channel Mode",
7157 .info = alc_ch_mode_info,
7158 .get = alc_ch_mode_get,
7159 .put = alc_ch_mode_put,
7160 },
7161 { } /* end */
7162};
7163
Takashi Iwai4953550a2009-06-30 15:28:30 +02007164static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007165 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007166 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7167 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7168 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007169 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007170 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7171 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7172 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007173 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007174 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7175 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7176 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007177 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007178 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7179 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7180 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007181
Takashi Iwaicb638122009-07-03 10:56:10 +02007182 /* mute analog input loopbacks */
7183 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7184 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7185 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7186 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7187 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7188
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007189 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007190 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007191 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007192 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007193 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007194 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007195 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007196 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007197 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007198 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007199 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007200 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007201 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007202 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007203 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007204 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007205 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007206 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007207 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7208 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007209 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007210 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7211 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007212 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007213 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7214 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7215 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7216 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7217 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007218 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007219 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007220
7221 /* FIXME: use matrix-type input source selection */
7222 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007223 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007224 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7225 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7226 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7227 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007228 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007229 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7230 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7231 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7232 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007233 /* ADC2: mute amp left and right */
7234 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007235 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007236 /* ADC3: mute amp left and right */
7237 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007238 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007239
7240 { }
7241};
7242
Takashi Iwai4953550a2009-06-30 15:28:30 +02007243static struct hda_verb alc882_adc1_init_verbs[] = {
7244 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7245 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7246 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7247 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7248 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7249 /* ADC1: mute amp left and right */
7250 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7251 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7252 { }
7253};
7254
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007255static struct hda_verb alc882_eapd_verbs[] = {
7256 /* change to EAPD mode */
7257 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007258 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007259 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007260};
7261
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007262static struct hda_verb alc889_eapd_verbs[] = {
7263 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7264 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7265 { }
7266};
7267
Wu Fengguang6732bd02009-07-30 09:19:14 +02007268static struct hda_verb alc_hp15_unsol_verbs[] = {
7269 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7270 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7271 {}
7272};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007273
7274static struct hda_verb alc885_init_verbs[] = {
7275 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7276 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7277 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7278 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7279 /* Rear mixer */
7280 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7281 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7282 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7283 /* CLFE mixer */
7284 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7285 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7286 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7287 /* Side mixer */
7288 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7289 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7290 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7291
7292 /* mute analog input loopbacks */
7293 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7294 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7295 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7296
7297 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007298 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007299 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7300 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7301 /* Front Pin: output 0 (0x0c) */
7302 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7303 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7304 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7305 /* Rear Pin: output 1 (0x0d) */
7306 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7307 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7308 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7309 /* CLFE Pin: output 2 (0x0e) */
7310 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7311 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7312 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7313 /* Side Pin: output 3 (0x0f) */
7314 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7315 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7316 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7317 /* Mic (rear) pin: input vref at 80% */
7318 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7319 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7320 /* Front Mic pin: input vref at 80% */
7321 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7322 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7323 /* Line In pin: input */
7324 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7325 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7326
7327 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7328 /* Input mixer1 */
7329 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7330 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7331 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7332 /* Input mixer2 */
7333 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7334 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7335 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7336 /* Input mixer3 */
7337 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7338 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7339 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7340 /* ADC2: mute amp left and right */
7341 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7342 /* ADC3: mute amp left and right */
7343 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7344
7345 { }
7346};
7347
7348static struct hda_verb alc885_init_input_verbs[] = {
7349 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7350 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7351 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7352 { }
7353};
7354
7355
7356/* Unmute Selector 24h and set the default input to front mic */
7357static struct hda_verb alc889_init_input_verbs[] = {
7358 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7359 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7360 { }
7361};
7362
7363
Takashi Iwai4953550a2009-06-30 15:28:30 +02007364#define alc883_init_verbs alc882_base_init_verbs
7365
Tobin Davis9102cd12006-12-15 10:02:12 +01007366/* Mac Pro test */
7367static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7368 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7369 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7370 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7371 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7372 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007373 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007374 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7375 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007376 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007377 { } /* end */
7378};
7379
7380static struct hda_verb alc882_macpro_init_verbs[] = {
7381 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7382 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7383 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7384 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7385 /* Front Pin: output 0 (0x0c) */
7386 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7387 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7388 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7389 /* Front Mic pin: input vref at 80% */
7390 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7391 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7392 /* Speaker: output */
7393 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7394 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7395 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7396 /* Headphone output (output 0 - 0x0c) */
7397 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7398 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7399 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7400
7401 /* FIXME: use matrix-type input source selection */
7402 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7403 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7404 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7405 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7406 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7407 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7408 /* Input mixer2 */
7409 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7410 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7411 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7412 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7413 /* Input mixer3 */
7414 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7415 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7416 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7417 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7418 /* ADC1: mute amp left and right */
7419 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7420 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7421 /* ADC2: mute amp left and right */
7422 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7423 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7424 /* ADC3: mute amp left and right */
7425 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7426 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7427
7428 { }
7429};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007430
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007431/* Macbook 5,1 */
7432static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007433 /* DACs */
7434 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7435 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7436 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7437 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007438 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007439 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7440 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7441 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007442 /* Surround mixer */
7443 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7444 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7445 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7446 /* LFE mixer */
7447 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7448 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7449 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7450 /* HP mixer */
7451 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7452 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7453 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7454 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007455 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7456 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007457 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7458 /* LFE Pin (0x0e) */
7459 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7460 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7461 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7462 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007463 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7464 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007465 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007466 /* Front Mic pin: input vref at 80% */
7467 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7468 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7469 /* Line In pin */
7470 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7471 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7472
7473 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7474 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7475 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7476 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7477 { }
7478};
7479
Takashi Iwai87350ad2007-08-16 18:19:38 +02007480/* Macbook Pro rev3 */
7481static struct hda_verb alc885_mbp3_init_verbs[] = {
7482 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7483 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7484 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7485 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7486 /* Rear mixer */
7487 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7488 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7489 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007490 /* HP mixer */
7491 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7492 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7493 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007494 /* Front Pin: output 0 (0x0c) */
7495 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7496 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7497 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007498 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007499 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007500 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7501 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007502 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7503 /* Mic (rear) pin: input vref at 80% */
7504 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7505 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7506 /* Front Mic pin: input vref at 80% */
7507 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7508 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7509 /* Line In pin: use output 1 when in LineOut mode */
7510 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7511 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7512 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7513
7514 /* FIXME: use matrix-type input source selection */
7515 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7516 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7517 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7518 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7519 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7520 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7521 /* Input mixer2 */
7522 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7523 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7524 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7525 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7526 /* Input mixer3 */
7527 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7528 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7529 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7530 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7531 /* ADC1: mute amp left and right */
7532 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7533 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7534 /* ADC2: mute amp left and right */
7535 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7536 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7537 /* ADC3: mute amp left and right */
7538 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7539 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7540
7541 { }
7542};
7543
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007544/* iMac 9,1 */
7545static struct hda_verb alc885_imac91_init_verbs[] = {
7546 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
7547 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7548 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7549 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7550 /* Rear mixer */
7551 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7552 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7553 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7554 /* HP Pin: output 0 (0x0c) */
7555 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7556 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7557 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7558 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7559 /* Internal Speakers: output 0 (0x0d) */
7560 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7561 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7562 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7563 /* Mic (rear) pin: input vref at 80% */
7564 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7565 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7566 /* Front Mic pin: input vref at 80% */
7567 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7568 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7569 /* Line In pin: use output 1 when in LineOut mode */
7570 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7571 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7572 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7573
7574 /* FIXME: use matrix-type input source selection */
7575 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7576 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7577 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7578 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7579 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7580 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7581 /* Input mixer2 */
7582 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7583 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7584 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7585 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7586 /* Input mixer3 */
7587 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7588 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7589 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7590 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7591 /* ADC1: mute amp left and right */
7592 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7593 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7594 /* ADC2: mute amp left and right */
7595 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7596 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7597 /* ADC3: mute amp left and right */
7598 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7599 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7600
7601 { }
7602};
7603
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007604/* iMac 24 mixer. */
7605static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7606 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7607 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7608 { } /* end */
7609};
7610
7611/* iMac 24 init verbs. */
7612static struct hda_verb alc885_imac24_init_verbs[] = {
7613 /* Internal speakers: output 0 (0x0c) */
7614 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7615 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7616 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7617 /* Internal speakers: output 0 (0x0c) */
7618 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7619 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7620 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7621 /* Headphone: output 0 (0x0c) */
7622 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7623 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7624 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7625 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7626 /* Front Mic: input vref at 80% */
7627 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7628 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7629 { }
7630};
7631
7632/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007633static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007634{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007635 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007636
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007637 spec->autocfg.hp_pins[0] = 0x14;
7638 spec->autocfg.speaker_pins[0] = 0x18;
7639 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007640}
7641
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007642static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007643{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007644 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007645
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007646 spec->autocfg.hp_pins[0] = 0x15;
7647 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02007648}
7649
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007650static void alc885_imac91_automute(struct hda_codec *codec)
7651{
7652 unsigned int present;
7653
7654 present = snd_hda_codec_read(codec, 0x14, 0,
7655 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7656 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7657 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7658 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
7659 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7660
7661}
7662
7663static void alc885_imac91_unsol_event(struct hda_codec *codec,
7664 unsigned int res)
7665{
7666 /* Headphone insertion or removal. */
7667 if ((res >> 26) == ALC880_HP_EVENT)
7668 alc885_imac91_automute(codec);
7669}
Takashi Iwai87350ad2007-08-16 18:19:38 +02007670
Kailang Yang272a5272007-05-14 11:00:38 +02007671static struct hda_verb alc882_targa_verbs[] = {
7672 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7673 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7674
7675 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7676 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007677
Kailang Yang272a5272007-05-14 11:00:38 +02007678 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7679 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7680 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7681
7682 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007683 { } /* end */
7684};
7685
7686/* toggle speaker-output according to the hp-jack state */
7687static void alc882_targa_automute(struct hda_codec *codec)
7688{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007689 struct alc_spec *spec = codec->spec;
7690 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007691 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007692 spec->jack_present ? 1 : 3);
7693}
7694
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007695static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007696{
7697 struct alc_spec *spec = codec->spec;
7698
7699 spec->autocfg.hp_pins[0] = 0x14;
7700 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02007701}
7702
7703static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7704{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007705 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007706 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007707}
7708
7709static struct hda_verb alc882_asus_a7j_verbs[] = {
7710 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7711 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7712
7713 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7714 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7715 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007716
Kailang Yang272a5272007-05-14 11:00:38 +02007717 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7718 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7719 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7720
7721 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7722 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7723 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7724 { } /* end */
7725};
7726
Takashi Iwai914759b2007-09-06 14:52:04 +02007727static struct hda_verb alc882_asus_a7m_verbs[] = {
7728 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7729 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7730
7731 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7732 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7733 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007734
Takashi Iwai914759b2007-09-06 14:52:04 +02007735 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7736 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7737 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7738
7739 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7740 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7741 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7742 { } /* end */
7743};
7744
Tobin Davis9102cd12006-12-15 10:02:12 +01007745static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7746{
7747 unsigned int gpiostate, gpiomask, gpiodir;
7748
7749 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7750 AC_VERB_GET_GPIO_DATA, 0);
7751
7752 if (!muted)
7753 gpiostate |= (1 << pin);
7754 else
7755 gpiostate &= ~(1 << pin);
7756
7757 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7758 AC_VERB_GET_GPIO_MASK, 0);
7759 gpiomask |= (1 << pin);
7760
7761 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7762 AC_VERB_GET_GPIO_DIRECTION, 0);
7763 gpiodir |= (1 << pin);
7764
7765
7766 snd_hda_codec_write(codec, codec->afg, 0,
7767 AC_VERB_SET_GPIO_MASK, gpiomask);
7768 snd_hda_codec_write(codec, codec->afg, 0,
7769 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7770
7771 msleep(1);
7772
7773 snd_hda_codec_write(codec, codec->afg, 0,
7774 AC_VERB_SET_GPIO_DATA, gpiostate);
7775}
7776
Takashi Iwai7debbe52007-08-16 15:01:03 +02007777/* set up GPIO at initialization */
7778static void alc885_macpro_init_hook(struct hda_codec *codec)
7779{
7780 alc882_gpio_mute(codec, 0, 0);
7781 alc882_gpio_mute(codec, 1, 0);
7782}
7783
7784/* set up GPIO and update auto-muting at initialization */
7785static void alc885_imac24_init_hook(struct hda_codec *codec)
7786{
7787 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007788 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007789}
7790
Kailang Yangdf694da2005-12-05 19:42:22 +01007791/*
7792 * generic initialization of ADC, input mixers and output mixers
7793 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007794static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007795 /*
7796 * Unmute ADC0-2 and set the default input to mic-in
7797 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007798 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7799 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7800 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7801 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7802
Takashi Iwaicb53c622007-08-10 17:21:45 +02007803 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007804 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007805 * Note: PASD motherboards uses the Line In 2 as the input for
7806 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007807 */
7808 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007809 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7810 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7811 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7812 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7813 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007814
7815 /*
7816 * Set up output mixers (0x0c - 0x0f)
7817 */
7818 /* set vol=0 to output mixers */
7819 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7820 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7821 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7822 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7823 /* set up input amps for analog loopback */
7824 /* Amp Indices: DAC = 0, mixer = 1 */
7825 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7826 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7827 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7828 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7829 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7830 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7831 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7832 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7833 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7834 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7835
7836 /* FIXME: use matrix-type input source selection */
7837 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01007838 /* Input mixer2 */
7839 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7840 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7841 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7842 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7843 /* Input mixer3 */
7844 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7845 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7846 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7847 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7848
7849 { }
7850};
7851
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007852/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7853static struct hda_verb alc889A_mb31_ch2_init[] = {
7854 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7855 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7856 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7857 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7858 { } /* end */
7859};
7860
7861/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7862static struct hda_verb alc889A_mb31_ch4_init[] = {
7863 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7864 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7865 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7866 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7867 { } /* end */
7868};
7869
7870/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7871static struct hda_verb alc889A_mb31_ch5_init[] = {
7872 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7873 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7874 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7875 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7876 { } /* end */
7877};
7878
7879/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7880static struct hda_verb alc889A_mb31_ch6_init[] = {
7881 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7882 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7883 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7884 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7885 { } /* end */
7886};
7887
7888static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7889 { 2, alc889A_mb31_ch2_init },
7890 { 4, alc889A_mb31_ch4_init },
7891 { 5, alc889A_mb31_ch5_init },
7892 { 6, alc889A_mb31_ch6_init },
7893};
7894
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007895static struct hda_verb alc883_medion_eapd_verbs[] = {
7896 /* eanable EAPD on medion laptop */
7897 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7898 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7899 { }
7900};
7901
Takashi Iwai4953550a2009-06-30 15:28:30 +02007902#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007903
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007904static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7905 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7906 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7907 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7908 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7909 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7910 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7911 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7912 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7913 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7914 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7915 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7916 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7917 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007918 { } /* end */
7919};
7920
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007921static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007922 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7923 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7924 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7925 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7926 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7927 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7928 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7929 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7930 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7931 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007932 { } /* end */
7933};
7934
Jiang zhefb97dc62008-03-06 11:07:11 +01007935static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7936 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7937 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7938 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7939 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7940 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7941 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7942 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7943 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7944 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7945 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007946 { } /* end */
7947};
7948
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007949static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7950 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7951 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7952 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7953 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7954 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7955 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7956 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7957 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007958 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007959 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7960 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007961 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007962 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007963 { } /* end */
7964};
7965
7966static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7967 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7968 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7969 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7970 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7971 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7972 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7973 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7974 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7975 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7976 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7977 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7978 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7979 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7980 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007981 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007982 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7983 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007984 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007985 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007986 { } /* end */
7987};
7988
Jiang zhe17bba1b2008-06-04 12:11:07 +02007989static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7990 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7991 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7992 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7993 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7994 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7995 HDA_OUTPUT),
7996 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7997 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7998 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7999 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8000 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8001 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8002 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8003 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8004 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8005 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8006 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8007 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8008 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8009 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008010 { } /* end */
8011};
8012
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008013static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8014 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8015 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8016 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8017 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8018 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8019 HDA_OUTPUT),
8020 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8021 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8022 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8023 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8024 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8025 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8026 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8027 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8028 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8029 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8030 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8031 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8032 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8033 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8034 { } /* end */
8035};
8036
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008037static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008038 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008039 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008040 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008041 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008042 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8043 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008044 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8045 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008046 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8047 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8048 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8049 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8050 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8051 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008052 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008053 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8054 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008055 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008056 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008057 { } /* end */
8058};
8059
Sasha Alexandrc2592492009-06-16 14:52:54 -04008060static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008061 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008062 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008063 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008064 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008065 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8066 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8067 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8068 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8069 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8070 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8071 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8072 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8073 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8074 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8075 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008076 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008077 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008078 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008079};
Kailang Yangccc656c2006-10-17 12:32:26 +02008080
Sasha Alexandrc2592492009-06-16 14:52:54 -04008081static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008082 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008083 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008084 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008085 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008086 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8087 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8088 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008089 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008090 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008091 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8092 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8093 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008094 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008095};
Kailang Yangccc656c2006-10-17 12:32:26 +02008096
Takashi Iwaib99dba32009-09-17 18:23:00 +02008097static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8098 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8099 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8100 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8101 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8102 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8103 { } /* end */
8104};
8105
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008106static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8107 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8108 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008109 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8110 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008111 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8112 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8113 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8114 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008115 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008116};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008117
Kailang Yang272a5272007-05-14 11:00:38 +02008118static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8119 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8120 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8121 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8122 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8123 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8124 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8125 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8126 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8127 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008128 { } /* end */
8129};
8130
8131static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8132 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8133 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8134 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8135 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8136 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8137 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8138 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8139 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8140 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008141 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008142};
Kailang Yang272a5272007-05-14 11:00:38 +02008143
Tobin Davis2880a862007-08-07 11:50:26 +02008144static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008145 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8146 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008147 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008148 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8149 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008150 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8151 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8152 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008153 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008154};
Tobin Davis2880a862007-08-07 11:50:26 +02008155
Tony Vroond2fd4b02009-06-21 00:40:10 +01008156static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8157 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8158 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8159 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8160 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008161 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8162 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008163 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8164 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8165 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8166 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8167 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8168 { } /* end */
8169};
8170
Kailang Yange2757d52008-08-26 13:17:46 +02008171static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8172 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8173 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8174 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8175 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8176 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8177 0x0d, 1, 0x0, HDA_OUTPUT),
8178 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8179 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8180 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8181 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8182 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008183 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8184 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8185 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8186 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8187 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8188 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8189 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8190 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8191 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8192 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008193 { } /* end */
8194};
8195
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008196static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8197 /* Output mixers */
8198 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8199 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8200 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8201 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8202 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8203 HDA_OUTPUT),
8204 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8205 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8206 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8207 /* Output switches */
8208 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8209 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8210 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8211 /* Boost mixers */
8212 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8213 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8214 /* Input mixers */
8215 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8216 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8217 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8218 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8219 { } /* end */
8220};
8221
Guido Günther3e1647c2009-06-05 00:47:26 +02008222static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8223 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8224 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8225 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8226 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8227 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8228 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8229 { } /* end */
8230};
8231
Kailang Yange2757d52008-08-26 13:17:46 +02008232static struct hda_bind_ctls alc883_bind_cap_vol = {
8233 .ops = &snd_hda_bind_vol,
8234 .values = {
8235 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8236 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8237 0
8238 },
8239};
8240
8241static struct hda_bind_ctls alc883_bind_cap_switch = {
8242 .ops = &snd_hda_bind_sw,
8243 .values = {
8244 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8245 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8246 0
8247 },
8248};
8249
8250static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8251 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8252 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8253 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8254 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8255 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8256 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),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008259 { } /* end */
8260};
8261
8262static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008263 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8264 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8265 {
8266 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8267 /* .name = "Capture Source", */
8268 .name = "Input Source",
8269 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008270 .info = alc_mux_enum_info,
8271 .get = alc_mux_enum_get,
8272 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008273 },
8274 { } /* end */
8275};
8276
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008277static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8278 {
8279 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8280 .name = "Channel Mode",
8281 .info = alc_ch_mode_info,
8282 .get = alc_ch_mode_get,
8283 .put = alc_ch_mode_put,
8284 },
8285 { } /* end */
8286};
8287
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008288/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008289static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008290{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008291 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008292
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008293 spec->autocfg.hp_pins[0] = 0x15;
8294 spec->autocfg.speaker_pins[0] = 0x14;
8295 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008296}
8297
8298/* auto-toggle front mic */
8299/*
8300static void alc883_mitac_mic_automute(struct hda_codec *codec)
8301{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008302 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008303
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008304 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8305}
8306*/
8307
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008308static struct hda_verb alc883_mitac_verbs[] = {
8309 /* HP */
8310 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8311 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8312 /* Subwoofer */
8313 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8314 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8315
8316 /* enable unsolicited event */
8317 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8318 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8319
8320 { } /* end */
8321};
8322
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308323static struct hda_verb alc883_clevo_m540r_verbs[] = {
8324 /* HP */
8325 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8326 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8327 /* Int speaker */
8328 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8329
8330 /* enable unsolicited event */
8331 /*
8332 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8333 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8334 */
8335
8336 { } /* end */
8337};
8338
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008339static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008340 /* HP */
8341 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8342 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8343 /* Int speaker */
8344 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8345 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8346
8347 /* enable unsolicited event */
8348 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008349 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008350
8351 { } /* end */
8352};
8353
Jiang zhefb97dc62008-03-06 11:07:11 +01008354static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8355 /* HP */
8356 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8357 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8358 /* Subwoofer */
8359 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8360 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8361
8362 /* enable unsolicited event */
8363 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8364
8365 { } /* end */
8366};
8367
Sasha Alexandrc2592492009-06-16 14:52:54 -04008368static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008369 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8370 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8371
8372 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8373 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008374
David Heidelberger64a8be72009-06-08 16:15:18 +02008375/* Connect Line-Out side jack (SPDIF) to Side */
8376 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8377 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8378 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8379/* Connect Mic jack to CLFE */
8380 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8381 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8382 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8383/* Connect Line-in jack to Surround */
8384 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8385 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8386 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8387/* Connect HP out jack to Front */
8388 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8389 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8390 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008391
8392 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008393
8394 { } /* end */
8395};
8396
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008397static struct hda_verb alc883_lenovo_101e_verbs[] = {
8398 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8399 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8400 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8401 { } /* end */
8402};
8403
Kailang Yang272a5272007-05-14 11:00:38 +02008404static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8405 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8406 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8407 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8408 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8409 { } /* end */
8410};
8411
8412static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8413 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8414 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8415 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8416 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8417 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8418 { } /* end */
8419};
8420
Kailang Yang189609a2007-08-20 11:31:23 +02008421static struct hda_verb alc883_haier_w66_verbs[] = {
8422 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8423 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8424
8425 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8426
8427 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8428 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8429 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8430 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8431 { } /* end */
8432};
8433
Kailang Yange2757d52008-08-26 13:17:46 +02008434static struct hda_verb alc888_lenovo_sky_verbs[] = {
8435 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8436 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8437 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8438 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8439 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8440 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8441 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8442 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8443 { } /* end */
8444};
8445
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008446static struct hda_verb alc888_6st_dell_verbs[] = {
8447 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8448 { }
8449};
8450
Guido Günther3e1647c2009-06-05 00:47:26 +02008451static struct hda_verb alc883_vaiott_verbs[] = {
8452 /* HP */
8453 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8454 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8455
8456 /* enable unsolicited event */
8457 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8458
8459 { } /* end */
8460};
8461
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008462static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008463{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008464 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008465
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008466 spec->autocfg.hp_pins[0] = 0x1b;
8467 spec->autocfg.speaker_pins[0] = 0x14;
8468 spec->autocfg.speaker_pins[1] = 0x16;
8469 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008470}
8471
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008472static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008473 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008474 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8475 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008476 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008477 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008478};
8479
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008480/*
8481 * 2ch mode
8482 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008483static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008484 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8485 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8486 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8487 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008488 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008489};
8490
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008491/*
8492 * 4ch mode
8493 */
8494static struct hda_verb alc888_3st_hp_4ch_init[] = {
8495 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8496 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8497 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8498 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8499 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8500 { } /* end */
8501};
8502
8503/*
8504 * 6ch mode
8505 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008506static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008507 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8508 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008509 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008510 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8511 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008512 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8513 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008514};
8515
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008516static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008517 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008518 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008519 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008520};
8521
Kailang Yang272a5272007-05-14 11:00:38 +02008522/* toggle front-jack and RCA according to the hp-jack state */
8523static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8524{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008525 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02008526
Takashi Iwai47fd8302007-08-10 17:11:07 +02008527 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8528 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8529 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8530 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008531}
8532
8533/* toggle RCA according to the front-jack state */
8534static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8535{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008536 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02008537
Takashi Iwai47fd8302007-08-10 17:11:07 +02008538 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8539 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008540}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008541
Kailang Yang272a5272007-05-14 11:00:38 +02008542static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8543 unsigned int res)
8544{
8545 if ((res >> 26) == ALC880_HP_EVENT)
8546 alc888_lenovo_ms7195_front_automute(codec);
8547 if ((res >> 26) == ALC880_FRONT_EVENT)
8548 alc888_lenovo_ms7195_rca_automute(codec);
8549}
8550
8551static struct hda_verb alc883_medion_md2_verbs[] = {
8552 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8553 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8554
8555 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8556
8557 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8558 { } /* end */
8559};
8560
8561/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008562static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008563{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008564 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008565
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008566 spec->autocfg.hp_pins[0] = 0x14;
8567 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008568}
8569
Kailang Yangccc656c2006-10-17 12:32:26 +02008570/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008571#define alc883_targa_init_hook alc882_targa_init_hook
8572#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008573
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008574static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8575{
8576 unsigned int present;
8577
Takashi Iwaid56757a2009-11-18 08:00:14 +01008578 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008579 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8580 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8581}
8582
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008583static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008584{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008585 struct alc_spec *spec = codec->spec;
8586
8587 spec->autocfg.hp_pins[0] = 0x15;
8588 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008589}
8590
8591static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8592{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008593 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008594 alc883_clevo_m720_mic_automute(codec);
8595}
8596
8597static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008598 unsigned int res)
8599{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008600 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008601 case ALC880_MIC_EVENT:
8602 alc883_clevo_m720_mic_automute(codec);
8603 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008604 default:
8605 alc_automute_amp_unsol_event(codec, res);
8606 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008607 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008608}
8609
Jiang zhefb97dc62008-03-06 11:07:11 +01008610/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008611static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008612{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008613 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008614
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008615 spec->autocfg.hp_pins[0] = 0x14;
8616 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01008617}
8618
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008619static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008620{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008621 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008622
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008623 spec->autocfg.hp_pins[0] = 0x1b;
8624 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02008625}
8626
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008627static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8628{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008629 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008630
Takashi Iwai47fd8302007-08-10 17:11:07 +02008631 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8632 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008633}
8634
8635static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8636{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008637 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008638
Takashi Iwai47fd8302007-08-10 17:11:07 +02008639 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8640 HDA_AMP_MUTE, bits);
8641 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8642 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008643}
8644
8645static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8646 unsigned int res)
8647{
8648 if ((res >> 26) == ALC880_HP_EVENT)
8649 alc883_lenovo_101e_all_automute(codec);
8650 if ((res >> 26) == ALC880_FRONT_EVENT)
8651 alc883_lenovo_101e_ispeaker_automute(codec);
8652}
8653
Takashi Iwai676a9b52007-08-16 15:23:35 +02008654/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008655static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008656{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008657 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008658
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008659 spec->autocfg.hp_pins[0] = 0x14;
8660 spec->autocfg.speaker_pins[0] = 0x15;
8661 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02008662}
8663
Kailang Yangd1a991a2007-08-15 16:21:59 +02008664static struct hda_verb alc883_acer_eapd_verbs[] = {
8665 /* HP Pin: output 0 (0x0c) */
8666 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8667 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8668 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8669 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008670 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8671 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008672 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008673 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8674 /* eanable EAPD on medion laptop */
8675 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8676 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008677 /* enable unsolicited event */
8678 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008679 { }
8680};
8681
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008682static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8683 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8684 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8685 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8686 { } /* end */
8687};
8688
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008689static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008690{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008691 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008692
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008693 spec->autocfg.hp_pins[0] = 0x1b;
8694 spec->autocfg.speaker_pins[0] = 0x14;
8695 spec->autocfg.speaker_pins[1] = 0x15;
8696 spec->autocfg.speaker_pins[2] = 0x16;
8697 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008698}
8699
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008700static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008701{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008702 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008703
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008704 spec->autocfg.hp_pins[0] = 0x1b;
8705 spec->autocfg.speaker_pins[0] = 0x14;
8706 spec->autocfg.speaker_pins[1] = 0x15;
8707 spec->autocfg.speaker_pins[2] = 0x16;
8708 spec->autocfg.speaker_pins[3] = 0x17;
8709 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02008710}
8711
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008712static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02008713{
8714 struct alc_spec *spec = codec->spec;
8715
8716 spec->autocfg.hp_pins[0] = 0x15;
8717 spec->autocfg.speaker_pins[0] = 0x14;
8718 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02008719}
8720
Kailang Yange2757d52008-08-26 13:17:46 +02008721static struct hda_verb alc888_asus_m90v_verbs[] = {
8722 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8723 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8724 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8725 /* enable unsolicited event */
8726 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8727 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8728 { } /* end */
8729};
8730
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008731static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008732{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008733 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008734
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008735 spec->autocfg.hp_pins[0] = 0x1b;
8736 spec->autocfg.speaker_pins[0] = 0x14;
8737 spec->autocfg.speaker_pins[1] = 0x15;
8738 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008739 spec->ext_mic.pin = 0x18;
8740 spec->int_mic.pin = 0x19;
8741 spec->ext_mic.mux_idx = 0;
8742 spec->int_mic.mux_idx = 1;
8743 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02008744}
8745
8746static struct hda_verb alc888_asus_eee1601_verbs[] = {
8747 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8748 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8749 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8750 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8751 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8752 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8753 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8754 /* enable unsolicited event */
8755 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8756 { } /* end */
8757};
8758
Kailang Yange2757d52008-08-26 13:17:46 +02008759static void alc883_eee1601_inithook(struct hda_codec *codec)
8760{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008761 struct alc_spec *spec = codec->spec;
8762
8763 spec->autocfg.hp_pins[0] = 0x14;
8764 spec->autocfg.speaker_pins[0] = 0x1b;
8765 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008766}
8767
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008768static struct hda_verb alc889A_mb31_verbs[] = {
8769 /* Init rear pin (used as headphone output) */
8770 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8771 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8772 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8773 /* Init line pin (used as output in 4ch and 6ch mode) */
8774 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8775 /* Init line 2 pin (used as headphone out by default) */
8776 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8777 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8778 { } /* end */
8779};
8780
8781/* Mute speakers according to the headphone jack state */
8782static void alc889A_mb31_automute(struct hda_codec *codec)
8783{
8784 unsigned int present;
8785
8786 /* Mute only in 2ch or 4ch mode */
8787 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8788 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08008789 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008790 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8791 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8792 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8793 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8794 }
8795}
8796
8797static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8798{
8799 if ((res >> 26) == ALC880_HP_EVENT)
8800 alc889A_mb31_automute(codec);
8801}
8802
Takashi Iwai4953550a2009-06-30 15:28:30 +02008803
Takashi Iwaicb53c622007-08-10 17:21:45 +02008804#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02008805#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02008806#endif
8807
Sasha Alexandrdef319f2009-06-16 16:00:15 -04008808/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008809#define alc882_pcm_analog_playback alc880_pcm_analog_playback
8810#define alc882_pcm_analog_capture alc880_pcm_analog_capture
8811#define alc882_pcm_digital_playback alc880_pcm_digital_playback
8812#define alc882_pcm_digital_capture alc880_pcm_digital_capture
8813
8814static hda_nid_t alc883_slave_dig_outs[] = {
8815 ALC1200_DIGOUT_NID, 0,
8816};
8817
8818static hda_nid_t alc1200_slave_dig_outs[] = {
8819 ALC883_DIGOUT_NID, 0,
8820};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008821
8822/*
8823 * configuration and preset
8824 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008825static const char *alc882_models[ALC882_MODEL_LAST] = {
8826 [ALC882_3ST_DIG] = "3stack-dig",
8827 [ALC882_6ST_DIG] = "6stack-dig",
8828 [ALC882_ARIMA] = "arima",
8829 [ALC882_W2JC] = "w2jc",
8830 [ALC882_TARGA] = "targa",
8831 [ALC882_ASUS_A7J] = "asus-a7j",
8832 [ALC882_ASUS_A7M] = "asus-a7m",
8833 [ALC885_MACPRO] = "macpro",
8834 [ALC885_MB5] = "mb5",
8835 [ALC885_MBP3] = "mbp3",
8836 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008837 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008838 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008839 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8840 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008841 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008842 [ALC883_TARGA_DIG] = "targa-dig",
8843 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02008844 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008845 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008846 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008847 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02008848 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02008849 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008850 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008851 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008852 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008853 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008854 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008855 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8856 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008857 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008858 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008859 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008860 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008861 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308862 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008863 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008864 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008865 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008866 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008867 [ALC889A_INTEL] = "intel-alc889a",
8868 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008869 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008870 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02008871 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008872 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008873};
8874
Takashi Iwai4953550a2009-06-30 15:28:30 +02008875static struct snd_pci_quirk alc882_cfg_tbl[] = {
8876 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8877
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008878 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008879 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008880 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008881 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8882 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008883 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008884 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8885 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008886 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01008887 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02008888 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8889 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02008890 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
8891 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008892 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
8893 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008894 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02008895 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008896 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01008897 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008898 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
8899 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02008900 /* default Acer -- disabled as it causes more problems.
8901 * model=auto should work fine now
8902 */
8903 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008904
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008905 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008906
Tobin Davisfebe3372007-06-12 11:27:46 +02008907 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008908 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8909 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008910 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008911 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008912 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008913
8914 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8915 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8916 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008917 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008918 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8919 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8920 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008921 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008922 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008923 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008924 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008925
8926 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02008927 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008928 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008929 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008930 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8931 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008932 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008933 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008934 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8935
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008936 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8937 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8938 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008939 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01008940 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008941 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008942 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008943 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008944 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8945 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8946 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8947 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8948 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8949 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008950 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008951 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8952 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8953 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02008954 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008955 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8956 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008957 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008958 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008959 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008960 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008961 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04008962 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008963 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008964 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008965
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008966 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008967 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8968 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308969 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008970 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008971 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008972 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008973 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008974 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008975 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008976 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008977 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008978 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008979 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008980 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8981 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008982 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008983 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008984 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008985 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008986 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008987
Jiang zhe17bba1b2008-06-04 12:11:07 +02008988 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8989 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008990 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008991 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
8992 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
8993 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008994 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008995
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008996 {}
8997};
8998
Takashi Iwai4953550a2009-06-30 15:28:30 +02008999/* codec SSID table for Intel Mac */
9000static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9001 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9002 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9003 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9004 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9005 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9006 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9007 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
9008 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9009 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9010 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009011 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009012 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009013 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9014 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009015 */
9016 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009017 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009018 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009019};
9020
Takashi Iwai4953550a2009-06-30 15:28:30 +02009021static struct alc_config_preset alc882_presets[] = {
9022 [ALC882_3ST_DIG] = {
9023 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009024 .init_verbs = { alc882_base_init_verbs,
9025 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009026 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9027 .dac_nids = alc882_dac_nids,
9028 .dig_out_nid = ALC882_DIGOUT_NID,
9029 .dig_in_nid = ALC882_DIGIN_NID,
9030 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9031 .channel_mode = alc882_ch_modes,
9032 .need_dac_fix = 1,
9033 .input_mux = &alc882_capture_source,
9034 },
9035 [ALC882_6ST_DIG] = {
9036 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009037 .init_verbs = { alc882_base_init_verbs,
9038 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009039 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9040 .dac_nids = alc882_dac_nids,
9041 .dig_out_nid = ALC882_DIGOUT_NID,
9042 .dig_in_nid = ALC882_DIGIN_NID,
9043 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9044 .channel_mode = alc882_sixstack_modes,
9045 .input_mux = &alc882_capture_source,
9046 },
9047 [ALC882_ARIMA] = {
9048 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009049 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9050 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009051 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9052 .dac_nids = alc882_dac_nids,
9053 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9054 .channel_mode = alc882_sixstack_modes,
9055 .input_mux = &alc882_capture_source,
9056 },
9057 [ALC882_W2JC] = {
9058 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009059 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9060 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009061 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9062 .dac_nids = alc882_dac_nids,
9063 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9064 .channel_mode = alc880_threestack_modes,
9065 .need_dac_fix = 1,
9066 .input_mux = &alc882_capture_source,
9067 .dig_out_nid = ALC882_DIGOUT_NID,
9068 },
9069 [ALC885_MBP3] = {
9070 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9071 .init_verbs = { alc885_mbp3_init_verbs,
9072 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009073 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009074 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009075 .hp_nid = 0x04,
9076 .channel_mode = alc885_mbp_4ch_modes,
9077 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009078 .input_mux = &alc882_capture_source,
9079 .dig_out_nid = ALC882_DIGOUT_NID,
9080 .dig_in_nid = ALC882_DIGIN_NID,
9081 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009082 .setup = alc885_mbp3_setup,
9083 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009084 },
9085 [ALC885_MB5] = {
9086 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9087 .init_verbs = { alc885_mb5_init_verbs,
9088 alc880_gpio1_init_verbs },
9089 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9090 .dac_nids = alc882_dac_nids,
9091 .channel_mode = alc885_mb5_6ch_modes,
9092 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9093 .input_mux = &mb5_capture_source,
9094 .dig_out_nid = ALC882_DIGOUT_NID,
9095 .dig_in_nid = ALC882_DIGIN_NID,
9096 },
9097 [ALC885_MACPRO] = {
9098 .mixers = { alc882_macpro_mixer },
9099 .init_verbs = { alc882_macpro_init_verbs },
9100 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9101 .dac_nids = alc882_dac_nids,
9102 .dig_out_nid = ALC882_DIGOUT_NID,
9103 .dig_in_nid = ALC882_DIGIN_NID,
9104 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9105 .channel_mode = alc882_ch_modes,
9106 .input_mux = &alc882_capture_source,
9107 .init_hook = alc885_macpro_init_hook,
9108 },
9109 [ALC885_IMAC24] = {
9110 .mixers = { alc885_imac24_mixer },
9111 .init_verbs = { alc885_imac24_init_verbs },
9112 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9113 .dac_nids = alc882_dac_nids,
9114 .dig_out_nid = ALC882_DIGOUT_NID,
9115 .dig_in_nid = ALC882_DIGIN_NID,
9116 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9117 .channel_mode = alc882_ch_modes,
9118 .input_mux = &alc882_capture_source,
9119 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009120 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009121 .init_hook = alc885_imac24_init_hook,
9122 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009123 [ALC885_IMAC91] = {
9124 .mixers = { alc885_imac91_mixer, alc882_chmode_mixer },
9125 .init_verbs = { alc885_imac91_init_verbs,
9126 alc880_gpio1_init_verbs },
9127 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9128 .dac_nids = alc882_dac_nids,
9129 .channel_mode = alc885_mbp_4ch_modes,
9130 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
9131 .input_mux = &alc882_capture_source,
9132 .dig_out_nid = ALC882_DIGOUT_NID,
9133 .dig_in_nid = ALC882_DIGIN_NID,
9134 .unsol_event = alc885_imac91_unsol_event,
9135 .init_hook = alc885_imac91_automute,
9136 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009137 [ALC882_TARGA] = {
9138 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009139 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009140 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009141 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9142 .dac_nids = alc882_dac_nids,
9143 .dig_out_nid = ALC882_DIGOUT_NID,
9144 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9145 .adc_nids = alc882_adc_nids,
9146 .capsrc_nids = alc882_capsrc_nids,
9147 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9148 .channel_mode = alc882_3ST_6ch_modes,
9149 .need_dac_fix = 1,
9150 .input_mux = &alc882_capture_source,
9151 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009152 .setup = alc882_targa_setup,
9153 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009154 },
9155 [ALC882_ASUS_A7J] = {
9156 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009157 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9158 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009159 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9160 .dac_nids = alc882_dac_nids,
9161 .dig_out_nid = ALC882_DIGOUT_NID,
9162 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9163 .adc_nids = alc882_adc_nids,
9164 .capsrc_nids = alc882_capsrc_nids,
9165 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9166 .channel_mode = alc882_3ST_6ch_modes,
9167 .need_dac_fix = 1,
9168 .input_mux = &alc882_capture_source,
9169 },
9170 [ALC882_ASUS_A7M] = {
9171 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009172 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9173 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009174 alc882_asus_a7m_verbs },
9175 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9176 .dac_nids = alc882_dac_nids,
9177 .dig_out_nid = ALC882_DIGOUT_NID,
9178 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9179 .channel_mode = alc880_threestack_modes,
9180 .need_dac_fix = 1,
9181 .input_mux = &alc882_capture_source,
9182 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009183 [ALC883_3ST_2ch_DIG] = {
9184 .mixers = { alc883_3ST_2ch_mixer },
9185 .init_verbs = { alc883_init_verbs },
9186 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9187 .dac_nids = alc883_dac_nids,
9188 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009189 .dig_in_nid = ALC883_DIGIN_NID,
9190 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9191 .channel_mode = alc883_3ST_2ch_modes,
9192 .input_mux = &alc883_capture_source,
9193 },
9194 [ALC883_3ST_6ch_DIG] = {
9195 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9196 .init_verbs = { alc883_init_verbs },
9197 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9198 .dac_nids = alc883_dac_nids,
9199 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009200 .dig_in_nid = ALC883_DIGIN_NID,
9201 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9202 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009203 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009204 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009205 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009206 [ALC883_3ST_6ch] = {
9207 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9208 .init_verbs = { alc883_init_verbs },
9209 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9210 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009211 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9212 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009213 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009214 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009215 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009216 [ALC883_3ST_6ch_INTEL] = {
9217 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9218 .init_verbs = { alc883_init_verbs },
9219 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9220 .dac_nids = alc883_dac_nids,
9221 .dig_out_nid = ALC883_DIGOUT_NID,
9222 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009223 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009224 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9225 .channel_mode = alc883_3ST_6ch_intel_modes,
9226 .need_dac_fix = 1,
9227 .input_mux = &alc883_3stack_6ch_intel,
9228 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009229 [ALC889A_INTEL] = {
9230 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009231 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9232 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009233 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9234 .dac_nids = alc883_dac_nids,
9235 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9236 .adc_nids = alc889_adc_nids,
9237 .dig_out_nid = ALC883_DIGOUT_NID,
9238 .dig_in_nid = ALC883_DIGIN_NID,
9239 .slave_dig_outs = alc883_slave_dig_outs,
9240 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9241 .channel_mode = alc889_8ch_intel_modes,
9242 .capsrc_nids = alc889_capsrc_nids,
9243 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009244 .setup = alc889_automute_setup,
9245 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009246 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009247 .need_dac_fix = 1,
9248 },
9249 [ALC889_INTEL] = {
9250 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9251 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009252 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009253 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9254 .dac_nids = alc883_dac_nids,
9255 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9256 .adc_nids = alc889_adc_nids,
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009257 .capsrc_nids = alc889_capsrc_nids,
9258 .capsrc_nids = alc889_capsrc_nids,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009259 .dig_out_nid = ALC883_DIGOUT_NID,
9260 .dig_in_nid = ALC883_DIGIN_NID,
9261 .slave_dig_outs = alc883_slave_dig_outs,
9262 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9263 .channel_mode = alc889_8ch_intel_modes,
9264 .capsrc_nids = alc889_capsrc_nids,
9265 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009266 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009267 .init_hook = alc889_intel_init_hook,
9268 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009269 .need_dac_fix = 1,
9270 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009271 [ALC883_6ST_DIG] = {
9272 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9273 .init_verbs = { alc883_init_verbs },
9274 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9275 .dac_nids = alc883_dac_nids,
9276 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009277 .dig_in_nid = ALC883_DIGIN_NID,
9278 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9279 .channel_mode = alc883_sixstack_modes,
9280 .input_mux = &alc883_capture_source,
9281 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009282 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009283 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009284 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9285 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009286 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9287 .dac_nids = alc883_dac_nids,
9288 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009289 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9290 .channel_mode = alc883_3ST_6ch_modes,
9291 .need_dac_fix = 1,
9292 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009293 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009294 .setup = alc882_targa_setup,
9295 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009296 },
9297 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009298 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009299 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9300 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009301 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9302 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009303 .adc_nids = alc883_adc_nids_alt,
9304 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009305 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +02009306 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009307 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9308 .channel_mode = alc883_3ST_2ch_modes,
9309 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009310 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009311 .setup = alc882_targa_setup,
9312 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009313 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009314 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009315 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9316 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +02009317 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009318 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009319 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9320 .dac_nids = alc883_dac_nids,
9321 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9322 .adc_nids = alc883_adc_nids_rev,
9323 .capsrc_nids = alc883_capsrc_nids_rev,
9324 .dig_out_nid = ALC883_DIGOUT_NID,
9325 .dig_in_nid = ALC883_DIGIN_NID,
9326 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9327 .channel_mode = alc883_4ST_8ch_modes,
9328 .need_dac_fix = 1,
9329 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009330 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009331 .setup = alc882_targa_setup,
9332 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009333 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009334 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009335 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009336 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9337 * and the headphone jack. Turn this on and rely on the
9338 * standard mute methods whenever the user wants to turn
9339 * these outputs off.
9340 */
9341 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9342 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9343 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009344 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9345 .channel_mode = alc883_3ST_2ch_modes,
9346 .input_mux = &alc883_capture_source,
9347 },
Tobin Davis2880a862007-08-07 11:50:26 +02009348 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009349 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009350 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009351 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9352 .dac_nids = alc883_dac_nids,
9353 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009354 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9355 .channel_mode = alc883_3ST_2ch_modes,
9356 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009357 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009358 .setup = alc883_acer_aspire_setup,
9359 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009360 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009361 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009362 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009363 alc883_chmode_mixer },
9364 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9365 alc888_acer_aspire_4930g_verbs },
9366 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9367 .dac_nids = alc883_dac_nids,
9368 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9369 .adc_nids = alc883_adc_nids_rev,
9370 .capsrc_nids = alc883_capsrc_nids_rev,
9371 .dig_out_nid = ALC883_DIGOUT_NID,
9372 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9373 .channel_mode = alc883_3ST_6ch_modes,
9374 .need_dac_fix = 1,
9375 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009376 ARRAY_SIZE(alc888_2_capture_sources),
9377 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009378 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009379 .setup = alc888_acer_aspire_4930g_setup,
9380 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009381 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009382 [ALC888_ACER_ASPIRE_6530G] = {
9383 .mixers = { alc888_acer_aspire_6530_mixer },
9384 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9385 alc888_acer_aspire_6530g_verbs },
9386 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9387 .dac_nids = alc883_dac_nids,
9388 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9389 .adc_nids = alc883_adc_nids_rev,
9390 .capsrc_nids = alc883_capsrc_nids_rev,
9391 .dig_out_nid = ALC883_DIGOUT_NID,
9392 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9393 .channel_mode = alc883_3ST_2ch_modes,
9394 .num_mux_defs =
9395 ARRAY_SIZE(alc888_2_capture_sources),
9396 .input_mux = alc888_acer_aspire_6530_sources,
9397 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009398 .setup = alc888_acer_aspire_6530g_setup,
9399 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009400 },
Hector Martin3b315d72009-06-02 10:54:19 +02009401 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +01009402 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +02009403 alc883_chmode_mixer },
9404 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +01009405 alc889_acer_aspire_8930g_verbs,
9406 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +02009407 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9408 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009409 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9410 .adc_nids = alc889_adc_nids,
9411 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009412 .dig_out_nid = ALC883_DIGOUT_NID,
9413 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9414 .channel_mode = alc883_3ST_6ch_modes,
9415 .need_dac_fix = 1,
9416 .const_channel_count = 6,
9417 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009418 ARRAY_SIZE(alc889_capture_sources),
9419 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009420 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009421 .setup = alc889_acer_aspire_8930g_setup,
9422 .init_hook = alc_automute_amp,
Hector Martin3b315d72009-06-02 10:54:19 +02009423 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009424 [ALC888_ACER_ASPIRE_7730G] = {
9425 .mixers = { alc883_3ST_6ch_mixer,
9426 alc883_chmode_mixer },
9427 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9428 alc888_acer_aspire_7730G_verbs },
9429 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9430 .dac_nids = alc883_dac_nids,
9431 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9432 .adc_nids = alc883_adc_nids_rev,
9433 .capsrc_nids = alc883_capsrc_nids_rev,
9434 .dig_out_nid = ALC883_DIGOUT_NID,
9435 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9436 .channel_mode = alc883_3ST_6ch_modes,
9437 .need_dac_fix = 1,
9438 .const_channel_count = 6,
9439 .input_mux = &alc883_capture_source,
9440 .unsol_event = alc_automute_amp_unsol_event,
9441 .setup = alc888_acer_aspire_6530g_setup,
9442 .init_hook = alc_automute_amp,
9443 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009444 [ALC883_MEDION] = {
9445 .mixers = { alc883_fivestack_mixer,
9446 alc883_chmode_mixer },
9447 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009448 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009449 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9450 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009451 .adc_nids = alc883_adc_nids_alt,
9452 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009453 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02009454 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9455 .channel_mode = alc883_sixstack_modes,
9456 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009457 },
Kailang Yang272a5272007-05-14 11:00:38 +02009458 [ALC883_MEDION_MD2] = {
9459 .mixers = { alc883_medion_md2_mixer},
9460 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9461 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9462 .dac_nids = alc883_dac_nids,
9463 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009464 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9465 .channel_mode = alc883_3ST_2ch_modes,
9466 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009467 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009468 .setup = alc883_medion_md2_setup,
9469 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009470 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009471 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009472 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009473 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9474 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9475 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009476 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9477 .channel_mode = alc883_3ST_2ch_modes,
9478 .input_mux = &alc883_capture_source,
9479 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309480 [ALC883_CLEVO_M540R] = {
9481 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9482 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9483 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9484 .dac_nids = alc883_dac_nids,
9485 .dig_out_nid = ALC883_DIGOUT_NID,
9486 .dig_in_nid = ALC883_DIGIN_NID,
9487 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9488 .channel_mode = alc883_3ST_6ch_clevo_modes,
9489 .need_dac_fix = 1,
9490 .input_mux = &alc883_capture_source,
9491 /* This machine has the hardware HP auto-muting, thus
9492 * we need no software mute via unsol event
9493 */
9494 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009495 [ALC883_CLEVO_M720] = {
9496 .mixers = { alc883_clevo_m720_mixer },
9497 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009498 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9499 .dac_nids = alc883_dac_nids,
9500 .dig_out_nid = ALC883_DIGOUT_NID,
9501 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9502 .channel_mode = alc883_3ST_2ch_modes,
9503 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009504 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009505 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009506 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009507 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009508 [ALC883_LENOVO_101E_2ch] = {
9509 .mixers = { alc883_lenovo_101e_2ch_mixer},
9510 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9511 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9512 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009513 .adc_nids = alc883_adc_nids_alt,
9514 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009515 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009516 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9517 .channel_mode = alc883_3ST_2ch_modes,
9518 .input_mux = &alc883_lenovo_101e_capture_source,
9519 .unsol_event = alc883_lenovo_101e_unsol_event,
9520 .init_hook = alc883_lenovo_101e_all_automute,
9521 },
Kailang Yang272a5272007-05-14 11:00:38 +02009522 [ALC883_LENOVO_NB0763] = {
9523 .mixers = { alc883_lenovo_nb0763_mixer },
9524 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9525 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9526 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009527 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9528 .channel_mode = alc883_3ST_2ch_modes,
9529 .need_dac_fix = 1,
9530 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009531 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009532 .setup = alc883_medion_md2_setup,
9533 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009534 },
9535 [ALC888_LENOVO_MS7195_DIG] = {
9536 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9537 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9538 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9539 .dac_nids = alc883_dac_nids,
9540 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009541 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9542 .channel_mode = alc883_3ST_6ch_modes,
9543 .need_dac_fix = 1,
9544 .input_mux = &alc883_capture_source,
9545 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9546 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009547 },
9548 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009549 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009550 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9551 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9552 .dac_nids = alc883_dac_nids,
9553 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009554 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9555 .channel_mode = alc883_3ST_2ch_modes,
9556 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009557 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009558 .setup = alc883_haier_w66_setup,
9559 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009560 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009561 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009562 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009563 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009564 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9565 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009566 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9567 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009568 .need_dac_fix = 1,
9569 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009570 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009571 .setup = alc888_3st_hp_setup,
9572 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009573 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009574 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009575 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009576 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9577 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9578 .dac_nids = alc883_dac_nids,
9579 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009580 .dig_in_nid = ALC883_DIGIN_NID,
9581 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9582 .channel_mode = alc883_sixstack_modes,
9583 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009584 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009585 .setup = alc888_6st_dell_setup,
9586 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009587 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009588 [ALC883_MITAC] = {
9589 .mixers = { alc883_mitac_mixer },
9590 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9591 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9592 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009593 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9594 .channel_mode = alc883_3ST_2ch_modes,
9595 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009596 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009597 .setup = alc883_mitac_setup,
9598 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009599 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009600 [ALC883_FUJITSU_PI2515] = {
9601 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9602 .init_verbs = { alc883_init_verbs,
9603 alc883_2ch_fujitsu_pi2515_verbs},
9604 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9605 .dac_nids = alc883_dac_nids,
9606 .dig_out_nid = ALC883_DIGOUT_NID,
9607 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9608 .channel_mode = alc883_3ST_2ch_modes,
9609 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009610 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009611 .setup = alc883_2ch_fujitsu_pi2515_setup,
9612 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +01009613 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009614 [ALC888_FUJITSU_XA3530] = {
9615 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9616 .init_verbs = { alc883_init_verbs,
9617 alc888_fujitsu_xa3530_verbs },
9618 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9619 .dac_nids = alc883_dac_nids,
9620 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9621 .adc_nids = alc883_adc_nids_rev,
9622 .capsrc_nids = alc883_capsrc_nids_rev,
9623 .dig_out_nid = ALC883_DIGOUT_NID,
9624 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9625 .channel_mode = alc888_4ST_8ch_intel_modes,
9626 .num_mux_defs =
9627 ARRAY_SIZE(alc888_2_capture_sources),
9628 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009629 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009630 .setup = alc888_fujitsu_xa3530_setup,
9631 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009632 },
Kailang Yange2757d52008-08-26 13:17:46 +02009633 [ALC888_LENOVO_SKY] = {
9634 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9635 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9636 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9637 .dac_nids = alc883_dac_nids,
9638 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009639 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9640 .channel_mode = alc883_sixstack_modes,
9641 .need_dac_fix = 1,
9642 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009643 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009644 .setup = alc888_lenovo_sky_setup,
9645 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +02009646 },
9647 [ALC888_ASUS_M90V] = {
9648 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9649 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9650 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9651 .dac_nids = alc883_dac_nids,
9652 .dig_out_nid = ALC883_DIGOUT_NID,
9653 .dig_in_nid = ALC883_DIGIN_NID,
9654 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9655 .channel_mode = alc883_3ST_6ch_modes,
9656 .need_dac_fix = 1,
9657 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009658 .unsol_event = alc_sku_unsol_event,
9659 .setup = alc883_mode2_setup,
9660 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +02009661 },
9662 [ALC888_ASUS_EEE1601] = {
9663 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009664 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009665 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9666 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9667 .dac_nids = alc883_dac_nids,
9668 .dig_out_nid = ALC883_DIGOUT_NID,
9669 .dig_in_nid = ALC883_DIGIN_NID,
9670 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9671 .channel_mode = alc883_3ST_2ch_modes,
9672 .need_dac_fix = 1,
9673 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009674 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009675 .init_hook = alc883_eee1601_inithook,
9676 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009677 [ALC1200_ASUS_P5Q] = {
9678 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9679 .init_verbs = { alc883_init_verbs },
9680 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9681 .dac_nids = alc883_dac_nids,
9682 .dig_out_nid = ALC1200_DIGOUT_NID,
9683 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009684 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009685 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9686 .channel_mode = alc883_sixstack_modes,
9687 .input_mux = &alc883_capture_source,
9688 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009689 [ALC889A_MB31] = {
9690 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9691 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9692 alc880_gpio1_init_verbs },
9693 .adc_nids = alc883_adc_nids,
9694 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009695 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009696 .dac_nids = alc883_dac_nids,
9697 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9698 .channel_mode = alc889A_mb31_6ch_modes,
9699 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9700 .input_mux = &alc889A_mb31_capture_source,
9701 .dig_out_nid = ALC883_DIGOUT_NID,
9702 .unsol_event = alc889A_mb31_unsol_event,
9703 .init_hook = alc889A_mb31_automute,
9704 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009705 [ALC883_SONY_VAIO_TT] = {
9706 .mixers = { alc883_vaiott_mixer },
9707 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9708 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9709 .dac_nids = alc883_dac_nids,
9710 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9711 .channel_mode = alc883_3ST_2ch_modes,
9712 .input_mux = &alc883_capture_source,
9713 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009714 .setup = alc883_vaiott_setup,
9715 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +02009716 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009717};
9718
9719
9720/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02009721 * Pin config fixes
9722 */
9723enum {
9724 PINFIX_ABIT_AW9D_MAX
9725};
9726
9727static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9728 { 0x15, 0x01080104 }, /* side */
9729 { 0x16, 0x01011012 }, /* rear */
9730 { 0x17, 0x01016011 }, /* clfe */
9731 { }
9732};
9733
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009734static const struct alc_fixup alc882_fixups[] = {
9735 [PINFIX_ABIT_AW9D_MAX] = {
9736 .pins = alc882_abit_aw9d_pinfix
9737 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009738};
9739
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009740static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009741 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9742 {}
9743};
9744
9745/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009746 * BIOS auto configuration
9747 */
Takashi Iwai05f5f472009-08-25 13:10:18 +02009748static int alc882_auto_create_input_ctls(struct hda_codec *codec,
9749 const struct auto_pin_cfg *cfg)
9750{
9751 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
9752}
9753
Takashi Iwai4953550a2009-06-30 15:28:30 +02009754static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009755 hda_nid_t nid, int pin_type,
9756 int dac_idx)
9757{
9758 /* set as output */
9759 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009760 int idx;
9761
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009762 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009763 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9764 idx = 4;
9765 else
9766 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009767 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9768
9769}
9770
Takashi Iwai4953550a2009-06-30 15:28:30 +02009771static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009772{
9773 struct alc_spec *spec = codec->spec;
9774 int i;
9775
9776 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009777 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009778 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009779 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009780 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009781 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009782 }
9783}
9784
Takashi Iwai4953550a2009-06-30 15:28:30 +02009785static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009786{
9787 struct alc_spec *spec = codec->spec;
9788 hda_nid_t pin;
9789
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009790 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009791 if (pin) /* connect to front */
9792 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009793 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009794 pin = spec->autocfg.speaker_pins[0];
9795 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009796 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009797}
9798
Takashi Iwai4953550a2009-06-30 15:28:30 +02009799static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009800{
9801 struct alc_spec *spec = codec->spec;
9802 int i;
9803
9804 for (i = 0; i < AUTO_PIN_LAST; i++) {
9805 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +02009806 if (!nid)
9807 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +02009808 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009809 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9810 snd_hda_codec_write(codec, nid, 0,
9811 AC_VERB_SET_AMP_GAIN_MUTE,
9812 AMP_OUT_MUTE);
9813 }
9814}
9815
9816static void alc882_auto_init_input_src(struct hda_codec *codec)
9817{
9818 struct alc_spec *spec = codec->spec;
9819 int c;
9820
9821 for (c = 0; c < spec->num_adc_nids; c++) {
9822 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9823 hda_nid_t nid = spec->capsrc_nids[c];
9824 unsigned int mux_idx;
9825 const struct hda_input_mux *imux;
9826 int conns, mute, idx, item;
9827
9828 conns = snd_hda_get_connections(codec, nid, conn_list,
9829 ARRAY_SIZE(conn_list));
9830 if (conns < 0)
9831 continue;
9832 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9833 imux = &spec->input_mux[mux_idx];
9834 for (idx = 0; idx < conns; idx++) {
9835 /* if the current connection is the selected one,
9836 * unmute it as default - otherwise mute it
9837 */
9838 mute = AMP_IN_MUTE(idx);
9839 for (item = 0; item < imux->num_items; item++) {
9840 if (imux->items[item].index == idx) {
9841 if (spec->cur_mux[c] == item)
9842 mute = AMP_IN_UNMUTE(idx);
9843 break;
9844 }
9845 }
9846 /* check if we have a selector or mixer
9847 * we could check for the widget type instead, but
9848 * just check for Amp-In presence (in case of mixer
9849 * without amp-in there is something wrong, this
9850 * function shouldn't be used or capsrc nid is wrong)
9851 */
9852 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009853 snd_hda_codec_write(codec, nid, 0,
9854 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009855 mute);
9856 else if (mute != AMP_IN_MUTE(idx))
9857 snd_hda_codec_write(codec, nid, 0,
9858 AC_VERB_SET_CONNECT_SEL,
9859 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009860 }
9861 }
9862}
9863
Takashi Iwai4953550a2009-06-30 15:28:30 +02009864/* add mic boosts if needed */
9865static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009866{
9867 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009868 int err;
9869 hda_nid_t nid;
9870
9871 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9872 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9873 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9874 "Mic Boost",
9875 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9876 if (err < 0)
9877 return err;
9878 }
9879 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9880 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9881 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9882 "Front Mic Boost",
9883 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9884 if (err < 0)
9885 return err;
9886 }
9887 return 0;
9888}
9889
9890/* almost identical with ALC880 parser... */
9891static int alc882_parse_auto_config(struct hda_codec *codec)
9892{
9893 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009894 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
9895 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009896
Takashi Iwai05f5f472009-08-25 13:10:18 +02009897 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9898 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009899 if (err < 0)
9900 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009901 if (!spec->autocfg.line_outs)
9902 return 0; /* can't find valid BIOS pin config */
9903
9904 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
9905 if (err < 0)
9906 return err;
9907 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
9908 if (err < 0)
9909 return err;
9910 err = alc880_auto_create_extra_out(spec,
9911 spec->autocfg.speaker_pins[0],
9912 "Speaker");
9913 if (err < 0)
9914 return err;
9915 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
9916 "Headphone");
9917 if (err < 0)
9918 return err;
9919 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
9920 if (err < 0)
9921 return err;
9922
9923 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9924
9925 /* check multiple SPDIF-out (for recent codecs) */
9926 for (i = 0; i < spec->autocfg.dig_outs; i++) {
9927 hda_nid_t dig_nid;
9928 err = snd_hda_get_connections(codec,
9929 spec->autocfg.dig_out_pins[i],
9930 &dig_nid, 1);
9931 if (err < 0)
9932 continue;
9933 if (!i)
9934 spec->multiout.dig_out_nid = dig_nid;
9935 else {
9936 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01009937 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai05f5f472009-08-25 13:10:18 +02009938 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01009939 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009940 }
9941 }
9942 if (spec->autocfg.dig_in_pin)
9943 spec->dig_in_nid = ALC880_DIGIN_NID;
9944
9945 if (spec->kctls.list)
9946 add_mixer(spec, spec->kctls.list);
9947
9948 add_verb(spec, alc883_auto_init_verbs);
9949 /* if ADC 0x07 is available, initialize it, too */
9950 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
9951 add_verb(spec, alc882_adc1_init_verbs);
9952
9953 spec->num_mux_defs = 1;
9954 spec->input_mux = &spec->private_imux[0];
9955
9956 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
Takashi Iwai776e1842007-08-29 15:07:11 +02009957
9958 err = alc_auto_add_mic_boost(codec);
9959 if (err < 0)
9960 return err;
9961
Takashi Iwai776e1842007-08-29 15:07:11 +02009962 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009963}
9964
9965/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009966static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009967{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009968 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009969 alc882_auto_init_multi_out(codec);
9970 alc882_auto_init_hp_out(codec);
9971 alc882_auto_init_analog_input(codec);
9972 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009973 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009974 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009975}
9976
Takashi Iwai4953550a2009-06-30 15:28:30 +02009977static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009978{
9979 struct alc_spec *spec;
9980 int err, board_config;
9981
9982 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9983 if (spec == NULL)
9984 return -ENOMEM;
9985
9986 codec->spec = spec;
9987
Takashi Iwai4953550a2009-06-30 15:28:30 +02009988 switch (codec->vendor_id) {
9989 case 0x10ec0882:
9990 case 0x10ec0885:
9991 break;
9992 default:
9993 /* ALC883 and variants */
9994 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9995 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009996 }
9997
Takashi Iwai4953550a2009-06-30 15:28:30 +02009998 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
9999 alc882_models,
10000 alc882_cfg_tbl);
10001
10002 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10003 board_config = snd_hda_check_board_codec_sid_config(codec,
10004 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10005
10006 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010007 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010008 codec->chip_name);
10009 board_config = ALC882_AUTO;
10010 }
10011
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010012 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010013
10014 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010015 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010016 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010017 if (err < 0) {
10018 alc_free(codec);
10019 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010020 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010021 printk(KERN_INFO
10022 "hda_codec: Cannot set up configuration "
10023 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010024 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010025 }
10026 }
10027
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010028 err = snd_hda_attach_beep_device(codec, 0x1);
10029 if (err < 0) {
10030 alc_free(codec);
10031 return err;
10032 }
10033
Takashi Iwai4953550a2009-06-30 15:28:30 +020010034 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010035 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010036
Takashi Iwai4953550a2009-06-30 15:28:30 +020010037 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10038 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10039 /* FIXME: setup DAC5 */
10040 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10041 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10042
10043 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10044 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10045
10046 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010047 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010048
10049 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010050 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010051 spec->num_adc_nids = 0;
10052 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010053 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010054 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010055 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010056 hda_nid_t nid = alc882_adc_nids[i];
10057 unsigned int wcap = get_wcaps(codec, nid);
10058 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010059 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010060 if (wcap != AC_WID_AUD_IN)
10061 continue;
10062 spec->private_adc_nids[spec->num_adc_nids] = nid;
10063 err = snd_hda_get_connections(codec, nid, &cap, 1);
10064 if (err < 0)
10065 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010066 err = snd_hda_get_connections(codec, cap, items,
10067 ARRAY_SIZE(items));
10068 if (err < 0)
10069 continue;
10070 for (j = 0; j < imux->num_items; j++)
10071 if (imux->items[j].index >= err)
10072 break;
10073 if (j < imux->num_items)
10074 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010075 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10076 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010077 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010078 spec->adc_nids = spec->private_adc_nids;
10079 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010080 }
10081
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010082 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010010083 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010084
Takashi Iwai2134ea42008-01-10 16:53:55 +010010085 spec->vmaster_nid = 0x0c;
10086
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010087 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010088 if (board_config == ALC882_AUTO)
10089 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010090#ifdef CONFIG_SND_HDA_POWER_SAVE
10091 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010092 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010093#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010010094 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010095
10096 return 0;
10097}
10098
Takashi Iwai4953550a2009-06-30 15:28:30 +020010099
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010100/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010101 * ALC262 support
10102 */
10103
10104#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10105#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10106
10107#define alc262_dac_nids alc260_dac_nids
10108#define alc262_adc_nids alc882_adc_nids
10109#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010110#define alc262_capsrc_nids alc882_capsrc_nids
10111#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010112
10113#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010114#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010115
Kailang Yang4e555fe2008-08-26 13:05:55 +020010116static hda_nid_t alc262_dmic_adc_nids[1] = {
10117 /* ADC0 */
10118 0x09
10119};
10120
10121static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10122
Kailang Yangdf694da2005-12-05 19:42:22 +010010123static struct snd_kcontrol_new alc262_base_mixer[] = {
10124 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10125 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10126 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10127 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10128 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10129 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10130 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10131 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010132 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010133 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10134 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010135 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010136 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10137 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10138 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10139 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010140 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010141};
10142
Takashi Iwaice875f02008-01-28 18:17:43 +010010143/* update HP, line and mono-out pins according to the master switch */
10144static void alc262_hp_master_update(struct hda_codec *codec)
10145{
10146 struct alc_spec *spec = codec->spec;
10147 int val = spec->master_sw;
10148
10149 /* HP & line-out */
10150 snd_hda_codec_write_cache(codec, 0x1b, 0,
10151 AC_VERB_SET_PIN_WIDGET_CONTROL,
10152 val ? PIN_HP : 0);
10153 snd_hda_codec_write_cache(codec, 0x15, 0,
10154 AC_VERB_SET_PIN_WIDGET_CONTROL,
10155 val ? PIN_HP : 0);
10156 /* mono (speaker) depending on the HP jack sense */
10157 val = val && !spec->jack_present;
10158 snd_hda_codec_write_cache(codec, 0x16, 0,
10159 AC_VERB_SET_PIN_WIDGET_CONTROL,
10160 val ? PIN_OUT : 0);
10161}
10162
10163static void alc262_hp_bpc_automute(struct hda_codec *codec)
10164{
10165 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010166
10167 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010168 alc262_hp_master_update(codec);
10169}
10170
10171static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10172{
10173 if ((res >> 26) != ALC880_HP_EVENT)
10174 return;
10175 alc262_hp_bpc_automute(codec);
10176}
10177
10178static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10179{
10180 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010181
10182 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010183 alc262_hp_master_update(codec);
10184}
10185
10186static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10187 unsigned int res)
10188{
10189 if ((res >> 26) != ALC880_HP_EVENT)
10190 return;
10191 alc262_hp_wildwest_automute(codec);
10192}
10193
Takashi Iwaib72519b2009-05-08 14:31:55 +020010194#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010195
10196static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10197 struct snd_ctl_elem_value *ucontrol)
10198{
10199 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10200 struct alc_spec *spec = codec->spec;
10201 int val = !!*ucontrol->value.integer.value;
10202
10203 if (val == spec->master_sw)
10204 return 0;
10205 spec->master_sw = val;
10206 alc262_hp_master_update(codec);
10207 return 1;
10208}
10209
Takashi Iwaib72519b2009-05-08 14:31:55 +020010210#define ALC262_HP_MASTER_SWITCH \
10211 { \
10212 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10213 .name = "Master Playback Switch", \
10214 .info = snd_ctl_boolean_mono_info, \
10215 .get = alc262_hp_master_sw_get, \
10216 .put = alc262_hp_master_sw_put, \
10217 }
10218
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010219static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010220 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010221 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10222 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10223 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010224 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10225 HDA_OUTPUT),
10226 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10227 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010228 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10229 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010230 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010231 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10232 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010233 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010234 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10235 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10236 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10237 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010238 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10239 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10240 { } /* end */
10241};
10242
Kailang Yangcd7509a2007-01-26 18:33:17 +010010243static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010244 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010245 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10246 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10247 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10248 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010249 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10250 HDA_OUTPUT),
10251 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10252 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010253 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10254 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010255 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010256 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10257 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10258 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10259 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010260 { } /* end */
10261};
10262
10263static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10264 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10265 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010266 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010267 { } /* end */
10268};
10269
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010270/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010271static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010272{
10273 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010274
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010275 spec->autocfg.hp_pins[0] = 0x15;
10276 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010277}
10278
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010279static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010280 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10281 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010282 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10283 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10284 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10285 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10286 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10287 { } /* end */
10288};
10289
10290static struct hda_verb alc262_hp_t5735_verbs[] = {
10291 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10292 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10293
10294 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10295 { }
10296};
10297
Kailang Yang8c427222008-01-10 13:03:59 +010010298static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010299 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10300 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010301 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10302 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010303 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10304 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10305 { } /* end */
10306};
10307
10308static struct hda_verb alc262_hp_rp5700_verbs[] = {
10309 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10310 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10311 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10312 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10313 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10314 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10315 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10316 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10317 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10318 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10319 {}
10320};
10321
10322static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10323 .num_items = 1,
10324 .items = {
10325 { "Line", 0x1 },
10326 },
10327};
10328
Takashi Iwai42171c12009-05-08 14:11:43 +020010329/* bind hp and internal speaker mute (with plug check) as master switch */
10330static void alc262_hippo_master_update(struct hda_codec *codec)
10331{
10332 struct alc_spec *spec = codec->spec;
10333 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10334 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10335 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10336 unsigned int mute;
10337
10338 /* HP */
10339 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10340 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10341 HDA_AMP_MUTE, mute);
10342 /* mute internal speaker per jack sense */
10343 if (spec->jack_present)
10344 mute = HDA_AMP_MUTE;
10345 if (line_nid)
10346 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10347 HDA_AMP_MUTE, mute);
10348 if (speaker_nid && speaker_nid != line_nid)
10349 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10350 HDA_AMP_MUTE, mute);
10351}
10352
10353#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10354
10355static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10356 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010357{
10358 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010359 struct alc_spec *spec = codec->spec;
10360 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010361
Takashi Iwai42171c12009-05-08 14:11:43 +020010362 if (val == spec->master_sw)
10363 return 0;
10364 spec->master_sw = val;
10365 alc262_hippo_master_update(codec);
10366 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010367}
Takashi Iwai5b319542007-07-26 11:49:22 +020010368
Takashi Iwai42171c12009-05-08 14:11:43 +020010369#define ALC262_HIPPO_MASTER_SWITCH \
10370 { \
10371 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10372 .name = "Master Playback Switch", \
10373 .info = snd_ctl_boolean_mono_info, \
10374 .get = alc262_hippo_master_sw_get, \
10375 .put = alc262_hippo_master_sw_put, \
10376 }
10377
10378static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10379 ALC262_HIPPO_MASTER_SWITCH,
10380 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10381 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10382 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10383 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10384 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10385 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10386 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10387 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10388 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10389 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10390 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10391 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10392 { } /* end */
10393};
10394
10395static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10396 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10397 ALC262_HIPPO_MASTER_SWITCH,
10398 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10399 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10400 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10401 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10402 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10403 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10404 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10405 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10406 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10407 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10408 { } /* end */
10409};
10410
10411/* mute/unmute internal speaker according to the hp jack and mute state */
10412static void alc262_hippo_automute(struct hda_codec *codec)
10413{
10414 struct alc_spec *spec = codec->spec;
10415 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020010416
Wu Fengguang864f92b2009-11-18 12:38:02 +080010417 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020010418 alc262_hippo_master_update(codec);
10419}
10420
10421static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10422{
10423 if ((res >> 26) != ALC880_HP_EVENT)
10424 return;
10425 alc262_hippo_automute(codec);
10426}
10427
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010428static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010429{
10430 struct alc_spec *spec = codec->spec;
10431
10432 spec->autocfg.hp_pins[0] = 0x15;
10433 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010434}
10435
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010436static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010437{
10438 struct alc_spec *spec = codec->spec;
10439
10440 spec->autocfg.hp_pins[0] = 0x1b;
10441 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010442}
10443
10444
Kailang Yang272a5272007-05-14 11:00:38 +020010445static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010446 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010447 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010448 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10449 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10450 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10451 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10452 { } /* end */
10453};
10454
Kailang Yang83c34212007-07-05 11:43:05 +020010455static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010456 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10457 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010458 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10459 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10460 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10461 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10462 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10463 { } /* end */
10464};
Kailang Yang272a5272007-05-14 11:00:38 +020010465
Tony Vroonba340e82009-02-02 19:01:30 +000010466static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10467 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10468 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10469 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10470 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10471 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10472 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10473 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10474 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10475 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10476 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10477 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10478 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10479 { } /* end */
10480};
10481
10482static struct hda_verb alc262_tyan_verbs[] = {
10483 /* Headphone automute */
10484 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10485 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10486 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10487
10488 /* P11 AUX_IN, white 4-pin connector */
10489 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10490 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10491 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10492 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10493
10494 {}
10495};
10496
10497/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010498static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010499{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010500 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010501
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010502 spec->autocfg.hp_pins[0] = 0x1b;
10503 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010504}
10505
Tony Vroonba340e82009-02-02 19:01:30 +000010506
Kailang Yangdf694da2005-12-05 19:42:22 +010010507#define alc262_capture_mixer alc882_capture_mixer
10508#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10509
10510/*
10511 * generic initialization of ADC, input mixers and output mixers
10512 */
10513static struct hda_verb alc262_init_verbs[] = {
10514 /*
10515 * Unmute ADC0-2 and set the default input to mic-in
10516 */
10517 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10518 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10519 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10520 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10521 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10522 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10523
Takashi Iwaicb53c622007-08-10 17:21:45 +020010524 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010525 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010526 * Note: PASD motherboards uses the Line In 2 as the input for
10527 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010528 */
10529 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010530 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10531 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10532 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10533 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10534 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010535
10536 /*
10537 * Set up output mixers (0x0c - 0x0e)
10538 */
10539 /* set vol=0 to output mixers */
10540 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10541 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10542 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10543 /* set up input amps for analog loopback */
10544 /* Amp Indices: DAC = 0, mixer = 1 */
10545 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10546 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10547 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10548 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10549 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10550 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10551
10552 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10553 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10554 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10555 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10556 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10557 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10558
10559 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10560 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10561 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10562 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10563 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010564
Kailang Yangdf694da2005-12-05 19:42:22 +010010565 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10566 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010567
Kailang Yangdf694da2005-12-05 19:42:22 +010010568 /* FIXME: use matrix-type input source selection */
10569 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10570 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10571 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10572 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10573 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10574 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10575 /* Input mixer2 */
10576 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10577 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10578 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10579 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10580 /* Input mixer3 */
10581 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10582 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10583 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010584 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010585
10586 { }
10587};
10588
Kailang Yang4e555fe2008-08-26 13:05:55 +020010589static struct hda_verb alc262_eapd_verbs[] = {
10590 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10591 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10592 { }
10593};
10594
Kailang Yangccc656c2006-10-17 12:32:26 +020010595static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10596 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10597 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10598 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10599
10600 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10601 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10602 {}
10603};
10604
Kailang Yang272a5272007-05-14 11:00:38 +020010605static struct hda_verb alc262_sony_unsol_verbs[] = {
10606 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10607 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10608 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10609
10610 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10611 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010612 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010613};
10614
Kailang Yang4e555fe2008-08-26 13:05:55 +020010615static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10616 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10617 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10618 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10619 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10620 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010621 { } /* end */
10622};
10623
10624static struct hda_verb alc262_toshiba_s06_verbs[] = {
10625 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10626 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10627 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10628 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10629 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10630 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10631 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10632 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10633 {}
10634};
10635
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010636static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020010637{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010638 struct alc_spec *spec = codec->spec;
10639
10640 spec->autocfg.hp_pins[0] = 0x15;
10641 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010642 spec->ext_mic.pin = 0x18;
10643 spec->ext_mic.mux_idx = 0;
10644 spec->int_mic.pin = 0x12;
10645 spec->int_mic.mux_idx = 9;
10646 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020010647}
10648
Takashi Iwai834be882006-03-01 14:16:17 +010010649/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010650 * nec model
10651 * 0x15 = headphone
10652 * 0x16 = internal speaker
10653 * 0x18 = external mic
10654 */
10655
10656static struct snd_kcontrol_new alc262_nec_mixer[] = {
10657 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10658 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10659
10660 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10661 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10662 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10663
10664 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10665 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10666 { } /* end */
10667};
10668
10669static struct hda_verb alc262_nec_verbs[] = {
10670 /* Unmute Speaker */
10671 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10672
10673 /* Headphone */
10674 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10675 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10676
10677 /* External mic to headphone */
10678 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10679 /* External mic to speaker */
10680 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10681 {}
10682};
10683
10684/*
Takashi Iwai834be882006-03-01 14:16:17 +010010685 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010686 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10687 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010688 */
10689
10690#define ALC_HP_EVENT 0x37
10691
10692static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10693 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10694 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010695 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10696 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010697 {}
10698};
10699
Jiang zhe0e31daf2008-03-20 12:12:39 +010010700static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10701 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10702 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10703 {}
10704};
10705
Daniel T Chene2595322009-12-19 18:19:02 -050010706static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
10707 /* Front Mic pin: input vref at 50% */
10708 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10709 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10710 {}
10711};
10712
Takashi Iwai834be882006-03-01 14:16:17 +010010713static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010714 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010715 .items = {
10716 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010717 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010718 { "CD", 0x4 },
10719 },
10720};
10721
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010722static struct hda_input_mux alc262_HP_capture_source = {
10723 .num_items = 5,
10724 .items = {
10725 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010726 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010727 { "Line", 0x2 },
10728 { "CD", 0x4 },
10729 { "AUX IN", 0x6 },
10730 },
10731};
10732
zhejiangaccbe492007-08-31 12:36:05 +020010733static struct hda_input_mux alc262_HP_D7000_capture_source = {
10734 .num_items = 4,
10735 .items = {
10736 { "Mic", 0x0 },
10737 { "Front Mic", 0x2 },
10738 { "Line", 0x1 },
10739 { "CD", 0x4 },
10740 },
10741};
10742
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010743/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010744static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10745{
10746 struct alc_spec *spec = codec->spec;
10747 unsigned int mute;
10748
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010749 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080010750 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
10751 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010010752 spec->sense_updated = 1;
10753 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010754 /* unmute internal speaker only if both HPs are unplugged and
10755 * master switch is on
10756 */
10757 if (spec->jack_present)
10758 mute = HDA_AMP_MUTE;
10759 else
Takashi Iwai834be882006-03-01 14:16:17 +010010760 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010761 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10762 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010763}
10764
10765/* unsolicited event for HP jack sensing */
10766static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10767 unsigned int res)
10768{
10769 if ((res >> 26) != ALC_HP_EVENT)
10770 return;
10771 alc262_fujitsu_automute(codec, 1);
10772}
10773
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010774static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10775{
10776 alc262_fujitsu_automute(codec, 1);
10777}
10778
Takashi Iwai834be882006-03-01 14:16:17 +010010779/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010780static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10781 .ops = &snd_hda_bind_vol,
10782 .values = {
10783 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10784 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10785 0
10786 },
10787};
Takashi Iwai834be882006-03-01 14:16:17 +010010788
Jiang zhe0e31daf2008-03-20 12:12:39 +010010789/* mute/unmute internal speaker according to the hp jack and mute state */
10790static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10791{
10792 struct alc_spec *spec = codec->spec;
10793 unsigned int mute;
10794
10795 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080010796 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010797 spec->sense_updated = 1;
10798 }
10799 if (spec->jack_present) {
10800 /* mute internal speaker */
10801 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10802 HDA_AMP_MUTE, HDA_AMP_MUTE);
10803 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10804 HDA_AMP_MUTE, HDA_AMP_MUTE);
10805 } else {
10806 /* unmute internal speaker if necessary */
10807 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10808 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10809 HDA_AMP_MUTE, mute);
10810 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10811 HDA_AMP_MUTE, mute);
10812 }
10813}
10814
10815/* unsolicited event for HP jack sensing */
10816static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10817 unsigned int res)
10818{
10819 if ((res >> 26) != ALC_HP_EVENT)
10820 return;
10821 alc262_lenovo_3000_automute(codec, 1);
10822}
10823
Takashi Iwai8de56b72009-07-24 16:51:47 +020010824static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10825 int dir, int idx, long *valp)
10826{
10827 int i, change = 0;
10828
10829 for (i = 0; i < 2; i++, valp++)
10830 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10831 HDA_AMP_MUTE,
10832 *valp ? 0 : HDA_AMP_MUTE);
10833 return change;
10834}
10835
Takashi Iwai834be882006-03-01 14:16:17 +010010836/* bind hp and internal speaker mute (with plug check) */
10837static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10838 struct snd_ctl_elem_value *ucontrol)
10839{
10840 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10841 long *valp = ucontrol->value.integer.value;
10842 int change;
10843
Takashi Iwai8de56b72009-07-24 16:51:47 +020010844 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10845 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010846 if (change)
10847 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010848 return change;
10849}
10850
10851static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010852 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010853 {
10854 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10855 .name = "Master Playback Switch",
10856 .info = snd_hda_mixer_amp_switch_info,
10857 .get = snd_hda_mixer_amp_switch_get,
10858 .put = alc262_fujitsu_master_sw_put,
10859 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10860 },
10861 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10862 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10863 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10864 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10865 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010866 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10867 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10868 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010869 { } /* end */
10870};
10871
Jiang zhe0e31daf2008-03-20 12:12:39 +010010872/* bind hp and internal speaker mute (with plug check) */
10873static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10874 struct snd_ctl_elem_value *ucontrol)
10875{
10876 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10877 long *valp = ucontrol->value.integer.value;
10878 int change;
10879
Takashi Iwai8de56b72009-07-24 16:51:47 +020010880 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010881 if (change)
10882 alc262_lenovo_3000_automute(codec, 0);
10883 return change;
10884}
10885
10886static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10887 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10888 {
10889 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10890 .name = "Master Playback Switch",
10891 .info = snd_hda_mixer_amp_switch_info,
10892 .get = snd_hda_mixer_amp_switch_get,
10893 .put = alc262_lenovo_3000_master_sw_put,
10894 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10895 },
10896 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10897 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10898 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10899 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10900 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10901 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10902 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10903 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10904 { } /* end */
10905};
10906
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010907static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10908 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010909 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010910 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10911 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10912 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10913 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10914 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10915 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10916 { } /* end */
10917};
10918
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010919/* additional init verbs for Benq laptops */
10920static struct hda_verb alc262_EAPD_verbs[] = {
10921 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10922 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10923 {}
10924};
10925
Kailang Yang83c34212007-07-05 11:43:05 +020010926static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10927 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10928 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10929
10930 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10931 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10932 {}
10933};
10934
Tobin Davisf651b502007-10-26 12:40:47 +020010935/* Samsung Q1 Ultra Vista model setup */
10936static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010937 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10938 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010939 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10940 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10941 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010942 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010943 { } /* end */
10944};
10945
10946static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010947 /* output mixer */
10948 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10949 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10950 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10951 /* speaker */
10952 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10953 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10954 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10955 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10956 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010957 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010958 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10959 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10960 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10961 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10962 /* internal mic */
10963 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10964 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10965 /* ADC, choose mic */
10966 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10967 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10968 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10969 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10970 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10971 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10972 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10973 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10974 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10975 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010976 {}
10977};
10978
Tobin Davisf651b502007-10-26 12:40:47 +020010979/* mute/unmute internal speaker according to the hp jack and mute state */
10980static void alc262_ultra_automute(struct hda_codec *codec)
10981{
10982 struct alc_spec *spec = codec->spec;
10983 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010984
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010985 mute = 0;
10986 /* auto-mute only when HP is used as HP */
10987 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080010988 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010989 if (spec->jack_present)
10990 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010991 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010992 /* mute/unmute internal speaker */
10993 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10994 HDA_AMP_MUTE, mute);
10995 /* mute/unmute HP */
10996 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10997 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010998}
10999
11000/* unsolicited event for HP jack sensing */
11001static void alc262_ultra_unsol_event(struct hda_codec *codec,
11002 unsigned int res)
11003{
11004 if ((res >> 26) != ALC880_HP_EVENT)
11005 return;
11006 alc262_ultra_automute(codec);
11007}
11008
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011009static struct hda_input_mux alc262_ultra_capture_source = {
11010 .num_items = 2,
11011 .items = {
11012 { "Mic", 0x1 },
11013 { "Headphone", 0x7 },
11014 },
11015};
11016
11017static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11018 struct snd_ctl_elem_value *ucontrol)
11019{
11020 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11021 struct alc_spec *spec = codec->spec;
11022 int ret;
11023
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011024 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011025 if (!ret)
11026 return 0;
11027 /* reprogram the HP pin as mic or HP according to the input source */
11028 snd_hda_codec_write_cache(codec, 0x15, 0,
11029 AC_VERB_SET_PIN_WIDGET_CONTROL,
11030 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11031 alc262_ultra_automute(codec); /* mute/unmute HP */
11032 return ret;
11033}
11034
11035static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11036 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11037 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11038 {
11039 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11040 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011041 .info = alc_mux_enum_info,
11042 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011043 .put = alc262_ultra_mux_enum_put,
11044 },
11045 { } /* end */
11046};
11047
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011048/* We use two mixers depending on the output pin; 0x16 is a mono output
11049 * and thus it's bound with a different mixer.
11050 * This function returns which mixer amp should be used.
11051 */
11052static int alc262_check_volbit(hda_nid_t nid)
11053{
11054 if (!nid)
11055 return 0;
11056 else if (nid == 0x16)
11057 return 2;
11058 else
11059 return 1;
11060}
11061
11062static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
11063 const char *pfx, int *vbits)
11064{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011065 unsigned long val;
11066 int vbit;
11067
11068 vbit = alc262_check_volbit(nid);
11069 if (!vbit)
11070 return 0;
11071 if (*vbits & vbit) /* a volume control for this mixer already there */
11072 return 0;
11073 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011074 if (vbit == 2)
11075 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11076 else
11077 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011078 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011079}
11080
11081static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
11082 const char *pfx)
11083{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011084 unsigned long val;
11085
11086 if (!nid)
11087 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011088 if (nid == 0x16)
11089 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11090 else
11091 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011092 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011093}
11094
Kailang Yangdf694da2005-12-05 19:42:22 +010011095/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011096static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11097 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011098{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011099 const char *pfx;
11100 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010011101 int err;
11102
11103 spec->multiout.num_dacs = 1; /* only use one dac */
11104 spec->multiout.dac_nids = spec->private_dac_nids;
11105 spec->multiout.dac_nids[0] = 2;
11106
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011107 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11108 pfx = "Master";
11109 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11110 pfx = "Speaker";
11111 else
11112 pfx = "Front";
11113 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11114 if (err < 0)
11115 return err;
11116 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11117 if (err < 0)
11118 return err;
11119 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11120 if (err < 0)
11121 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011122
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011123 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11124 alc262_check_volbit(cfg->speaker_pins[0]) |
11125 alc262_check_volbit(cfg->hp_pins[0]);
11126 if (vbits == 1 || vbits == 2)
11127 pfx = "Master"; /* only one mixer is used */
11128 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11129 pfx = "Speaker";
11130 else
11131 pfx = "Front";
11132 vbits = 0;
11133 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11134 if (err < 0)
11135 return err;
11136 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11137 &vbits);
11138 if (err < 0)
11139 return err;
11140 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11141 &vbits);
11142 if (err < 0)
11143 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011144 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011145}
11146
Takashi Iwai05f5f472009-08-25 13:10:18 +020011147#define alc262_auto_create_input_ctls \
11148 alc880_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011149
11150/*
11151 * generic initialization of ADC, input mixers and output mixers
11152 */
11153static struct hda_verb alc262_volume_init_verbs[] = {
11154 /*
11155 * Unmute ADC0-2 and set the default input to mic-in
11156 */
11157 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11158 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11159 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11160 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11161 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11162 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11163
Takashi Iwaicb53c622007-08-10 17:21:45 +020011164 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011165 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011166 * Note: PASD motherboards uses the Line In 2 as the input for
11167 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011168 */
11169 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011170 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11171 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11172 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11173 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11174 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011175
11176 /*
11177 * Set up output mixers (0x0c - 0x0f)
11178 */
11179 /* set vol=0 to output mixers */
11180 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11181 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11182 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011183
Kailang Yangdf694da2005-12-05 19:42:22 +010011184 /* set up input amps for analog loopback */
11185 /* Amp Indices: DAC = 0, mixer = 1 */
11186 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11187 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11188 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11189 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11190 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11191 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11192
11193 /* FIXME: use matrix-type input source selection */
11194 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11195 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11196 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11197 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11198 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11199 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11200 /* Input mixer2 */
11201 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11202 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11203 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11204 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11205 /* Input mixer3 */
11206 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11207 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11208 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11209 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11210
11211 { }
11212};
11213
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011214static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11215 /*
11216 * Unmute ADC0-2 and set the default input to mic-in
11217 */
11218 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11219 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11220 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11221 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11222 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11223 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11224
Takashi Iwaicb53c622007-08-10 17:21:45 +020011225 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011226 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011227 * Note: PASD motherboards uses the Line In 2 as the input for
11228 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011229 */
11230 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011231 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11232 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11233 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11234 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11235 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11236 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11237 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011238
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011239 /*
11240 * Set up output mixers (0x0c - 0x0e)
11241 */
11242 /* set vol=0 to output mixers */
11243 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11244 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11245 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11246
11247 /* set up input amps for analog loopback */
11248 /* Amp Indices: DAC = 0, mixer = 1 */
11249 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11250 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11251 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11252 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11253 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11254 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11255
Takashi Iwaice875f02008-01-28 18:17:43 +010011256 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011257 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11258 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11259
11260 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11261 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11262
11263 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11264 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11265
11266 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11267 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11268 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11269 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11270 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11271
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011272 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011273 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11274 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011275 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011276 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11277 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11278
11279
11280 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011281 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11282 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011283 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011284 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11285 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11286 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11287 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11288 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11289 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11290 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11291 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011292 /* Input mixer2 */
11293 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011294 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11295 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11296 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11297 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11298 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11299 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11300 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11301 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011302 /* Input mixer3 */
11303 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011304 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11305 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11306 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11307 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11308 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11309 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11310 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11311 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011312
Takashi Iwaice875f02008-01-28 18:17:43 +010011313 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11314
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011315 { }
11316};
11317
Kailang Yangcd7509a2007-01-26 18:33:17 +010011318static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11319 /*
11320 * Unmute ADC0-2 and set the default input to mic-in
11321 */
11322 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11323 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11324 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11325 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11326 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11327 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11328
Takashi Iwaicb53c622007-08-10 17:21:45 +020011329 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011330 * mixer widget
11331 * Note: PASD motherboards uses the Line In 2 as the input for front
11332 * panel mic (mic 2)
11333 */
11334 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011335 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11336 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11337 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11338 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11339 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11340 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11341 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11342 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011343 /*
11344 * Set up output mixers (0x0c - 0x0e)
11345 */
11346 /* set vol=0 to output mixers */
11347 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11348 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11349 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11350
11351 /* set up input amps for analog loopback */
11352 /* Amp Indices: DAC = 0, mixer = 1 */
11353 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11354 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11355 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11356 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11357 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11358 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11359
11360
11361 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11362 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11363 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11364 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11365 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11366 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11367 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
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, 0x01},
11374
11375 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11376 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11377 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11378 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11379 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11380 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11381
11382 /* FIXME: use matrix-type input source selection */
11383 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11384 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11385 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11386 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11387 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11388 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11389 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11390 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11391 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11392 /* Input mixer2 */
11393 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11394 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11395 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11396 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11397 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11398 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11399 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11400 /* Input mixer3 */
11401 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11402 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11403 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11404 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11405 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11406 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11407 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11408
Takashi Iwaice875f02008-01-28 18:17:43 +010011409 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11410
Kailang Yangcd7509a2007-01-26 18:33:17 +010011411 { }
11412};
11413
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011414static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11415
11416 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11417 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11418 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11419
11420 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11421 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11422 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11423 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11424
11425 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11426 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11427 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11428 {}
11429};
11430
11431
Takashi Iwaicb53c622007-08-10 17:21:45 +020011432#ifdef CONFIG_SND_HDA_POWER_SAVE
11433#define alc262_loopbacks alc880_loopbacks
11434#endif
11435
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011436/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011437#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11438#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11439#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11440#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11441
11442/*
11443 * BIOS auto configuration
11444 */
11445static int alc262_parse_auto_config(struct hda_codec *codec)
11446{
11447 struct alc_spec *spec = codec->spec;
11448 int err;
11449 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11450
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011451 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11452 alc262_ignore);
11453 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011454 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011455 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011456 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011457 spec->multiout.max_channels = 2;
11458 spec->no_analog = 1;
11459 goto dig_only;
11460 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011461 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011462 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011463 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11464 if (err < 0)
11465 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011466 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011467 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011468 return err;
11469
11470 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11471
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011472 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011473 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011474 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011475 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011476 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011477 if (spec->autocfg.dig_in_pin)
11478 spec->dig_in_nid = ALC262_DIGIN_NID;
11479
Takashi Iwai603c4012008-07-30 15:01:44 +020011480 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011481 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011482
Takashi Iwaid88897e2008-10-31 15:01:37 +010011483 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011484 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011485 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011486
Takashi Iwai776e1842007-08-29 15:07:11 +020011487 err = alc_auto_add_mic_boost(codec);
11488 if (err < 0)
11489 return err;
11490
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011491 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11492
Kailang Yangdf694da2005-12-05 19:42:22 +010011493 return 1;
11494}
11495
11496#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11497#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11498#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011499#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011500
11501
11502/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011503static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011504{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011505 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011506 alc262_auto_init_multi_out(codec);
11507 alc262_auto_init_hp_out(codec);
11508 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011509 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011510 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011511 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011512}
11513
11514/*
11515 * configuration and preset
11516 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011517static const char *alc262_models[ALC262_MODEL_LAST] = {
11518 [ALC262_BASIC] = "basic",
11519 [ALC262_HIPPO] = "hippo",
11520 [ALC262_HIPPO_1] = "hippo_1",
11521 [ALC262_FUJITSU] = "fujitsu",
11522 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011523 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011524 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011525 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011526 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011527 [ALC262_BENQ_T31] = "benq-t31",
11528 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011529 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011530 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011531 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011532 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011533 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011534 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011535 [ALC262_AUTO] = "auto",
11536};
11537
11538static struct snd_pci_quirk alc262_cfg_tbl[] = {
11539 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011540 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011541 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11542 ALC262_HP_BPC),
11543 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11544 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011545 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11546 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011547 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011548 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011549 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011550 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011551 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011552 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011553 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011554 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011555 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11556 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11557 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011558 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11559 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011560 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011561 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011562 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011563 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011564 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011565 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050011566 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010011567 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011568#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010011569 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11570 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011571#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090011572 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011573 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011574 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011575 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011576 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011577 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011578 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11579 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011580 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011581 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011582 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011583 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011584 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011585 {}
11586};
11587
11588static struct alc_config_preset alc262_presets[] = {
11589 [ALC262_BASIC] = {
11590 .mixers = { alc262_base_mixer },
11591 .init_verbs = { alc262_init_verbs },
11592 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11593 .dac_nids = alc262_dac_nids,
11594 .hp_nid = 0x03,
11595 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11596 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011597 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011598 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011599 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011600 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011601 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011602 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11603 .dac_nids = alc262_dac_nids,
11604 .hp_nid = 0x03,
11605 .dig_out_nid = ALC262_DIGOUT_NID,
11606 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11607 .channel_mode = alc262_modes,
11608 .input_mux = &alc262_capture_source,
11609 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011610 .setup = alc262_hippo_setup,
11611 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011612 },
11613 [ALC262_HIPPO_1] = {
11614 .mixers = { alc262_hippo1_mixer },
11615 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11616 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11617 .dac_nids = alc262_dac_nids,
11618 .hp_nid = 0x02,
11619 .dig_out_nid = ALC262_DIGOUT_NID,
11620 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11621 .channel_mode = alc262_modes,
11622 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011623 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011624 .setup = alc262_hippo1_setup,
11625 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011626 },
Takashi Iwai834be882006-03-01 14:16:17 +010011627 [ALC262_FUJITSU] = {
11628 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011629 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11630 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011631 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11632 .dac_nids = alc262_dac_nids,
11633 .hp_nid = 0x03,
11634 .dig_out_nid = ALC262_DIGOUT_NID,
11635 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11636 .channel_mode = alc262_modes,
11637 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011638 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011639 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011640 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011641 [ALC262_HP_BPC] = {
11642 .mixers = { alc262_HP_BPC_mixer },
11643 .init_verbs = { alc262_HP_BPC_init_verbs },
11644 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11645 .dac_nids = alc262_dac_nids,
11646 .hp_nid = 0x03,
11647 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11648 .channel_mode = alc262_modes,
11649 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011650 .unsol_event = alc262_hp_bpc_unsol_event,
11651 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011652 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011653 [ALC262_HP_BPC_D7000_WF] = {
11654 .mixers = { alc262_HP_BPC_WildWest_mixer },
11655 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11656 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11657 .dac_nids = alc262_dac_nids,
11658 .hp_nid = 0x03,
11659 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11660 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011661 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011662 .unsol_event = alc262_hp_wildwest_unsol_event,
11663 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011664 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011665 [ALC262_HP_BPC_D7000_WL] = {
11666 .mixers = { alc262_HP_BPC_WildWest_mixer,
11667 alc262_HP_BPC_WildWest_option_mixer },
11668 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11669 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11670 .dac_nids = alc262_dac_nids,
11671 .hp_nid = 0x03,
11672 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11673 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011674 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011675 .unsol_event = alc262_hp_wildwest_unsol_event,
11676 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011677 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011678 [ALC262_HP_TC_T5735] = {
11679 .mixers = { alc262_hp_t5735_mixer },
11680 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11681 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11682 .dac_nids = alc262_dac_nids,
11683 .hp_nid = 0x03,
11684 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11685 .channel_mode = alc262_modes,
11686 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011687 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011688 .setup = alc262_hp_t5735_setup,
11689 .init_hook = alc_automute_amp,
Kailang Yang8c427222008-01-10 13:03:59 +010011690 },
11691 [ALC262_HP_RP5700] = {
11692 .mixers = { alc262_hp_rp5700_mixer },
11693 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11694 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11695 .dac_nids = alc262_dac_nids,
11696 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11697 .channel_mode = alc262_modes,
11698 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011699 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011700 [ALC262_BENQ_ED8] = {
11701 .mixers = { alc262_base_mixer },
11702 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11703 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11704 .dac_nids = alc262_dac_nids,
11705 .hp_nid = 0x03,
11706 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11707 .channel_mode = alc262_modes,
11708 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011709 },
Kailang Yang272a5272007-05-14 11:00:38 +020011710 [ALC262_SONY_ASSAMD] = {
11711 .mixers = { alc262_sony_mixer },
11712 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11713 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11714 .dac_nids = alc262_dac_nids,
11715 .hp_nid = 0x02,
11716 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11717 .channel_mode = alc262_modes,
11718 .input_mux = &alc262_capture_source,
11719 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011720 .setup = alc262_hippo_setup,
11721 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020011722 },
11723 [ALC262_BENQ_T31] = {
11724 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011725 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
11726 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020011727 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11728 .dac_nids = alc262_dac_nids,
11729 .hp_nid = 0x03,
11730 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11731 .channel_mode = alc262_modes,
11732 .input_mux = &alc262_capture_source,
11733 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011734 .setup = alc262_hippo_setup,
11735 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020011736 },
Tobin Davisf651b502007-10-26 12:40:47 +020011737 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011738 .mixers = { alc262_ultra_mixer },
11739 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011740 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011741 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11742 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011743 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11744 .channel_mode = alc262_modes,
11745 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011746 .adc_nids = alc262_adc_nids, /* ADC0 */
11747 .capsrc_nids = alc262_capsrc_nids,
11748 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011749 .unsol_event = alc262_ultra_unsol_event,
11750 .init_hook = alc262_ultra_automute,
11751 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011752 [ALC262_LENOVO_3000] = {
11753 .mixers = { alc262_lenovo_3000_mixer },
11754 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050011755 alc262_lenovo_3000_unsol_verbs,
11756 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011757 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11758 .dac_nids = alc262_dac_nids,
11759 .hp_nid = 0x03,
11760 .dig_out_nid = ALC262_DIGOUT_NID,
11761 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11762 .channel_mode = alc262_modes,
11763 .input_mux = &alc262_fujitsu_capture_source,
11764 .unsol_event = alc262_lenovo_3000_unsol_event,
11765 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011766 [ALC262_NEC] = {
11767 .mixers = { alc262_nec_mixer },
11768 .init_verbs = { alc262_nec_verbs },
11769 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11770 .dac_nids = alc262_dac_nids,
11771 .hp_nid = 0x03,
11772 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11773 .channel_mode = alc262_modes,
11774 .input_mux = &alc262_capture_source,
11775 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011776 [ALC262_TOSHIBA_S06] = {
11777 .mixers = { alc262_toshiba_s06_mixer },
11778 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11779 alc262_eapd_verbs },
11780 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11781 .capsrc_nids = alc262_dmic_capsrc_nids,
11782 .dac_nids = alc262_dac_nids,
11783 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011784 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011785 .dig_out_nid = ALC262_DIGOUT_NID,
11786 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11787 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011788 .unsol_event = alc_sku_unsol_event,
11789 .setup = alc262_toshiba_s06_setup,
11790 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020011791 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011792 [ALC262_TOSHIBA_RX1] = {
11793 .mixers = { alc262_toshiba_rx1_mixer },
11794 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11795 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11796 .dac_nids = alc262_dac_nids,
11797 .hp_nid = 0x03,
11798 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11799 .channel_mode = alc262_modes,
11800 .input_mux = &alc262_capture_source,
11801 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011802 .setup = alc262_hippo_setup,
11803 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011804 },
Tony Vroonba340e82009-02-02 19:01:30 +000011805 [ALC262_TYAN] = {
11806 .mixers = { alc262_tyan_mixer },
11807 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11808 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11809 .dac_nids = alc262_dac_nids,
11810 .hp_nid = 0x02,
11811 .dig_out_nid = ALC262_DIGOUT_NID,
11812 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11813 .channel_mode = alc262_modes,
11814 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011815 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011816 .setup = alc262_tyan_setup,
11817 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000011818 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011819};
11820
11821static int patch_alc262(struct hda_codec *codec)
11822{
11823 struct alc_spec *spec;
11824 int board_config;
11825 int err;
11826
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011827 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011828 if (spec == NULL)
11829 return -ENOMEM;
11830
11831 codec->spec = spec;
11832#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011833 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11834 * under-run
11835 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011836 {
11837 int tmp;
11838 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11839 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11840 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11841 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11842 }
11843#endif
11844
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011845 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11846
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011847 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11848 alc262_models,
11849 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011850
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011851 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011852 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11853 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011854 board_config = ALC262_AUTO;
11855 }
11856
11857 if (board_config == ALC262_AUTO) {
11858 /* automatic parse from the BIOS config */
11859 err = alc262_parse_auto_config(codec);
11860 if (err < 0) {
11861 alc_free(codec);
11862 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011863 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011864 printk(KERN_INFO
11865 "hda_codec: Cannot set up configuration "
11866 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011867 board_config = ALC262_BASIC;
11868 }
11869 }
11870
Takashi Iwai07eba612009-02-19 08:06:35 +010011871 if (!spec->no_analog) {
11872 err = snd_hda_attach_beep_device(codec, 0x1);
11873 if (err < 0) {
11874 alc_free(codec);
11875 return err;
11876 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011877 }
11878
Kailang Yangdf694da2005-12-05 19:42:22 +010011879 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011880 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011881
Kailang Yangdf694da2005-12-05 19:42:22 +010011882 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11883 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011884
Kailang Yangdf694da2005-12-05 19:42:22 +010011885 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11886 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11887
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011888 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011889 int i;
11890 /* check whether the digital-mic has to be supported */
11891 for (i = 0; i < spec->input_mux->num_items; i++) {
11892 if (spec->input_mux->items[i].index >= 9)
11893 break;
11894 }
11895 if (i < spec->input_mux->num_items) {
11896 /* use only ADC0 */
11897 spec->adc_nids = alc262_dmic_adc_nids;
11898 spec->num_adc_nids = 1;
11899 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011900 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011901 /* all analog inputs */
11902 /* check whether NID 0x07 is valid */
11903 unsigned int wcap = get_wcaps(codec, 0x07);
11904
11905 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011906 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020011907 if (wcap != AC_WID_AUD_IN) {
11908 spec->adc_nids = alc262_adc_nids_alt;
11909 spec->num_adc_nids =
11910 ARRAY_SIZE(alc262_adc_nids_alt);
11911 spec->capsrc_nids = alc262_capsrc_nids_alt;
11912 } else {
11913 spec->adc_nids = alc262_adc_nids;
11914 spec->num_adc_nids =
11915 ARRAY_SIZE(alc262_adc_nids);
11916 spec->capsrc_nids = alc262_capsrc_nids;
11917 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011918 }
11919 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011920 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011921 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011922 if (!spec->no_analog)
11923 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011924
Takashi Iwai2134ea42008-01-10 16:53:55 +010011925 spec->vmaster_nid = 0x0c;
11926
Kailang Yangdf694da2005-12-05 19:42:22 +010011927 codec->patch_ops = alc_patch_ops;
11928 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011929 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011930#ifdef CONFIG_SND_HDA_POWER_SAVE
11931 if (!spec->loopback.amplist)
11932 spec->loopback.amplist = alc262_loopbacks;
11933#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011934 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011935
Kailang Yangdf694da2005-12-05 19:42:22 +010011936 return 0;
11937}
11938
Kailang Yangdf694da2005-12-05 19:42:22 +010011939/*
Kailang Yanga361d842007-06-05 12:30:55 +020011940 * ALC268 channel source setting (2 channel)
11941 */
11942#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11943#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011944
Kailang Yanga361d842007-06-05 12:30:55 +020011945static hda_nid_t alc268_dac_nids[2] = {
11946 /* front, hp */
11947 0x02, 0x03
11948};
11949
11950static hda_nid_t alc268_adc_nids[2] = {
11951 /* ADC0-1 */
11952 0x08, 0x07
11953};
11954
11955static hda_nid_t alc268_adc_nids_alt[1] = {
11956 /* ADC0 */
11957 0x08
11958};
11959
Takashi Iwaie1406342008-02-11 18:32:32 +010011960static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11961
Kailang Yanga361d842007-06-05 12:30:55 +020011962static struct snd_kcontrol_new alc268_base_mixer[] = {
11963 /* output mixer control */
11964 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11965 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11966 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11967 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011968 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11969 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11970 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011971 { }
11972};
11973
Takashi Iwai42171c12009-05-08 14:11:43 +020011974static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11975 /* output mixer control */
11976 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11977 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11978 ALC262_HIPPO_MASTER_SWITCH,
11979 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11980 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11981 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11982 { }
11983};
11984
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011985/* bind Beep switches of both NID 0x0f and 0x10 */
11986static struct hda_bind_ctls alc268_bind_beep_sw = {
11987 .ops = &snd_hda_bind_sw,
11988 .values = {
11989 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11990 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11991 0
11992 },
11993};
11994
11995static struct snd_kcontrol_new alc268_beep_mixer[] = {
11996 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11997 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11998 { }
11999};
12000
Kailang Yangd1a991a2007-08-15 16:21:59 +020012001static struct hda_verb alc268_eapd_verbs[] = {
12002 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12003 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12004 { }
12005};
12006
Takashi Iwaid2738092007-08-16 14:59:45 +020012007/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012008static struct hda_verb alc268_toshiba_verbs[] = {
12009 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12010 { } /* end */
12011};
12012
12013/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012014/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012015static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12016 .ops = &snd_hda_bind_vol,
12017 .values = {
12018 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12019 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12020 0
12021 },
12022};
12023
Takashi Iwai889c4392007-08-23 18:56:52 +020012024/* mute/unmute internal speaker according to the hp jack and mute state */
12025static void alc268_acer_automute(struct hda_codec *codec, int force)
12026{
12027 struct alc_spec *spec = codec->spec;
12028 unsigned int mute;
12029
12030 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012031 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012032 spec->sense_updated = 1;
12033 }
12034 if (spec->jack_present)
12035 mute = HDA_AMP_MUTE; /* mute internal speaker */
12036 else /* unmute internal speaker if necessary */
12037 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12038 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12039 HDA_AMP_MUTE, mute);
12040}
12041
12042
12043/* bind hp and internal speaker mute (with plug check) */
12044static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12045 struct snd_ctl_elem_value *ucontrol)
12046{
12047 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12048 long *valp = ucontrol->value.integer.value;
12049 int change;
12050
Takashi Iwai8de56b72009-07-24 16:51:47 +020012051 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012052 if (change)
12053 alc268_acer_automute(codec, 0);
12054 return change;
12055}
Takashi Iwaid2738092007-08-16 14:59:45 +020012056
Kailang Yang8ef355d2008-08-26 13:10:22 +020012057static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12058 /* output mixer control */
12059 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12060 {
12061 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12062 .name = "Master Playback Switch",
12063 .info = snd_hda_mixer_amp_switch_info,
12064 .get = snd_hda_mixer_amp_switch_get,
12065 .put = alc268_acer_master_sw_put,
12066 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12067 },
12068 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12069 { }
12070};
12071
Takashi Iwaid2738092007-08-16 14:59:45 +020012072static struct snd_kcontrol_new alc268_acer_mixer[] = {
12073 /* output mixer control */
12074 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12075 {
12076 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12077 .name = "Master Playback Switch",
12078 .info = snd_hda_mixer_amp_switch_info,
12079 .get = snd_hda_mixer_amp_switch_get,
12080 .put = alc268_acer_master_sw_put,
12081 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12082 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012083 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12084 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12085 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012086 { }
12087};
12088
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012089static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12090 /* output mixer control */
12091 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12092 {
12093 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12094 .name = "Master Playback Switch",
12095 .info = snd_hda_mixer_amp_switch_info,
12096 .get = snd_hda_mixer_amp_switch_get,
12097 .put = alc268_acer_master_sw_put,
12098 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12099 },
12100 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12101 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12102 { }
12103};
12104
Kailang Yang8ef355d2008-08-26 13:10:22 +020012105static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12106 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12107 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12108 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12109 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12110 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12111 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12112 { }
12113};
12114
Takashi Iwaid2738092007-08-16 14:59:45 +020012115static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012116 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12117 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012118 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12119 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012120 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12121 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012122 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12123 { }
12124};
12125
12126/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012127#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012128#define alc268_toshiba_setup alc262_hippo_setup
12129#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012130
12131static void alc268_acer_unsol_event(struct hda_codec *codec,
12132 unsigned int res)
12133{
Takashi Iwai889c4392007-08-23 18:56:52 +020012134 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012135 return;
12136 alc268_acer_automute(codec, 1);
12137}
12138
Takashi Iwai889c4392007-08-23 18:56:52 +020012139static void alc268_acer_init_hook(struct hda_codec *codec)
12140{
12141 alc268_acer_automute(codec, 1);
12142}
12143
Kailang Yang8ef355d2008-08-26 13:10:22 +020012144/* toggle speaker-output according to the hp-jack state */
12145static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12146{
12147 unsigned int present;
12148 unsigned char bits;
12149
Wu Fengguang864f92b2009-11-18 12:38:02 +080012150 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012151 bits = present ? AMP_IN_MUTE(0) : 0;
12152 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
12153 AMP_IN_MUTE(0), bits);
12154 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
12155 AMP_IN_MUTE(0), bits);
12156}
12157
Kailang Yang8ef355d2008-08-26 13:10:22 +020012158static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12159 unsigned int res)
12160{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012161 switch (res >> 26) {
12162 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012163 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012164 break;
12165 case ALC880_MIC_EVENT:
12166 alc_mic_automute(codec);
12167 break;
12168 }
12169}
12170
12171static void alc268_acer_lc_setup(struct hda_codec *codec)
12172{
12173 struct alc_spec *spec = codec->spec;
12174 spec->ext_mic.pin = 0x18;
12175 spec->ext_mic.mux_idx = 0;
12176 spec->int_mic.pin = 0x12;
12177 spec->int_mic.mux_idx = 6;
12178 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012179}
12180
12181static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12182{
12183 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012184 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012185}
12186
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012187static struct snd_kcontrol_new alc268_dell_mixer[] = {
12188 /* output mixer control */
12189 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12190 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12191 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12192 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12193 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12194 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12195 { }
12196};
12197
12198static struct hda_verb alc268_dell_verbs[] = {
12199 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12200 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12201 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012202 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012203 { }
12204};
12205
12206/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012207static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012208{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012209 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012210
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012211 spec->autocfg.hp_pins[0] = 0x15;
12212 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012213 spec->ext_mic.pin = 0x18;
12214 spec->ext_mic.mux_idx = 0;
12215 spec->int_mic.pin = 0x19;
12216 spec->int_mic.mux_idx = 1;
12217 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012218}
12219
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012220static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12221 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12222 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12223 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12224 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12225 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12226 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12227 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12228 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12229 { }
12230};
12231
12232static struct hda_verb alc267_quanta_il1_verbs[] = {
12233 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12234 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12235 { }
12236};
12237
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012238static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012239{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012240 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012241 spec->autocfg.hp_pins[0] = 0x15;
12242 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012243 spec->ext_mic.pin = 0x18;
12244 spec->ext_mic.mux_idx = 0;
12245 spec->int_mic.pin = 0x19;
12246 spec->int_mic.mux_idx = 1;
12247 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012248}
12249
Kailang Yanga361d842007-06-05 12:30:55 +020012250/*
12251 * generic initialization of ADC, input mixers and output mixers
12252 */
12253static struct hda_verb alc268_base_init_verbs[] = {
12254 /* Unmute DAC0-1 and set vol = 0 */
12255 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012256 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012257
12258 /*
12259 * Set up output mixers (0x0c - 0x0e)
12260 */
12261 /* set vol=0 to output mixers */
12262 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012263 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12264
12265 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12266 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12267
12268 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12269 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12270 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12271 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12272 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12273 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12274 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12275 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12276
12277 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12278 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12279 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12280 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012281 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012282
12283 /* set PCBEEP vol = 0, mute connections */
12284 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12285 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12286 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012287
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012288 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012289
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012290 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12291 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12292 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12293 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012294
Kailang Yanga361d842007-06-05 12:30:55 +020012295 { }
12296};
12297
12298/*
12299 * generic initialization of ADC, input mixers and output mixers
12300 */
12301static struct hda_verb alc268_volume_init_verbs[] = {
12302 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012303 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12304 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012305
12306 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12307 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12308 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12309 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12310 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12311
Kailang Yanga361d842007-06-05 12:30:55 +020012312 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012313 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12314 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12315
12316 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012317 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012318
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012319 /* set PCBEEP vol = 0, mute connections */
12320 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12321 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12322 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012323
12324 { }
12325};
12326
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012327static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12328 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12329 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12330 { } /* end */
12331};
12332
Kailang Yanga361d842007-06-05 12:30:55 +020012333static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12334 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12335 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012336 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012337 { } /* end */
12338};
12339
12340static struct snd_kcontrol_new alc268_capture_mixer[] = {
12341 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12342 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12343 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12344 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012345 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012346 { } /* end */
12347};
12348
12349static struct hda_input_mux alc268_capture_source = {
12350 .num_items = 4,
12351 .items = {
12352 { "Mic", 0x0 },
12353 { "Front Mic", 0x1 },
12354 { "Line", 0x2 },
12355 { "CD", 0x3 },
12356 },
12357};
12358
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012359static struct hda_input_mux alc268_acer_capture_source = {
12360 .num_items = 3,
12361 .items = {
12362 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012363 { "Internal Mic", 0x1 },
12364 { "Line", 0x2 },
12365 },
12366};
12367
12368static struct hda_input_mux alc268_acer_dmic_capture_source = {
12369 .num_items = 3,
12370 .items = {
12371 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012372 { "Internal Mic", 0x6 },
12373 { "Line", 0x2 },
12374 },
12375};
12376
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012377#ifdef CONFIG_SND_DEBUG
12378static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012379 /* Volume widgets */
12380 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12381 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12382 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12383 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12384 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12385 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12386 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12387 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12388 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12389 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12390 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12391 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12392 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012393 /* The below appears problematic on some hardwares */
12394 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012395 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12396 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12397 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12398 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12399
12400 /* Modes for retasking pin widgets */
12401 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12402 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12403 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12404 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12405
12406 /* Controls for GPIO pins, assuming they are configured as outputs */
12407 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12408 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12409 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12410 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12411
12412 /* Switches to allow the digital SPDIF output pin to be enabled.
12413 * The ALC268 does not have an SPDIF input.
12414 */
12415 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12416
12417 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12418 * this output to turn on an external amplifier.
12419 */
12420 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12421 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12422
12423 { } /* end */
12424};
12425#endif
12426
Kailang Yanga361d842007-06-05 12:30:55 +020012427/* create input playback/capture controls for the given pin */
12428static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12429 const char *ctlname, int idx)
12430{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012431 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012432 int err;
12433
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012434 switch (nid) {
12435 case 0x14:
12436 case 0x16:
12437 dac = 0x02;
12438 break;
12439 case 0x15:
12440 dac = 0x03;
12441 break;
12442 default:
12443 return 0;
12444 }
12445 if (spec->multiout.dac_nids[0] != dac &&
12446 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012447 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012448 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012449 HDA_OUTPUT));
12450 if (err < 0)
12451 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012452 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12453 }
12454
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012455 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012456 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020012457 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012458 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012459 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012460 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012461 if (err < 0)
12462 return err;
12463 return 0;
12464}
12465
12466/* add playback controls from the parsed DAC table */
12467static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12468 const struct auto_pin_cfg *cfg)
12469{
12470 hda_nid_t nid;
12471 int err;
12472
Kailang Yanga361d842007-06-05 12:30:55 +020012473 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012474
12475 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012476 if (nid) {
12477 const char *name;
12478 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12479 name = "Speaker";
12480 else
12481 name = "Front";
12482 err = alc268_new_analog_output(spec, nid, name, 0);
12483 if (err < 0)
12484 return err;
12485 }
Kailang Yanga361d842007-06-05 12:30:55 +020012486
12487 nid = cfg->speaker_pins[0];
12488 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012489 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020012490 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12491 if (err < 0)
12492 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012493 } else {
12494 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12495 if (err < 0)
12496 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012497 }
12498 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012499 if (nid) {
12500 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12501 if (err < 0)
12502 return err;
12503 }
Kailang Yanga361d842007-06-05 12:30:55 +020012504
12505 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12506 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012507 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012508 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012509 if (err < 0)
12510 return err;
12511 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012512 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012513}
12514
12515/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020012516static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020012517 const struct auto_pin_cfg *cfg)
12518{
Takashi Iwai05f5f472009-08-25 13:10:18 +020012519 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020012520}
12521
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012522static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12523 hda_nid_t nid, int pin_type)
12524{
12525 int idx;
12526
12527 alc_set_pin_output(codec, nid, pin_type);
12528 if (nid == 0x14 || nid == 0x16)
12529 idx = 0;
12530 else
12531 idx = 1;
12532 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12533}
12534
12535static void alc268_auto_init_multi_out(struct hda_codec *codec)
12536{
12537 struct alc_spec *spec = codec->spec;
12538 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12539 if (nid) {
12540 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12541 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12542 }
12543}
12544
12545static void alc268_auto_init_hp_out(struct hda_codec *codec)
12546{
12547 struct alc_spec *spec = codec->spec;
12548 hda_nid_t pin;
12549
12550 pin = spec->autocfg.hp_pins[0];
12551 if (pin)
12552 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12553 pin = spec->autocfg.speaker_pins[0];
12554 if (pin)
12555 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12556}
12557
Kailang Yanga361d842007-06-05 12:30:55 +020012558static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12559{
12560 struct alc_spec *spec = codec->spec;
12561 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12562 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12563 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12564 unsigned int dac_vol1, dac_vol2;
12565
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012566 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020012567 snd_hda_codec_write(codec, speaker_nid, 0,
12568 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012569 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012570 snd_hda_codec_write(codec, 0x0f, 0,
12571 AC_VERB_SET_AMP_GAIN_MUTE,
12572 AMP_IN_UNMUTE(1));
12573 snd_hda_codec_write(codec, 0x10, 0,
12574 AC_VERB_SET_AMP_GAIN_MUTE,
12575 AMP_IN_UNMUTE(1));
12576 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012577 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012578 snd_hda_codec_write(codec, 0x0f, 0,
12579 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12580 snd_hda_codec_write(codec, 0x10, 0,
12581 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12582 }
12583
12584 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012585 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012586 dac_vol2 = AMP_OUT_ZERO;
12587 else if (line_nid == 0x15)
12588 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012589 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012590 dac_vol2 = AMP_OUT_ZERO;
12591 else if (hp_nid == 0x15)
12592 dac_vol1 = AMP_OUT_ZERO;
12593 if (line_nid != 0x16 || hp_nid != 0x16 ||
12594 spec->autocfg.line_out_pins[1] != 0x16 ||
12595 spec->autocfg.line_out_pins[2] != 0x16)
12596 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12597
12598 snd_hda_codec_write(codec, 0x02, 0,
12599 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12600 snd_hda_codec_write(codec, 0x03, 0,
12601 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12602}
12603
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012604/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012605#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12606#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012607#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012608#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12609
12610/*
12611 * BIOS auto configuration
12612 */
12613static int alc268_parse_auto_config(struct hda_codec *codec)
12614{
12615 struct alc_spec *spec = codec->spec;
12616 int err;
12617 static hda_nid_t alc268_ignore[] = { 0 };
12618
12619 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12620 alc268_ignore);
12621 if (err < 0)
12622 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012623 if (!spec->autocfg.line_outs) {
12624 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12625 spec->multiout.max_channels = 2;
12626 spec->no_analog = 1;
12627 goto dig_only;
12628 }
Kailang Yanga361d842007-06-05 12:30:55 +020012629 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012630 }
Kailang Yanga361d842007-06-05 12:30:55 +020012631 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12632 if (err < 0)
12633 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012634 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020012635 if (err < 0)
12636 return err;
12637
12638 spec->multiout.max_channels = 2;
12639
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012640 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012641 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012642 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012643 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012644 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12645 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012646 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012647 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012648
Takashi Iwai892981f2009-03-02 08:04:35 +010012649 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012650 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012651
Takashi Iwaid88897e2008-10-31 15:01:37 +010012652 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012653 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012654 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012655
Takashi Iwai776e1842007-08-29 15:07:11 +020012656 err = alc_auto_add_mic_boost(codec);
12657 if (err < 0)
12658 return err;
12659
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012660 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12661
Kailang Yanga361d842007-06-05 12:30:55 +020012662 return 1;
12663}
12664
Kailang Yanga361d842007-06-05 12:30:55 +020012665#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12666
12667/* init callback for auto-configuration model -- overriding the default init */
12668static void alc268_auto_init(struct hda_codec *codec)
12669{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012670 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012671 alc268_auto_init_multi_out(codec);
12672 alc268_auto_init_hp_out(codec);
12673 alc268_auto_init_mono_speaker_out(codec);
12674 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012675 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012676 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012677}
12678
12679/*
12680 * configuration and preset
12681 */
12682static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012683 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012684 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012685 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012686 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012687 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012688 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012689 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012690 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012691#ifdef CONFIG_SND_DEBUG
12692 [ALC268_TEST] = "test",
12693#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012694 [ALC268_AUTO] = "auto",
12695};
12696
12697static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012698 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012699 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012700 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012701 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012702 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012703 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12704 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012705 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050012706 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
12707 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020012708 /* almost compatible with toshiba but with optional digital outs;
12709 * auto-probing seems working fine
12710 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012711 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020012712 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020012713 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012714 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012715 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012716 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012717 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012718 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012719 {}
12720};
12721
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012722/* Toshiba laptops have no unique PCI SSID but only codec SSID */
12723static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
12724 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
12725 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
12726 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12727 ALC268_TOSHIBA),
12728 {}
12729};
12730
Kailang Yanga361d842007-06-05 12:30:55 +020012731static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012732 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012733 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
12734 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012735 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12736 alc267_quanta_il1_verbs },
12737 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12738 .dac_nids = alc268_dac_nids,
12739 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12740 .adc_nids = alc268_adc_nids_alt,
12741 .hp_nid = 0x03,
12742 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12743 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012744 .unsol_event = alc_sku_unsol_event,
12745 .setup = alc267_quanta_il1_setup,
12746 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012747 },
Kailang Yanga361d842007-06-05 12:30:55 +020012748 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012749 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12750 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012751 .init_verbs = { alc268_base_init_verbs },
12752 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12753 .dac_nids = alc268_dac_nids,
12754 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12755 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012756 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012757 .hp_nid = 0x03,
12758 .dig_out_nid = ALC268_DIGOUT_NID,
12759 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12760 .channel_mode = alc268_modes,
12761 .input_mux = &alc268_capture_source,
12762 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012763 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012764 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012765 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012766 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12767 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012768 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12769 .dac_nids = alc268_dac_nids,
12770 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12771 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012772 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012773 .hp_nid = 0x03,
12774 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12775 .channel_mode = alc268_modes,
12776 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012777 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012778 .setup = alc268_toshiba_setup,
12779 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020012780 },
12781 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020012782 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012783 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012784 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12785 alc268_acer_verbs },
12786 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12787 .dac_nids = alc268_dac_nids,
12788 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12789 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012790 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012791 .hp_nid = 0x02,
12792 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12793 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012794 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012795 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012796 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012797 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012798 [ALC268_ACER_DMIC] = {
12799 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12800 alc268_beep_mixer },
12801 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12802 alc268_acer_verbs },
12803 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12804 .dac_nids = alc268_dac_nids,
12805 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12806 .adc_nids = alc268_adc_nids_alt,
12807 .capsrc_nids = alc268_capsrc_nids,
12808 .hp_nid = 0x02,
12809 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12810 .channel_mode = alc268_modes,
12811 .input_mux = &alc268_acer_dmic_capture_source,
12812 .unsol_event = alc268_acer_unsol_event,
12813 .init_hook = alc268_acer_init_hook,
12814 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012815 [ALC268_ACER_ASPIRE_ONE] = {
12816 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012817 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012818 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012819 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12820 alc268_acer_aspire_one_verbs },
12821 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12822 .dac_nids = alc268_dac_nids,
12823 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12824 .adc_nids = alc268_adc_nids_alt,
12825 .capsrc_nids = alc268_capsrc_nids,
12826 .hp_nid = 0x03,
12827 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12828 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012829 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012830 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012831 .init_hook = alc268_acer_lc_init_hook,
12832 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012833 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012834 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
12835 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012836 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12837 alc268_dell_verbs },
12838 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12839 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012840 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12841 .adc_nids = alc268_adc_nids_alt,
12842 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012843 .hp_nid = 0x02,
12844 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12845 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012846 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012847 .setup = alc268_dell_setup,
12848 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012849 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012850 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012851 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12852 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012853 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12854 alc268_toshiba_verbs },
12855 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12856 .dac_nids = alc268_dac_nids,
12857 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12858 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012859 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012860 .hp_nid = 0x03,
12861 .dig_out_nid = ALC268_DIGOUT_NID,
12862 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12863 .channel_mode = alc268_modes,
12864 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012865 .setup = alc268_toshiba_setup,
12866 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012867 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012868#ifdef CONFIG_SND_DEBUG
12869 [ALC268_TEST] = {
12870 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12871 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12872 alc268_volume_init_verbs },
12873 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12874 .dac_nids = alc268_dac_nids,
12875 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12876 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012877 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012878 .hp_nid = 0x03,
12879 .dig_out_nid = ALC268_DIGOUT_NID,
12880 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12881 .channel_mode = alc268_modes,
12882 .input_mux = &alc268_capture_source,
12883 },
12884#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012885};
12886
12887static int patch_alc268(struct hda_codec *codec)
12888{
12889 struct alc_spec *spec;
12890 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012891 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012892
12893 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12894 if (spec == NULL)
12895 return -ENOMEM;
12896
12897 codec->spec = spec;
12898
12899 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12900 alc268_models,
12901 alc268_cfg_tbl);
12902
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012903 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
12904 board_config = snd_hda_check_board_codec_sid_config(codec,
12905 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
12906
Kailang Yanga361d842007-06-05 12:30:55 +020012907 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012908 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12909 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012910 board_config = ALC268_AUTO;
12911 }
12912
12913 if (board_config == ALC268_AUTO) {
12914 /* automatic parse from the BIOS config */
12915 err = alc268_parse_auto_config(codec);
12916 if (err < 0) {
12917 alc_free(codec);
12918 return err;
12919 } else if (!err) {
12920 printk(KERN_INFO
12921 "hda_codec: Cannot set up configuration "
12922 "from BIOS. Using base mode...\n");
12923 board_config = ALC268_3ST;
12924 }
12925 }
12926
12927 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012928 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020012929
Kailang Yanga361d842007-06-05 12:30:55 +020012930 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12931 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012932 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012933
Kailang Yanga361d842007-06-05 12:30:55 +020012934 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12935
Takashi Iwai22971e32009-02-10 11:56:44 +010012936 has_beep = 0;
12937 for (i = 0; i < spec->num_mixers; i++) {
12938 if (spec->mixers[i] == alc268_beep_mixer) {
12939 has_beep = 1;
12940 break;
12941 }
12942 }
12943
12944 if (has_beep) {
12945 err = snd_hda_attach_beep_device(codec, 0x1);
12946 if (err < 0) {
12947 alc_free(codec);
12948 return err;
12949 }
12950 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12951 /* override the amp caps for beep generator */
12952 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012953 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12954 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12955 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12956 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012957 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012958
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012959 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012960 /* check whether NID 0x07 is valid */
12961 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012962 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012963
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020012964 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012965 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012966 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012967 if (spec->auto_mic ||
12968 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012969 spec->adc_nids = alc268_adc_nids_alt;
12970 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020012971 if (spec->auto_mic)
12972 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012973 if (spec->auto_mic || spec->input_mux->num_items == 1)
12974 add_mixer(spec, alc268_capture_nosrc_mixer);
12975 else
12976 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012977 } else {
12978 spec->adc_nids = alc268_adc_nids;
12979 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012980 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012981 }
Takashi Iwai85860c02008-02-19 15:00:15 +010012982 /* set default input source */
12983 for (i = 0; i < spec->num_adc_nids; i++)
12984 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12985 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012986 i < spec->num_mux_defs ?
12987 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010012988 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012989 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012990
12991 spec->vmaster_nid = 0x02;
12992
Kailang Yanga361d842007-06-05 12:30:55 +020012993 codec->patch_ops = alc_patch_ops;
12994 if (board_config == ALC268_AUTO)
12995 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012996
Takashi Iwaidaead532008-11-28 12:55:36 +010012997 codec->proc_widget_hook = print_realtek_coef;
12998
Kailang Yanga361d842007-06-05 12:30:55 +020012999 return 0;
13000}
13001
13002/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013003 * ALC269 channel source setting (2 channel)
13004 */
13005#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13006
13007#define alc269_dac_nids alc260_dac_nids
13008
13009static hda_nid_t alc269_adc_nids[1] = {
13010 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013011 0x08,
13012};
13013
Takashi Iwaie01bf502008-08-21 16:25:07 +020013014static hda_nid_t alc269_capsrc_nids[1] = {
13015 0x23,
13016};
13017
13018/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
13019 * not a mux!
13020 */
13021
Kailang Yangf6a92242007-12-13 16:52:54 +010013022#define alc269_modes alc260_modes
13023#define alc269_capture_source alc880_lg_lw_capture_source
13024
13025static struct snd_kcontrol_new alc269_base_mixer[] = {
13026 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13027 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13028 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13029 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13030 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13031 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13032 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13033 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13034 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13035 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13036 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13037 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13038 { } /* end */
13039};
13040
Kailang Yang60db6b52008-08-26 13:13:00 +020013041static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13042 /* output mixer control */
13043 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13044 {
13045 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13046 .name = "Master Playback Switch",
13047 .info = snd_hda_mixer_amp_switch_info,
13048 .get = snd_hda_mixer_amp_switch_get,
13049 .put = alc268_acer_master_sw_put,
13050 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13051 },
13052 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13053 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13054 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13055 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13056 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13057 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013058 { }
13059};
13060
Tony Vroon64154832008-11-06 15:08:49 +000013061static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13062 /* output mixer control */
13063 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13064 {
13065 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13066 .name = "Master Playback Switch",
13067 .info = snd_hda_mixer_amp_switch_info,
13068 .get = snd_hda_mixer_amp_switch_get,
13069 .put = alc268_acer_master_sw_put,
13070 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13071 },
13072 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13073 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13074 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13075 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13076 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13077 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13078 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13079 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13080 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013081 { }
13082};
13083
Kailang Yangf53281e2008-07-18 12:36:43 +020013084static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013085 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013086 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013087 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013088 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013089 { } /* end */
13090};
13091
Kailang Yangf6a92242007-12-13 16:52:54 +010013092/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020013093static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
13094 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13095 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013096 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13097 { } /* end */
13098};
13099
13100/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020013101#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013102
Kailang Yang60db6b52008-08-26 13:13:00 +020013103static struct hda_verb alc269_quanta_fl1_verbs[] = {
13104 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13105 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13106 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13107 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13108 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13109 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13110 { }
13111};
13112
Tony Vroon64154832008-11-06 15:08:49 +000013113static struct hda_verb alc269_lifebook_verbs[] = {
13114 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13115 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13116 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13117 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13118 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13119 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13120 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13121 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13122 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13123 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13124 { }
13125};
13126
Kailang Yang60db6b52008-08-26 13:13:00 +020013127/* toggle speaker-output according to the hp-jack state */
13128static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13129{
13130 unsigned int present;
13131 unsigned char bits;
13132
Wu Fengguang864f92b2009-11-18 12:38:02 +080013133 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang60db6b52008-08-26 13:13:00 +020013134 bits = present ? AMP_IN_MUTE(0) : 0;
13135 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13136 AMP_IN_MUTE(0), bits);
13137 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13138 AMP_IN_MUTE(0), bits);
13139
13140 snd_hda_codec_write(codec, 0x20, 0,
13141 AC_VERB_SET_COEF_INDEX, 0x0c);
13142 snd_hda_codec_write(codec, 0x20, 0,
13143 AC_VERB_SET_PROC_COEF, 0x680);
13144
13145 snd_hda_codec_write(codec, 0x20, 0,
13146 AC_VERB_SET_COEF_INDEX, 0x0c);
13147 snd_hda_codec_write(codec, 0x20, 0,
13148 AC_VERB_SET_PROC_COEF, 0x480);
13149}
13150
Tony Vroon64154832008-11-06 15:08:49 +000013151/* toggle speaker-output according to the hp-jacks state */
13152static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13153{
13154 unsigned int present;
13155 unsigned char bits;
13156
13157 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013158 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013159
13160 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013161 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013162
13163 bits = present ? AMP_IN_MUTE(0) : 0;
13164 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13165 AMP_IN_MUTE(0), bits);
13166 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13167 AMP_IN_MUTE(0), bits);
13168
13169 snd_hda_codec_write(codec, 0x20, 0,
13170 AC_VERB_SET_COEF_INDEX, 0x0c);
13171 snd_hda_codec_write(codec, 0x20, 0,
13172 AC_VERB_SET_PROC_COEF, 0x680);
13173
13174 snd_hda_codec_write(codec, 0x20, 0,
13175 AC_VERB_SET_COEF_INDEX, 0x0c);
13176 snd_hda_codec_write(codec, 0x20, 0,
13177 AC_VERB_SET_PROC_COEF, 0x480);
13178}
13179
Tony Vroon64154832008-11-06 15:08:49 +000013180static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13181{
13182 unsigned int present_laptop;
13183 unsigned int present_dock;
13184
Wu Fengguang864f92b2009-11-18 12:38:02 +080013185 present_laptop = snd_hda_jack_detect(codec, 0x18);
13186 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000013187
13188 /* Laptop mic port overrides dock mic port, design decision */
13189 if (present_dock)
13190 snd_hda_codec_write(codec, 0x23, 0,
13191 AC_VERB_SET_CONNECT_SEL, 0x3);
13192 if (present_laptop)
13193 snd_hda_codec_write(codec, 0x23, 0,
13194 AC_VERB_SET_CONNECT_SEL, 0x0);
13195 if (!present_dock && !present_laptop)
13196 snd_hda_codec_write(codec, 0x23, 0,
13197 AC_VERB_SET_CONNECT_SEL, 0x1);
13198}
13199
Kailang Yang60db6b52008-08-26 13:13:00 +020013200static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13201 unsigned int res)
13202{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013203 switch (res >> 26) {
13204 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013205 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013206 break;
13207 case ALC880_MIC_EVENT:
13208 alc_mic_automute(codec);
13209 break;
13210 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013211}
13212
Tony Vroon64154832008-11-06 15:08:49 +000013213static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13214 unsigned int res)
13215{
13216 if ((res >> 26) == ALC880_HP_EVENT)
13217 alc269_lifebook_speaker_automute(codec);
13218 if ((res >> 26) == ALC880_MIC_EVENT)
13219 alc269_lifebook_mic_autoswitch(codec);
13220}
13221
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013222static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13223{
13224 struct alc_spec *spec = codec->spec;
13225 spec->ext_mic.pin = 0x18;
13226 spec->ext_mic.mux_idx = 0;
13227 spec->int_mic.pin = 0x19;
13228 spec->int_mic.mux_idx = 1;
13229 spec->auto_mic = 1;
13230}
13231
Kailang Yang60db6b52008-08-26 13:13:00 +020013232static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13233{
13234 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013235 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013236}
13237
Tony Vroon64154832008-11-06 15:08:49 +000013238static void alc269_lifebook_init_hook(struct hda_codec *codec)
13239{
13240 alc269_lifebook_speaker_automute(codec);
13241 alc269_lifebook_mic_autoswitch(codec);
13242}
13243
Kailang Yang60db6b52008-08-26 13:13:00 +020013244static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
13245 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13246 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13247 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13248 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13249 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13250 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13251 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13252 {}
13253};
13254
13255static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
13256 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13257 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13258 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13259 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13260 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13261 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13262 {}
13263};
13264
13265/* toggle speaker-output according to the hp-jack state */
13266static void alc269_speaker_automute(struct hda_codec *codec)
13267{
Kailang Yangebb83ee2009-12-17 12:23:00 +010013268 struct alc_spec *spec = codec->spec;
13269 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020013270 unsigned int present;
13271 unsigned char bits;
13272
Kailang Yangebb83ee2009-12-17 12:23:00 +010013273 present = snd_hda_jack_detect(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020013274 bits = present ? AMP_IN_MUTE(0) : 0;
13275 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13276 AMP_IN_MUTE(0), bits);
13277 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13278 AMP_IN_MUTE(0), bits);
13279}
13280
Kailang Yang60db6b52008-08-26 13:13:00 +020013281/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013282static void alc269_eeepc_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013283 unsigned int res)
13284{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013285 switch (res >> 26) {
13286 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013287 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013288 break;
13289 case ALC880_MIC_EVENT:
13290 alc_mic_automute(codec);
13291 break;
13292 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013293}
13294
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013295static void alc269_eeepc_dmic_setup(struct hda_codec *codec)
13296{
13297 struct alc_spec *spec = codec->spec;
13298 spec->ext_mic.pin = 0x18;
13299 spec->ext_mic.mux_idx = 0;
13300 spec->int_mic.pin = 0x12;
13301 spec->int_mic.mux_idx = 5;
13302 spec->auto_mic = 1;
13303}
13304
13305static void alc269_eeepc_amic_setup(struct hda_codec *codec)
13306{
13307 struct alc_spec *spec = codec->spec;
13308 spec->ext_mic.pin = 0x18;
13309 spec->ext_mic.mux_idx = 0;
13310 spec->int_mic.pin = 0x19;
13311 spec->int_mic.mux_idx = 1;
13312 spec->auto_mic = 1;
13313}
13314
13315static void alc269_eeepc_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013316{
13317 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013318 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013319}
13320
Kailang Yangf6a92242007-12-13 16:52:54 +010013321/*
13322 * generic initialization of ADC, input mixers and output mixers
13323 */
13324static struct hda_verb alc269_init_verbs[] = {
13325 /*
13326 * Unmute ADC0 and set the default input to mic-in
13327 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013328 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013329
13330 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13331 * analog-loopback mixer widget
13332 * Note: PASD motherboards uses the Line In 2 as the input for
13333 * front panel mic (mic 2)
13334 */
13335 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13336 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13337 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13338 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13339 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13340 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13341
13342 /*
13343 * Set up output mixers (0x0c - 0x0e)
13344 */
13345 /* set vol=0 to output mixers */
13346 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13347 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13348
13349 /* set up input amps for analog loopback */
13350 /* Amp Indices: DAC = 0, mixer = 1 */
13351 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13352 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13353 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13354 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13355 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13356 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13357
13358 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13359 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13360 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13361 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13362 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13363 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13364 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13365
13366 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13367 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13368 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13369 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13370 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13371 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13372 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13373
13374 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13375 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13376
13377 /* FIXME: use matrix-type input source selection */
13378 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13379 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013380 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13381 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013382 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13383 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13384
13385 /* set EAPD */
13386 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13387 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13388 { }
13389};
13390
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013391#define alc269_auto_create_multi_out_ctls \
13392 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020013393#define alc269_auto_create_input_ctls \
13394 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013395
13396#ifdef CONFIG_SND_HDA_POWER_SAVE
13397#define alc269_loopbacks alc880_loopbacks
13398#endif
13399
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013400/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013401#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13402#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13403#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13404#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13405
Takashi Iwaif03d3112009-03-05 14:18:16 +010013406static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13407 .substreams = 1,
13408 .channels_min = 2,
13409 .channels_max = 8,
13410 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13411 /* NID is set in alc_build_pcms */
13412 .ops = {
13413 .open = alc880_playback_pcm_open,
13414 .prepare = alc880_playback_pcm_prepare,
13415 .cleanup = alc880_playback_pcm_cleanup
13416 },
13417};
13418
13419static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13420 .substreams = 1,
13421 .channels_min = 2,
13422 .channels_max = 2,
13423 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13424 /* NID is set in alc_build_pcms */
13425};
13426
Kailang Yangf6a92242007-12-13 16:52:54 +010013427/*
13428 * BIOS auto configuration
13429 */
13430static int alc269_parse_auto_config(struct hda_codec *codec)
13431{
13432 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013433 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013434 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13435
13436 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13437 alc269_ignore);
13438 if (err < 0)
13439 return err;
13440
13441 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13442 if (err < 0)
13443 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013444 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010013445 if (err < 0)
13446 return err;
13447
13448 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13449
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013450 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013451 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13452
Takashi Iwai603c4012008-07-30 15:01:44 +020013453 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013454 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013455
Takashi Iwaid88897e2008-10-31 15:01:37 +010013456 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013457 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013458 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013459 /* set default input source */
13460 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13461 0, AC_VERB_SET_CONNECT_SEL,
13462 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013463
13464 err = alc_auto_add_mic_boost(codec);
13465 if (err < 0)
13466 return err;
13467
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013468 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013469 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013470
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013471 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13472
Kailang Yangf6a92242007-12-13 16:52:54 +010013473 return 1;
13474}
13475
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013476#define alc269_auto_init_multi_out alc268_auto_init_multi_out
13477#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010013478#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13479
13480
13481/* init callback for auto-configuration model -- overriding the default init */
13482static void alc269_auto_init(struct hda_codec *codec)
13483{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013484 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013485 alc269_auto_init_multi_out(codec);
13486 alc269_auto_init_hp_out(codec);
13487 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013488 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013489 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013490}
13491
13492/*
13493 * configuration and preset
13494 */
13495static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013496 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013497 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013498 [ALC269_ASUS_AMIC] = "asus-amic",
13499 [ALC269_ASUS_DMIC] = "asus-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000013500 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020013501 [ALC269_LIFEBOOK] = "lifebook",
13502 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010013503};
13504
13505static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013506 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013507 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013508 ALC269_ASUS_AMIC),
13509 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_ASUS_AMIC),
13510 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80JT", ALC269_ASUS_AMIC),
13511 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_ASUS_AMIC),
13512 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_ASUS_AMIC),
13513 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_ASUS_AMIC),
13514 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_ASUS_AMIC),
13515 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_ASUS_AMIC),
13516 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_ASUS_AMIC),
13517 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_ASUS_AMIC),
13518 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_ASUS_AMIC),
13519 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_ASUS_AMIC),
13520 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_ASUS_AMIC),
13521 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_ASUS_AMIC),
13522 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_ASUS_AMIC),
13523 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_ASUS_AMIC),
13524 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_ASUS_AMIC),
13525 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_ASUS_AMIC),
13526 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_ASUS_AMIC),
13527 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_ASUS_AMIC),
13528 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_ASUS_AMIC),
13529 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_AMIC),
13530 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_ASUS_AMIC),
13531 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_AMIC),
13532 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_DMIC),
13533 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_AMIC),
13534 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_AMIC),
13535 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_AMIC),
13536 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020013537 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013538 ALC269_ASUS_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020013539 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yangebb83ee2009-12-17 12:23:00 +010013540 ALC269_ASUS_DMIC),
13541 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_ASUS_DMIC),
13542 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_ASUS_DMIC),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013543 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013544 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013545 {}
13546};
13547
13548static struct alc_config_preset alc269_presets[] = {
13549 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013550 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013551 .init_verbs = { alc269_init_verbs },
13552 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13553 .dac_nids = alc269_dac_nids,
13554 .hp_nid = 0x03,
13555 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13556 .channel_mode = alc269_modes,
13557 .input_mux = &alc269_capture_source,
13558 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013559 [ALC269_QUANTA_FL1] = {
13560 .mixers = { alc269_quanta_fl1_mixer },
13561 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13562 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13563 .dac_nids = alc269_dac_nids,
13564 .hp_nid = 0x03,
13565 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13566 .channel_mode = alc269_modes,
13567 .input_mux = &alc269_capture_source,
13568 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013569 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020013570 .init_hook = alc269_quanta_fl1_init_hook,
13571 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010013572 [ALC269_ASUS_AMIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013573 .mixers = { alc269_eeepc_mixer },
13574 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013575 .init_verbs = { alc269_init_verbs,
13576 alc269_eeepc_amic_init_verbs },
13577 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13578 .dac_nids = alc269_dac_nids,
13579 .hp_nid = 0x03,
13580 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13581 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013582 .unsol_event = alc269_eeepc_unsol_event,
13583 .setup = alc269_eeepc_amic_setup,
13584 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013585 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010013586 [ALC269_ASUS_DMIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013587 .mixers = { alc269_eeepc_mixer },
13588 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013589 .init_verbs = { alc269_init_verbs,
13590 alc269_eeepc_dmic_init_verbs },
13591 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13592 .dac_nids = alc269_dac_nids,
13593 .hp_nid = 0x03,
13594 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13595 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013596 .unsol_event = alc269_eeepc_unsol_event,
13597 .setup = alc269_eeepc_dmic_setup,
13598 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013599 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013600 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013601 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013602 .cap_mixer = alc269_epc_capture_mixer,
13603 .init_verbs = { alc269_init_verbs,
13604 alc269_eeepc_dmic_init_verbs },
13605 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13606 .dac_nids = alc269_dac_nids,
13607 .hp_nid = 0x03,
13608 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13609 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013610 .unsol_event = alc269_eeepc_unsol_event,
13611 .setup = alc269_eeepc_dmic_setup,
13612 .init_hook = alc269_eeepc_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010013613 },
Tony Vroon64154832008-11-06 15:08:49 +000013614 [ALC269_LIFEBOOK] = {
13615 .mixers = { alc269_lifebook_mixer },
13616 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13617 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13618 .dac_nids = alc269_dac_nids,
13619 .hp_nid = 0x03,
13620 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13621 .channel_mode = alc269_modes,
13622 .input_mux = &alc269_capture_source,
13623 .unsol_event = alc269_lifebook_unsol_event,
13624 .init_hook = alc269_lifebook_init_hook,
13625 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013626};
13627
13628static int patch_alc269(struct hda_codec *codec)
13629{
13630 struct alc_spec *spec;
13631 int board_config;
13632 int err;
13633
13634 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13635 if (spec == NULL)
13636 return -ENOMEM;
13637
13638 codec->spec = spec;
13639
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013640 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13641
Kailang Yang274693f2009-12-03 10:07:50 +010013642 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
13643 kfree(codec->chip_name);
13644 codec->chip_name = kstrdup("ALC259", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010013645 if (!codec->chip_name) {
13646 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010013647 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010013648 }
Kailang Yang274693f2009-12-03 10:07:50 +010013649 }
13650
Kailang Yangf6a92242007-12-13 16:52:54 +010013651 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13652 alc269_models,
13653 alc269_cfg_tbl);
13654
13655 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013656 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13657 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013658 board_config = ALC269_AUTO;
13659 }
13660
13661 if (board_config == ALC269_AUTO) {
13662 /* automatic parse from the BIOS config */
13663 err = alc269_parse_auto_config(codec);
13664 if (err < 0) {
13665 alc_free(codec);
13666 return err;
13667 } else if (!err) {
13668 printk(KERN_INFO
13669 "hda_codec: Cannot set up configuration "
13670 "from BIOS. Using base mode...\n");
13671 board_config = ALC269_BASIC;
13672 }
13673 }
13674
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013675 err = snd_hda_attach_beep_device(codec, 0x1);
13676 if (err < 0) {
13677 alc_free(codec);
13678 return err;
13679 }
13680
Kailang Yangf6a92242007-12-13 16:52:54 +010013681 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013682 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010013683
Takashi Iwaif03d3112009-03-05 14:18:16 +010013684 if (codec->subsystem_id == 0x17aa3bf8) {
13685 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13686 * fix the sample rate of analog I/O to 44.1kHz
13687 */
13688 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13689 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13690 } else {
13691 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13692 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13693 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013694 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13695 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13696
13697 spec->adc_nids = alc269_adc_nids;
13698 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013699 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013700 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013701 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013702 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013703
Takashi Iwai100d5eb2009-08-10 11:55:51 +020013704 spec->vmaster_nid = 0x02;
13705
Kailang Yangf6a92242007-12-13 16:52:54 +010013706 codec->patch_ops = alc_patch_ops;
13707 if (board_config == ALC269_AUTO)
13708 spec->init_hook = alc269_auto_init;
13709#ifdef CONFIG_SND_HDA_POWER_SAVE
13710 if (!spec->loopback.amplist)
13711 spec->loopback.amplist = alc269_loopbacks;
13712#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013713 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013714
13715 return 0;
13716}
13717
13718/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013719 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13720 */
13721
13722/*
13723 * set the path ways for 2 channel output
13724 * need to set the codec line out and mic 1 pin widgets to inputs
13725 */
13726static struct hda_verb alc861_threestack_ch2_init[] = {
13727 /* set pin widget 1Ah (line in) for input */
13728 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013729 /* set pin widget 18h (mic1/2) for input, for mic also enable
13730 * the vref
13731 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013732 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13733
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013734 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13735#if 0
13736 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13737 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13738#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013739 { } /* end */
13740};
13741/*
13742 * 6ch mode
13743 * need to set the codec line out and mic 1 pin widgets to outputs
13744 */
13745static struct hda_verb alc861_threestack_ch6_init[] = {
13746 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13747 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13748 /* set pin widget 18h (mic1) for output (CLFE)*/
13749 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13750
13751 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013752 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013753
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013754 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13755#if 0
13756 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13757 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13758#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013759 { } /* end */
13760};
13761
13762static struct hda_channel_mode alc861_threestack_modes[2] = {
13763 { 2, alc861_threestack_ch2_init },
13764 { 6, alc861_threestack_ch6_init },
13765};
Takashi Iwai22309c32006-08-09 16:57:28 +020013766/* Set mic1 as input and unmute the mixer */
13767static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13768 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13769 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13770 { } /* end */
13771};
13772/* Set mic1 as output and mute mixer */
13773static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13774 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13775 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13776 { } /* end */
13777};
13778
13779static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13780 { 2, alc861_uniwill_m31_ch2_init },
13781 { 4, alc861_uniwill_m31_ch4_init },
13782};
Kailang Yangdf694da2005-12-05 19:42:22 +010013783
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013784/* Set mic1 and line-in as input and unmute the mixer */
13785static struct hda_verb alc861_asus_ch2_init[] = {
13786 /* set pin widget 1Ah (line in) for input */
13787 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013788 /* set pin widget 18h (mic1/2) for input, for mic also enable
13789 * the vref
13790 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013791 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13792
13793 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13794#if 0
13795 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13796 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13797#endif
13798 { } /* end */
13799};
13800/* Set mic1 nad line-in as output and mute mixer */
13801static struct hda_verb alc861_asus_ch6_init[] = {
13802 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13803 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13804 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13805 /* set pin widget 18h (mic1) for output (CLFE)*/
13806 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13807 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13808 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13809 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13810
13811 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13812#if 0
13813 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13814 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13815#endif
13816 { } /* end */
13817};
13818
13819static struct hda_channel_mode alc861_asus_modes[2] = {
13820 { 2, alc861_asus_ch2_init },
13821 { 6, alc861_asus_ch6_init },
13822};
13823
Kailang Yangdf694da2005-12-05 19:42:22 +010013824/* patch-ALC861 */
13825
13826static struct snd_kcontrol_new alc861_base_mixer[] = {
13827 /* output mixer control */
13828 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13829 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13830 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13831 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13832 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13833
13834 /*Input mixer control */
13835 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13836 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13837 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13838 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13839 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13840 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13841 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13842 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13843 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13844 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013845
Kailang Yangdf694da2005-12-05 19:42:22 +010013846 { } /* end */
13847};
13848
13849static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13850 /* output mixer control */
13851 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13852 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13853 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13854 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13855 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13856
13857 /* Input mixer control */
13858 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13859 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13860 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13861 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13862 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13863 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13864 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13865 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13866 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13867 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013868
Kailang Yangdf694da2005-12-05 19:42:22 +010013869 {
13870 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13871 .name = "Channel Mode",
13872 .info = alc_ch_mode_info,
13873 .get = alc_ch_mode_get,
13874 .put = alc_ch_mode_put,
13875 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13876 },
13877 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013878};
13879
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013880static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013881 /* output mixer control */
13882 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13883 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13884 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013885
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013886 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013887};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013888
Takashi Iwai22309c32006-08-09 16:57:28 +020013889static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13890 /* output mixer control */
13891 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13892 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13893 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13894 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13895 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13896
13897 /* Input mixer control */
13898 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13899 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13900 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13901 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13902 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13903 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13904 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13905 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13906 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13907 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013908
Takashi Iwai22309c32006-08-09 16:57:28 +020013909 {
13910 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13911 .name = "Channel Mode",
13912 .info = alc_ch_mode_info,
13913 .get = alc_ch_mode_get,
13914 .put = alc_ch_mode_put,
13915 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13916 },
13917 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013918};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013919
13920static struct snd_kcontrol_new alc861_asus_mixer[] = {
13921 /* output mixer control */
13922 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13923 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13924 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13925 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13926 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13927
13928 /* Input mixer control */
13929 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13930 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13931 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13932 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13933 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13934 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13936 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13937 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013938 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13939
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013940 {
13941 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13942 .name = "Channel Mode",
13943 .info = alc_ch_mode_info,
13944 .get = alc_ch_mode_get,
13945 .put = alc_ch_mode_put,
13946 .private_value = ARRAY_SIZE(alc861_asus_modes),
13947 },
13948 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013949};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013950
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013951/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013952static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013953 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13954 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013955 { }
13956};
13957
Kailang Yangdf694da2005-12-05 19:42:22 +010013958/*
13959 * generic initialization of ADC, input mixers and output mixers
13960 */
13961static struct hda_verb alc861_base_init_verbs[] = {
13962 /*
13963 * Unmute ADC0 and set the default input to mic-in
13964 */
13965 /* port-A for surround (rear panel) */
13966 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13967 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13968 /* port-B for mic-in (rear panel) with vref */
13969 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13970 /* port-C for line-in (rear panel) */
13971 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13972 /* port-D for Front */
13973 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13974 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13975 /* port-E for HP out (front panel) */
13976 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13977 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013978 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013979 /* port-F for mic-in (front panel) with vref */
13980 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13981 /* port-G for CLFE (rear panel) */
13982 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13983 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13984 /* port-H for side (rear panel) */
13985 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13986 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13987 /* CD-in */
13988 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13989 /* route front mic to ADC1*/
13990 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13991 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013992
Kailang Yangdf694da2005-12-05 19:42:22 +010013993 /* Unmute DAC0~3 & spdif out*/
13994 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13995 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13996 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13997 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13998 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013999
Kailang Yangdf694da2005-12-05 19:42:22 +010014000 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14001 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14002 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14003 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14004 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014005
Kailang Yangdf694da2005-12-05 19:42:22 +010014006 /* Unmute Stereo Mixer 15 */
14007 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14008 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14009 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014010 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014011
14012 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14013 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14014 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14015 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14016 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14017 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14018 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14019 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014020 /* hp used DAC 3 (Front) */
14021 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014022 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14023
14024 { }
14025};
14026
14027static struct hda_verb alc861_threestack_init_verbs[] = {
14028 /*
14029 * Unmute ADC0 and set the default input to mic-in
14030 */
14031 /* port-A for surround (rear panel) */
14032 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14033 /* port-B for mic-in (rear panel) with vref */
14034 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14035 /* port-C for line-in (rear panel) */
14036 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14037 /* port-D for Front */
14038 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14039 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14040 /* port-E for HP out (front panel) */
14041 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14042 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014043 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014044 /* port-F for mic-in (front panel) with vref */
14045 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14046 /* port-G for CLFE (rear panel) */
14047 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14048 /* port-H for side (rear panel) */
14049 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14050 /* CD-in */
14051 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14052 /* route front mic to ADC1*/
14053 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14054 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14055 /* Unmute DAC0~3 & spdif out*/
14056 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14057 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14058 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14059 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14060 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014061
Kailang Yangdf694da2005-12-05 19:42:22 +010014062 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14063 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14064 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14065 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14066 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014067
Kailang Yangdf694da2005-12-05 19:42:22 +010014068 /* Unmute Stereo Mixer 15 */
14069 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14070 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14071 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014072 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014073
14074 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14075 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14076 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14077 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14078 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14079 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14080 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14081 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014082 /* hp used DAC 3 (Front) */
14083 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014084 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14085 { }
14086};
Takashi Iwai22309c32006-08-09 16:57:28 +020014087
14088static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
14089 /*
14090 * Unmute ADC0 and set the default input to mic-in
14091 */
14092 /* port-A for surround (rear panel) */
14093 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14094 /* port-B for mic-in (rear panel) with vref */
14095 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14096 /* port-C for line-in (rear panel) */
14097 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14098 /* port-D for Front */
14099 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14100 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14101 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014102 /* this has to be set to VREF80 */
14103 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014104 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014105 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014106 /* port-F for mic-in (front panel) with vref */
14107 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14108 /* port-G for CLFE (rear panel) */
14109 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14110 /* port-H for side (rear panel) */
14111 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14112 /* CD-in */
14113 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14114 /* route front mic to ADC1*/
14115 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14116 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14117 /* Unmute DAC0~3 & spdif out*/
14118 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14119 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14120 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14121 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14122 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014123
Takashi Iwai22309c32006-08-09 16:57:28 +020014124 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14125 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14126 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14127 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14128 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014129
Takashi Iwai22309c32006-08-09 16:57:28 +020014130 /* Unmute Stereo Mixer 15 */
14131 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14132 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14133 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014134 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014135
14136 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14137 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14138 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14139 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14140 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14141 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14142 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14143 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014144 /* hp used DAC 3 (Front) */
14145 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014146 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14147 { }
14148};
14149
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014150static struct hda_verb alc861_asus_init_verbs[] = {
14151 /*
14152 * Unmute ADC0 and set the default input to mic-in
14153 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014154 /* port-A for surround (rear panel)
14155 * according to codec#0 this is the HP jack
14156 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014157 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14158 /* route front PCM to HP */
14159 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14160 /* port-B for mic-in (rear panel) with vref */
14161 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14162 /* port-C for line-in (rear panel) */
14163 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14164 /* port-D for Front */
14165 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14166 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14167 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014168 /* this has to be set to VREF80 */
14169 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014170 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014171 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014172 /* port-F for mic-in (front panel) with vref */
14173 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14174 /* port-G for CLFE (rear panel) */
14175 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14176 /* port-H for side (rear panel) */
14177 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14178 /* CD-in */
14179 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14180 /* route front mic to ADC1*/
14181 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14182 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14183 /* Unmute DAC0~3 & spdif out*/
14184 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14185 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14186 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14187 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14188 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14189 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14190 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14191 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14192 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14193 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014194
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014195 /* Unmute Stereo Mixer 15 */
14196 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14197 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14198 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014199 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014200
14201 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14202 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14203 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14204 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14205 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14206 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14207 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14208 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014209 /* hp used DAC 3 (Front) */
14210 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014211 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14212 { }
14213};
14214
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014215/* additional init verbs for ASUS laptops */
14216static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14217 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14218 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14219 { }
14220};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014221
Kailang Yangdf694da2005-12-05 19:42:22 +010014222/*
14223 * generic initialization of ADC, input mixers and output mixers
14224 */
14225static struct hda_verb alc861_auto_init_verbs[] = {
14226 /*
14227 * Unmute ADC0 and set the default input to mic-in
14228 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014229 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014230 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014231
Kailang Yangdf694da2005-12-05 19:42:22 +010014232 /* Unmute DAC0~3 & spdif out*/
14233 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14234 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14235 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14236 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14237 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014238
Kailang Yangdf694da2005-12-05 19:42:22 +010014239 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14240 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14241 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14242 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14243 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014244
Kailang Yangdf694da2005-12-05 19:42:22 +010014245 /* Unmute Stereo Mixer 15 */
14246 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14247 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14248 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14249 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14250
Takashi Iwai1c209302009-07-22 15:17:45 +020014251 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14252 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14253 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14254 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14255 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14256 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14257 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14258 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014259
14260 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14261 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014262 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14263 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014264 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14265 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014266 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14267 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014268
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014269 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014270
14271 { }
14272};
14273
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014274static struct hda_verb alc861_toshiba_init_verbs[] = {
14275 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014276
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014277 { }
14278};
14279
14280/* toggle speaker-output according to the hp-jack state */
14281static void alc861_toshiba_automute(struct hda_codec *codec)
14282{
Wu Fengguang864f92b2009-11-18 12:38:02 +080014283 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014284
Takashi Iwai47fd8302007-08-10 17:11:07 +020014285 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14286 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14287 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14288 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014289}
14290
14291static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14292 unsigned int res)
14293{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014294 if ((res >> 26) == ALC880_HP_EVENT)
14295 alc861_toshiba_automute(codec);
14296}
14297
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014298/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014299#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14300#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14301#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14302#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14303
14304
14305#define ALC861_DIGOUT_NID 0x07
14306
14307static struct hda_channel_mode alc861_8ch_modes[1] = {
14308 { 8, NULL }
14309};
14310
14311static hda_nid_t alc861_dac_nids[4] = {
14312 /* front, surround, clfe, side */
14313 0x03, 0x06, 0x05, 0x04
14314};
14315
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014316static hda_nid_t alc660_dac_nids[3] = {
14317 /* front, clfe, surround */
14318 0x03, 0x05, 0x06
14319};
14320
Kailang Yangdf694da2005-12-05 19:42:22 +010014321static hda_nid_t alc861_adc_nids[1] = {
14322 /* ADC0-2 */
14323 0x08,
14324};
14325
14326static struct hda_input_mux alc861_capture_source = {
14327 .num_items = 5,
14328 .items = {
14329 { "Mic", 0x0 },
14330 { "Front Mic", 0x3 },
14331 { "Line", 0x1 },
14332 { "CD", 0x4 },
14333 { "Mixer", 0x5 },
14334 },
14335};
14336
Takashi Iwai1c209302009-07-22 15:17:45 +020014337static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14338{
14339 struct alc_spec *spec = codec->spec;
14340 hda_nid_t mix, srcs[5];
14341 int i, j, num;
14342
14343 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14344 return 0;
14345 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14346 if (num < 0)
14347 return 0;
14348 for (i = 0; i < num; i++) {
14349 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014350 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014351 if (type != AC_WID_AUD_OUT)
14352 continue;
14353 for (j = 0; j < spec->multiout.num_dacs; j++)
14354 if (spec->multiout.dac_nids[j] == srcs[i])
14355 break;
14356 if (j >= spec->multiout.num_dacs)
14357 return srcs[i];
14358 }
14359 return 0;
14360}
14361
Kailang Yangdf694da2005-12-05 19:42:22 +010014362/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014363static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014364 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014365{
Takashi Iwai1c209302009-07-22 15:17:45 +020014366 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014367 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014368 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014369
14370 spec->multiout.dac_nids = spec->private_dac_nids;
14371 for (i = 0; i < cfg->line_outs; i++) {
14372 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014373 dac = alc861_look_for_dac(codec, nid);
14374 if (!dac)
14375 continue;
14376 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014377 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014378 return 0;
14379}
14380
Takashi Iwai1c209302009-07-22 15:17:45 +020014381static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14382 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014383{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020014384 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020014385 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14386}
14387
14388/* add playback controls from the parsed DAC table */
14389static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14390 const struct auto_pin_cfg *cfg)
14391{
14392 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014393 static const char *chname[4] = {
14394 "Front", "Surround", NULL /*CLFE*/, "Side"
14395 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014396 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014397 int i, err;
14398
14399 if (cfg->line_outs == 1) {
14400 const char *pfx = NULL;
14401 if (!cfg->hp_outs)
14402 pfx = "Master";
14403 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14404 pfx = "Speaker";
14405 if (pfx) {
14406 nid = spec->multiout.dac_nids[0];
14407 return alc861_create_out_sw(codec, pfx, nid, 3);
14408 }
14409 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014410
14411 for (i = 0; i < cfg->line_outs; i++) {
14412 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014413 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014414 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014415 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014416 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014417 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014418 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014419 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014420 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014421 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014422 return err;
14423 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014424 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014425 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014426 return err;
14427 }
14428 }
14429 return 0;
14430}
14431
Takashi Iwai1c209302009-07-22 15:17:45 +020014432static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014433{
Takashi Iwai1c209302009-07-22 15:17:45 +020014434 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014435 int err;
14436 hda_nid_t nid;
14437
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014438 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014439 return 0;
14440
14441 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014442 nid = alc861_look_for_dac(codec, pin);
14443 if (nid) {
14444 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14445 if (err < 0)
14446 return err;
14447 spec->multiout.hp_nid = nid;
14448 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014449 }
14450 return 0;
14451}
14452
14453/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020014454static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014455 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014456{
Takashi Iwai05f5f472009-08-25 13:10:18 +020014457 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014458}
14459
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014460static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14461 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014462 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014463{
Takashi Iwai1c209302009-07-22 15:17:45 +020014464 hda_nid_t mix, srcs[5];
14465 int i, num;
14466
Jacek Luczak564c5be2008-05-03 18:41:23 +020014467 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14468 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014469 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014470 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014471 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14472 return;
14473 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14474 if (num < 0)
14475 return;
14476 for (i = 0; i < num; i++) {
14477 unsigned int mute;
14478 if (srcs[i] == dac || srcs[i] == 0x15)
14479 mute = AMP_IN_UNMUTE(i);
14480 else
14481 mute = AMP_IN_MUTE(i);
14482 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14483 mute);
14484 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014485}
14486
14487static void alc861_auto_init_multi_out(struct hda_codec *codec)
14488{
14489 struct alc_spec *spec = codec->spec;
14490 int i;
14491
14492 for (i = 0; i < spec->autocfg.line_outs; i++) {
14493 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014494 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014495 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014496 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014497 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014498 }
14499}
14500
14501static void alc861_auto_init_hp_out(struct hda_codec *codec)
14502{
14503 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014504
Takashi Iwai15870f02009-10-05 08:25:13 +020014505 if (spec->autocfg.hp_outs)
14506 alc861_auto_set_output_and_unmute(codec,
14507 spec->autocfg.hp_pins[0],
14508 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014509 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020014510 if (spec->autocfg.speaker_outs)
14511 alc861_auto_set_output_and_unmute(codec,
14512 spec->autocfg.speaker_pins[0],
14513 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020014514 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014515}
14516
14517static void alc861_auto_init_analog_input(struct hda_codec *codec)
14518{
14519 struct alc_spec *spec = codec->spec;
14520 int i;
14521
14522 for (i = 0; i < AUTO_PIN_LAST; i++) {
14523 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014524 if (nid >= 0x0c && nid <= 0x11)
14525 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014526 }
14527}
14528
14529/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014530/* return 1 if successful, 0 if the proper config is not found,
14531 * or a negative error code
14532 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014533static int alc861_parse_auto_config(struct hda_codec *codec)
14534{
14535 struct alc_spec *spec = codec->spec;
14536 int err;
14537 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14538
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014539 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14540 alc861_ignore);
14541 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014542 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014543 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014544 return 0; /* can't find valid BIOS pin config */
14545
Takashi Iwai1c209302009-07-22 15:17:45 +020014546 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014547 if (err < 0)
14548 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014549 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014550 if (err < 0)
14551 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014552 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014553 if (err < 0)
14554 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014555 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014556 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014557 return err;
14558
14559 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14560
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014561 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014562 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14563
Takashi Iwai603c4012008-07-30 15:01:44 +020014564 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014565 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014566
Takashi Iwaid88897e2008-10-31 15:01:37 +010014567 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014568
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014569 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014570 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014571
14572 spec->adc_nids = alc861_adc_nids;
14573 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014574 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014575
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014576 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14577
Kailang Yangdf694da2005-12-05 19:42:22 +010014578 return 1;
14579}
14580
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014581/* additional initialization for auto-configuration model */
14582static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014583{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014584 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014585 alc861_auto_init_multi_out(codec);
14586 alc861_auto_init_hp_out(codec);
14587 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014588 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014589 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014590}
14591
Takashi Iwaicb53c622007-08-10 17:21:45 +020014592#ifdef CONFIG_SND_HDA_POWER_SAVE
14593static struct hda_amp_list alc861_loopbacks[] = {
14594 { 0x15, HDA_INPUT, 0 },
14595 { 0x15, HDA_INPUT, 1 },
14596 { 0x15, HDA_INPUT, 2 },
14597 { 0x15, HDA_INPUT, 3 },
14598 { } /* end */
14599};
14600#endif
14601
Kailang Yangdf694da2005-12-05 19:42:22 +010014602
14603/*
14604 * configuration and preset
14605 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014606static const char *alc861_models[ALC861_MODEL_LAST] = {
14607 [ALC861_3ST] = "3stack",
14608 [ALC660_3ST] = "3stack-660",
14609 [ALC861_3ST_DIG] = "3stack-dig",
14610 [ALC861_6ST_DIG] = "6stack-dig",
14611 [ALC861_UNIWILL_M31] = "uniwill-m31",
14612 [ALC861_TOSHIBA] = "toshiba",
14613 [ALC861_ASUS] = "asus",
14614 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14615 [ALC861_AUTO] = "auto",
14616};
14617
14618static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014619 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014620 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14621 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14622 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014623 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014624 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014625 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014626 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14627 * Any other models that need this preset?
14628 */
14629 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014630 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14631 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014632 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14633 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14634 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14635 /* FIXME: the below seems conflict */
14636 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14637 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14638 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014639 {}
14640};
14641
14642static struct alc_config_preset alc861_presets[] = {
14643 [ALC861_3ST] = {
14644 .mixers = { alc861_3ST_mixer },
14645 .init_verbs = { alc861_threestack_init_verbs },
14646 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14647 .dac_nids = alc861_dac_nids,
14648 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14649 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014650 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014651 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14652 .adc_nids = alc861_adc_nids,
14653 .input_mux = &alc861_capture_source,
14654 },
14655 [ALC861_3ST_DIG] = {
14656 .mixers = { alc861_base_mixer },
14657 .init_verbs = { alc861_threestack_init_verbs },
14658 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14659 .dac_nids = alc861_dac_nids,
14660 .dig_out_nid = ALC861_DIGOUT_NID,
14661 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14662 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014663 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014664 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14665 .adc_nids = alc861_adc_nids,
14666 .input_mux = &alc861_capture_source,
14667 },
14668 [ALC861_6ST_DIG] = {
14669 .mixers = { alc861_base_mixer },
14670 .init_verbs = { alc861_base_init_verbs },
14671 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14672 .dac_nids = alc861_dac_nids,
14673 .dig_out_nid = ALC861_DIGOUT_NID,
14674 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14675 .channel_mode = alc861_8ch_modes,
14676 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14677 .adc_nids = alc861_adc_nids,
14678 .input_mux = &alc861_capture_source,
14679 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014680 [ALC660_3ST] = {
14681 .mixers = { alc861_3ST_mixer },
14682 .init_verbs = { alc861_threestack_init_verbs },
14683 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14684 .dac_nids = alc660_dac_nids,
14685 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14686 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014687 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014688 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14689 .adc_nids = alc861_adc_nids,
14690 .input_mux = &alc861_capture_source,
14691 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014692 [ALC861_UNIWILL_M31] = {
14693 .mixers = { alc861_uniwill_m31_mixer },
14694 .init_verbs = { alc861_uniwill_m31_init_verbs },
14695 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14696 .dac_nids = alc861_dac_nids,
14697 .dig_out_nid = ALC861_DIGOUT_NID,
14698 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14699 .channel_mode = alc861_uniwill_m31_modes,
14700 .need_dac_fix = 1,
14701 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14702 .adc_nids = alc861_adc_nids,
14703 .input_mux = &alc861_capture_source,
14704 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014705 [ALC861_TOSHIBA] = {
14706 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014707 .init_verbs = { alc861_base_init_verbs,
14708 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014709 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14710 .dac_nids = alc861_dac_nids,
14711 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14712 .channel_mode = alc883_3ST_2ch_modes,
14713 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14714 .adc_nids = alc861_adc_nids,
14715 .input_mux = &alc861_capture_source,
14716 .unsol_event = alc861_toshiba_unsol_event,
14717 .init_hook = alc861_toshiba_automute,
14718 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014719 [ALC861_ASUS] = {
14720 .mixers = { alc861_asus_mixer },
14721 .init_verbs = { alc861_asus_init_verbs },
14722 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14723 .dac_nids = alc861_dac_nids,
14724 .dig_out_nid = ALC861_DIGOUT_NID,
14725 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14726 .channel_mode = alc861_asus_modes,
14727 .need_dac_fix = 1,
14728 .hp_nid = 0x06,
14729 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14730 .adc_nids = alc861_adc_nids,
14731 .input_mux = &alc861_capture_source,
14732 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014733 [ALC861_ASUS_LAPTOP] = {
14734 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14735 .init_verbs = { alc861_asus_init_verbs,
14736 alc861_asus_laptop_init_verbs },
14737 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14738 .dac_nids = alc861_dac_nids,
14739 .dig_out_nid = ALC861_DIGOUT_NID,
14740 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14741 .channel_mode = alc883_3ST_2ch_modes,
14742 .need_dac_fix = 1,
14743 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14744 .adc_nids = alc861_adc_nids,
14745 .input_mux = &alc861_capture_source,
14746 },
14747};
Kailang Yangdf694da2005-12-05 19:42:22 +010014748
Takashi Iwaicfc9b062009-12-01 12:19:37 +010014749/* Pin config fixes */
14750enum {
14751 PINFIX_FSC_AMILO_PI1505,
14752};
14753
14754static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = {
14755 { 0x0b, 0x0221101f }, /* HP */
14756 { 0x0f, 0x90170310 }, /* speaker */
14757 { }
14758};
14759
14760static const struct alc_fixup alc861_fixups[] = {
14761 [PINFIX_FSC_AMILO_PI1505] = {
14762 .pins = alc861_fsc_amilo_pi1505_pinfix
14763 },
14764};
14765
14766static struct snd_pci_quirk alc861_fixup_tbl[] = {
14767 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
14768 {}
14769};
Kailang Yangdf694da2005-12-05 19:42:22 +010014770
14771static int patch_alc861(struct hda_codec *codec)
14772{
14773 struct alc_spec *spec;
14774 int board_config;
14775 int err;
14776
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014777 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014778 if (spec == NULL)
14779 return -ENOMEM;
14780
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014781 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014782
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014783 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14784 alc861_models,
14785 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014786
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014787 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014788 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14789 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014790 board_config = ALC861_AUTO;
14791 }
14792
Takashi Iwaicfc9b062009-12-01 12:19:37 +010014793 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups);
14794
Kailang Yangdf694da2005-12-05 19:42:22 +010014795 if (board_config == ALC861_AUTO) {
14796 /* automatic parse from the BIOS config */
14797 err = alc861_parse_auto_config(codec);
14798 if (err < 0) {
14799 alc_free(codec);
14800 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014801 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014802 printk(KERN_INFO
14803 "hda_codec: Cannot set up configuration "
14804 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014805 board_config = ALC861_3ST_DIG;
14806 }
14807 }
14808
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014809 err = snd_hda_attach_beep_device(codec, 0x23);
14810 if (err < 0) {
14811 alc_free(codec);
14812 return err;
14813 }
14814
Kailang Yangdf694da2005-12-05 19:42:22 +010014815 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014816 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014817
Kailang Yangdf694da2005-12-05 19:42:22 +010014818 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14819 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14820
Kailang Yangdf694da2005-12-05 19:42:22 +010014821 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14822 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14823
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014824 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14825
Takashi Iwai2134ea42008-01-10 16:53:55 +010014826 spec->vmaster_nid = 0x03;
14827
Kailang Yangdf694da2005-12-05 19:42:22 +010014828 codec->patch_ops = alc_patch_ops;
14829 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014830 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014831#ifdef CONFIG_SND_HDA_POWER_SAVE
14832 if (!spec->loopback.amplist)
14833 spec->loopback.amplist = alc861_loopbacks;
14834#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014835 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014836
Kailang Yangdf694da2005-12-05 19:42:22 +010014837 return 0;
14838}
14839
14840/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014841 * ALC861-VD support
14842 *
14843 * Based on ALC882
14844 *
14845 * In addition, an independent DAC
14846 */
14847#define ALC861VD_DIGOUT_NID 0x06
14848
14849static hda_nid_t alc861vd_dac_nids[4] = {
14850 /* front, surr, clfe, side surr */
14851 0x02, 0x03, 0x04, 0x05
14852};
14853
14854/* dac_nids for ALC660vd are in a different order - according to
14855 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014856 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014857 * of ALC660vd codecs, but for now there is only 3stack mixer
14858 * - and it is the same as in 861vd.
14859 * adc_nids in ALC660vd are (is) the same as in 861vd
14860 */
14861static hda_nid_t alc660vd_dac_nids[3] = {
14862 /* front, rear, clfe, rear_surr */
14863 0x02, 0x04, 0x03
14864};
14865
14866static hda_nid_t alc861vd_adc_nids[1] = {
14867 /* ADC0 */
14868 0x09,
14869};
14870
Takashi Iwaie1406342008-02-11 18:32:32 +010014871static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14872
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014873/* input MUX */
14874/* FIXME: should be a matrix-type input source selection */
14875static struct hda_input_mux alc861vd_capture_source = {
14876 .num_items = 4,
14877 .items = {
14878 { "Mic", 0x0 },
14879 { "Front Mic", 0x1 },
14880 { "Line", 0x2 },
14881 { "CD", 0x4 },
14882 },
14883};
14884
Kailang Yang272a5272007-05-14 11:00:38 +020014885static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014886 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014887 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014888 { "Ext Mic", 0x0 },
14889 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014890 },
14891};
14892
Kailang Yangd1a991a2007-08-15 16:21:59 +020014893static struct hda_input_mux alc861vd_hp_capture_source = {
14894 .num_items = 2,
14895 .items = {
14896 { "Front Mic", 0x0 },
14897 { "ATAPI Mic", 0x1 },
14898 },
14899};
14900
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014901/*
14902 * 2ch mode
14903 */
14904static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14905 { 2, NULL }
14906};
14907
14908/*
14909 * 6ch mode
14910 */
14911static struct hda_verb alc861vd_6stack_ch6_init[] = {
14912 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14913 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14914 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14915 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14916 { } /* end */
14917};
14918
14919/*
14920 * 8ch mode
14921 */
14922static struct hda_verb alc861vd_6stack_ch8_init[] = {
14923 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14924 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14925 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14926 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14927 { } /* end */
14928};
14929
14930static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14931 { 6, alc861vd_6stack_ch6_init },
14932 { 8, alc861vd_6stack_ch8_init },
14933};
14934
14935static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14936 {
14937 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14938 .name = "Channel Mode",
14939 .info = alc_ch_mode_info,
14940 .get = alc_ch_mode_get,
14941 .put = alc_ch_mode_put,
14942 },
14943 { } /* end */
14944};
14945
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014946/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14947 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14948 */
14949static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14950 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14951 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14952
14953 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14954 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14955
14956 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14957 HDA_OUTPUT),
14958 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14959 HDA_OUTPUT),
14960 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14961 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14962
14963 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14964 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14965
14966 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14967
14968 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14970 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14971
14972 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14973 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14974 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14975
14976 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14977 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14978
14979 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14980 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14981
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014982 { } /* end */
14983};
14984
14985static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14986 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14987 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14988
14989 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14990
14991 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14992 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14993 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14994
14995 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14996 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14997 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14998
14999 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15000 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15001
15002 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15003 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15004
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015005 { } /* end */
15006};
15007
Kailang Yangbdd148a2007-05-08 15:19:08 +020015008static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
15009 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15010 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
15011 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15012
15013 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15014
15015 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15016 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15017 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15018
15019 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15020 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15021 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15022
15023 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15024 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15025
15026 { } /* end */
15027};
15028
Tobin Davisb419f342008-03-07 11:57:51 +010015029/* Pin assignment: Speaker=0x14, HP = 0x15,
15030 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020015031 */
15032static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010015033 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15034 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015035 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15036 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010015037 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
15038 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15039 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15040 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
15041 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15042 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015043 { } /* end */
15044};
15045
Kailang Yangd1a991a2007-08-15 16:21:59 +020015046/* Pin assignment: Speaker=0x14, Line-out = 0x15,
15047 * Front Mic=0x18, ATAPI Mic = 0x19,
15048 */
15049static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
15050 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15051 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15052 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15053 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
15054 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15055 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15056 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15057 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015058
Kailang Yangd1a991a2007-08-15 16:21:59 +020015059 { } /* end */
15060};
15061
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015062/*
15063 * generic initialization of ADC, input mixers and output mixers
15064 */
15065static struct hda_verb alc861vd_volume_init_verbs[] = {
15066 /*
15067 * Unmute ADC0 and set the default input to mic-in
15068 */
15069 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15070 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15071
15072 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
15073 * the analog-loopback mixer widget
15074 */
15075 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015076 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15077 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15078 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15079 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15080 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015081
15082 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020015083 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15084 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15085 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015086 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015087
15088 /*
15089 * Set up output mixers (0x02 - 0x05)
15090 */
15091 /* set vol=0 to output mixers */
15092 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15093 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15094 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15095 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15096
15097 /* set up input amps for analog loopback */
15098 /* Amp Indices: DAC = 0, mixer = 1 */
15099 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15100 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15101 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15102 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15103 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15104 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15105 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15106 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15107
15108 { }
15109};
15110
15111/*
15112 * 3-stack pin configuration:
15113 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
15114 */
15115static struct hda_verb alc861vd_3stack_init_verbs[] = {
15116 /*
15117 * Set pin mode and muting
15118 */
15119 /* set front pin widgets 0x14 for output */
15120 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15121 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15122 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15123
15124 /* Mic (rear) pin: input vref at 80% */
15125 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15126 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15127 /* Front Mic pin: input vref at 80% */
15128 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15129 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15130 /* Line In pin: input */
15131 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15132 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15133 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15134 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15135 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15136 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15137 /* CD pin widget for input */
15138 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15139
15140 { }
15141};
15142
15143/*
15144 * 6-stack pin configuration:
15145 */
15146static struct hda_verb alc861vd_6stack_init_verbs[] = {
15147 /*
15148 * Set pin mode and muting
15149 */
15150 /* set front pin widgets 0x14 for output */
15151 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15152 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15153 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15154
15155 /* Rear Pin: output 1 (0x0d) */
15156 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15157 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15158 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15159 /* CLFE Pin: output 2 (0x0e) */
15160 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15161 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15162 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15163 /* Side Pin: output 3 (0x0f) */
15164 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15165 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15166 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15167
15168 /* Mic (rear) pin: input vref at 80% */
15169 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15170 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15171 /* Front Mic pin: input vref at 80% */
15172 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15173 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15174 /* Line In pin: input */
15175 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15176 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15177 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15178 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15179 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15180 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15181 /* CD pin widget for input */
15182 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15183
15184 { }
15185};
15186
Kailang Yangbdd148a2007-05-08 15:19:08 +020015187static struct hda_verb alc861vd_eapd_verbs[] = {
15188 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15189 { }
15190};
15191
Kailang Yangf9423e72008-05-27 12:32:25 +020015192static struct hda_verb alc660vd_eapd_verbs[] = {
15193 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15194 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15195 { }
15196};
15197
Kailang Yangbdd148a2007-05-08 15:19:08 +020015198static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15199 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15200 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15201 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15202 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015203 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015204 {}
15205};
15206
Kailang Yangbdd148a2007-05-08 15:19:08 +020015207static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15208{
15209 unsigned int present;
15210 unsigned char bits;
15211
Wu Fengguang864f92b2009-11-18 12:38:02 +080015212 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020015213 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080015214
Takashi Iwai47fd8302007-08-10 17:11:07 +020015215 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15216 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015217}
15218
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015219static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015220{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015221 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015222 spec->autocfg.hp_pins[0] = 0x1b;
15223 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015224}
15225
15226static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15227{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015228 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015229 alc861vd_lenovo_mic_automute(codec);
15230}
15231
15232static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15233 unsigned int res)
15234{
15235 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015236 case ALC880_MIC_EVENT:
15237 alc861vd_lenovo_mic_automute(codec);
15238 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015239 default:
15240 alc_automute_amp_unsol_event(codec, res);
15241 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015242 }
15243}
15244
Kailang Yang272a5272007-05-14 11:00:38 +020015245static struct hda_verb alc861vd_dallas_verbs[] = {
15246 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15247 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15248 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15249 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15250
15251 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15252 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15253 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15254 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15255 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15256 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15257 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15258 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015259
Kailang Yang272a5272007-05-14 11:00:38 +020015260 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15261 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15262 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15263 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15264 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15265 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15266 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15267 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15268
15269 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15270 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15271 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15272 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15273 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15274 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15275 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15276 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15277
15278 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15279 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15280 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15281 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15282
15283 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015284 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015285 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15286
15287 { } /* end */
15288};
15289
15290/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015291static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015292{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015293 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015294
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015295 spec->autocfg.hp_pins[0] = 0x15;
15296 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020015297}
15298
Takashi Iwaicb53c622007-08-10 17:21:45 +020015299#ifdef CONFIG_SND_HDA_POWER_SAVE
15300#define alc861vd_loopbacks alc880_loopbacks
15301#endif
15302
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015303/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015304#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15305#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15306#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15307#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15308
15309/*
15310 * configuration and preset
15311 */
15312static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15313 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015314 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015315 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015316 [ALC861VD_3ST] = "3stack",
15317 [ALC861VD_3ST_DIG] = "3stack-digout",
15318 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015319 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015320 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015321 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015322 [ALC861VD_AUTO] = "auto",
15323};
15324
15325static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015326 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15327 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015328 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015329 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010015330 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015331 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015332 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015333 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015334 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015335 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015336 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015337 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015338 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015339 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015340 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015341 {}
15342};
15343
15344static struct alc_config_preset alc861vd_presets[] = {
15345 [ALC660VD_3ST] = {
15346 .mixers = { alc861vd_3st_mixer },
15347 .init_verbs = { alc861vd_volume_init_verbs,
15348 alc861vd_3stack_init_verbs },
15349 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15350 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015351 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15352 .channel_mode = alc861vd_3stack_2ch_modes,
15353 .input_mux = &alc861vd_capture_source,
15354 },
Mike Crash6963f842007-06-25 12:12:51 +020015355 [ALC660VD_3ST_DIG] = {
15356 .mixers = { alc861vd_3st_mixer },
15357 .init_verbs = { alc861vd_volume_init_verbs,
15358 alc861vd_3stack_init_verbs },
15359 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15360 .dac_nids = alc660vd_dac_nids,
15361 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015362 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15363 .channel_mode = alc861vd_3stack_2ch_modes,
15364 .input_mux = &alc861vd_capture_source,
15365 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015366 [ALC861VD_3ST] = {
15367 .mixers = { alc861vd_3st_mixer },
15368 .init_verbs = { alc861vd_volume_init_verbs,
15369 alc861vd_3stack_init_verbs },
15370 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15371 .dac_nids = alc861vd_dac_nids,
15372 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15373 .channel_mode = alc861vd_3stack_2ch_modes,
15374 .input_mux = &alc861vd_capture_source,
15375 },
15376 [ALC861VD_3ST_DIG] = {
15377 .mixers = { alc861vd_3st_mixer },
15378 .init_verbs = { alc861vd_volume_init_verbs,
15379 alc861vd_3stack_init_verbs },
15380 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15381 .dac_nids = alc861vd_dac_nids,
15382 .dig_out_nid = ALC861VD_DIGOUT_NID,
15383 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15384 .channel_mode = alc861vd_3stack_2ch_modes,
15385 .input_mux = &alc861vd_capture_source,
15386 },
15387 [ALC861VD_6ST_DIG] = {
15388 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15389 .init_verbs = { alc861vd_volume_init_verbs,
15390 alc861vd_6stack_init_verbs },
15391 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15392 .dac_nids = alc861vd_dac_nids,
15393 .dig_out_nid = ALC861VD_DIGOUT_NID,
15394 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15395 .channel_mode = alc861vd_6stack_modes,
15396 .input_mux = &alc861vd_capture_source,
15397 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015398 [ALC861VD_LENOVO] = {
15399 .mixers = { alc861vd_lenovo_mixer },
15400 .init_verbs = { alc861vd_volume_init_verbs,
15401 alc861vd_3stack_init_verbs,
15402 alc861vd_eapd_verbs,
15403 alc861vd_lenovo_unsol_verbs },
15404 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15405 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015406 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15407 .channel_mode = alc861vd_3stack_2ch_modes,
15408 .input_mux = &alc861vd_capture_source,
15409 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015410 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015411 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015412 },
Kailang Yang272a5272007-05-14 11:00:38 +020015413 [ALC861VD_DALLAS] = {
15414 .mixers = { alc861vd_dallas_mixer },
15415 .init_verbs = { alc861vd_dallas_verbs },
15416 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15417 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015418 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15419 .channel_mode = alc861vd_3stack_2ch_modes,
15420 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015421 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015422 .setup = alc861vd_dallas_setup,
15423 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015424 },
15425 [ALC861VD_HP] = {
15426 .mixers = { alc861vd_hp_mixer },
15427 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15428 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15429 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015430 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015431 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15432 .channel_mode = alc861vd_3stack_2ch_modes,
15433 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015434 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015435 .setup = alc861vd_dallas_setup,
15436 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020015437 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015438 [ALC660VD_ASUS_V1S] = {
15439 .mixers = { alc861vd_lenovo_mixer },
15440 .init_verbs = { alc861vd_volume_init_verbs,
15441 alc861vd_3stack_init_verbs,
15442 alc861vd_eapd_verbs,
15443 alc861vd_lenovo_unsol_verbs },
15444 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15445 .dac_nids = alc660vd_dac_nids,
15446 .dig_out_nid = ALC861VD_DIGOUT_NID,
15447 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15448 .channel_mode = alc861vd_3stack_2ch_modes,
15449 .input_mux = &alc861vd_capture_source,
15450 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015451 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015452 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015453 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015454};
15455
15456/*
15457 * BIOS auto configuration
15458 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015459static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15460 const struct auto_pin_cfg *cfg)
15461{
15462 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
15463}
15464
15465
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015466static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15467 hda_nid_t nid, int pin_type, int dac_idx)
15468{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015469 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015470}
15471
15472static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15473{
15474 struct alc_spec *spec = codec->spec;
15475 int i;
15476
15477 for (i = 0; i <= HDA_SIDE; i++) {
15478 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015479 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015480 if (nid)
15481 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015482 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015483 }
15484}
15485
15486
15487static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15488{
15489 struct alc_spec *spec = codec->spec;
15490 hda_nid_t pin;
15491
15492 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015493 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015494 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015495 pin = spec->autocfg.speaker_pins[0];
15496 if (pin)
15497 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015498}
15499
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015500#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15501
15502static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15503{
15504 struct alc_spec *spec = codec->spec;
15505 int i;
15506
15507 for (i = 0; i < AUTO_PIN_LAST; i++) {
15508 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020015509 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015510 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015511 if (nid != ALC861VD_PIN_CD_NID &&
15512 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015513 snd_hda_codec_write(codec, nid, 0,
15514 AC_VERB_SET_AMP_GAIN_MUTE,
15515 AMP_OUT_MUTE);
15516 }
15517 }
15518}
15519
Takashi Iwaif511b012008-08-15 16:46:42 +020015520#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15521
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015522#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15523#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15524
15525/* add playback controls from the parsed DAC table */
15526/* Based on ALC880 version. But ALC861VD has separate,
15527 * different NIDs for mute/unmute switch and volume control */
15528static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15529 const struct auto_pin_cfg *cfg)
15530{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015531 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15532 hda_nid_t nid_v, nid_s;
15533 int i, err;
15534
15535 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015536 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015537 continue;
15538 nid_v = alc861vd_idx_to_mixer_vol(
15539 alc880_dac_to_idx(
15540 spec->multiout.dac_nids[i]));
15541 nid_s = alc861vd_idx_to_mixer_switch(
15542 alc880_dac_to_idx(
15543 spec->multiout.dac_nids[i]));
15544
15545 if (i == 2) {
15546 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015547 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
15548 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015549 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15550 HDA_OUTPUT));
15551 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015552 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015553 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
15554 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015555 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15556 HDA_OUTPUT));
15557 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015558 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015559 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
15560 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015561 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15562 HDA_INPUT));
15563 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015564 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015565 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
15566 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015567 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15568 HDA_INPUT));
15569 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015570 return err;
15571 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015572 const char *pfx;
15573 if (cfg->line_outs == 1 &&
15574 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
15575 if (!cfg->hp_pins)
15576 pfx = "Speaker";
15577 else
15578 pfx = "PCM";
15579 } else
15580 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015581 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015582 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15583 HDA_OUTPUT));
15584 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015585 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015586 if (cfg->line_outs == 1 &&
15587 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15588 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015589 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015590 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015591 HDA_INPUT));
15592 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015593 return err;
15594 }
15595 }
15596 return 0;
15597}
15598
15599/* add playback controls for speaker and HP outputs */
15600/* Based on ALC880 version. But ALC861VD has separate,
15601 * different NIDs for mute/unmute switch and volume control */
15602static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15603 hda_nid_t pin, const char *pfx)
15604{
15605 hda_nid_t nid_v, nid_s;
15606 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015607
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015608 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015609 return 0;
15610
15611 if (alc880_is_fixed_pin(pin)) {
15612 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15613 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015614 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015615 spec->multiout.hp_nid = nid_v;
15616 else
15617 spec->multiout.extra_out_nid[0] = nid_v;
15618 /* control HP volume/switch on the output mixer amp */
15619 nid_v = alc861vd_idx_to_mixer_vol(
15620 alc880_fixed_pin_idx(pin));
15621 nid_s = alc861vd_idx_to_mixer_switch(
15622 alc880_fixed_pin_idx(pin));
15623
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015624 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015625 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15626 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015627 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015628 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015629 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15630 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015631 return err;
15632 } else if (alc880_is_multi_pin(pin)) {
15633 /* set manual connection */
15634 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015635 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015636 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15637 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015638 return err;
15639 }
15640 return 0;
15641}
15642
15643/* parse the BIOS configuration and set up the alc_spec
15644 * return 1 if successful, 0 if the proper config is not found,
15645 * or a negative error code
15646 * Based on ALC880 version - had to change it to override
15647 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15648static int alc861vd_parse_auto_config(struct hda_codec *codec)
15649{
15650 struct alc_spec *spec = codec->spec;
15651 int err;
15652 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15653
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015654 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15655 alc861vd_ignore);
15656 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015657 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015658 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015659 return 0; /* can't find valid BIOS pin config */
15660
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015661 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15662 if (err < 0)
15663 return err;
15664 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15665 if (err < 0)
15666 return err;
15667 err = alc861vd_auto_create_extra_out(spec,
15668 spec->autocfg.speaker_pins[0],
15669 "Speaker");
15670 if (err < 0)
15671 return err;
15672 err = alc861vd_auto_create_extra_out(spec,
15673 spec->autocfg.hp_pins[0],
15674 "Headphone");
15675 if (err < 0)
15676 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015677 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015678 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015679 return err;
15680
15681 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15682
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015683 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015684 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15685
Takashi Iwai603c4012008-07-30 15:01:44 +020015686 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015687 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015688
Takashi Iwaid88897e2008-10-31 15:01:37 +010015689 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015690
15691 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015692 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015693
Takashi Iwai776e1842007-08-29 15:07:11 +020015694 err = alc_auto_add_mic_boost(codec);
15695 if (err < 0)
15696 return err;
15697
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015698 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15699
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015700 return 1;
15701}
15702
15703/* additional initialization for auto-configuration model */
15704static void alc861vd_auto_init(struct hda_codec *codec)
15705{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015706 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015707 alc861vd_auto_init_multi_out(codec);
15708 alc861vd_auto_init_hp_out(codec);
15709 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015710 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015711 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015712 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015713}
15714
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015715enum {
15716 ALC660VD_FIX_ASUS_GPIO1
15717};
15718
15719/* reset GPIO1 */
15720static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
15721 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
15722 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
15723 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
15724 { }
15725};
15726
15727static const struct alc_fixup alc861vd_fixups[] = {
15728 [ALC660VD_FIX_ASUS_GPIO1] = {
15729 .verbs = alc660vd_fix_asus_gpio1_verbs,
15730 },
15731};
15732
15733static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
15734 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
15735 {}
15736};
15737
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015738static int patch_alc861vd(struct hda_codec *codec)
15739{
15740 struct alc_spec *spec;
15741 int err, board_config;
15742
15743 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15744 if (spec == NULL)
15745 return -ENOMEM;
15746
15747 codec->spec = spec;
15748
15749 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15750 alc861vd_models,
15751 alc861vd_cfg_tbl);
15752
15753 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015754 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15755 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015756 board_config = ALC861VD_AUTO;
15757 }
15758
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015759 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups);
15760
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015761 if (board_config == ALC861VD_AUTO) {
15762 /* automatic parse from the BIOS config */
15763 err = alc861vd_parse_auto_config(codec);
15764 if (err < 0) {
15765 alc_free(codec);
15766 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015767 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015768 printk(KERN_INFO
15769 "hda_codec: Cannot set up configuration "
15770 "from BIOS. Using base mode...\n");
15771 board_config = ALC861VD_3ST;
15772 }
15773 }
15774
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015775 err = snd_hda_attach_beep_device(codec, 0x23);
15776 if (err < 0) {
15777 alc_free(codec);
15778 return err;
15779 }
15780
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015781 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015782 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015783
Kailang Yang2f893282008-05-27 12:14:47 +020015784 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015785 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015786 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015787 }
15788
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015789 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15790 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15791
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015792 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15793 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15794
Takashi Iwaidd704692009-08-11 08:45:11 +020015795 if (!spec->adc_nids) {
15796 spec->adc_nids = alc861vd_adc_nids;
15797 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15798 }
15799 if (!spec->capsrc_nids)
15800 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015801
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015802 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015803 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015804
Takashi Iwai2134ea42008-01-10 16:53:55 +010015805 spec->vmaster_nid = 0x02;
15806
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015807 codec->patch_ops = alc_patch_ops;
15808
15809 if (board_config == ALC861VD_AUTO)
15810 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015811#ifdef CONFIG_SND_HDA_POWER_SAVE
15812 if (!spec->loopback.amplist)
15813 spec->loopback.amplist = alc861vd_loopbacks;
15814#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015815 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015816
15817 return 0;
15818}
15819
15820/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015821 * ALC662 support
15822 *
15823 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15824 * configuration. Each pin widget can choose any input DACs and a mixer.
15825 * Each ADC is connected from a mixer of all inputs. This makes possible
15826 * 6-channel independent captures.
15827 *
15828 * In addition, an independent DAC for the multi-playback (not used in this
15829 * driver yet).
15830 */
15831#define ALC662_DIGOUT_NID 0x06
15832#define ALC662_DIGIN_NID 0x0a
15833
15834static hda_nid_t alc662_dac_nids[4] = {
15835 /* front, rear, clfe, rear_surr */
15836 0x02, 0x03, 0x04
15837};
15838
Kailang Yang622e84c2009-04-21 07:39:04 +020015839static hda_nid_t alc272_dac_nids[2] = {
15840 0x02, 0x03
15841};
15842
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015843static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015844 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015845 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015846};
Takashi Iwaie1406342008-02-11 18:32:32 +010015847
Kailang Yang622e84c2009-04-21 07:39:04 +020015848static hda_nid_t alc272_adc_nids[1] = {
15849 /* ADC1-2 */
15850 0x08,
15851};
15852
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015853static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015854static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15855
Takashi Iwaie1406342008-02-11 18:32:32 +010015856
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015857/* input MUX */
15858/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015859static struct hda_input_mux alc662_capture_source = {
15860 .num_items = 4,
15861 .items = {
15862 { "Mic", 0x0 },
15863 { "Front Mic", 0x1 },
15864 { "Line", 0x2 },
15865 { "CD", 0x4 },
15866 },
15867};
15868
15869static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15870 .num_items = 2,
15871 .items = {
15872 { "Mic", 0x1 },
15873 { "Line", 0x2 },
15874 },
15875};
Kailang Yang291702f2007-10-16 14:28:03 +020015876
Kailang Yang6dda9f42008-05-27 12:05:31 +020015877static struct hda_input_mux alc663_capture_source = {
15878 .num_items = 3,
15879 .items = {
15880 { "Mic", 0x0 },
15881 { "Front Mic", 0x1 },
15882 { "Line", 0x2 },
15883 },
15884};
15885
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015886#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020015887static struct hda_input_mux alc272_nc10_capture_source = {
15888 .num_items = 16,
15889 .items = {
15890 { "Autoselect Mic", 0x0 },
15891 { "Internal Mic", 0x1 },
15892 { "In-0x02", 0x2 },
15893 { "In-0x03", 0x3 },
15894 { "In-0x04", 0x4 },
15895 { "In-0x05", 0x5 },
15896 { "In-0x06", 0x6 },
15897 { "In-0x07", 0x7 },
15898 { "In-0x08", 0x8 },
15899 { "In-0x09", 0x9 },
15900 { "In-0x0a", 0x0a },
15901 { "In-0x0b", 0x0b },
15902 { "In-0x0c", 0x0c },
15903 { "In-0x0d", 0x0d },
15904 { "In-0x0e", 0x0e },
15905 { "In-0x0f", 0x0f },
15906 },
15907};
15908#endif
15909
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015910/*
15911 * 2ch mode
15912 */
15913static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15914 { 2, NULL }
15915};
15916
15917/*
15918 * 2ch mode
15919 */
15920static struct hda_verb alc662_3ST_ch2_init[] = {
15921 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15922 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15923 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15924 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15925 { } /* end */
15926};
15927
15928/*
15929 * 6ch mode
15930 */
15931static struct hda_verb alc662_3ST_ch6_init[] = {
15932 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15933 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15934 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15935 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15936 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15937 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15938 { } /* end */
15939};
15940
15941static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15942 { 2, alc662_3ST_ch2_init },
15943 { 6, alc662_3ST_ch6_init },
15944};
15945
15946/*
15947 * 2ch mode
15948 */
15949static struct hda_verb alc662_sixstack_ch6_init[] = {
15950 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15951 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15952 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15953 { } /* end */
15954};
15955
15956/*
15957 * 6ch mode
15958 */
15959static struct hda_verb alc662_sixstack_ch8_init[] = {
15960 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15961 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15962 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15963 { } /* end */
15964};
15965
15966static struct hda_channel_mode alc662_5stack_modes[2] = {
15967 { 2, alc662_sixstack_ch6_init },
15968 { 6, alc662_sixstack_ch8_init },
15969};
15970
15971/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15972 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15973 */
15974
15975static struct snd_kcontrol_new alc662_base_mixer[] = {
15976 /* output mixer control */
15977 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015978 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015979 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015980 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015981 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15982 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015983 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15984 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015985 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15986
15987 /*Input mixer control */
15988 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15989 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15990 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15991 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15992 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15993 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15994 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15995 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015996 { } /* end */
15997};
15998
15999static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
16000 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016001 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016002 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16003 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16004 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16005 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16006 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16007 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16008 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16009 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16010 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016011 { } /* end */
16012};
16013
16014static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
16015 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016016 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016017 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016018 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016019 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16020 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016021 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16022 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016023 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16024 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16025 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16026 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16027 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16028 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16029 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16030 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16031 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016032 { } /* end */
16033};
16034
16035static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
16036 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16037 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010016038 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16039 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016040 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16041 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16042 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16043 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16044 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016045 { } /* end */
16046};
16047
Kailang Yang291702f2007-10-16 14:28:03 +020016048static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016049 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16050 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020016051
16052 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
16053 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16054 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16055
16056 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16057 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16058 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16059 { } /* end */
16060};
16061
Kailang Yang8c427222008-01-10 13:03:59 +010016062static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016063 ALC262_HIPPO_MASTER_SWITCH,
16064 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016065 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016066 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16067 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016068 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
16069 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16070 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16071 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16072 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16073 { } /* end */
16074};
16075
Kailang Yangf1d4e282008-08-26 14:03:29 +020016076static struct hda_bind_ctls alc663_asus_bind_master_vol = {
16077 .ops = &snd_hda_bind_vol,
16078 .values = {
16079 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16080 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
16081 0
16082 },
16083};
16084
16085static struct hda_bind_ctls alc663_asus_one_bind_switch = {
16086 .ops = &snd_hda_bind_sw,
16087 .values = {
16088 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16089 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16090 0
16091 },
16092};
16093
Kailang Yang6dda9f42008-05-27 12:05:31 +020016094static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016095 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16096 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
16097 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16098 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16099 { } /* end */
16100};
16101
16102static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
16103 .ops = &snd_hda_bind_sw,
16104 .values = {
16105 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16106 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16107 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16108 0
16109 },
16110};
16111
16112static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
16113 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16114 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
16115 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16116 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16117 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16118 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16119
16120 { } /* end */
16121};
16122
16123static struct hda_bind_ctls alc663_asus_four_bind_switch = {
16124 .ops = &snd_hda_bind_sw,
16125 .values = {
16126 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16127 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16128 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16129 0
16130 },
16131};
16132
16133static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
16134 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16135 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
16136 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16137 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16138 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16139 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16140 { } /* end */
16141};
16142
16143static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016144 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16145 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016146 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16147 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16148 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16149 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16150 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16151 { } /* end */
16152};
16153
16154static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
16155 .ops = &snd_hda_bind_vol,
16156 .values = {
16157 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16158 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16159 0
16160 },
16161};
16162
16163static struct hda_bind_ctls alc663_asus_two_bind_switch = {
16164 .ops = &snd_hda_bind_sw,
16165 .values = {
16166 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16167 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
16168 0
16169 },
16170};
16171
16172static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16173 HDA_BIND_VOL("Master Playback Volume",
16174 &alc663_asus_two_bind_master_vol),
16175 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16176 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016177 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16178 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16179 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016180 { } /* end */
16181};
16182
16183static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16184 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16185 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16186 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16187 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16188 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16189 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016190 { } /* end */
16191};
16192
16193static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16194 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16195 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16196 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16197 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16198 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16199
16200 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16201 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16202 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16203 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16204 { } /* end */
16205};
16206
16207static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16208 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16209 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16210 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16211
16212 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16213 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16214 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16215 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16216 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16217 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16218 { } /* end */
16219};
16220
Kailang Yangebb83ee2009-12-17 12:23:00 +010016221static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
16222 .ops = &snd_hda_bind_sw,
16223 .values = {
16224 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16225 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16226 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16227 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16228 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16229 0
16230 },
16231};
16232
16233static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
16234 .ops = &snd_hda_bind_sw,
16235 .values = {
16236 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16237 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16238 0
16239 },
16240};
16241
16242static struct snd_kcontrol_new alc663_mode7_mixer[] = {
16243 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16244 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16245 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16246 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16247 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16248 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16249 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16250 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16251 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16252 { } /* end */
16253};
16254
16255static struct snd_kcontrol_new alc663_mode8_mixer[] = {
16256 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16257 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16258 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16259 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16260 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16261 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16262 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16263 { } /* end */
16264};
16265
16266
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016267static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16268 {
16269 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16270 .name = "Channel Mode",
16271 .info = alc_ch_mode_info,
16272 .get = alc_ch_mode_get,
16273 .put = alc_ch_mode_put,
16274 },
16275 { } /* end */
16276};
16277
16278static struct hda_verb alc662_init_verbs[] = {
16279 /* ADC: mute amp left and right */
16280 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16281 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16282 /* Front mixer: unmute input/output amp left and right (volume = 0) */
16283
Takashi Iwaicb53c622007-08-10 17:21:45 +020016284 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16285 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16286 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16287 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16288 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016289
Kailang Yangb60dd392007-09-20 12:50:29 +020016290 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16291 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16292 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16293 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16294 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16295 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016296
16297 /* Front Pin: output 0 (0x0c) */
16298 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16299 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16300
16301 /* Rear Pin: output 1 (0x0d) */
16302 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16303 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16304
16305 /* CLFE Pin: output 2 (0x0e) */
16306 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16307 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16308
16309 /* Mic (rear) pin: input vref at 80% */
16310 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16311 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16312 /* Front Mic pin: input vref at 80% */
16313 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16314 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16315 /* Line In pin: input */
16316 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16317 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16318 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16319 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16320 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16321 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16322 /* CD pin widget for input */
16323 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16324
16325 /* FIXME: use matrix-type input source selection */
16326 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16327 /* Input mixer */
16328 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016329 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016330
16331 /* always trun on EAPD */
16332 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16333 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16334
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016335 { }
16336};
16337
16338static struct hda_verb alc662_sue_init_verbs[] = {
16339 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16340 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016341 {}
16342};
16343
16344static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16345 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16346 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16347 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016348};
16349
Kailang Yang8c427222008-01-10 13:03:59 +010016350/* Set Unsolicited Event*/
16351static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16352 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16353 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16354 {}
16355};
16356
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016357/*
16358 * generic initialization of ADC, input mixers and output mixers
16359 */
16360static struct hda_verb alc662_auto_init_verbs[] = {
16361 /*
16362 * Unmute ADC and set the default input to mic-in
16363 */
16364 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16365 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16366
16367 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16368 * mixer widget
16369 * Note: PASD motherboards uses the Line In 2 as the input for front
16370 * panel mic (mic 2)
16371 */
16372 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016373 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16374 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16375 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16376 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16377 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016378
16379 /*
16380 * Set up output mixers (0x0c - 0x0f)
16381 */
16382 /* set vol=0 to output mixers */
16383 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16384 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16385 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16386
16387 /* set up input amps for analog loopback */
16388 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020016389 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16390 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16391 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16392 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16393 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16394 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016395
16396
16397 /* FIXME: use matrix-type input source selection */
16398 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16399 /* Input mixer */
16400 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016401 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016402 { }
16403};
16404
Takashi Iwai24fb9172008-09-02 14:48:20 +020016405/* additional verbs for ALC663 */
16406static struct hda_verb alc663_auto_init_verbs[] = {
16407 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16408 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16409 { }
16410};
16411
Kailang Yang6dda9f42008-05-27 12:05:31 +020016412static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016413 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16414 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016415 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16416 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016417 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16418 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16419 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016420 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16421 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16422 {}
16423};
16424
Kailang Yangf1d4e282008-08-26 14:03:29 +020016425static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16426 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16427 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16428 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16429 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16430 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16431 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16432 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16433 {}
16434};
16435
16436static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16437 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16438 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16439 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16440 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16441 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16442 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16443 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16444 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16445 {}
16446};
16447
16448static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16449 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16450 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16451 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16452 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16453 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16454 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16455 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16456 {}
16457};
16458
16459static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16460 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16461 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16462 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16463 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16464 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16465 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16466 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16467 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16468 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16469 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16470 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16471 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16472 {}
16473};
16474
16475static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16476 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16477 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16478 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16479 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16480 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16481 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16482 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16483 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16484 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16485 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16486 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16487 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16488 {}
16489};
16490
Kailang Yang6dda9f42008-05-27 12:05:31 +020016491static struct hda_verb alc663_g71v_init_verbs[] = {
16492 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16493 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16494 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16495
16496 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16497 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16498 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16499
16500 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16501 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16502 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16503 {}
16504};
16505
16506static struct hda_verb alc663_g50v_init_verbs[] = {
16507 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16508 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16509 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16510
16511 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16512 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16513 {}
16514};
16515
Kailang Yangf1d4e282008-08-26 14:03:29 +020016516static struct hda_verb alc662_ecs_init_verbs[] = {
16517 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16518 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16519 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16520 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16521 {}
16522};
16523
Kailang Yang622e84c2009-04-21 07:39:04 +020016524static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16525 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16526 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16527 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16528 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16529 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16530 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16531 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16532 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16533 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16534 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16535 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16536 {}
16537};
16538
16539static struct hda_verb alc272_dell_init_verbs[] = {
16540 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16541 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16542 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16543 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16544 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16545 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16546 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16547 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16548 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16549 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16550 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16551 {}
16552};
16553
Kailang Yangebb83ee2009-12-17 12:23:00 +010016554static struct hda_verb alc663_mode7_init_verbs[] = {
16555 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16556 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16557 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16558 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16559 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16560 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16561 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
16562 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16563 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16564 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16565 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16566 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16567 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16568 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16569 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16570 {}
16571};
16572
16573static struct hda_verb alc663_mode8_init_verbs[] = {
16574 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16575 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16576 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16577 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16578 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16579 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16580 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16581 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16582 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16583 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16584 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16585 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16586 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16587 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16588 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16589 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16590 {}
16591};
16592
Kailang Yangf1d4e282008-08-26 14:03:29 +020016593static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16594 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16595 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16596 { } /* end */
16597};
16598
Kailang Yang622e84c2009-04-21 07:39:04 +020016599static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16600 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16601 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16602 { } /* end */
16603};
16604
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016605static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16606{
16607 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016608 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016609
Wu Fengguang864f92b2009-11-18 12:38:02 +080016610 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016611 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016612
Takashi Iwai47fd8302007-08-10 17:11:07 +020016613 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16614 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016615}
16616
16617static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16618{
16619 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016620 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016621
Wu Fengguang864f92b2009-11-18 12:38:02 +080016622 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016623 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016624
Takashi Iwai47fd8302007-08-10 17:11:07 +020016625 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16626 HDA_AMP_MUTE, bits);
16627 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16628 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016629}
16630
16631static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16632 unsigned int res)
16633{
16634 if ((res >> 26) == ALC880_HP_EVENT)
16635 alc662_lenovo_101e_all_automute(codec);
16636 if ((res >> 26) == ALC880_FRONT_EVENT)
16637 alc662_lenovo_101e_ispeaker_automute(codec);
16638}
16639
Kailang Yang291702f2007-10-16 14:28:03 +020016640/* unsolicited event for HP jack sensing */
16641static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16642 unsigned int res)
16643{
Kailang Yang291702f2007-10-16 14:28:03 +020016644 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016645 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016646 else
16647 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016648}
16649
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016650static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020016651{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016652 struct alc_spec *spec = codec->spec;
16653
16654 alc262_hippo1_setup(codec);
16655 spec->ext_mic.pin = 0x18;
16656 spec->ext_mic.mux_idx = 0;
16657 spec->int_mic.pin = 0x19;
16658 spec->int_mic.mux_idx = 1;
16659 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020016660}
16661
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016662static void alc662_eeepc_inithook(struct hda_codec *codec)
16663{
16664 alc262_hippo_automute(codec);
16665 alc_mic_automute(codec);
16666}
16667
16668static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010016669{
Takashi Iwai42171c12009-05-08 14:11:43 +020016670 struct alc_spec *spec = codec->spec;
16671
16672 spec->autocfg.hp_pins[0] = 0x14;
16673 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010016674}
16675
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016676#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
16677
Kailang Yang6dda9f42008-05-27 12:05:31 +020016678static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16679{
16680 unsigned int present;
16681 unsigned char bits;
16682
Wu Fengguang864f92b2009-11-18 12:38:02 +080016683 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016684 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016685 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16686 AMP_IN_MUTE(0), bits);
16687 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16688 AMP_IN_MUTE(0), bits);
16689}
16690
16691static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16692{
16693 unsigned int present;
16694 unsigned char bits;
16695
Wu Fengguang864f92b2009-11-18 12:38:02 +080016696 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016697 bits = present ? HDA_AMP_MUTE : 0;
16698 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16699 AMP_IN_MUTE(0), bits);
16700 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16701 AMP_IN_MUTE(0), bits);
16702 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16703 AMP_IN_MUTE(0), bits);
16704 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16705 AMP_IN_MUTE(0), bits);
16706}
16707
16708static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16709{
16710 unsigned int present;
16711 unsigned char bits;
16712
Wu Fengguang864f92b2009-11-18 12:38:02 +080016713 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016714 bits = present ? HDA_AMP_MUTE : 0;
16715 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16716 AMP_IN_MUTE(0), bits);
16717 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16718 AMP_IN_MUTE(0), bits);
16719 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16720 AMP_IN_MUTE(0), bits);
16721 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16722 AMP_IN_MUTE(0), bits);
16723}
16724
16725static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16726{
16727 unsigned int present;
16728 unsigned char bits;
16729
Wu Fengguang864f92b2009-11-18 12:38:02 +080016730 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016731 bits = present ? 0 : PIN_OUT;
16732 snd_hda_codec_write(codec, 0x14, 0,
16733 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16734}
16735
16736static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16737{
16738 unsigned int present1, present2;
16739
Wu Fengguang864f92b2009-11-18 12:38:02 +080016740 present1 = snd_hda_jack_detect(codec, 0x21);
16741 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016742
16743 if (present1 || present2) {
16744 snd_hda_codec_write_cache(codec, 0x14, 0,
16745 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16746 } else {
16747 snd_hda_codec_write_cache(codec, 0x14, 0,
16748 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16749 }
16750}
16751
16752static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16753{
16754 unsigned int present1, present2;
16755
Wu Fengguang864f92b2009-11-18 12:38:02 +080016756 present1 = snd_hda_jack_detect(codec, 0x1b);
16757 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016758
16759 if (present1 || present2) {
16760 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16761 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16762 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16763 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16764 } else {
16765 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16766 AMP_IN_MUTE(0), 0);
16767 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16768 AMP_IN_MUTE(0), 0);
16769 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016770}
16771
Kailang Yangebb83ee2009-12-17 12:23:00 +010016772static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
16773{
16774 unsigned int present1, present2;
16775
16776 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16777 AC_VERB_GET_PIN_SENSE, 0)
16778 & AC_PINSENSE_PRESENCE;
16779 present2 = snd_hda_codec_read(codec, 0x21, 0,
16780 AC_VERB_GET_PIN_SENSE, 0)
16781 & AC_PINSENSE_PRESENCE;
16782
16783 if (present1 || present2) {
16784 snd_hda_codec_write_cache(codec, 0x14, 0,
16785 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16786 snd_hda_codec_write_cache(codec, 0x17, 0,
16787 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16788 } else {
16789 snd_hda_codec_write_cache(codec, 0x14, 0,
16790 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16791 snd_hda_codec_write_cache(codec, 0x17, 0,
16792 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16793 }
16794}
16795
16796static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
16797{
16798 unsigned int present1, present2;
16799
16800 present1 = snd_hda_codec_read(codec, 0x21, 0,
16801 AC_VERB_GET_PIN_SENSE, 0)
16802 & AC_PINSENSE_PRESENCE;
16803 present2 = snd_hda_codec_read(codec, 0x15, 0,
16804 AC_VERB_GET_PIN_SENSE, 0)
16805 & AC_PINSENSE_PRESENCE;
16806
16807 if (present1 || present2) {
16808 snd_hda_codec_write_cache(codec, 0x14, 0,
16809 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16810 snd_hda_codec_write_cache(codec, 0x17, 0,
16811 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16812 } else {
16813 snd_hda_codec_write_cache(codec, 0x14, 0,
16814 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16815 snd_hda_codec_write_cache(codec, 0x17, 0,
16816 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16817 }
16818}
16819
Kailang Yang6dda9f42008-05-27 12:05:31 +020016820static void alc663_m51va_unsol_event(struct hda_codec *codec,
16821 unsigned int res)
16822{
16823 switch (res >> 26) {
16824 case ALC880_HP_EVENT:
16825 alc663_m51va_speaker_automute(codec);
16826 break;
16827 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016828 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016829 break;
16830 }
16831}
16832
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016833static void alc663_m51va_setup(struct hda_codec *codec)
16834{
16835 struct alc_spec *spec = codec->spec;
16836 spec->ext_mic.pin = 0x18;
16837 spec->ext_mic.mux_idx = 0;
16838 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010016839 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016840 spec->auto_mic = 1;
16841}
16842
Kailang Yang6dda9f42008-05-27 12:05:31 +020016843static void alc663_m51va_inithook(struct hda_codec *codec)
16844{
16845 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016846 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016847}
16848
Kailang Yangf1d4e282008-08-26 14:03:29 +020016849/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016850#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010016851
16852static void alc663_mode1_setup(struct hda_codec *codec)
16853{
16854 struct alc_spec *spec = codec->spec;
16855 spec->ext_mic.pin = 0x18;
16856 spec->ext_mic.mux_idx = 0;
16857 spec->int_mic.pin = 0x19;
16858 spec->int_mic.mux_idx = 1;
16859 spec->auto_mic = 1;
16860}
16861
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016862#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020016863
Kailang Yangf1d4e282008-08-26 14:03:29 +020016864/* ***************** Mode2 ******************************/
16865static void alc662_mode2_unsol_event(struct hda_codec *codec,
16866 unsigned int res)
16867{
16868 switch (res >> 26) {
16869 case ALC880_HP_EVENT:
16870 alc662_f5z_speaker_automute(codec);
16871 break;
16872 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016873 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016874 break;
16875 }
16876}
16877
Kailang Yangebb83ee2009-12-17 12:23:00 +010016878#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016879
Kailang Yangf1d4e282008-08-26 14:03:29 +020016880static void alc662_mode2_inithook(struct hda_codec *codec)
16881{
16882 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016883 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016884}
16885/* ***************** Mode3 ******************************/
16886static void alc663_mode3_unsol_event(struct hda_codec *codec,
16887 unsigned int res)
16888{
16889 switch (res >> 26) {
16890 case ALC880_HP_EVENT:
16891 alc663_two_hp_m1_speaker_automute(codec);
16892 break;
16893 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016894 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016895 break;
16896 }
16897}
16898
Kailang Yangebb83ee2009-12-17 12:23:00 +010016899#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016900
Kailang Yangf1d4e282008-08-26 14:03:29 +020016901static void alc663_mode3_inithook(struct hda_codec *codec)
16902{
16903 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016904 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016905}
16906/* ***************** Mode4 ******************************/
16907static void alc663_mode4_unsol_event(struct hda_codec *codec,
16908 unsigned int res)
16909{
16910 switch (res >> 26) {
16911 case ALC880_HP_EVENT:
16912 alc663_21jd_two_speaker_automute(codec);
16913 break;
16914 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016915 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016916 break;
16917 }
16918}
16919
Kailang Yangebb83ee2009-12-17 12:23:00 +010016920#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016921
Kailang Yangf1d4e282008-08-26 14:03:29 +020016922static void alc663_mode4_inithook(struct hda_codec *codec)
16923{
16924 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016925 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016926}
16927/* ***************** Mode5 ******************************/
16928static void alc663_mode5_unsol_event(struct hda_codec *codec,
16929 unsigned int res)
16930{
16931 switch (res >> 26) {
16932 case ALC880_HP_EVENT:
16933 alc663_15jd_two_speaker_automute(codec);
16934 break;
16935 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016936 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016937 break;
16938 }
16939}
16940
Kailang Yangebb83ee2009-12-17 12:23:00 +010016941#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016942
Kailang Yangf1d4e282008-08-26 14:03:29 +020016943static void alc663_mode5_inithook(struct hda_codec *codec)
16944{
16945 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016946 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016947}
16948/* ***************** Mode6 ******************************/
16949static void alc663_mode6_unsol_event(struct hda_codec *codec,
16950 unsigned int res)
16951{
16952 switch (res >> 26) {
16953 case ALC880_HP_EVENT:
16954 alc663_two_hp_m2_speaker_automute(codec);
16955 break;
16956 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016957 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016958 break;
16959 }
16960}
16961
Kailang Yangebb83ee2009-12-17 12:23:00 +010016962#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016963
Kailang Yangf1d4e282008-08-26 14:03:29 +020016964static void alc663_mode6_inithook(struct hda_codec *codec)
16965{
16966 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016967 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016968}
16969
Kailang Yangebb83ee2009-12-17 12:23:00 +010016970/* ***************** Mode7 ******************************/
16971static void alc663_mode7_unsol_event(struct hda_codec *codec,
16972 unsigned int res)
16973{
16974 switch (res >> 26) {
16975 case ALC880_HP_EVENT:
16976 alc663_two_hp_m7_speaker_automute(codec);
16977 break;
16978 case ALC880_MIC_EVENT:
16979 alc_mic_automute(codec);
16980 break;
16981 }
16982}
16983
16984#define alc663_mode7_setup alc663_mode1_setup
16985
16986static void alc663_mode7_inithook(struct hda_codec *codec)
16987{
16988 alc663_two_hp_m7_speaker_automute(codec);
16989 alc_mic_automute(codec);
16990}
16991
16992/* ***************** Mode8 ******************************/
16993static void alc663_mode8_unsol_event(struct hda_codec *codec,
16994 unsigned int res)
16995{
16996 switch (res >> 26) {
16997 case ALC880_HP_EVENT:
16998 alc663_two_hp_m8_speaker_automute(codec);
16999 break;
17000 case ALC880_MIC_EVENT:
17001 alc_mic_automute(codec);
17002 break;
17003 }
17004}
17005
17006#define alc663_mode8_setup alc663_m51va_setup
17007
17008static void alc663_mode8_inithook(struct hda_codec *codec)
17009{
17010 alc663_two_hp_m8_speaker_automute(codec);
17011 alc_mic_automute(codec);
17012}
17013
Kailang Yang6dda9f42008-05-27 12:05:31 +020017014static void alc663_g71v_hp_automute(struct hda_codec *codec)
17015{
17016 unsigned int present;
17017 unsigned char bits;
17018
Wu Fengguang864f92b2009-11-18 12:38:02 +080017019 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017020 bits = present ? HDA_AMP_MUTE : 0;
17021 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17022 HDA_AMP_MUTE, bits);
17023 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17024 HDA_AMP_MUTE, bits);
17025}
17026
17027static void alc663_g71v_front_automute(struct hda_codec *codec)
17028{
17029 unsigned int present;
17030 unsigned char bits;
17031
Wu Fengguang864f92b2009-11-18 12:38:02 +080017032 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017033 bits = present ? HDA_AMP_MUTE : 0;
17034 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17035 HDA_AMP_MUTE, bits);
17036}
17037
17038static void alc663_g71v_unsol_event(struct hda_codec *codec,
17039 unsigned int res)
17040{
17041 switch (res >> 26) {
17042 case ALC880_HP_EVENT:
17043 alc663_g71v_hp_automute(codec);
17044 break;
17045 case ALC880_FRONT_EVENT:
17046 alc663_g71v_front_automute(codec);
17047 break;
17048 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017049 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017050 break;
17051 }
17052}
17053
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017054#define alc663_g71v_setup alc663_m51va_setup
17055
Kailang Yang6dda9f42008-05-27 12:05:31 +020017056static void alc663_g71v_inithook(struct hda_codec *codec)
17057{
17058 alc663_g71v_front_automute(codec);
17059 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017060 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017061}
17062
17063static void alc663_g50v_unsol_event(struct hda_codec *codec,
17064 unsigned int res)
17065{
17066 switch (res >> 26) {
17067 case ALC880_HP_EVENT:
17068 alc663_m51va_speaker_automute(codec);
17069 break;
17070 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017071 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017072 break;
17073 }
17074}
17075
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017076#define alc663_g50v_setup alc663_m51va_setup
17077
Kailang Yang6dda9f42008-05-27 12:05:31 +020017078static void alc663_g50v_inithook(struct hda_codec *codec)
17079{
17080 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017081 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017082}
17083
Kailang Yangf1d4e282008-08-26 14:03:29 +020017084static struct snd_kcontrol_new alc662_ecs_mixer[] = {
17085 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020017086 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017087
17088 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
17089 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
17090 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
17091
17092 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17093 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17094 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17095 { } /* end */
17096};
17097
Chris Pockelé9541ba12009-05-12 08:08:53 +020017098static struct snd_kcontrol_new alc272_nc10_mixer[] = {
17099 /* Master Playback automatically created from Speaker and Headphone */
17100 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17101 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17102 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17103 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17104
17105 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17106 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17107 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
17108
17109 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17110 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17111 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
17112 { } /* end */
17113};
17114
Takashi Iwaicb53c622007-08-10 17:21:45 +020017115#ifdef CONFIG_SND_HDA_POWER_SAVE
17116#define alc662_loopbacks alc880_loopbacks
17117#endif
17118
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017119
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017120/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017121#define alc662_pcm_analog_playback alc880_pcm_analog_playback
17122#define alc662_pcm_analog_capture alc880_pcm_analog_capture
17123#define alc662_pcm_digital_playback alc880_pcm_digital_playback
17124#define alc662_pcm_digital_capture alc880_pcm_digital_capture
17125
17126/*
17127 * configuration and preset
17128 */
17129static const char *alc662_models[ALC662_MODEL_LAST] = {
17130 [ALC662_3ST_2ch_DIG] = "3stack-dig",
17131 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
17132 [ALC662_3ST_6ch] = "3stack-6ch",
17133 [ALC662_5ST_DIG] = "6stack-dig",
17134 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020017135 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010017136 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017137 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020017138 [ALC663_ASUS_M51VA] = "m51va",
17139 [ALC663_ASUS_G71V] = "g71v",
17140 [ALC663_ASUS_H13] = "h13",
17141 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017142 [ALC663_ASUS_MODE1] = "asus-mode1",
17143 [ALC662_ASUS_MODE2] = "asus-mode2",
17144 [ALC663_ASUS_MODE3] = "asus-mode3",
17145 [ALC663_ASUS_MODE4] = "asus-mode4",
17146 [ALC663_ASUS_MODE5] = "asus-mode5",
17147 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010017148 [ALC663_ASUS_MODE7] = "asus-mode7",
17149 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020017150 [ALC272_DELL] = "dell",
17151 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020017152 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017153 [ALC662_AUTO] = "auto",
17154};
17155
17156static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010017157 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020017158 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
17159 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017160 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
17161 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
17162 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
17163 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
17164 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
17165 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017166 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
17167 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017168 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017169 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
17170 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
17171 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
17172 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
17173 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017174 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017175 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
17176 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017177 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
17178 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
17179 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
17180 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017181 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017182 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
17183 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
17184 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017185 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
17186 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
17187 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
17188 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017189 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017190 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
17191 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017192 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017193 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
17194 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
17195 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017196 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
17197 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
17198 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017199 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
17200 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
17201 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017202 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017203 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
17204 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017205 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017206 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020017207 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017208 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
17209 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
17210 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017211 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017212 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
17213 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010017214 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020017215 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010017216 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017217 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030017218 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
17219 ALC662_3ST_6ch_DIG),
Manoj Iyer3db6c032009-09-22 18:33:29 -050017220 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB200", ALC663_ASUS_MODE4),
Chris Pockelé9541ba12009-05-12 08:08:53 +020017221 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030017222 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
17223 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020017224 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020017225 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017226 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020017227 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020017228 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017229 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
17230 ALC663_ASUS_H13),
David Santinoli7aee6742009-12-09 12:34:26 +010017231 SND_PCI_QUIRK(0x8086, 0xd604, "Intel mobo", ALC662_3ST_2ch_DIG),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017232 {}
17233};
17234
17235static struct alc_config_preset alc662_presets[] = {
17236 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017237 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017238 .init_verbs = { alc662_init_verbs },
17239 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17240 .dac_nids = alc662_dac_nids,
17241 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017242 .dig_in_nid = ALC662_DIGIN_NID,
17243 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17244 .channel_mode = alc662_3ST_2ch_modes,
17245 .input_mux = &alc662_capture_source,
17246 },
17247 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017248 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017249 .init_verbs = { alc662_init_verbs },
17250 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17251 .dac_nids = alc662_dac_nids,
17252 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017253 .dig_in_nid = ALC662_DIGIN_NID,
17254 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17255 .channel_mode = alc662_3ST_6ch_modes,
17256 .need_dac_fix = 1,
17257 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017258 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017259 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017260 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017261 .init_verbs = { alc662_init_verbs },
17262 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17263 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017264 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17265 .channel_mode = alc662_3ST_6ch_modes,
17266 .need_dac_fix = 1,
17267 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017268 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017269 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017270 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017271 .init_verbs = { alc662_init_verbs },
17272 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17273 .dac_nids = alc662_dac_nids,
17274 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017275 .dig_in_nid = ALC662_DIGIN_NID,
17276 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
17277 .channel_mode = alc662_5stack_modes,
17278 .input_mux = &alc662_capture_source,
17279 },
17280 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017281 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017282 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
17283 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17284 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017285 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17286 .channel_mode = alc662_3ST_2ch_modes,
17287 .input_mux = &alc662_lenovo_101e_capture_source,
17288 .unsol_event = alc662_lenovo_101e_unsol_event,
17289 .init_hook = alc662_lenovo_101e_all_automute,
17290 },
Kailang Yang291702f2007-10-16 14:28:03 +020017291 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017292 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020017293 .init_verbs = { alc662_init_verbs,
17294 alc662_eeepc_sue_init_verbs },
17295 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17296 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020017297 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17298 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020017299 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017300 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020017301 .init_hook = alc662_eeepc_inithook,
17302 },
Kailang Yang8c427222008-01-10 13:03:59 +010017303 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017304 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010017305 alc662_chmode_mixer },
17306 .init_verbs = { alc662_init_verbs,
17307 alc662_eeepc_ep20_sue_init_verbs },
17308 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17309 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010017310 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17311 .channel_mode = alc662_3ST_6ch_modes,
17312 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020017313 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017314 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010017315 .init_hook = alc662_eeepc_ep20_inithook,
17316 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017317 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017318 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017319 .init_verbs = { alc662_init_verbs,
17320 alc662_ecs_init_verbs },
17321 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17322 .dac_nids = alc662_dac_nids,
17323 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17324 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017325 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017326 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017327 .init_hook = alc662_eeepc_inithook,
17328 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017329 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017330 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017331 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17332 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17333 .dac_nids = alc662_dac_nids,
17334 .dig_out_nid = ALC662_DIGOUT_NID,
17335 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17336 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017337 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017338 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017339 .init_hook = alc663_m51va_inithook,
17340 },
17341 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017342 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017343 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
17344 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17345 .dac_nids = alc662_dac_nids,
17346 .dig_out_nid = ALC662_DIGOUT_NID,
17347 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17348 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017349 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017350 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017351 .init_hook = alc663_g71v_inithook,
17352 },
17353 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017354 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017355 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17356 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17357 .dac_nids = alc662_dac_nids,
17358 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17359 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017360 .unsol_event = alc663_m51va_unsol_event,
17361 .init_hook = alc663_m51va_inithook,
17362 },
17363 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017364 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017365 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17366 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17367 .dac_nids = alc662_dac_nids,
17368 .dig_out_nid = ALC662_DIGOUT_NID,
17369 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17370 .channel_mode = alc662_3ST_6ch_modes,
17371 .input_mux = &alc663_capture_source,
17372 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017373 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017374 .init_hook = alc663_g50v_inithook,
17375 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017376 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017377 .mixers = { alc663_m51va_mixer },
17378 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017379 .init_verbs = { alc662_init_verbs,
17380 alc663_21jd_amic_init_verbs },
17381 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17382 .hp_nid = 0x03,
17383 .dac_nids = alc662_dac_nids,
17384 .dig_out_nid = ALC662_DIGOUT_NID,
17385 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17386 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017387 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017388 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017389 .init_hook = alc663_mode1_inithook,
17390 },
17391 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017392 .mixers = { alc662_1bjd_mixer },
17393 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017394 .init_verbs = { alc662_init_verbs,
17395 alc662_1bjd_amic_init_verbs },
17396 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17397 .dac_nids = alc662_dac_nids,
17398 .dig_out_nid = ALC662_DIGOUT_NID,
17399 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17400 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017401 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017402 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017403 .init_hook = alc662_mode2_inithook,
17404 },
17405 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017406 .mixers = { alc663_two_hp_m1_mixer },
17407 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017408 .init_verbs = { alc662_init_verbs,
17409 alc663_two_hp_amic_m1_init_verbs },
17410 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17411 .hp_nid = 0x03,
17412 .dac_nids = alc662_dac_nids,
17413 .dig_out_nid = ALC662_DIGOUT_NID,
17414 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17415 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017416 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017417 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017418 .init_hook = alc663_mode3_inithook,
17419 },
17420 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017421 .mixers = { alc663_asus_21jd_clfe_mixer },
17422 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017423 .init_verbs = { alc662_init_verbs,
17424 alc663_21jd_amic_init_verbs},
17425 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17426 .hp_nid = 0x03,
17427 .dac_nids = alc662_dac_nids,
17428 .dig_out_nid = ALC662_DIGOUT_NID,
17429 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17430 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017431 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017432 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017433 .init_hook = alc663_mode4_inithook,
17434 },
17435 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017436 .mixers = { alc663_asus_15jd_clfe_mixer },
17437 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017438 .init_verbs = { alc662_init_verbs,
17439 alc663_15jd_amic_init_verbs },
17440 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17441 .hp_nid = 0x03,
17442 .dac_nids = alc662_dac_nids,
17443 .dig_out_nid = ALC662_DIGOUT_NID,
17444 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17445 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017446 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017447 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017448 .init_hook = alc663_mode5_inithook,
17449 },
17450 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017451 .mixers = { alc663_two_hp_m2_mixer },
17452 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017453 .init_verbs = { alc662_init_verbs,
17454 alc663_two_hp_amic_m2_init_verbs },
17455 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17456 .hp_nid = 0x03,
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 Yangf1d4e282008-08-26 14:03:29 +020017461 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017462 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017463 .init_hook = alc663_mode6_inithook,
17464 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010017465 [ALC663_ASUS_MODE7] = {
17466 .mixers = { alc663_mode7_mixer },
17467 .cap_mixer = alc662_auto_capture_mixer,
17468 .init_verbs = { alc662_init_verbs,
17469 alc663_mode7_init_verbs },
17470 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17471 .hp_nid = 0x03,
17472 .dac_nids = alc662_dac_nids,
17473 .dig_out_nid = ALC662_DIGOUT_NID,
17474 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17475 .channel_mode = alc662_3ST_2ch_modes,
17476 .unsol_event = alc663_mode7_unsol_event,
17477 .setup = alc663_mode7_setup,
17478 .init_hook = alc663_mode7_inithook,
17479 },
17480 [ALC663_ASUS_MODE8] = {
17481 .mixers = { alc663_mode8_mixer },
17482 .cap_mixer = alc662_auto_capture_mixer,
17483 .init_verbs = { alc662_init_verbs,
17484 alc663_mode8_init_verbs },
17485 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17486 .hp_nid = 0x03,
17487 .dac_nids = alc662_dac_nids,
17488 .dig_out_nid = ALC662_DIGOUT_NID,
17489 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17490 .channel_mode = alc662_3ST_2ch_modes,
17491 .unsol_event = alc663_mode8_unsol_event,
17492 .setup = alc663_mode8_setup,
17493 .init_hook = alc663_mode8_inithook,
17494 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017495 [ALC272_DELL] = {
17496 .mixers = { alc663_m51va_mixer },
17497 .cap_mixer = alc272_auto_capture_mixer,
17498 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17499 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17500 .dac_nids = alc662_dac_nids,
17501 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17502 .adc_nids = alc272_adc_nids,
17503 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17504 .capsrc_nids = alc272_capsrc_nids,
17505 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017506 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017507 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017508 .init_hook = alc663_m51va_inithook,
17509 },
17510 [ALC272_DELL_ZM1] = {
17511 .mixers = { alc663_m51va_mixer },
17512 .cap_mixer = alc662_auto_capture_mixer,
17513 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17514 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17515 .dac_nids = alc662_dac_nids,
17516 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17517 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017518 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020017519 .capsrc_nids = alc662_capsrc_nids,
17520 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017521 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017522 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017523 .init_hook = alc663_m51va_inithook,
17524 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017525 [ALC272_SAMSUNG_NC10] = {
17526 .mixers = { alc272_nc10_mixer },
17527 .init_verbs = { alc662_init_verbs,
17528 alc663_21jd_amic_init_verbs },
17529 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17530 .dac_nids = alc272_dac_nids,
17531 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17532 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017533 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020017534 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017535 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020017536 .init_hook = alc663_mode4_inithook,
17537 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017538};
17539
17540
17541/*
17542 * BIOS auto configuration
17543 */
17544
Takashi Iwai7085ec12009-10-02 09:03:58 +020017545/* convert from MIX nid to DAC */
17546static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
17547{
17548 if (nid == 0x0f)
17549 return 0x02;
17550 else if (nid >= 0x0c && nid <= 0x0e)
17551 return nid - 0x0c + 0x02;
17552 else
17553 return 0;
17554}
17555
17556/* get MIX nid connected to the given pin targeted to DAC */
17557static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
17558 hda_nid_t dac)
17559{
17560 hda_nid_t mix[4];
17561 int i, num;
17562
17563 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
17564 for (i = 0; i < num; i++) {
17565 if (alc662_mix_to_dac(mix[i]) == dac)
17566 return mix[i];
17567 }
17568 return 0;
17569}
17570
17571/* look for an empty DAC slot */
17572static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
17573{
17574 struct alc_spec *spec = codec->spec;
17575 hda_nid_t srcs[5];
17576 int i, j, num;
17577
17578 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
17579 if (num < 0)
17580 return 0;
17581 for (i = 0; i < num; i++) {
17582 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
17583 if (!nid)
17584 continue;
17585 for (j = 0; j < spec->multiout.num_dacs; j++)
17586 if (spec->multiout.dac_nids[j] == nid)
17587 break;
17588 if (j >= spec->multiout.num_dacs)
17589 return nid;
17590 }
17591 return 0;
17592}
17593
17594/* fill in the dac_nids table from the parsed pin configuration */
17595static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
17596 const struct auto_pin_cfg *cfg)
17597{
17598 struct alc_spec *spec = codec->spec;
17599 int i;
17600 hda_nid_t dac;
17601
17602 spec->multiout.dac_nids = spec->private_dac_nids;
17603 for (i = 0; i < cfg->line_outs; i++) {
17604 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
17605 if (!dac)
17606 continue;
17607 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
17608 }
17609 return 0;
17610}
17611
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017612static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017613 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017614{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017615 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017616 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
17617}
17618
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017619static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017620 hda_nid_t nid, unsigned int chs)
17621{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017622 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017623 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
17624}
17625
17626#define alc662_add_stereo_vol(spec, pfx, nid) \
17627 alc662_add_vol_ctl(spec, pfx, nid, 3)
17628#define alc662_add_stereo_sw(spec, pfx, nid) \
17629 alc662_add_sw_ctl(spec, pfx, nid, 3)
17630
17631/* add playback controls from the parsed DAC table */
17632static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
17633 const struct auto_pin_cfg *cfg)
17634{
17635 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017636 static const char *chname[4] = {
17637 "Front", "Surround", NULL /*CLFE*/, "Side"
17638 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020017639 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017640 int i, err;
17641
17642 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017643 nid = spec->multiout.dac_nids[i];
17644 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017645 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017646 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
17647 if (!mix)
17648 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017649 if (i == 2) {
17650 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017651 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017652 if (err < 0)
17653 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017654 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017655 if (err < 0)
17656 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017657 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017658 if (err < 0)
17659 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017660 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017661 if (err < 0)
17662 return err;
17663 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017664 const char *pfx;
17665 if (cfg->line_outs == 1 &&
17666 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017667 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017668 pfx = "Speaker";
17669 else
17670 pfx = "PCM";
17671 } else
17672 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017673 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017674 if (err < 0)
17675 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017676 if (cfg->line_outs == 1 &&
17677 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
17678 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020017679 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017680 if (err < 0)
17681 return err;
17682 }
17683 }
17684 return 0;
17685}
17686
17687/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017688/* return DAC nid if any new DAC is assigned */
17689static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017690 const char *pfx)
17691{
Takashi Iwai7085ec12009-10-02 09:03:58 +020017692 struct alc_spec *spec = codec->spec;
17693 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017694 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017695
17696 if (!pin)
17697 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017698 nid = alc662_look_for_dac(codec, pin);
17699 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017700 /* the corresponding DAC is already occupied */
17701 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
17702 return 0; /* no way */
17703 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017704 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017705 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17706 }
17707
17708 mix = alc662_dac_to_mix(codec, pin, nid);
17709 if (!mix)
17710 return 0;
17711 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
17712 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020017713 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017714 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
17715 if (err < 0)
17716 return err;
17717 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017718}
17719
17720/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017721#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020017722 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017723
17724static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17725 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017726 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017727{
Takashi Iwai7085ec12009-10-02 09:03:58 +020017728 int i, num;
17729 hda_nid_t srcs[4];
17730
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017731 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017732 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017733 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
17734 if (num <= 1)
17735 return;
17736 for (i = 0; i < num; i++) {
17737 if (alc662_mix_to_dac(srcs[i]) != dac)
17738 continue;
17739 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
17740 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017741 }
17742}
17743
17744static void alc662_auto_init_multi_out(struct hda_codec *codec)
17745{
17746 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017747 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017748 int i;
17749
17750 for (i = 0; i <= HDA_SIDE; i++) {
17751 hda_nid_t nid = spec->autocfg.line_out_pins[i];
17752 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017753 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017754 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017755 }
17756}
17757
17758static void alc662_auto_init_hp_out(struct hda_codec *codec)
17759{
17760 struct alc_spec *spec = codec->spec;
17761 hda_nid_t pin;
17762
17763 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017764 if (pin)
17765 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
17766 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017767 pin = spec->autocfg.speaker_pins[0];
17768 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020017769 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
17770 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017771}
17772
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017773#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17774
17775static void alc662_auto_init_analog_input(struct hda_codec *codec)
17776{
17777 struct alc_spec *spec = codec->spec;
17778 int i;
17779
17780 for (i = 0; i < AUTO_PIN_LAST; i++) {
17781 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020017782 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017783 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017784 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017785 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017786 snd_hda_codec_write(codec, nid, 0,
17787 AC_VERB_SET_AMP_GAIN_MUTE,
17788 AMP_OUT_MUTE);
17789 }
17790 }
17791}
17792
Takashi Iwaif511b012008-08-15 16:46:42 +020017793#define alc662_auto_init_input_src alc882_auto_init_input_src
17794
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017795static int alc662_parse_auto_config(struct hda_codec *codec)
17796{
17797 struct alc_spec *spec = codec->spec;
17798 int err;
17799 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17800
17801 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17802 alc662_ignore);
17803 if (err < 0)
17804 return err;
17805 if (!spec->autocfg.line_outs)
17806 return 0; /* can't find valid BIOS pin config */
17807
Takashi Iwai7085ec12009-10-02 09:03:58 +020017808 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017809 if (err < 0)
17810 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017811 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017812 if (err < 0)
17813 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017814 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017815 spec->autocfg.speaker_pins[0],
17816 "Speaker");
17817 if (err < 0)
17818 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017819 if (err)
17820 spec->multiout.extra_out_nid[0] = err;
17821 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017822 "Headphone");
17823 if (err < 0)
17824 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017825 if (err)
17826 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017827 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017828 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017829 return err;
17830
17831 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17832
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017833 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017834 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17835
Takashi Iwai603c4012008-07-30 15:01:44 +020017836 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017837 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017838
17839 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017840 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017841
Takashi Iwaid88897e2008-10-31 15:01:37 +010017842 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017843 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017844 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017845
17846 err = alc_auto_add_mic_boost(codec);
17847 if (err < 0)
17848 return err;
17849
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017850 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17851
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017852 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017853}
17854
17855/* additional initialization for auto-configuration model */
17856static void alc662_auto_init(struct hda_codec *codec)
17857{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017858 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017859 alc662_auto_init_multi_out(codec);
17860 alc662_auto_init_hp_out(codec);
17861 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017862 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017863 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017864 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017865}
17866
17867static int patch_alc662(struct hda_codec *codec)
17868{
17869 struct alc_spec *spec;
17870 int err, board_config;
17871
17872 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17873 if (!spec)
17874 return -ENOMEM;
17875
17876 codec->spec = spec;
17877
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017878 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17879
Kailang Yang274693f2009-12-03 10:07:50 +010017880 if (alc_read_coef_idx(codec, 0)==0x8020){
17881 kfree(codec->chip_name);
17882 codec->chip_name = kstrdup("ALC661", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017883 if (!codec->chip_name) {
17884 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010017885 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017886 }
Kailang Yang274693f2009-12-03 10:07:50 +010017887 }
17888
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017889 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17890 alc662_models,
17891 alc662_cfg_tbl);
17892 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017893 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17894 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017895 board_config = ALC662_AUTO;
17896 }
17897
17898 if (board_config == ALC662_AUTO) {
17899 /* automatic parse from the BIOS config */
17900 err = alc662_parse_auto_config(codec);
17901 if (err < 0) {
17902 alc_free(codec);
17903 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017904 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017905 printk(KERN_INFO
17906 "hda_codec: Cannot set up configuration "
17907 "from BIOS. Using base mode...\n");
17908 board_config = ALC662_3ST_2ch_DIG;
17909 }
17910 }
17911
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017912 err = snd_hda_attach_beep_device(codec, 0x1);
17913 if (err < 0) {
17914 alc_free(codec);
17915 return err;
17916 }
17917
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017918 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017919 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017920
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017921 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17922 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17923
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017924 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17925 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17926
Takashi Iwaidd704692009-08-11 08:45:11 +020017927 if (!spec->adc_nids) {
17928 spec->adc_nids = alc662_adc_nids;
17929 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17930 }
17931 if (!spec->capsrc_nids)
17932 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017933
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017934 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017935 set_capture_mixer(codec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017936 if (codec->vendor_id == 0x10ec0662)
17937 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17938 else
17939 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017940
Takashi Iwai2134ea42008-01-10 16:53:55 +010017941 spec->vmaster_nid = 0x02;
17942
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017943 codec->patch_ops = alc_patch_ops;
17944 if (board_config == ALC662_AUTO)
17945 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017946#ifdef CONFIG_SND_HDA_POWER_SAVE
17947 if (!spec->loopback.amplist)
17948 spec->loopback.amplist = alc662_loopbacks;
17949#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017950 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017951
17952 return 0;
17953}
17954
Kailang Yang274693f2009-12-03 10:07:50 +010017955static int patch_alc888(struct hda_codec *codec)
17956{
17957 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
17958 kfree(codec->chip_name);
17959 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017960 if (!codec->chip_name) {
17961 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010017962 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017963 }
17964 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010017965 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017966 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010017967}
17968
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017969/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017970 * patch entries
17971 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017972static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017973 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017974 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017975 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017976 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017977 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010017978 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017979 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010017980 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017981 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017982 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017983 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17984 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17985 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017986 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017987 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017988 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17989 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017990 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017991 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017992 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017993 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020017994 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017995 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020017996 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017997 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017998 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017999 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020018000 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018001 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018002 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018003 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018004 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018005 {} /* terminator */
18006};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018007
18008MODULE_ALIAS("snd-hda-codec-id:10ec*");
18009
18010MODULE_LICENSE("GPL");
18011MODULE_DESCRIPTION("Realtek HD-audio codec");
18012
18013static struct hda_codec_preset_list realtek_list = {
18014 .preset = snd_hda_preset_realtek,
18015 .owner = THIS_MODULE,
18016};
18017
18018static int __init patch_realtek_init(void)
18019{
18020 return snd_hda_add_codec_preset(&realtek_list);
18021}
18022
18023static void __exit patch_realtek_exit(void)
18024{
18025 snd_hda_delete_codec_preset(&realtek_list);
18026}
18027
18028module_init(patch_realtek_init)
18029module_exit(patch_realtek_exit)