blob: b5a6ba025930c3efeaf21023b2483ca1c4e57d62 [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 Yang84898e82010-02-04 14:16:14 +0100134 ALC269_AMIC,
135 ALC269_DMIC,
136 ALC269VB_AMIC,
137 ALC269VB_DMIC,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100138 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000139 ALC269_LIFEBOOK,
Kailang Yangf6a92242007-12-13 16:52:54 +0100140 ALC269_AUTO,
141 ALC269_MODEL_LAST /* last tag */
142};
143
Kailang Yangdf694da2005-12-05 19:42:22 +0100144/* ALC861 models */
145enum {
146 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200147 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100148 ALC861_3ST_DIG,
149 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200150 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200151 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200152 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100153 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100154 ALC861_AUTO,
155 ALC861_MODEL_LAST,
156};
157
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100158/* ALC861-VD models */
159enum {
160 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200161 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100162 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100163 ALC861VD_3ST,
164 ALC861VD_3ST_DIG,
165 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200166 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200167 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200168 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100169 ALC861VD_AUTO,
170 ALC861VD_MODEL_LAST,
171};
172
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200173/* ALC662 models */
174enum {
175 ALC662_3ST_2ch_DIG,
176 ALC662_3ST_6ch_DIG,
177 ALC662_3ST_6ch,
178 ALC662_5ST_DIG,
179 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200180 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100181 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200182 ALC663_ASUS_M51VA,
183 ALC663_ASUS_G71V,
184 ALC663_ASUS_H13,
185 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200186 ALC662_ECS,
187 ALC663_ASUS_MODE1,
188 ALC662_ASUS_MODE2,
189 ALC663_ASUS_MODE3,
190 ALC663_ASUS_MODE4,
191 ALC663_ASUS_MODE5,
192 ALC663_ASUS_MODE6,
Kailang Yangebb83ee2009-12-17 12:23:00 +0100193 ALC663_ASUS_MODE7,
194 ALC663_ASUS_MODE8,
Kailang Yang622e84c2009-04-21 07:39:04 +0200195 ALC272_DELL,
196 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200197 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200198 ALC662_AUTO,
199 ALC662_MODEL_LAST,
200};
201
Kailang Yangdf694da2005-12-05 19:42:22 +0100202/* ALC882 models */
203enum {
204 ALC882_3ST_DIG,
205 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200206 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200207 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200208 ALC882_TARGA,
209 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200210 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100211 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200212 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200213 ALC885_MB5,
Luke Yelaviche458b1f2010-02-12 16:28:29 +1100214 ALC885_MACMINI3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200215 ALC885_IMAC24,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -0800216 ALC885_IMAC91,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200217 ALC883_3ST_2ch_DIG,
218 ALC883_3ST_6ch_DIG,
219 ALC883_3ST_6ch,
220 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200221 ALC883_TARGA_DIG,
222 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200223 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200224 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200225 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800226 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100227 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200228 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200229 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200230 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200231 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100232 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200233 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200234 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200235 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200236 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200237 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200238 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100239 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100240 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430241 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100242 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100243 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800244 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200245 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200246 ALC889A_INTEL,
247 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200248 ALC888_ASUS_M90V,
249 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200250 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100251 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200252 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200253 ALC882_AUTO,
254 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200255};
256
Kailang Yangdf694da2005-12-05 19:42:22 +0100257/* for GPIO Poll */
258#define GPIO_MASK 0x03
259
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200260/* extra amp-initialization sequence types */
261enum {
262 ALC_INIT_NONE,
263 ALC_INIT_DEFAULT,
264 ALC_INIT_GPIO1,
265 ALC_INIT_GPIO2,
266 ALC_INIT_GPIO3,
267};
268
Takashi Iwai6c819492009-08-10 18:47:44 +0200269struct alc_mic_route {
270 hda_nid_t pin;
271 unsigned char mux_idx;
272 unsigned char amix_idx;
273};
274
275#define MUX_IDX_UNDEF ((unsigned char)-1)
276
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277struct alc_spec {
278 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100279 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100281 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100282 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200284 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200285 * don't forget NULL
286 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200287 */
288 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200290 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 struct hda_pcm_stream *stream_analog_playback;
292 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100293 struct hda_pcm_stream *stream_analog_alt_playback;
294 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200296 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 struct hda_pcm_stream *stream_digital_playback;
298 struct hda_pcm_stream *stream_digital_capture;
299
300 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200301 struct hda_multi_out multiout; /* playback set-up
302 * max_channels, dacs must be set
303 * dig_out_nid and hp_nid are optional
304 */
Takashi Iwai63300792008-01-24 15:31:36 +0100305 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100306 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100307 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308
309 /* capture */
310 unsigned int num_adc_nids;
311 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100312 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200313 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314
315 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200316 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 const struct hda_input_mux *input_mux;
318 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200319 struct alc_mic_route ext_mic;
320 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321
322 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100323 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200325 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200326 int const_channel_count;
327 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328
329 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100330 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200331
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200332 /* dynamic controls, init_verbs and input_mux */
333 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200334 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200335 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200336 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200337 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
338 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100339
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100340 /* hooks */
341 void (*init_hook)(struct hda_codec *codec);
342 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100343#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -0500344 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100345#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100346
Takashi Iwai834be882006-03-01 14:16:17 +0100347 /* for pin sensing */
348 unsigned int sense_updated: 1;
349 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100350 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200351 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200352
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100353 /* other flags */
354 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200355 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100356
Takashi Iwai2134ea42008-01-10 16:53:55 +0100357 /* for virtual master */
358 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200359#ifdef CONFIG_SND_HDA_POWER_SAVE
360 struct hda_loopback_check loopback;
361#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200362
363 /* for PLL fix */
364 hda_nid_t pll_nid;
365 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100366};
367
368/*
369 * configuration template - to be copied to the spec instance
370 */
371struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200372 struct snd_kcontrol_new *mixers[5]; /* should be identical size
373 * with spec
374 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100375 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100376 const struct hda_verb *init_verbs[5];
377 unsigned int num_dacs;
378 hda_nid_t *dac_nids;
379 hda_nid_t dig_out_nid; /* optional */
380 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800381 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100382 unsigned int num_adc_nids;
383 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100384 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100385 hda_nid_t dig_in_nid;
386 unsigned int num_channel_mode;
387 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200388 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200389 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200390 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100391 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100392 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200393 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100394 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200395#ifdef CONFIG_SND_HDA_POWER_SAVE
396 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500397 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200398#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399};
400
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401
402/*
403 * input MUX handling
404 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200405static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
406 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407{
408 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
409 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200410 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
411 if (mux_idx >= spec->num_mux_defs)
412 mux_idx = 0;
413 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414}
415
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200416static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
417 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418{
419 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
420 struct alc_spec *spec = codec->spec;
421 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
422
423 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
424 return 0;
425}
426
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200427static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
428 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429{
430 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
431 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100432 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100434 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100435 hda_nid_t nid = spec->capsrc_nids ?
436 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200437 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438
Takashi Iwaicd896c32008-11-18 12:36:33 +0100439 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
440 imux = &spec->input_mux[mux_idx];
441
Takashi Iwaia22d5432009-07-27 12:54:26 +0200442 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200443 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100444 /* Matrix-mixer style (e.g. ALC882) */
445 unsigned int *cur_val = &spec->cur_mux[adc_idx];
446 unsigned int i, idx;
447
448 idx = ucontrol->value.enumerated.item[0];
449 if (idx >= imux->num_items)
450 idx = imux->num_items - 1;
451 if (*cur_val == idx)
452 return 0;
453 for (i = 0; i < imux->num_items; i++) {
454 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
455 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
456 imux->items[i].index,
457 HDA_AMP_MUTE, v);
458 }
459 *cur_val = idx;
460 return 1;
461 } else {
462 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100463 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100464 &spec->cur_mux[adc_idx]);
465 }
466}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200467
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468/*
469 * channel mode setting
470 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200471static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
472 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473{
474 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
475 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100476 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
477 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478}
479
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200480static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
481 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482{
483 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
484 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100485 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200486 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200487 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488}
489
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200490static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
491 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492{
493 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
494 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200495 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
496 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200497 &spec->ext_channel_count);
498 if (err >= 0 && !spec->const_channel_count) {
499 spec->multiout.max_channels = spec->ext_channel_count;
500 if (spec->need_dac_fix)
501 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
502 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200503 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504}
505
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100507 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200508 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100509 * being part of a format specifier. Maximum allowed length of a value is
510 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100511 *
512 * Note: some retasking pin complexes seem to ignore requests for input
513 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
514 * are requested. Therefore order this list so that this behaviour will not
515 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200516 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
517 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200518 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100519static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100520 "Mic 50pc bias", "Mic 80pc bias",
521 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100522};
523static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100524 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100525};
526/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200527 * in the pin being assumed to be exclusively an input or an output pin. In
528 * addition, "input" pins may or may not process the mic bias option
529 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
530 * accept requests for bias as of chip versions up to March 2006) and/or
531 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100532 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200533#define ALC_PIN_DIR_IN 0x00
534#define ALC_PIN_DIR_OUT 0x01
535#define ALC_PIN_DIR_INOUT 0x02
536#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
537#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100538
Kailang Yangea1fb292008-08-26 12:58:38 +0200539/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100540 * For each direction the minimum and maximum values are given.
541 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200542static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100543 { 0, 2 }, /* ALC_PIN_DIR_IN */
544 { 3, 4 }, /* ALC_PIN_DIR_OUT */
545 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200546 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
547 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100548};
549#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
550#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
551#define alc_pin_mode_n_items(_dir) \
552 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
553
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200554static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
555 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200556{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100557 unsigned int item_num = uinfo->value.enumerated.item;
558 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
559
560 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200561 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100562 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
563
564 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
565 item_num = alc_pin_mode_min(dir);
566 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200567 return 0;
568}
569
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200570static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
571 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200572{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100573 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200574 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
575 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100576 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200577 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200578 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
579 AC_VERB_GET_PIN_WIDGET_CONTROL,
580 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200581
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100582 /* Find enumerated value for current pinctl setting */
583 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200584 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100585 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200586 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100587 return 0;
588}
589
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200590static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
591 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100592{
593 signed int change;
594 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
595 hda_nid_t nid = kcontrol->private_value & 0xffff;
596 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
597 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200598 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
599 AC_VERB_GET_PIN_WIDGET_CONTROL,
600 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100601
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200602 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100603 val = alc_pin_mode_min(dir);
604
605 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100606 if (change) {
607 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200608 snd_hda_codec_write_cache(codec, nid, 0,
609 AC_VERB_SET_PIN_WIDGET_CONTROL,
610 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100611
Kailang Yangea1fb292008-08-26 12:58:38 +0200612 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100613 * for the requested pin mode. Enum values of 2 or less are
614 * input modes.
615 *
616 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200617 * reduces noise slightly (particularly on input) so we'll
618 * do it. However, having both input and output buffers
619 * enabled simultaneously doesn't seem to be problematic if
620 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100621 */
622 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200623 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
624 HDA_AMP_MUTE, HDA_AMP_MUTE);
625 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
626 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100627 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200628 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
629 HDA_AMP_MUTE, HDA_AMP_MUTE);
630 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
631 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100632 }
633 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200634 return change;
635}
636
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100637#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200638 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100639 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100640 .info = alc_pin_mode_info, \
641 .get = alc_pin_mode_get, \
642 .put = alc_pin_mode_put, \
643 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100644
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100645/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
646 * together using a mask with more than one bit set. This control is
647 * currently used only by the ALC260 test model. At this stage they are not
648 * needed for any "production" models.
649 */
650#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200651#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200652
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200653static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
654 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100655{
656 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
657 hda_nid_t nid = kcontrol->private_value & 0xffff;
658 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
659 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200660 unsigned int val = snd_hda_codec_read(codec, nid, 0,
661 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100662
663 *valp = (val & mask) != 0;
664 return 0;
665}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200666static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
667 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100668{
669 signed int change;
670 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
671 hda_nid_t nid = kcontrol->private_value & 0xffff;
672 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
673 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200674 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
675 AC_VERB_GET_GPIO_DATA,
676 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100677
678 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200679 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
680 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100681 gpio_data &= ~mask;
682 else
683 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200684 snd_hda_codec_write_cache(codec, nid, 0,
685 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100686
687 return change;
688}
689#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
690 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100691 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100692 .info = alc_gpio_data_info, \
693 .get = alc_gpio_data_get, \
694 .put = alc_gpio_data_put, \
695 .private_value = nid | (mask<<16) }
696#endif /* CONFIG_SND_DEBUG */
697
Jonathan Woithe92621f12006-02-28 11:47:47 +0100698/* A switch control to allow the enabling of the digital IO pins on the
699 * ALC260. This is incredibly simplistic; the intention of this control is
700 * to provide something in the test model allowing digital outputs to be
701 * identified if present. If models are found which can utilise these
702 * outputs a more complete mixer control can be devised for those models if
703 * necessary.
704 */
705#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200706#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200707
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200708static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
709 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100710{
711 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
712 hda_nid_t nid = kcontrol->private_value & 0xffff;
713 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
714 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200715 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100716 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100717
718 *valp = (val & mask) != 0;
719 return 0;
720}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200721static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
722 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100723{
724 signed int change;
725 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
726 hda_nid_t nid = kcontrol->private_value & 0xffff;
727 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
728 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200729 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100730 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200731 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100732
733 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200734 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100735 if (val==0)
736 ctrl_data &= ~mask;
737 else
738 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200739 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
740 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100741
742 return change;
743}
744#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
745 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100746 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100747 .info = alc_spdif_ctrl_info, \
748 .get = alc_spdif_ctrl_get, \
749 .put = alc_spdif_ctrl_put, \
750 .private_value = nid | (mask<<16) }
751#endif /* CONFIG_SND_DEBUG */
752
Jonathan Woithef8225f62008-01-08 12:16:54 +0100753/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
754 * Again, this is only used in the ALC26x test models to help identify when
755 * the EAPD line must be asserted for features to work.
756 */
757#ifdef CONFIG_SND_DEBUG
758#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
759
760static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
761 struct snd_ctl_elem_value *ucontrol)
762{
763 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
764 hda_nid_t nid = kcontrol->private_value & 0xffff;
765 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
766 long *valp = ucontrol->value.integer.value;
767 unsigned int val = snd_hda_codec_read(codec, nid, 0,
768 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
769
770 *valp = (val & mask) != 0;
771 return 0;
772}
773
774static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
775 struct snd_ctl_elem_value *ucontrol)
776{
777 int change;
778 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
779 hda_nid_t nid = kcontrol->private_value & 0xffff;
780 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
781 long val = *ucontrol->value.integer.value;
782 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
783 AC_VERB_GET_EAPD_BTLENABLE,
784 0x00);
785
786 /* Set/unset the masked control bit(s) as needed */
787 change = (!val ? 0 : mask) != (ctrl_data & mask);
788 if (!val)
789 ctrl_data &= ~mask;
790 else
791 ctrl_data |= mask;
792 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
793 ctrl_data);
794
795 return change;
796}
797
798#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
799 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100800 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100801 .info = alc_eapd_ctrl_info, \
802 .get = alc_eapd_ctrl_get, \
803 .put = alc_eapd_ctrl_put, \
804 .private_value = nid | (mask<<16) }
805#endif /* CONFIG_SND_DEBUG */
806
Kailang Yangdf694da2005-12-05 19:42:22 +0100807/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100808 * set up the input pin config (depending on the given auto-pin type)
809 */
810static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
811 int auto_pin_type)
812{
813 unsigned int val = PIN_IN;
814
815 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
816 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100817 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100818 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
819 if (pincap & AC_PINCAP_VREF_80)
820 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200821 else if (pincap & AC_PINCAP_VREF_50)
822 val = PIN_VREF50;
823 else if (pincap & AC_PINCAP_VREF_100)
824 val = PIN_VREF100;
825 else if (pincap & AC_PINCAP_VREF_GRD)
826 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100827 }
828 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
829}
830
831/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100832 */
833static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
834{
835 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
836 return;
837 spec->mixers[spec->num_mixers++] = mix;
838}
839
840static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
841{
842 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
843 return;
844 spec->init_verbs[spec->num_init_verbs++] = verb;
845}
846
847/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100848 * set up from the preset table
849 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200850static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200851 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100852{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200853 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100854 int i;
855
856 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100857 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100858 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200859 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
860 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100861 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200862
Kailang Yangdf694da2005-12-05 19:42:22 +0100863 spec->channel_mode = preset->channel_mode;
864 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200865 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200866 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100867
Hector Martin3b315d72009-06-02 10:54:19 +0200868 if (preset->const_channel_count)
869 spec->multiout.max_channels = preset->const_channel_count;
870 else
871 spec->multiout.max_channels = spec->channel_mode[0].channels;
872 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100873
874 spec->multiout.num_dacs = preset->num_dacs;
875 spec->multiout.dac_nids = preset->dac_nids;
876 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800877 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100878 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200879
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200880 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200881 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200882 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100883 spec->input_mux = preset->input_mux;
884
885 spec->num_adc_nids = preset->num_adc_nids;
886 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100887 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100888 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100889
890 spec->unsol_event = preset->unsol_event;
891 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200892#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100893 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200894 spec->loopback.amplist = preset->loopbacks;
895#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200896
897 if (preset->setup)
898 preset->setup(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100899}
900
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200901/* Enable GPIO mask and set output */
902static struct hda_verb alc_gpio1_init_verbs[] = {
903 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
904 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
905 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
906 { }
907};
908
909static struct hda_verb alc_gpio2_init_verbs[] = {
910 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
911 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
912 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
913 { }
914};
915
Kailang Yangbdd148a2007-05-08 15:19:08 +0200916static struct hda_verb alc_gpio3_init_verbs[] = {
917 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
918 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
919 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
920 { }
921};
922
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200923/*
924 * Fix hardware PLL issue
925 * On some codecs, the analog PLL gating control must be off while
926 * the default value is 1.
927 */
928static void alc_fix_pll(struct hda_codec *codec)
929{
930 struct alc_spec *spec = codec->spec;
931 unsigned int val;
932
933 if (!spec->pll_nid)
934 return;
935 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
936 spec->pll_coef_idx);
937 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
938 AC_VERB_GET_PROC_COEF, 0);
939 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
940 spec->pll_coef_idx);
941 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
942 val & ~(1 << spec->pll_coef_bit));
943}
944
945static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
946 unsigned int coef_idx, unsigned int coef_bit)
947{
948 struct alc_spec *spec = codec->spec;
949 spec->pll_nid = nid;
950 spec->pll_coef_idx = coef_idx;
951 spec->pll_coef_bit = coef_bit;
952 alc_fix_pll(codec);
953}
954
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200955static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200956{
957 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200958 unsigned int nid = spec->autocfg.hp_pins[0];
959 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200960
Takashi Iwaiad87c642009-11-02 14:23:15 +0100961 if (!nid)
962 return;
Wu Fengguang864f92b2009-11-18 12:38:02 +0800963 spec->jack_present = snd_hda_jack_detect(codec, nid);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200964 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
965 nid = spec->autocfg.speaker_pins[i];
966 if (!nid)
967 break;
968 snd_hda_codec_write(codec, nid, 0,
969 AC_VERB_SET_PIN_WIDGET_CONTROL,
970 spec->jack_present ? 0 : PIN_OUT);
971 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200972}
973
Takashi Iwai6c819492009-08-10 18:47:44 +0200974static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
975 hda_nid_t nid)
976{
977 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
978 int i, nums;
979
980 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
981 for (i = 0; i < nums; i++)
982 if (conn[i] == nid)
983 return i;
984 return -1;
985}
986
Kailang Yang7fb0d782008-10-15 11:12:35 +0200987static void alc_mic_automute(struct hda_codec *codec)
988{
989 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +0200990 struct alc_mic_route *dead, *alive;
991 unsigned int present, type;
992 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +0200993
Takashi Iwaib59bdf32009-08-11 09:47:30 +0200994 if (!spec->auto_mic)
995 return;
Takashi Iwai6c819492009-08-10 18:47:44 +0200996 if (!spec->int_mic.pin || !spec->ext_mic.pin)
997 return;
998 if (snd_BUG_ON(!spec->adc_nids))
999 return;
1000
1001 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1002
Wu Fengguang864f92b2009-11-18 12:38:02 +08001003 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001004 if (present) {
1005 alive = &spec->ext_mic;
1006 dead = &spec->int_mic;
1007 } else {
1008 alive = &spec->int_mic;
1009 dead = &spec->ext_mic;
1010 }
1011
Takashi Iwai6c819492009-08-10 18:47:44 +02001012 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1013 if (type == AC_WID_AUD_MIX) {
1014 /* Matrix-mixer style (e.g. ALC882) */
1015 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1016 alive->mux_idx,
1017 HDA_AMP_MUTE, 0);
1018 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1019 dead->mux_idx,
1020 HDA_AMP_MUTE, HDA_AMP_MUTE);
1021 } else {
1022 /* MUX style (e.g. ALC880) */
1023 snd_hda_codec_write_cache(codec, cap_nid, 0,
1024 AC_VERB_SET_CONNECT_SEL,
1025 alive->mux_idx);
1026 }
1027
1028 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001029}
1030
Kailang Yangc9b58002007-10-16 14:30:01 +02001031/* unsolicited event for HP jack sensing */
1032static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1033{
1034 if (codec->vendor_id == 0x10ec0880)
1035 res >>= 28;
1036 else
1037 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001038 switch (res) {
1039 case ALC880_HP_EVENT:
1040 alc_automute_pin(codec);
1041 break;
1042 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001043 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001044 break;
1045 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001046}
1047
1048static void alc_inithook(struct hda_codec *codec)
1049{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001050 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001051 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001052}
1053
Kailang Yangf9423e72008-05-27 12:32:25 +02001054/* additional initialization for ALC888 variants */
1055static void alc888_coef_init(struct hda_codec *codec)
1056{
1057 unsigned int tmp;
1058
1059 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1060 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1061 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001062 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001063 /* alc888S-VC */
1064 snd_hda_codec_read(codec, 0x20, 0,
1065 AC_VERB_SET_PROC_COEF, 0x830);
1066 else
1067 /* alc888-VB */
1068 snd_hda_codec_read(codec, 0x20, 0,
1069 AC_VERB_SET_PROC_COEF, 0x3030);
1070}
1071
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001072static void alc889_coef_init(struct hda_codec *codec)
1073{
1074 unsigned int tmp;
1075
1076 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1077 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1078 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1079 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1080}
1081
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001082/* turn on/off EAPD control (only if available) */
1083static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1084{
1085 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1086 return;
1087 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1088 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1089 on ? 2 : 0);
1090}
1091
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001092static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001093{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001094 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001095
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001096 switch (type) {
1097 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001098 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1099 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001100 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001101 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1102 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001103 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001104 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1105 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001106 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001107 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001108 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001109 set_eapd(codec, 0x0f, 1);
1110 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001111 break;
1112 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001113 case 0x10ec0267:
1114 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001115 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001116 case 0x10ec0270:
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:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001123 set_eapd(codec, 0x14, 1);
1124 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001125 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001126 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001127 switch (codec->vendor_id) {
1128 case 0x10ec0260:
1129 snd_hda_codec_write(codec, 0x1a, 0,
1130 AC_VERB_SET_COEF_INDEX, 7);
1131 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1132 AC_VERB_GET_PROC_COEF, 0);
1133 snd_hda_codec_write(codec, 0x1a, 0,
1134 AC_VERB_SET_COEF_INDEX, 7);
1135 snd_hda_codec_write(codec, 0x1a, 0,
1136 AC_VERB_SET_PROC_COEF,
1137 tmp | 0x2010);
1138 break;
1139 case 0x10ec0262:
1140 case 0x10ec0880:
1141 case 0x10ec0882:
1142 case 0x10ec0883:
1143 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001144 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001145 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001146 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001147 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001148 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001149 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001150 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001151#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001152 case 0x10ec0267:
1153 case 0x10ec0268:
1154 snd_hda_codec_write(codec, 0x20, 0,
1155 AC_VERB_SET_COEF_INDEX, 7);
1156 tmp = snd_hda_codec_read(codec, 0x20, 0,
1157 AC_VERB_GET_PROC_COEF, 0);
1158 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001159 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001160 snd_hda_codec_write(codec, 0x20, 0,
1161 AC_VERB_SET_PROC_COEF,
1162 tmp | 0x3000);
1163 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001164#endif /* XXX */
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 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001228 if (!ext || !fixed)
1229 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001230 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1231 return; /* no unsol support */
1232 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1233 ext, fixed);
1234 spec->ext_mic.pin = ext;
1235 spec->int_mic.pin = fixed;
1236 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1237 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1238 spec->auto_mic = 1;
1239 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1240 AC_VERB_SET_UNSOLICITED_ENABLE,
1241 AC_USRSP_EN | ALC880_MIC_EVENT);
1242 spec->unsol_event = alc_sku_unsol_event;
1243}
1244
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001245/* check subsystem ID and set up device-specific initialization;
1246 * return 1 if initialized, 0 if invalid SSID
1247 */
1248/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1249 * 31 ~ 16 : Manufacture ID
1250 * 15 ~ 8 : SKU ID
1251 * 7 ~ 0 : Assembly ID
1252 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1253 */
1254static int alc_subsystem_id(struct hda_codec *codec,
1255 hda_nid_t porta, hda_nid_t porte,
1256 hda_nid_t portd)
1257{
1258 unsigned int ass, tmp, i;
1259 unsigned nid;
1260 struct alc_spec *spec = codec->spec;
1261
1262 ass = codec->subsystem_id & 0xffff;
1263 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1264 goto do_sku;
1265
1266 /* invalid SSID, check the special NID pin defcfg instead */
1267 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001268 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001269 * 29~21 : reserve
1270 * 20 : PCBEEP input
1271 * 19~16 : Check sum (15:1)
1272 * 15~1 : Custom
1273 * 0 : override
1274 */
1275 nid = 0x1d;
1276 if (codec->vendor_id == 0x10ec0260)
1277 nid = 0x17;
1278 ass = snd_hda_codec_get_pincfg(codec, nid);
1279 snd_printd("realtek: No valid SSID, "
1280 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001281 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001282 if (!(ass & 1) && !(ass & 0x100000))
1283 return 0;
1284 if ((ass >> 30) != 1) /* no physical connection */
1285 return 0;
1286
1287 /* check sum */
1288 tmp = 0;
1289 for (i = 1; i < 16; i++) {
1290 if ((ass >> i) & 1)
1291 tmp++;
1292 }
1293 if (((ass >> 16) & 0xf) != tmp)
1294 return 0;
1295do_sku:
1296 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1297 ass & 0xffff, codec->vendor_id);
1298 /*
1299 * 0 : override
1300 * 1 : Swap Jack
1301 * 2 : 0 --> Desktop, 1 --> Laptop
1302 * 3~5 : External Amplifier control
1303 * 7~6 : Reserved
1304 */
1305 tmp = (ass & 0x38) >> 3; /* external Amp control */
1306 switch (tmp) {
1307 case 1:
1308 spec->init_amp = ALC_INIT_GPIO1;
1309 break;
1310 case 3:
1311 spec->init_amp = ALC_INIT_GPIO2;
1312 break;
1313 case 7:
1314 spec->init_amp = ALC_INIT_GPIO3;
1315 break;
1316 case 5:
1317 spec->init_amp = ALC_INIT_DEFAULT;
1318 break;
1319 }
1320
1321 /* is laptop or Desktop and enable the function "Mute internal speaker
1322 * when the external headphone out jack is plugged"
1323 */
1324 if (!(ass & 0x8000))
1325 return 1;
1326 /*
1327 * 10~8 : Jack location
1328 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1329 * 14~13: Resvered
1330 * 15 : 1 --> enable the function "Mute internal speaker
1331 * when the external headphone out jack is plugged"
1332 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001333 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001334 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001335 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1336 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001337 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001338 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001339 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001340 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001341 nid = portd;
Kailang Yangc9b58002007-10-16 14:30:01 +02001342 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001343 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001344 for (i = 0; i < spec->autocfg.line_outs; i++)
1345 if (spec->autocfg.line_out_pins[i] == nid)
1346 return 1;
1347 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001348 }
1349
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001350 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001351 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001352 return 1;
1353}
Kailang Yangea1fb292008-08-26 12:58:38 +02001354
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001355static void alc_ssid_check(struct hda_codec *codec,
1356 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1357{
1358 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1359 struct alc_spec *spec = codec->spec;
1360 snd_printd("realtek: "
1361 "Enable default setup for auto mode as fallback\n");
1362 spec->init_amp = ALC_INIT_DEFAULT;
1363 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001364 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001365 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001366}
1367
Takashi Iwai41e41f12005-06-08 14:48:49 +02001368/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001369 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001370 */
1371
1372struct alc_pincfg {
1373 hda_nid_t nid;
1374 u32 val;
1375};
1376
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001377struct alc_fixup {
1378 const struct alc_pincfg *pins;
1379 const struct hda_verb *verbs;
1380};
1381
1382static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001383 const struct snd_pci_quirk *quirk,
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001384 const struct alc_fixup *fix)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001385{
1386 const struct alc_pincfg *cfg;
1387
1388 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1389 if (!quirk)
1390 return;
1391
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001392 fix += quirk->value;
1393 cfg = fix->pins;
1394 if (cfg) {
1395 for (; cfg->nid; cfg++)
1396 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1397 }
1398 if (fix->verbs)
1399 add_verb(codec->spec, fix->verbs);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001400}
1401
Kailang Yang274693f2009-12-03 10:07:50 +01001402static int alc_read_coef_idx(struct hda_codec *codec,
1403 unsigned int coef_idx)
1404{
1405 unsigned int val;
1406 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1407 coef_idx);
1408 val = snd_hda_codec_read(codec, 0x20, 0,
1409 AC_VERB_GET_PROC_COEF, 0);
1410 return val;
1411}
1412
Takashi Iwaif95474e2007-07-10 00:47:43 +02001413/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001414 * ALC888
1415 */
1416
1417/*
1418 * 2ch mode
1419 */
1420static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1421/* Mic-in jack as mic in */
1422 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1423 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1424/* Line-in jack as Line in */
1425 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1426 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1427/* Line-Out as Front */
1428 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1429 { } /* end */
1430};
1431
1432/*
1433 * 4ch mode
1434 */
1435static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1436/* Mic-in jack as mic in */
1437 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1438 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1439/* Line-in jack as Surround */
1440 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1441 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1442/* Line-Out as Front */
1443 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1444 { } /* end */
1445};
1446
1447/*
1448 * 6ch mode
1449 */
1450static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1451/* Mic-in jack as CLFE */
1452 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1453 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1454/* Line-in jack as Surround */
1455 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1456 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1457/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1458 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1459 { } /* end */
1460};
1461
1462/*
1463 * 8ch mode
1464 */
1465static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1466/* Mic-in jack as CLFE */
1467 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1468 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1469/* Line-in jack as Surround */
1470 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1471 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1472/* Line-Out as Side */
1473 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1474 { } /* end */
1475};
1476
1477static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1478 { 2, alc888_4ST_ch2_intel_init },
1479 { 4, alc888_4ST_ch4_intel_init },
1480 { 6, alc888_4ST_ch6_intel_init },
1481 { 8, alc888_4ST_ch8_intel_init },
1482};
1483
1484/*
1485 * ALC888 Fujitsu Siemens Amillo xa3530
1486 */
1487
1488static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1489/* Front Mic: set to PIN_IN (empty by default) */
1490 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1491/* Connect Internal HP to Front */
1492 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1493 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1494 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1495/* Connect Bass HP to Front */
1496 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1497 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1498 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1499/* Connect Line-Out side jack (SPDIF) to Side */
1500 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1501 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1502 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1503/* Connect Mic jack to CLFE */
1504 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1505 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1506 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1507/* Connect Line-in jack to Surround */
1508 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1509 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1510 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1511/* Connect HP out jack to Front */
1512 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1513 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1514 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1515/* Enable unsolicited event for HP jack and Line-out jack */
1516 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1517 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1518 {}
1519};
1520
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001521static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001522{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001523 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001524 unsigned int mute;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001525 hda_nid_t nid;
1526 int i;
1527
1528 spec->jack_present = 0;
1529 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1530 nid = spec->autocfg.hp_pins[i];
1531 if (!nid)
1532 break;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001533 if (snd_hda_jack_detect(codec, nid)) {
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001534 spec->jack_present = 1;
1535 break;
1536 }
1537 }
1538
1539 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001540 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001541 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1542 nid = spec->autocfg.speaker_pins[i];
1543 if (!nid)
1544 break;
1545 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1546 HDA_AMP_MUTE, mute);
1547 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001548}
1549
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001550static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1551 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001552{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001553 if (codec->vendor_id == 0x10ec0880)
1554 res >>= 28;
1555 else
1556 res >>= 26;
1557 if (res == ALC880_HP_EVENT)
1558 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001559}
1560
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001561static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001562{
1563 struct alc_spec *spec = codec->spec;
1564
1565 spec->autocfg.hp_pins[0] = 0x15;
1566 spec->autocfg.speaker_pins[0] = 0x14;
1567 spec->autocfg.speaker_pins[1] = 0x16;
1568 spec->autocfg.speaker_pins[2] = 0x17;
1569 spec->autocfg.speaker_pins[3] = 0x19;
1570 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001571}
1572
1573static void alc889_intel_init_hook(struct hda_codec *codec)
1574{
1575 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001576 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001577}
1578
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001579static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001580{
1581 struct alc_spec *spec = codec->spec;
1582
1583 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1584 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1585 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1586 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001587}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001588
1589/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001590 * ALC888 Acer Aspire 4930G model
1591 */
1592
1593static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1594/* Front Mic: set to PIN_IN (empty by default) */
1595 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1596/* Unselect Front Mic by default in input mixer 3 */
1597 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001598/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001599 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1600/* Connect Internal HP to front */
1601 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1602 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1603 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1604/* Connect HP out to front */
1605 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1606 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1607 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1608 { }
1609};
1610
Hector Martin3b315d72009-06-02 10:54:19 +02001611/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001612 * ALC888 Acer Aspire 6530G model
1613 */
1614
1615static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1616/* Bias voltage on for external mic port */
1617 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001618/* Front Mic: set to PIN_IN (empty by default) */
1619 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1620/* Unselect Front Mic by default in input mixer 3 */
1621 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001622/* Enable unsolicited event for HP jack */
1623 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1624/* Enable speaker output */
1625 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1626 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1627/* Enable headphone output */
1628 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1629 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1630 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1631 { }
1632};
1633
1634/*
Hector Martin018df412009-06-04 00:13:40 +02001635 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001636 */
1637
Hector Martin018df412009-06-04 00:13:40 +02001638static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001639/* Front Mic: set to PIN_IN (empty by default) */
1640 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1641/* Unselect Front Mic by default in input mixer 3 */
1642 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1643/* Enable unsolicited event for HP jack */
1644 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1645/* Connect Internal Front to Front */
1646 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1647 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1648 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1649/* Connect Internal Rear to Rear */
1650 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1651 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1652 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1653/* Connect Internal CLFE to CLFE */
1654 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1655 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1656 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1657/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001658 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001659 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1660 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1661/* Enable all DACs */
1662/* DAC DISABLE/MUTE 1? */
1663/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1664 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1665 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1666/* DAC DISABLE/MUTE 2? */
1667/* some bit here disables the other DACs. Init=0x4900 */
1668 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1669 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02001670/* DMIC fix
1671 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1672 * which makes the stereo useless. However, either the mic or the ALC889
1673 * makes the signal become a difference/sum signal instead of standard
1674 * stereo, which is annoying. So instead we flip this bit which makes the
1675 * codec replicate the sum signal to both channels, turning it into a
1676 * normal mono mic.
1677 */
1678/* DMIC_CONTROL? Init value = 0x0001 */
1679 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1680 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001681 { }
1682};
1683
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001684static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001685 /* Front mic only available on one ADC */
1686 {
1687 .num_items = 4,
1688 .items = {
1689 { "Mic", 0x0 },
1690 { "Line", 0x2 },
1691 { "CD", 0x4 },
1692 { "Front Mic", 0xb },
1693 },
1694 },
1695 {
1696 .num_items = 3,
1697 .items = {
1698 { "Mic", 0x0 },
1699 { "Line", 0x2 },
1700 { "CD", 0x4 },
1701 },
1702 }
1703};
1704
Tony Vroond2fd4b02009-06-21 00:40:10 +01001705static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1706 /* Interal mic only available on one ADC */
1707 {
Tony Vroon684a8842009-06-26 09:27:50 +01001708 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001709 .items = {
1710 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001711 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001712 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001713 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001714 { "Int Mic", 0xb },
1715 },
1716 },
1717 {
Tony Vroon684a8842009-06-26 09:27:50 +01001718 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001719 .items = {
1720 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001721 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001722 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001723 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001724 },
1725 }
1726};
1727
Hector Martin018df412009-06-04 00:13:40 +02001728static struct hda_input_mux alc889_capture_sources[3] = {
1729 /* Digital mic only available on first "ADC" */
1730 {
1731 .num_items = 5,
1732 .items = {
1733 { "Mic", 0x0 },
1734 { "Line", 0x2 },
1735 { "CD", 0x4 },
1736 { "Front Mic", 0xb },
1737 { "Input Mix", 0xa },
1738 },
1739 },
1740 {
1741 .num_items = 4,
1742 .items = {
1743 { "Mic", 0x0 },
1744 { "Line", 0x2 },
1745 { "CD", 0x4 },
1746 { "Input Mix", 0xa },
1747 },
1748 },
1749 {
1750 .num_items = 4,
1751 .items = {
1752 { "Mic", 0x0 },
1753 { "Line", 0x2 },
1754 { "CD", 0x4 },
1755 { "Input Mix", 0xa },
1756 },
1757 }
1758};
1759
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001760static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001761 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1762 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1763 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1764 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1765 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1766 HDA_OUTPUT),
1767 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1768 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1769 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1770 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1771 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1772 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1773 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1774 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1775 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1776 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1777 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1778 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001779 { } /* end */
1780};
1781
Hector Martin556eea92009-12-20 22:51:23 +01001782static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
1783 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1784 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1785 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1786 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1787 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1788 HDA_OUTPUT),
1789 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1790 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1791 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1792 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1793 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1794 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1795 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1796 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1797 { } /* end */
1798};
1799
1800
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001801static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001802{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001803 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001804
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001805 spec->autocfg.hp_pins[0] = 0x15;
1806 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01001807 spec->autocfg.speaker_pins[1] = 0x16;
1808 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001809}
1810
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001811static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001812{
1813 struct alc_spec *spec = codec->spec;
1814
1815 spec->autocfg.hp_pins[0] = 0x15;
1816 spec->autocfg.speaker_pins[0] = 0x14;
1817 spec->autocfg.speaker_pins[1] = 0x16;
1818 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001819}
1820
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001821static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001822{
1823 struct alc_spec *spec = codec->spec;
1824
1825 spec->autocfg.hp_pins[0] = 0x15;
1826 spec->autocfg.speaker_pins[0] = 0x14;
1827 spec->autocfg.speaker_pins[1] = 0x16;
1828 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001829}
1830
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001831/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001832 * ALC880 3-stack model
1833 *
1834 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001835 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1836 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001837 */
1838
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001839static hda_nid_t alc880_dac_nids[4] = {
1840 /* front, rear, clfe, rear_surr */
1841 0x02, 0x05, 0x04, 0x03
1842};
1843
1844static hda_nid_t alc880_adc_nids[3] = {
1845 /* ADC0-2 */
1846 0x07, 0x08, 0x09,
1847};
1848
1849/* The datasheet says the node 0x07 is connected from inputs,
1850 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001851 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001852 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001853static hda_nid_t alc880_adc_nids_alt[2] = {
1854 /* ADC1-2 */
1855 0x08, 0x09,
1856};
1857
1858#define ALC880_DIGOUT_NID 0x06
1859#define ALC880_DIGIN_NID 0x0a
1860
1861static struct hda_input_mux alc880_capture_source = {
1862 .num_items = 4,
1863 .items = {
1864 { "Mic", 0x0 },
1865 { "Front Mic", 0x3 },
1866 { "Line", 0x2 },
1867 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001868 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001869};
1870
1871/* channel source setting (2/6 channel selection for 3-stack) */
1872/* 2ch mode */
1873static struct hda_verb alc880_threestack_ch2_init[] = {
1874 /* set line-in to input, mute it */
1875 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1876 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1877 /* set mic-in to input vref 80%, mute it */
1878 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1879 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001880 { } /* end */
1881};
1882
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001883/* 6ch mode */
1884static struct hda_verb alc880_threestack_ch6_init[] = {
1885 /* set line-in to output, unmute it */
1886 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1887 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1888 /* set mic-in to output, unmute it */
1889 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1890 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1891 { } /* end */
1892};
1893
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001894static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001895 { 2, alc880_threestack_ch2_init },
1896 { 6, alc880_threestack_ch6_init },
1897};
1898
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001899static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001900 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001901 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001902 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001903 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001904 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1905 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001906 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1907 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001908 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1909 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1910 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1911 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1912 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1913 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1914 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1915 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001916 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001917 {
1918 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1919 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001920 .info = alc_ch_mode_info,
1921 .get = alc_ch_mode_get,
1922 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001923 },
1924 { } /* end */
1925};
1926
1927/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001928static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1929 struct snd_ctl_elem_info *uinfo)
1930{
1931 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1932 struct alc_spec *spec = codec->spec;
1933 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001934
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001935 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001936 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1937 HDA_INPUT);
1938 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001939 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001940 return err;
1941}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001942
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001943static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1944 unsigned int size, unsigned int __user *tlv)
1945{
1946 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1947 struct alc_spec *spec = codec->spec;
1948 int err;
1949
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001950 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001951 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1952 HDA_INPUT);
1953 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001954 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001955 return err;
1956}
1957
1958typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1959 struct snd_ctl_elem_value *ucontrol);
1960
1961static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1962 struct snd_ctl_elem_value *ucontrol,
1963 getput_call_t func)
1964{
1965 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1966 struct alc_spec *spec = codec->spec;
1967 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1968 int err;
1969
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001970 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001971 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1972 3, 0, HDA_INPUT);
1973 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001974 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001975 return err;
1976}
1977
1978static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1979 struct snd_ctl_elem_value *ucontrol)
1980{
1981 return alc_cap_getput_caller(kcontrol, ucontrol,
1982 snd_hda_mixer_amp_volume_get);
1983}
1984
1985static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1986 struct snd_ctl_elem_value *ucontrol)
1987{
1988 return alc_cap_getput_caller(kcontrol, ucontrol,
1989 snd_hda_mixer_amp_volume_put);
1990}
1991
1992/* capture mixer elements */
1993#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1994
1995static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1996 struct snd_ctl_elem_value *ucontrol)
1997{
1998 return alc_cap_getput_caller(kcontrol, ucontrol,
1999 snd_hda_mixer_amp_switch_get);
2000}
2001
2002static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2003 struct snd_ctl_elem_value *ucontrol)
2004{
2005 return alc_cap_getput_caller(kcontrol, ucontrol,
2006 snd_hda_mixer_amp_switch_put);
2007}
2008
Takashi Iwaia23b6882009-03-23 15:21:36 +01002009#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002010 { \
2011 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2012 .name = "Capture Switch", \
2013 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2014 .count = num, \
2015 .info = alc_cap_sw_info, \
2016 .get = alc_cap_sw_get, \
2017 .put = alc_cap_sw_put, \
2018 }, \
2019 { \
2020 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2021 .name = "Capture Volume", \
2022 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2023 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2024 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2025 .count = num, \
2026 .info = alc_cap_vol_info, \
2027 .get = alc_cap_vol_get, \
2028 .put = alc_cap_vol_put, \
2029 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002030 }
2031
2032#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002033 { \
2034 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2035 /* .name = "Capture Source", */ \
2036 .name = "Input Source", \
2037 .count = num, \
2038 .info = alc_mux_enum_info, \
2039 .get = alc_mux_enum_get, \
2040 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002041 }
2042
2043#define DEFINE_CAPMIX(num) \
2044static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2045 _DEFINE_CAPMIX(num), \
2046 _DEFINE_CAPSRC(num), \
2047 { } /* end */ \
2048}
2049
2050#define DEFINE_CAPMIX_NOSRC(num) \
2051static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2052 _DEFINE_CAPMIX(num), \
2053 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002054}
2055
2056/* up to three ADCs */
2057DEFINE_CAPMIX(1);
2058DEFINE_CAPMIX(2);
2059DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002060DEFINE_CAPMIX_NOSRC(1);
2061DEFINE_CAPMIX_NOSRC(2);
2062DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002063
2064/*
2065 * ALC880 5-stack model
2066 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002067 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2068 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002069 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2070 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2071 */
2072
2073/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002074static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002075 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002076 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002077 { } /* end */
2078};
2079
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002080/* channel source setting (6/8 channel selection for 5-stack) */
2081/* 6ch mode */
2082static struct hda_verb alc880_fivestack_ch6_init[] = {
2083 /* set line-in to input, mute it */
2084 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2085 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002086 { } /* end */
2087};
2088
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002089/* 8ch mode */
2090static struct hda_verb alc880_fivestack_ch8_init[] = {
2091 /* set line-in to output, unmute it */
2092 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2093 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2094 { } /* end */
2095};
2096
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002097static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002098 { 6, alc880_fivestack_ch6_init },
2099 { 8, alc880_fivestack_ch8_init },
2100};
2101
2102
2103/*
2104 * ALC880 6-stack model
2105 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002106 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2107 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002108 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2109 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2110 */
2111
2112static hda_nid_t alc880_6st_dac_nids[4] = {
2113 /* front, rear, clfe, rear_surr */
2114 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002115};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002116
2117static struct hda_input_mux alc880_6stack_capture_source = {
2118 .num_items = 4,
2119 .items = {
2120 { "Mic", 0x0 },
2121 { "Front Mic", 0x1 },
2122 { "Line", 0x2 },
2123 { "CD", 0x4 },
2124 },
2125};
2126
2127/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002128static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002129 { 8, NULL },
2130};
2131
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002132static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002133 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002134 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002135 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002136 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002137 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2138 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002139 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2140 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002141 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002142 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002143 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2144 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2145 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2146 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2147 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2148 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2149 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2150 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002151 {
2152 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2153 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002154 .info = alc_ch_mode_info,
2155 .get = alc_ch_mode_get,
2156 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002157 },
2158 { } /* end */
2159};
2160
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002161
2162/*
2163 * ALC880 W810 model
2164 *
2165 * W810 has rear IO for:
2166 * Front (DAC 02)
2167 * Surround (DAC 03)
2168 * Center/LFE (DAC 04)
2169 * Digital out (06)
2170 *
2171 * The system also has a pair of internal speakers, and a headphone jack.
2172 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002173 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002174 * There is a variable resistor to control the speaker or headphone
2175 * volume. This is a hardware-only device without a software API.
2176 *
2177 * Plugging headphones in will disable the internal speakers. This is
2178 * implemented in hardware, not via the driver using jack sense. In
2179 * a similar fashion, plugging into the rear socket marked "front" will
2180 * disable both the speakers and headphones.
2181 *
2182 * For input, there's a microphone jack, and an "audio in" jack.
2183 * These may not do anything useful with this driver yet, because I
2184 * haven't setup any initialization verbs for these yet...
2185 */
2186
2187static hda_nid_t alc880_w810_dac_nids[3] = {
2188 /* front, rear/surround, clfe */
2189 0x02, 0x03, 0x04
2190};
2191
2192/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002193static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002194 { 6, NULL }
2195};
2196
2197/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002198static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002199 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002200 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002201 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002202 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002203 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2204 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002205 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2206 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002207 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2208 { } /* end */
2209};
2210
2211
2212/*
2213 * Z710V model
2214 *
2215 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002216 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2217 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002218 */
2219
2220static hda_nid_t alc880_z71v_dac_nids[1] = {
2221 0x02
2222};
2223#define ALC880_Z71V_HP_DAC 0x03
2224
2225/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002226static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002227 { 2, NULL }
2228};
2229
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002230static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002231 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002232 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002233 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002234 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002235 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2236 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2237 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2238 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2239 { } /* end */
2240};
2241
2242
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002243/*
2244 * ALC880 F1734 model
2245 *
2246 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2247 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2248 */
2249
2250static hda_nid_t alc880_f1734_dac_nids[1] = {
2251 0x03
2252};
2253#define ALC880_F1734_HP_DAC 0x02
2254
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002255static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002256 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002257 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002258 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2259 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002260 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2261 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002262 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2263 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002264 { } /* end */
2265};
2266
Takashi Iwai937b4162008-02-11 14:52:36 +01002267static struct hda_input_mux alc880_f1734_capture_source = {
2268 .num_items = 2,
2269 .items = {
2270 { "Mic", 0x1 },
2271 { "CD", 0x4 },
2272 },
2273};
2274
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002275
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002276/*
2277 * ALC880 ASUS model
2278 *
2279 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2280 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2281 * Mic = 0x18, Line = 0x1a
2282 */
2283
2284#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2285#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2286
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002287static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002288 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002289 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002290 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002291 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002292 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2293 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002294 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2295 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002296 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2297 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2298 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2299 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2300 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2301 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002302 {
2303 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2304 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002305 .info = alc_ch_mode_info,
2306 .get = alc_ch_mode_get,
2307 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002308 },
2309 { } /* end */
2310};
2311
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002312/*
2313 * ALC880 ASUS W1V model
2314 *
2315 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2316 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2317 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2318 */
2319
2320/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002321static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002322 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2323 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002324 { } /* end */
2325};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002326
Kailang Yangdf694da2005-12-05 19:42:22 +01002327/* TCL S700 */
2328static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2329 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2330 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2331 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2332 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2333 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2334 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2335 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2336 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2337 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002338 { } /* end */
2339};
2340
Kailang Yangccc656c2006-10-17 12:32:26 +02002341/* Uniwill */
2342static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002343 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2344 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2345 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2346 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002347 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2348 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2349 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2350 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2351 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2352 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2353 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2354 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2355 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2356 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2357 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2358 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002359 {
2360 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2361 .name = "Channel Mode",
2362 .info = alc_ch_mode_info,
2363 .get = alc_ch_mode_get,
2364 .put = alc_ch_mode_put,
2365 },
2366 { } /* end */
2367};
2368
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002369static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2370 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2371 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2372 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2373 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2374 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2375 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2376 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2377 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2378 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2379 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2380 { } /* end */
2381};
2382
Kailang Yangccc656c2006-10-17 12:32:26 +02002383static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002384 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2385 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2386 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2387 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002388 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2389 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2390 { } /* end */
2391};
2392
Linus Torvalds1da177e2005-04-16 15:20:36 -07002393/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002394 * virtual master controls
2395 */
2396
2397/*
2398 * slave controls for virtual master
2399 */
2400static const char *alc_slave_vols[] = {
2401 "Front Playback Volume",
2402 "Surround Playback Volume",
2403 "Center Playback Volume",
2404 "LFE Playback Volume",
2405 "Side Playback Volume",
2406 "Headphone Playback Volume",
2407 "Speaker Playback Volume",
2408 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002409 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002410 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002411 NULL,
2412};
2413
2414static const char *alc_slave_sws[] = {
2415 "Front Playback Switch",
2416 "Surround Playback Switch",
2417 "Center Playback Switch",
2418 "LFE Playback Switch",
2419 "Side Playback Switch",
2420 "Headphone Playback Switch",
2421 "Speaker Playback Switch",
2422 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002423 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002424 "Line-Out Playback Switch",
2425 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002426 NULL,
2427};
2428
2429/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002430 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002431 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002432
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002433#define NID_MAPPING (-1)
2434
2435#define SUBDEV_SPEAKER_ (0 << 6)
2436#define SUBDEV_HP_ (1 << 6)
2437#define SUBDEV_LINE_ (2 << 6)
2438#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2439#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2440#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2441
Takashi Iwai603c4012008-07-30 15:01:44 +02002442static void alc_free_kctls(struct hda_codec *codec);
2443
Takashi Iwai67d634c2009-11-16 15:35:59 +01002444#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002445/* additional beep mixers; the actual parameters are overwritten at build */
2446static struct snd_kcontrol_new alc_beep_mixer[] = {
2447 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002448 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002449 { } /* end */
2450};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002451#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002452
Linus Torvalds1da177e2005-04-16 15:20:36 -07002453static int alc_build_controls(struct hda_codec *codec)
2454{
2455 struct alc_spec *spec = codec->spec;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002456 struct snd_kcontrol *kctl;
2457 struct snd_kcontrol_new *knew;
2458 int i, j, err;
2459 unsigned int u;
2460 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002461
2462 for (i = 0; i < spec->num_mixers; i++) {
2463 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2464 if (err < 0)
2465 return err;
2466 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002467 if (spec->cap_mixer) {
2468 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2469 if (err < 0)
2470 return err;
2471 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002472 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002473 err = snd_hda_create_spdif_out_ctls(codec,
2474 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002475 if (err < 0)
2476 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002477 if (!spec->no_analog) {
2478 err = snd_hda_create_spdif_share_sw(codec,
2479 &spec->multiout);
2480 if (err < 0)
2481 return err;
2482 spec->multiout.share_spdif = 1;
2483 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002484 }
2485 if (spec->dig_in_nid) {
2486 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2487 if (err < 0)
2488 return err;
2489 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002490
Takashi Iwai67d634c2009-11-16 15:35:59 +01002491#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002492 /* create beep controls if needed */
2493 if (spec->beep_amp) {
2494 struct snd_kcontrol_new *knew;
2495 for (knew = alc_beep_mixer; knew->name; knew++) {
2496 struct snd_kcontrol *kctl;
2497 kctl = snd_ctl_new1(knew, codec);
2498 if (!kctl)
2499 return -ENOMEM;
2500 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002501 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002502 if (err < 0)
2503 return err;
2504 }
2505 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002506#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002507
Takashi Iwai2134ea42008-01-10 16:53:55 +01002508 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002509 if (!spec->no_analog &&
2510 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002511 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002512 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002513 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002514 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002515 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002516 if (err < 0)
2517 return err;
2518 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002519 if (!spec->no_analog &&
2520 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002521 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2522 NULL, alc_slave_sws);
2523 if (err < 0)
2524 return err;
2525 }
2526
Takashi Iwai603c4012008-07-30 15:01:44 +02002527 alc_free_kctls(codec); /* no longer needed */
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002528
2529 /* assign Capture Source enums to NID */
2530 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2531 if (!kctl)
2532 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2533 for (i = 0; kctl && i < kctl->count; i++) {
Takashi Iwaid1409ae2009-12-17 15:01:31 +01002534 hda_nid_t *nids = spec->capsrc_nids;
2535 if (!nids)
2536 nids = spec->adc_nids;
Takashi Iwai21949f02009-12-23 08:31:59 +01002537 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002538 if (err < 0)
2539 return err;
2540 }
2541 if (spec->cap_mixer) {
2542 const char *kname = kctl ? kctl->id.name : NULL;
2543 for (knew = spec->cap_mixer; knew->name; knew++) {
2544 if (kname && strcmp(knew->name, kname) == 0)
2545 continue;
2546 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2547 for (i = 0; kctl && i < kctl->count; i++) {
2548 err = snd_hda_add_nid(codec, kctl, i,
2549 spec->adc_nids[i]);
2550 if (err < 0)
2551 return err;
2552 }
2553 }
2554 }
2555
2556 /* other nid->control mapping */
2557 for (i = 0; i < spec->num_mixers; i++) {
2558 for (knew = spec->mixers[i]; knew->name; knew++) {
2559 if (knew->iface != NID_MAPPING)
2560 continue;
2561 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2562 if (kctl == NULL)
2563 continue;
2564 u = knew->subdevice;
2565 for (j = 0; j < 4; j++, u >>= 8) {
2566 nid = u & 0x3f;
2567 if (nid == 0)
2568 continue;
2569 switch (u & 0xc0) {
2570 case SUBDEV_SPEAKER_:
2571 nid = spec->autocfg.speaker_pins[nid];
2572 break;
2573 case SUBDEV_LINE_:
2574 nid = spec->autocfg.line_out_pins[nid];
2575 break;
2576 case SUBDEV_HP_:
2577 nid = spec->autocfg.hp_pins[nid];
2578 break;
2579 default:
2580 continue;
2581 }
2582 err = snd_hda_add_nid(codec, kctl, 0, nid);
2583 if (err < 0)
2584 return err;
2585 }
2586 u = knew->private_value;
2587 for (j = 0; j < 4; j++, u >>= 8) {
2588 nid = u & 0xff;
2589 if (nid == 0)
2590 continue;
2591 err = snd_hda_add_nid(codec, kctl, 0, nid);
2592 if (err < 0)
2593 return err;
2594 }
2595 }
2596 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002597 return 0;
2598}
2599
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002600
Linus Torvalds1da177e2005-04-16 15:20:36 -07002601/*
2602 * initialize the codec volumes, etc
2603 */
2604
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002605/*
2606 * generic initialization of ADC, input mixers and output mixers
2607 */
2608static struct hda_verb alc880_volume_init_verbs[] = {
2609 /*
2610 * Unmute ADC0-2 and set the default input to mic-in
2611 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002612 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002613 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002614 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002615 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002616 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002617 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002618
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002619 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2620 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002621 * Note: PASD motherboards uses the Line In 2 as the input for front
2622 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002623 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002624 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002625 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2626 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2627 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2628 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2629 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2630 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2631 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002632
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002633 /*
2634 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002635 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002636 /* set vol=0 to output mixers */
2637 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2638 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2639 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2640 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2641 /* set up input amps for analog loopback */
2642 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002643 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2644 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002645 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2646 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002647 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2648 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002649 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2650 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002651
2652 { }
2653};
2654
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002655/*
2656 * 3-stack pin configuration:
2657 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2658 */
2659static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2660 /*
2661 * preset connection lists of input pins
2662 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2663 */
2664 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2665 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2666 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2667
2668 /*
2669 * Set pin mode and muting
2670 */
2671 /* set front pin widgets 0x14 for output */
2672 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2673 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2674 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2675 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2676 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2677 /* Mic2 (as headphone out) for HP output */
2678 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2679 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2680 /* Line In pin widget for input */
2681 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2682 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2683 /* Line2 (as front mic) pin widget for input and vref at 80% */
2684 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2685 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2686 /* CD pin widget for input */
2687 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2688
2689 { }
2690};
2691
2692/*
2693 * 5-stack pin configuration:
2694 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2695 * line-in/side = 0x1a, f-mic = 0x1b
2696 */
2697static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2698 /*
2699 * preset connection lists of input pins
2700 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2701 */
2702 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2703 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2704
2705 /*
2706 * Set pin mode and muting
2707 */
2708 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002709 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2710 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2711 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2712 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002713 /* unmute pins for output (no gain on this amp) */
2714 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2715 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2716 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2717 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2718
Linus Torvalds1da177e2005-04-16 15:20:36 -07002719 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002720 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002721 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2722 /* Mic2 (as headphone out) for HP output */
2723 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002724 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002725 /* Line In pin widget for input */
2726 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2727 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2728 /* Line2 (as front mic) pin widget for input and vref at 80% */
2729 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2730 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2731 /* CD pin widget for input */
2732 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002733
2734 { }
2735};
2736
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002737/*
2738 * W810 pin configuration:
2739 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2740 */
2741static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002742 /* hphone/speaker input selector: front DAC */
2743 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2744
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002745 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2746 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2747 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2748 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2749 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2750 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2751
2752 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002753 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002754
Linus Torvalds1da177e2005-04-16 15:20:36 -07002755 { }
2756};
2757
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002758/*
2759 * Z71V pin configuration:
2760 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2761 */
2762static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002763 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002764 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002765 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002766 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002767
Takashi Iwai16ded522005-06-10 19:58:24 +02002768 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002769 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002770 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002771 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002772
2773 { }
2774};
2775
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002776/*
2777 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002778 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2779 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002780 */
2781static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2782 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2783
Takashi Iwai16ded522005-06-10 19:58:24 +02002784 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002785 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002786 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002787 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002788 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002789 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002790 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002791 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2792
Takashi Iwai16ded522005-06-10 19:58:24 +02002793 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002794 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002795 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002796 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002797 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002798 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002799 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002800 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002801 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002802
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002803 { }
2804};
Takashi Iwai16ded522005-06-10 19:58:24 +02002805
Kailang Yangccc656c2006-10-17 12:32:26 +02002806/*
2807 * Uniwill pin configuration:
2808 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2809 * line = 0x1a
2810 */
2811static struct hda_verb alc880_uniwill_init_verbs[] = {
2812 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2813
2814 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2815 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2816 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2817 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2818 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2819 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2820 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2821 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2822 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2823 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2824 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2825 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2826 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2827 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2828
2829 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2830 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2831 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2832 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2833 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2834 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2835 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2836 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2837 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2838
2839 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2840 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2841
2842 { }
2843};
2844
2845/*
2846* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002847* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002848 */
2849static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2850 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2851
2852 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2853 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2854 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2855 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2856 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2857 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2858 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2859 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2860 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2861 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2862 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2863 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2864
2865 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2866 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2867 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2868 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2869 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2870 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2871
2872 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2873 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2874
2875 { }
2876};
2877
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002878static struct hda_verb alc880_beep_init_verbs[] = {
2879 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2880 { }
2881};
2882
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002883/* auto-toggle front mic */
2884static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2885{
2886 unsigned int present;
2887 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002888
Wu Fengguang864f92b2009-11-18 12:38:02 +08002889 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002890 bits = present ? HDA_AMP_MUTE : 0;
2891 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002892}
2893
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002894static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002895{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002896 struct alc_spec *spec = codec->spec;
2897
2898 spec->autocfg.hp_pins[0] = 0x14;
2899 spec->autocfg.speaker_pins[0] = 0x15;
2900 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002901}
2902
2903static void alc880_uniwill_init_hook(struct hda_codec *codec)
2904{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002905 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002906 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002907}
2908
2909static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2910 unsigned int res)
2911{
2912 /* Looks like the unsol event is incompatible with the standard
2913 * definition. 4bit tag is placed at 28 bit!
2914 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002915 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002916 case ALC880_MIC_EVENT:
2917 alc880_uniwill_mic_automute(codec);
2918 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002919 default:
2920 alc_automute_amp_unsol_event(codec, res);
2921 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002922 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002923}
2924
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002925static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002926{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002927 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002928
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002929 spec->autocfg.hp_pins[0] = 0x14;
2930 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02002931}
2932
2933static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2934{
2935 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002936
Kailang Yangccc656c2006-10-17 12:32:26 +02002937 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002938 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2939 present &= HDA_AMP_VOLMASK;
2940 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2941 HDA_AMP_VOLMASK, present);
2942 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2943 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002944}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002945
Kailang Yangccc656c2006-10-17 12:32:26 +02002946static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2947 unsigned int res)
2948{
2949 /* Looks like the unsol event is incompatible with the standard
2950 * definition. 4bit tag is placed at 28 bit!
2951 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002952 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002953 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002954 else
2955 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002956}
2957
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002958/*
2959 * F1734 pin configuration:
2960 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2961 */
2962static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002963 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002964 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2965 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2966 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2967 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2968
2969 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2970 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2971 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2972 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2973
2974 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2975 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002976 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002977 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2978 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2979 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2980 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2981 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2982 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002983
Takashi Iwai937b4162008-02-11 14:52:36 +01002984 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2985 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2986
Takashi Iwai16ded522005-06-10 19:58:24 +02002987 { }
2988};
2989
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002990/*
2991 * ASUS pin configuration:
2992 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2993 */
2994static struct hda_verb alc880_pin_asus_init_verbs[] = {
2995 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2996 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2997 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2998 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2999
3000 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3001 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3002 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3003 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3004 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3005 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3006 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3007 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3008
3009 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3010 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3011 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3012 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3013 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3014 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3015 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3016 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3017 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003018
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003019 { }
3020};
3021
3022/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003023#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3024#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003025#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003026
Kailang Yangdf694da2005-12-05 19:42:22 +01003027/* Clevo m520g init */
3028static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3029 /* headphone output */
3030 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3031 /* line-out */
3032 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3033 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3034 /* Line-in */
3035 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3036 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3037 /* CD */
3038 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3039 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3040 /* Mic1 (rear panel) */
3041 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3042 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3043 /* Mic2 (front panel) */
3044 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3045 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3046 /* headphone */
3047 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3048 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3049 /* change to EAPD mode */
3050 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3051 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3052
3053 { }
3054};
3055
3056static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003057 /* change to EAPD mode */
3058 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3059 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3060
Kailang Yangdf694da2005-12-05 19:42:22 +01003061 /* Headphone output */
3062 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3063 /* Front output*/
3064 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3065 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3066
3067 /* Line In pin widget for input */
3068 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3069 /* CD pin widget for input */
3070 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3071 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3072 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3073
3074 /* change to EAPD mode */
3075 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3076 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3077
3078 { }
3079};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003080
3081/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003082 * LG m1 express dual
3083 *
3084 * Pin assignment:
3085 * Rear Line-In/Out (blue): 0x14
3086 * Build-in Mic-In: 0x15
3087 * Speaker-out: 0x17
3088 * HP-Out (green): 0x1b
3089 * Mic-In/Out (red): 0x19
3090 * SPDIF-Out: 0x1e
3091 */
3092
3093/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3094static hda_nid_t alc880_lg_dac_nids[3] = {
3095 0x05, 0x02, 0x03
3096};
3097
3098/* seems analog CD is not working */
3099static struct hda_input_mux alc880_lg_capture_source = {
3100 .num_items = 3,
3101 .items = {
3102 { "Mic", 0x1 },
3103 { "Line", 0x5 },
3104 { "Internal Mic", 0x6 },
3105 },
3106};
3107
3108/* 2,4,6 channel modes */
3109static struct hda_verb alc880_lg_ch2_init[] = {
3110 /* set line-in and mic-in to input */
3111 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3112 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3113 { }
3114};
3115
3116static struct hda_verb alc880_lg_ch4_init[] = {
3117 /* set line-in to out and mic-in to input */
3118 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3119 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3120 { }
3121};
3122
3123static struct hda_verb alc880_lg_ch6_init[] = {
3124 /* set line-in and mic-in to output */
3125 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3126 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3127 { }
3128};
3129
3130static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3131 { 2, alc880_lg_ch2_init },
3132 { 4, alc880_lg_ch4_init },
3133 { 6, alc880_lg_ch6_init },
3134};
3135
3136static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003137 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3138 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003139 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3140 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3141 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3142 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3143 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3144 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3145 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3146 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3147 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3148 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3149 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3150 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3151 {
3152 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3153 .name = "Channel Mode",
3154 .info = alc_ch_mode_info,
3155 .get = alc_ch_mode_get,
3156 .put = alc_ch_mode_put,
3157 },
3158 { } /* end */
3159};
3160
3161static struct hda_verb alc880_lg_init_verbs[] = {
3162 /* set capture source to mic-in */
3163 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3164 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3165 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3166 /* mute all amp mixer inputs */
3167 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003168 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3169 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003170 /* line-in to input */
3171 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3172 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3173 /* built-in mic */
3174 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3175 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3176 /* speaker-out */
3177 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3178 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3179 /* mic-in to input */
3180 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3181 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3182 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3183 /* HP-out */
3184 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3185 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3186 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3187 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003188 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003189 { }
3190};
3191
3192/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003193static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003194{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003195 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003196
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003197 spec->autocfg.hp_pins[0] = 0x1b;
3198 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003199}
3200
3201/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003202 * LG LW20
3203 *
3204 * Pin assignment:
3205 * Speaker-out: 0x14
3206 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003207 * Built-in Mic-In: 0x19
3208 * Line-In: 0x1b
3209 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003210 * SPDIF-Out: 0x1e
3211 */
3212
Takashi Iwaid6815182006-03-23 16:06:23 +01003213static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003214 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003215 .items = {
3216 { "Mic", 0x0 },
3217 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003218 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003219 },
3220};
3221
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003222#define alc880_lg_lw_modes alc880_threestack_modes
3223
Takashi Iwaid6815182006-03-23 16:06:23 +01003224static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003225 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3226 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3227 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3228 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3229 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3230 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3231 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3232 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3233 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3234 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003235 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3236 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3237 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3238 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003239 {
3240 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3241 .name = "Channel Mode",
3242 .info = alc_ch_mode_info,
3243 .get = alc_ch_mode_get,
3244 .put = alc_ch_mode_put,
3245 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003246 { } /* end */
3247};
3248
3249static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003250 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3251 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3252 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3253
Takashi Iwaid6815182006-03-23 16:06:23 +01003254 /* set capture source to mic-in */
3255 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3256 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3257 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003258 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003259 /* speaker-out */
3260 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3261 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3262 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003263 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3264 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3265 /* mic-in to input */
3266 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3267 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3268 /* built-in mic */
3269 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3270 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3271 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003272 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003273 { }
3274};
3275
3276/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003277static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003278{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003279 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003280
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003281 spec->autocfg.hp_pins[0] = 0x1b;
3282 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003283}
3284
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003285static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3286 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3287 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3288 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3289 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3290 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3291 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3292 { } /* end */
3293};
3294
3295static struct hda_input_mux alc880_medion_rim_capture_source = {
3296 .num_items = 2,
3297 .items = {
3298 { "Mic", 0x0 },
3299 { "Internal Mic", 0x1 },
3300 },
3301};
3302
3303static struct hda_verb alc880_medion_rim_init_verbs[] = {
3304 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3305
3306 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3307 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3308
3309 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3310 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3311 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3312 /* Mic2 (as headphone out) for HP output */
3313 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3314 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3315 /* Internal Speaker */
3316 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3317 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3318
3319 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3320 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3321
3322 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3323 { }
3324};
3325
3326/* toggle speaker-output according to the hp-jack state */
3327static void alc880_medion_rim_automute(struct hda_codec *codec)
3328{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003329 struct alc_spec *spec = codec->spec;
3330 alc_automute_amp(codec);
3331 /* toggle EAPD */
3332 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003333 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3334 else
3335 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3336}
3337
3338static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3339 unsigned int res)
3340{
3341 /* Looks like the unsol event is incompatible with the standard
3342 * definition. 4bit tag is placed at 28 bit!
3343 */
3344 if ((res >> 28) == ALC880_HP_EVENT)
3345 alc880_medion_rim_automute(codec);
3346}
3347
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003348static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003349{
3350 struct alc_spec *spec = codec->spec;
3351
3352 spec->autocfg.hp_pins[0] = 0x14;
3353 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003354}
3355
Takashi Iwaicb53c622007-08-10 17:21:45 +02003356#ifdef CONFIG_SND_HDA_POWER_SAVE
3357static struct hda_amp_list alc880_loopbacks[] = {
3358 { 0x0b, HDA_INPUT, 0 },
3359 { 0x0b, HDA_INPUT, 1 },
3360 { 0x0b, HDA_INPUT, 2 },
3361 { 0x0b, HDA_INPUT, 3 },
3362 { 0x0b, HDA_INPUT, 4 },
3363 { } /* end */
3364};
3365
3366static struct hda_amp_list alc880_lg_loopbacks[] = {
3367 { 0x0b, HDA_INPUT, 1 },
3368 { 0x0b, HDA_INPUT, 6 },
3369 { 0x0b, HDA_INPUT, 7 },
3370 { } /* end */
3371};
3372#endif
3373
Takashi Iwaid6815182006-03-23 16:06:23 +01003374/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003375 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003376 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003377
Linus Torvalds1da177e2005-04-16 15:20:36 -07003378static int alc_init(struct hda_codec *codec)
3379{
3380 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003381 unsigned int i;
3382
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003383 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003384 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003385
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003386 for (i = 0; i < spec->num_init_verbs; i++)
3387 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003388
3389 if (spec->init_hook)
3390 spec->init_hook(codec);
3391
Linus Torvalds1da177e2005-04-16 15:20:36 -07003392 return 0;
3393}
3394
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003395static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3396{
3397 struct alc_spec *spec = codec->spec;
3398
3399 if (spec->unsol_event)
3400 spec->unsol_event(codec, res);
3401}
3402
Takashi Iwaicb53c622007-08-10 17:21:45 +02003403#ifdef CONFIG_SND_HDA_POWER_SAVE
3404static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3405{
3406 struct alc_spec *spec = codec->spec;
3407 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3408}
3409#endif
3410
Linus Torvalds1da177e2005-04-16 15:20:36 -07003411/*
3412 * Analog playback callbacks
3413 */
3414static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3415 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;
Takashi Iwai9a081602008-02-12 18:37:26 +01003419 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3420 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003421}
3422
3423static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3424 struct hda_codec *codec,
3425 unsigned int stream_tag,
3426 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003427 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003428{
3429 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003430 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3431 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003432}
3433
3434static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3435 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003436 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003437{
3438 struct alc_spec *spec = codec->spec;
3439 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3440}
3441
3442/*
3443 * Digital out
3444 */
3445static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3446 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003447 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003448{
3449 struct alc_spec *spec = codec->spec;
3450 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3451}
3452
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003453static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3454 struct hda_codec *codec,
3455 unsigned int stream_tag,
3456 unsigned int format,
3457 struct snd_pcm_substream *substream)
3458{
3459 struct alc_spec *spec = codec->spec;
3460 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3461 stream_tag, format, substream);
3462}
3463
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003464static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3465 struct hda_codec *codec,
3466 struct snd_pcm_substream *substream)
3467{
3468 struct alc_spec *spec = codec->spec;
3469 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3470}
3471
Linus Torvalds1da177e2005-04-16 15:20:36 -07003472static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3473 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003474 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003475{
3476 struct alc_spec *spec = codec->spec;
3477 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3478}
3479
3480/*
3481 * Analog capture
3482 */
Takashi Iwai63300792008-01-24 15:31:36 +01003483static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003484 struct hda_codec *codec,
3485 unsigned int stream_tag,
3486 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003487 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003488{
3489 struct alc_spec *spec = codec->spec;
3490
Takashi Iwai63300792008-01-24 15:31:36 +01003491 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003492 stream_tag, 0, format);
3493 return 0;
3494}
3495
Takashi Iwai63300792008-01-24 15:31:36 +01003496static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003497 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003498 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003499{
3500 struct alc_spec *spec = codec->spec;
3501
Takashi Iwai888afa12008-03-18 09:57:50 +01003502 snd_hda_codec_cleanup_stream(codec,
3503 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003504 return 0;
3505}
3506
3507
3508/*
3509 */
3510static struct hda_pcm_stream alc880_pcm_analog_playback = {
3511 .substreams = 1,
3512 .channels_min = 2,
3513 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003514 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003515 .ops = {
3516 .open = alc880_playback_pcm_open,
3517 .prepare = alc880_playback_pcm_prepare,
3518 .cleanup = alc880_playback_pcm_cleanup
3519 },
3520};
3521
3522static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003523 .substreams = 1,
3524 .channels_min = 2,
3525 .channels_max = 2,
3526 /* NID is set in alc_build_pcms */
3527};
3528
3529static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3530 .substreams = 1,
3531 .channels_min = 2,
3532 .channels_max = 2,
3533 /* NID is set in alc_build_pcms */
3534};
3535
3536static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3537 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003538 .channels_min = 2,
3539 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003540 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003541 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003542 .prepare = alc880_alt_capture_pcm_prepare,
3543 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003544 },
3545};
3546
3547static struct hda_pcm_stream alc880_pcm_digital_playback = {
3548 .substreams = 1,
3549 .channels_min = 2,
3550 .channels_max = 2,
3551 /* NID is set in alc_build_pcms */
3552 .ops = {
3553 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003554 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003555 .prepare = alc880_dig_playback_pcm_prepare,
3556 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003557 },
3558};
3559
3560static struct hda_pcm_stream alc880_pcm_digital_capture = {
3561 .substreams = 1,
3562 .channels_min = 2,
3563 .channels_max = 2,
3564 /* NID is set in alc_build_pcms */
3565};
3566
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003567/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003568static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003569 .substreams = 0,
3570 .channels_min = 0,
3571 .channels_max = 0,
3572};
3573
Linus Torvalds1da177e2005-04-16 15:20:36 -07003574static int alc_build_pcms(struct hda_codec *codec)
3575{
3576 struct alc_spec *spec = codec->spec;
3577 struct hda_pcm *info = spec->pcm_rec;
3578 int i;
3579
3580 codec->num_pcms = 1;
3581 codec->pcm_info = info;
3582
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003583 if (spec->no_analog)
3584 goto skip_analog;
3585
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003586 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3587 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003588 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003589
Takashi Iwai4a471b72005-12-07 13:56:29 +01003590 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003591 if (snd_BUG_ON(!spec->multiout.dac_nids))
3592 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003593 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3594 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3595 }
3596 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003597 if (snd_BUG_ON(!spec->adc_nids))
3598 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003599 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3600 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3601 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003602
Takashi Iwai4a471b72005-12-07 13:56:29 +01003603 if (spec->channel_mode) {
3604 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3605 for (i = 0; i < spec->num_channel_mode; i++) {
3606 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3607 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3608 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003609 }
3610 }
3611
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003612 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003613 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003614 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003615 snprintf(spec->stream_name_digital,
3616 sizeof(spec->stream_name_digital),
3617 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003618 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003619 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003620 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003621 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003622 if (spec->dig_out_type)
3623 info->pcm_type = spec->dig_out_type;
3624 else
3625 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003626 if (spec->multiout.dig_out_nid &&
3627 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003628 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3629 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3630 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003631 if (spec->dig_in_nid &&
3632 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003633 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3634 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3635 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003636 /* FIXME: do we need this for all Realtek codec models? */
3637 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003638 }
3639
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003640 if (spec->no_analog)
3641 return 0;
3642
Takashi Iwaie08a0072006-09-07 17:52:14 +02003643 /* If the use of more than one ADC is requested for the current
3644 * model, configure a second analog capture-only PCM.
3645 */
3646 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003647 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3648 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003649 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003650 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003651 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003652 if (spec->alt_dac_nid) {
3653 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3654 *spec->stream_analog_alt_playback;
3655 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3656 spec->alt_dac_nid;
3657 } else {
3658 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3659 alc_pcm_null_stream;
3660 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3661 }
3662 if (spec->num_adc_nids > 1) {
3663 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3664 *spec->stream_analog_alt_capture;
3665 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3666 spec->adc_nids[1];
3667 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3668 spec->num_adc_nids - 1;
3669 } else {
3670 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3671 alc_pcm_null_stream;
3672 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003673 }
3674 }
3675
Linus Torvalds1da177e2005-04-16 15:20:36 -07003676 return 0;
3677}
3678
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003679static inline void alc_shutup(struct hda_codec *codec)
3680{
3681 snd_hda_shutup_pins(codec);
3682}
3683
Takashi Iwai603c4012008-07-30 15:01:44 +02003684static void alc_free_kctls(struct hda_codec *codec)
3685{
3686 struct alc_spec *spec = codec->spec;
3687
3688 if (spec->kctls.list) {
3689 struct snd_kcontrol_new *kctl = spec->kctls.list;
3690 int i;
3691 for (i = 0; i < spec->kctls.used; i++)
3692 kfree(kctl[i].name);
3693 }
3694 snd_array_free(&spec->kctls);
3695}
3696
Linus Torvalds1da177e2005-04-16 15:20:36 -07003697static void alc_free(struct hda_codec *codec)
3698{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003699 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003700
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003701 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003702 return;
3703
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003704 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02003705 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003706 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003707 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003708}
3709
Hector Martinf5de24b2009-12-20 22:51:31 +01003710#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05003711static void alc_power_eapd(struct hda_codec *codec)
3712{
3713 /* We currently only handle front, HP */
3714 switch (codec->vendor_id) {
3715 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003716 set_eapd(codec, 0x0f, 0);
3717 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003718 break;
3719 case 0x10ec0262:
3720 case 0x10ec0267:
3721 case 0x10ec0268:
3722 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003723 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05003724 case 0x10ec0272:
3725 case 0x10ec0660:
3726 case 0x10ec0662:
3727 case 0x10ec0663:
3728 case 0x10ec0862:
3729 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003730 set_eapd(codec, 0x14, 0);
3731 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003732 break;
3733 }
3734}
3735
Hector Martinf5de24b2009-12-20 22:51:31 +01003736static int alc_suspend(struct hda_codec *codec, pm_message_t state)
3737{
3738 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003739 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003740 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05003741 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003742 return 0;
3743}
3744#endif
3745
Takashi Iwaie044c392008-10-27 16:56:24 +01003746#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003747static int alc_resume(struct hda_codec *codec)
3748{
Takashi Iwaie044c392008-10-27 16:56:24 +01003749 codec->patch_ops.init(codec);
3750 snd_hda_codec_resume_amp(codec);
3751 snd_hda_codec_resume_cache(codec);
3752 return 0;
3753}
Takashi Iwaie044c392008-10-27 16:56:24 +01003754#endif
3755
Linus Torvalds1da177e2005-04-16 15:20:36 -07003756/*
3757 */
3758static struct hda_codec_ops alc_patch_ops = {
3759 .build_controls = alc_build_controls,
3760 .build_pcms = alc_build_pcms,
3761 .init = alc_init,
3762 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003763 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003764#ifdef SND_HDA_NEEDS_RESUME
3765 .resume = alc_resume,
3766#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003767#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01003768 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003769 .check_power_status = alc_check_power_status,
3770#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05003771 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003772};
3773
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003774
3775/*
3776 * Test configuration for debugging
3777 *
3778 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3779 * enum controls.
3780 */
3781#ifdef CONFIG_SND_DEBUG
3782static hda_nid_t alc880_test_dac_nids[4] = {
3783 0x02, 0x03, 0x04, 0x05
3784};
3785
3786static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003787 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003788 .items = {
3789 { "In-1", 0x0 },
3790 { "In-2", 0x1 },
3791 { "In-3", 0x2 },
3792 { "In-4", 0x3 },
3793 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003794 { "Front", 0x5 },
3795 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003796 },
3797};
3798
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003799static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003800 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003801 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003802 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003803 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003804};
3805
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003806static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3807 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003808{
3809 static char *texts[] = {
3810 "N/A", "Line Out", "HP Out",
3811 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3812 };
3813 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3814 uinfo->count = 1;
3815 uinfo->value.enumerated.items = 8;
3816 if (uinfo->value.enumerated.item >= 8)
3817 uinfo->value.enumerated.item = 7;
3818 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3819 return 0;
3820}
3821
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003822static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3823 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003824{
3825 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3826 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3827 unsigned int pin_ctl, item = 0;
3828
3829 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3830 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3831 if (pin_ctl & AC_PINCTL_OUT_EN) {
3832 if (pin_ctl & AC_PINCTL_HP_EN)
3833 item = 2;
3834 else
3835 item = 1;
3836 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3837 switch (pin_ctl & AC_PINCTL_VREFEN) {
3838 case AC_PINCTL_VREF_HIZ: item = 3; break;
3839 case AC_PINCTL_VREF_50: item = 4; break;
3840 case AC_PINCTL_VREF_GRD: item = 5; break;
3841 case AC_PINCTL_VREF_80: item = 6; break;
3842 case AC_PINCTL_VREF_100: item = 7; break;
3843 }
3844 }
3845 ucontrol->value.enumerated.item[0] = item;
3846 return 0;
3847}
3848
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003849static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3850 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003851{
3852 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3853 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3854 static unsigned int ctls[] = {
3855 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3856 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3857 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3858 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3859 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3860 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3861 };
3862 unsigned int old_ctl, new_ctl;
3863
3864 old_ctl = snd_hda_codec_read(codec, nid, 0,
3865 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3866 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3867 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003868 int val;
3869 snd_hda_codec_write_cache(codec, nid, 0,
3870 AC_VERB_SET_PIN_WIDGET_CONTROL,
3871 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003872 val = ucontrol->value.enumerated.item[0] >= 3 ?
3873 HDA_AMP_MUTE : 0;
3874 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3875 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003876 return 1;
3877 }
3878 return 0;
3879}
3880
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003881static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3882 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003883{
3884 static char *texts[] = {
3885 "Front", "Surround", "CLFE", "Side"
3886 };
3887 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3888 uinfo->count = 1;
3889 uinfo->value.enumerated.items = 4;
3890 if (uinfo->value.enumerated.item >= 4)
3891 uinfo->value.enumerated.item = 3;
3892 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3893 return 0;
3894}
3895
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003896static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3897 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003898{
3899 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3900 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3901 unsigned int sel;
3902
3903 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3904 ucontrol->value.enumerated.item[0] = sel & 3;
3905 return 0;
3906}
3907
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003908static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3909 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003910{
3911 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3912 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3913 unsigned int sel;
3914
3915 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3916 if (ucontrol->value.enumerated.item[0] != sel) {
3917 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003918 snd_hda_codec_write_cache(codec, nid, 0,
3919 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003920 return 1;
3921 }
3922 return 0;
3923}
3924
3925#define PIN_CTL_TEST(xname,nid) { \
3926 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3927 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003928 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003929 .info = alc_test_pin_ctl_info, \
3930 .get = alc_test_pin_ctl_get, \
3931 .put = alc_test_pin_ctl_put, \
3932 .private_value = nid \
3933 }
3934
3935#define PIN_SRC_TEST(xname,nid) { \
3936 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3937 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003938 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003939 .info = alc_test_pin_src_info, \
3940 .get = alc_test_pin_src_get, \
3941 .put = alc_test_pin_src_put, \
3942 .private_value = nid \
3943 }
3944
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003945static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003946 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3947 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3948 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3949 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003950 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3951 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3952 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3953 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003954 PIN_CTL_TEST("Front Pin Mode", 0x14),
3955 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3956 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3957 PIN_CTL_TEST("Side Pin Mode", 0x17),
3958 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3959 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3960 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3961 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3962 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3963 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3964 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3965 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3966 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3967 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3968 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3969 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3970 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3971 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3972 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3973 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3974 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3975 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003976 {
3977 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3978 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003979 .info = alc_ch_mode_info,
3980 .get = alc_ch_mode_get,
3981 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003982 },
3983 { } /* end */
3984};
3985
3986static struct hda_verb alc880_test_init_verbs[] = {
3987 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003988 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3989 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3990 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3991 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3992 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3993 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3994 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3995 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003996 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003997 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3998 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3999 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4000 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004001 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004002 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4003 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4004 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4005 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004006 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004007 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4008 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4009 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4010 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004011 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004012 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4013 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004014 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4015 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4016 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004017 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004018 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4019 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4020 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4021 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004022 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004023 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004024 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004025 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004026 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004027 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004028 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004029 /* Analog input/passthru */
4030 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4031 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4032 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4033 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4034 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004035 { }
4036};
4037#endif
4038
Linus Torvalds1da177e2005-04-16 15:20:36 -07004039/*
4040 */
4041
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004042static const char *alc880_models[ALC880_MODEL_LAST] = {
4043 [ALC880_3ST] = "3stack",
4044 [ALC880_TCL_S700] = "tcl",
4045 [ALC880_3ST_DIG] = "3stack-digout",
4046 [ALC880_CLEVO] = "clevo",
4047 [ALC880_5ST] = "5stack",
4048 [ALC880_5ST_DIG] = "5stack-digout",
4049 [ALC880_W810] = "w810",
4050 [ALC880_Z71V] = "z71v",
4051 [ALC880_6ST] = "6stack",
4052 [ALC880_6ST_DIG] = "6stack-digout",
4053 [ALC880_ASUS] = "asus",
4054 [ALC880_ASUS_W1V] = "asus-w1v",
4055 [ALC880_ASUS_DIG] = "asus-dig",
4056 [ALC880_ASUS_DIG2] = "asus-dig2",
4057 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004058 [ALC880_UNIWILL_P53] = "uniwill-p53",
4059 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004060 [ALC880_F1734] = "F1734",
4061 [ALC880_LG] = "lg",
4062 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004063 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004064#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004065 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004066#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004067 [ALC880_AUTO] = "auto",
4068};
4069
4070static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004071 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004072 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4073 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4074 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4075 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4076 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4077 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4078 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4079 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004080 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4081 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004082 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4083 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4084 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4085 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4086 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4087 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4088 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4089 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4090 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4091 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004092 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004093 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4094 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4095 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004096 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004097 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004098 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4099 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004100 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4101 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004102 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4103 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4104 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4105 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004106 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4107 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004108 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004109 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004110 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004111 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004112 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4113 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004114 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004115 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004116 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004117 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004118 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004119 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004120 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004121 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004122 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004123 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4124 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004125 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004126 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4127 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4128 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4129 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004130 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4131 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004132 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004133 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004134 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4135 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004136 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4137 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4138 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004139 /* default Intel */
4140 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004141 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4142 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004143 {}
4144};
4145
Takashi Iwai16ded522005-06-10 19:58:24 +02004146/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004147 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004148 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004149static struct alc_config_preset alc880_presets[] = {
4150 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004151 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004152 .init_verbs = { alc880_volume_init_verbs,
4153 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004154 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004155 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004156 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4157 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004158 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004159 .input_mux = &alc880_capture_source,
4160 },
4161 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004162 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004163 .init_verbs = { alc880_volume_init_verbs,
4164 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004165 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004166 .dac_nids = alc880_dac_nids,
4167 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004168 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4169 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004170 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004171 .input_mux = &alc880_capture_source,
4172 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004173 [ALC880_TCL_S700] = {
4174 .mixers = { alc880_tcl_s700_mixer },
4175 .init_verbs = { alc880_volume_init_verbs,
4176 alc880_pin_tcl_S700_init_verbs,
4177 alc880_gpio2_init_verbs },
4178 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4179 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004180 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4181 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004182 .hp_nid = 0x03,
4183 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4184 .channel_mode = alc880_2_jack_modes,
4185 .input_mux = &alc880_capture_source,
4186 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004187 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004188 .mixers = { alc880_three_stack_mixer,
4189 alc880_five_stack_mixer},
4190 .init_verbs = { alc880_volume_init_verbs,
4191 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004192 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4193 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004194 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4195 .channel_mode = alc880_fivestack_modes,
4196 .input_mux = &alc880_capture_source,
4197 },
4198 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004199 .mixers = { alc880_three_stack_mixer,
4200 alc880_five_stack_mixer },
4201 .init_verbs = { alc880_volume_init_verbs,
4202 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004203 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4204 .dac_nids = alc880_dac_nids,
4205 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004206 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4207 .channel_mode = alc880_fivestack_modes,
4208 .input_mux = &alc880_capture_source,
4209 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004210 [ALC880_6ST] = {
4211 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004212 .init_verbs = { alc880_volume_init_verbs,
4213 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004214 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4215 .dac_nids = alc880_6st_dac_nids,
4216 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4217 .channel_mode = alc880_sixstack_modes,
4218 .input_mux = &alc880_6stack_capture_source,
4219 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004220 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004221 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004222 .init_verbs = { alc880_volume_init_verbs,
4223 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004224 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4225 .dac_nids = alc880_6st_dac_nids,
4226 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004227 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4228 .channel_mode = alc880_sixstack_modes,
4229 .input_mux = &alc880_6stack_capture_source,
4230 },
4231 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004232 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004233 .init_verbs = { alc880_volume_init_verbs,
4234 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004235 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004236 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4237 .dac_nids = alc880_w810_dac_nids,
4238 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004239 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4240 .channel_mode = alc880_w810_modes,
4241 .input_mux = &alc880_capture_source,
4242 },
4243 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004244 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004245 .init_verbs = { alc880_volume_init_verbs,
4246 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004247 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4248 .dac_nids = alc880_z71v_dac_nids,
4249 .dig_out_nid = ALC880_DIGOUT_NID,
4250 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004251 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4252 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004253 .input_mux = &alc880_capture_source,
4254 },
4255 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004256 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004257 .init_verbs = { alc880_volume_init_verbs,
4258 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004259 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4260 .dac_nids = alc880_f1734_dac_nids,
4261 .hp_nid = 0x02,
4262 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4263 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004264 .input_mux = &alc880_f1734_capture_source,
4265 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004266 .setup = alc880_uniwill_p53_setup,
4267 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004268 },
4269 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004270 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004271 .init_verbs = { alc880_volume_init_verbs,
4272 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004273 alc880_gpio1_init_verbs },
4274 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4275 .dac_nids = alc880_asus_dac_nids,
4276 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4277 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004278 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004279 .input_mux = &alc880_capture_source,
4280 },
4281 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004282 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004283 .init_verbs = { alc880_volume_init_verbs,
4284 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004285 alc880_gpio1_init_verbs },
4286 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4287 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004288 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004289 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4290 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004291 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004292 .input_mux = &alc880_capture_source,
4293 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004294 [ALC880_ASUS_DIG2] = {
4295 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004296 .init_verbs = { alc880_volume_init_verbs,
4297 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004298 alc880_gpio2_init_verbs }, /* use GPIO2 */
4299 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4300 .dac_nids = alc880_asus_dac_nids,
4301 .dig_out_nid = ALC880_DIGOUT_NID,
4302 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4303 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004304 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004305 .input_mux = &alc880_capture_source,
4306 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004307 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004308 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004309 .init_verbs = { alc880_volume_init_verbs,
4310 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004311 alc880_gpio1_init_verbs },
4312 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4313 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004314 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004315 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4316 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004317 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004318 .input_mux = &alc880_capture_source,
4319 },
4320 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004321 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004322 .init_verbs = { alc880_volume_init_verbs,
4323 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004324 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4325 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004326 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004327 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4328 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004329 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004330 .input_mux = &alc880_capture_source,
4331 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004332 [ALC880_UNIWILL] = {
4333 .mixers = { alc880_uniwill_mixer },
4334 .init_verbs = { alc880_volume_init_verbs,
4335 alc880_uniwill_init_verbs },
4336 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4337 .dac_nids = alc880_asus_dac_nids,
4338 .dig_out_nid = ALC880_DIGOUT_NID,
4339 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4340 .channel_mode = alc880_threestack_modes,
4341 .need_dac_fix = 1,
4342 .input_mux = &alc880_capture_source,
4343 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004344 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004345 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004346 },
4347 [ALC880_UNIWILL_P53] = {
4348 .mixers = { alc880_uniwill_p53_mixer },
4349 .init_verbs = { alc880_volume_init_verbs,
4350 alc880_uniwill_p53_init_verbs },
4351 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4352 .dac_nids = alc880_asus_dac_nids,
4353 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004354 .channel_mode = alc880_threestack_modes,
4355 .input_mux = &alc880_capture_source,
4356 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004357 .setup = alc880_uniwill_p53_setup,
4358 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004359 },
4360 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004361 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004362 .init_verbs = { alc880_volume_init_verbs,
4363 alc880_uniwill_p53_init_verbs,
4364 alc880_beep_init_verbs },
4365 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4366 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004367 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004368 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4369 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004370 .input_mux = &alc880_capture_source,
4371 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004372 .setup = alc880_uniwill_p53_setup,
4373 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004374 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004375 [ALC880_CLEVO] = {
4376 .mixers = { alc880_three_stack_mixer },
4377 .init_verbs = { alc880_volume_init_verbs,
4378 alc880_pin_clevo_init_verbs },
4379 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4380 .dac_nids = alc880_dac_nids,
4381 .hp_nid = 0x03,
4382 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4383 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004384 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004385 .input_mux = &alc880_capture_source,
4386 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004387 [ALC880_LG] = {
4388 .mixers = { alc880_lg_mixer },
4389 .init_verbs = { alc880_volume_init_verbs,
4390 alc880_lg_init_verbs },
4391 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4392 .dac_nids = alc880_lg_dac_nids,
4393 .dig_out_nid = ALC880_DIGOUT_NID,
4394 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4395 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004396 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004397 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004398 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004399 .setup = alc880_lg_setup,
4400 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004401#ifdef CONFIG_SND_HDA_POWER_SAVE
4402 .loopbacks = alc880_lg_loopbacks,
4403#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004404 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004405 [ALC880_LG_LW] = {
4406 .mixers = { alc880_lg_lw_mixer },
4407 .init_verbs = { alc880_volume_init_verbs,
4408 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004409 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004410 .dac_nids = alc880_dac_nids,
4411 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004412 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4413 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004414 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004415 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004416 .setup = alc880_lg_lw_setup,
4417 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004418 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004419 [ALC880_MEDION_RIM] = {
4420 .mixers = { alc880_medion_rim_mixer },
4421 .init_verbs = { alc880_volume_init_verbs,
4422 alc880_medion_rim_init_verbs,
4423 alc_gpio2_init_verbs },
4424 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4425 .dac_nids = alc880_dac_nids,
4426 .dig_out_nid = ALC880_DIGOUT_NID,
4427 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4428 .channel_mode = alc880_2_jack_modes,
4429 .input_mux = &alc880_medion_rim_capture_source,
4430 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004431 .setup = alc880_medion_rim_setup,
4432 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004433 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004434#ifdef CONFIG_SND_DEBUG
4435 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004436 .mixers = { alc880_test_mixer },
4437 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004438 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4439 .dac_nids = alc880_test_dac_nids,
4440 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004441 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4442 .channel_mode = alc880_test_modes,
4443 .input_mux = &alc880_test_capture_source,
4444 },
4445#endif
4446};
4447
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004448/*
4449 * Automatic parse of I/O pins from the BIOS configuration
4450 */
4451
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004452enum {
4453 ALC_CTL_WIDGET_VOL,
4454 ALC_CTL_WIDGET_MUTE,
4455 ALC_CTL_BIND_MUTE,
4456};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004457static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004458 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4459 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004460 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004461};
4462
4463/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004464static int add_control(struct alc_spec *spec, int type, const char *name,
4465 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004466{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004467 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004468
Takashi Iwai603c4012008-07-30 15:01:44 +02004469 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4470 knew = snd_array_new(&spec->kctls);
4471 if (!knew)
4472 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004473 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004474 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004475 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004476 return -ENOMEM;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004477 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004478 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004479 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004480 return 0;
4481}
4482
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004483static int add_control_with_pfx(struct alc_spec *spec, int type,
4484 const char *pfx, const char *dir,
4485 const char *sfx, unsigned long val)
4486{
4487 char name[32];
4488 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
4489 return add_control(spec, type, name, val);
4490}
4491
4492#define add_pb_vol_ctrl(spec, type, pfx, val) \
4493 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val)
4494#define add_pb_sw_ctrl(spec, type, pfx, val) \
4495 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val)
4496
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004497#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4498#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4499#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4500#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004501#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4502#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4503#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4504#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4505#define ALC880_PIN_CD_NID 0x1c
4506
4507/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004508static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4509 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004510{
4511 hda_nid_t nid;
4512 int assigned[4];
4513 int i, j;
4514
4515 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004516 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004517
4518 /* check the pins hardwired to audio widget */
4519 for (i = 0; i < cfg->line_outs; i++) {
4520 nid = cfg->line_out_pins[i];
4521 if (alc880_is_fixed_pin(nid)) {
4522 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004523 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004524 assigned[idx] = 1;
4525 }
4526 }
4527 /* left pins can be connect to any audio widget */
4528 for (i = 0; i < cfg->line_outs; i++) {
4529 nid = cfg->line_out_pins[i];
4530 if (alc880_is_fixed_pin(nid))
4531 continue;
4532 /* search for an empty channel */
4533 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004534 if (!assigned[j]) {
4535 spec->multiout.dac_nids[i] =
4536 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004537 assigned[j] = 1;
4538 break;
4539 }
4540 }
4541 }
4542 spec->multiout.num_dacs = cfg->line_outs;
4543 return 0;
4544}
4545
4546/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004547static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4548 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004549{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004550 static const char *chname[4] = {
4551 "Front", "Surround", NULL /*CLFE*/, "Side"
4552 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004553 hda_nid_t nid;
4554 int i, err;
4555
4556 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004557 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004558 continue;
4559 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4560 if (i == 2) {
4561 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004562 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4563 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004564 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4565 HDA_OUTPUT));
4566 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004567 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004568 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4569 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004570 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4571 HDA_OUTPUT));
4572 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004573 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004574 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4575 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004576 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4577 HDA_INPUT));
4578 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004579 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004580 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4581 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004582 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4583 HDA_INPUT));
4584 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004585 return err;
4586 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004587 const char *pfx;
4588 if (cfg->line_outs == 1 &&
4589 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4590 pfx = "Speaker";
4591 else
4592 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004593 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004594 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4595 HDA_OUTPUT));
4596 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004597 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004598 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004599 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4600 HDA_INPUT));
4601 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004602 return err;
4603 }
4604 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004605 return 0;
4606}
4607
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004608/* add playback controls for speaker and HP outputs */
4609static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4610 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004611{
4612 hda_nid_t nid;
4613 int err;
4614
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004615 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004616 return 0;
4617
4618 if (alc880_is_fixed_pin(pin)) {
4619 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004620 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004621 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004622 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004623 else
4624 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004625 /* control HP volume/switch on the output mixer amp */
4626 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004627 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004628 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4629 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004630 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004631 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004632 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4633 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004634 return err;
4635 } else if (alc880_is_multi_pin(pin)) {
4636 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004637 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004638 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004639 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4640 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004641 return err;
4642 }
4643 return 0;
4644}
4645
4646/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004647static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4648 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004649 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004650{
Kailang Yangdf694da2005-12-05 19:42:22 +01004651 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004652
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004653 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004654 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4655 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004656 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004657 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004658 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4659 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004660 return err;
4661 return 0;
4662}
4663
Takashi Iwai05f5f472009-08-25 13:10:18 +02004664static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004665{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004666 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4667 return (pincap & AC_PINCAP_IN) != 0;
4668}
4669
4670/* create playback/capture controls for input pins */
4671static int alc_auto_create_input_ctls(struct hda_codec *codec,
4672 const struct auto_pin_cfg *cfg,
4673 hda_nid_t mixer,
4674 hda_nid_t cap1, hda_nid_t cap2)
4675{
4676 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004677 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004678 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004679
4680 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004681 hda_nid_t pin;
4682
4683 pin = cfg->input_pins[i];
4684 if (!alc_is_input_pin(codec, pin))
4685 continue;
4686
4687 if (mixer) {
4688 idx = get_connection_index(codec, mixer, pin);
4689 if (idx >= 0) {
4690 err = new_analog_input(spec, pin,
4691 auto_pin_cfg_labels[i],
4692 idx, mixer);
4693 if (err < 0)
4694 return err;
4695 }
4696 }
4697
4698 if (!cap1)
4699 continue;
4700 idx = get_connection_index(codec, cap1, pin);
4701 if (idx < 0 && cap2)
4702 idx = get_connection_index(codec, cap2, pin);
4703 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004704 imux->items[imux->num_items].label =
4705 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004706 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004707 imux->num_items++;
4708 }
4709 }
4710 return 0;
4711}
4712
Takashi Iwai05f5f472009-08-25 13:10:18 +02004713static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4714 const struct auto_pin_cfg *cfg)
4715{
4716 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4717}
4718
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004719static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4720 unsigned int pin_type)
4721{
4722 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4723 pin_type);
4724 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004725 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4726 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004727}
4728
Kailang Yangdf694da2005-12-05 19:42:22 +01004729static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4730 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004731 int dac_idx)
4732{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004733 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004734 /* need the manual connection? */
4735 if (alc880_is_multi_pin(nid)) {
4736 struct alc_spec *spec = codec->spec;
4737 int idx = alc880_multi_pin_idx(nid);
4738 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4739 AC_VERB_SET_CONNECT_SEL,
4740 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4741 }
4742}
4743
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004744static int get_pin_type(int line_out_type)
4745{
4746 if (line_out_type == AUTO_PIN_HP_OUT)
4747 return PIN_HP;
4748 else
4749 return PIN_OUT;
4750}
4751
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004752static void alc880_auto_init_multi_out(struct hda_codec *codec)
4753{
4754 struct alc_spec *spec = codec->spec;
4755 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004756
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004757 for (i = 0; i < spec->autocfg.line_outs; i++) {
4758 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004759 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4760 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004761 }
4762}
4763
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004764static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004765{
4766 struct alc_spec *spec = codec->spec;
4767 hda_nid_t pin;
4768
Takashi Iwai82bc9552006-03-21 11:24:42 +01004769 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004770 if (pin) /* connect to front */
4771 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004772 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004773 if (pin) /* connect to front */
4774 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4775}
4776
4777static void alc880_auto_init_analog_input(struct hda_codec *codec)
4778{
4779 struct alc_spec *spec = codec->spec;
4780 int i;
4781
4782 for (i = 0; i < AUTO_PIN_LAST; i++) {
4783 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004784 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004785 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004786 if (nid != ALC880_PIN_CD_NID &&
4787 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004788 snd_hda_codec_write(codec, nid, 0,
4789 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004790 AMP_OUT_MUTE);
4791 }
4792 }
4793}
4794
4795/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004796/* return 1 if successful, 0 if the proper config is not found,
4797 * or a negative error code
4798 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004799static int alc880_parse_auto_config(struct hda_codec *codec)
4800{
4801 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004802 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004803 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004804
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004805 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4806 alc880_ignore);
4807 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004808 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004809 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004810 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004811
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004812 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4813 if (err < 0)
4814 return err;
4815 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4816 if (err < 0)
4817 return err;
4818 err = alc880_auto_create_extra_out(spec,
4819 spec->autocfg.speaker_pins[0],
4820 "Speaker");
4821 if (err < 0)
4822 return err;
4823 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4824 "Headphone");
4825 if (err < 0)
4826 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004827 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004828 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004829 return err;
4830
4831 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4832
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004833 /* check multiple SPDIF-out (for recent codecs) */
4834 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4835 hda_nid_t dig_nid;
4836 err = snd_hda_get_connections(codec,
4837 spec->autocfg.dig_out_pins[i],
4838 &dig_nid, 1);
4839 if (err < 0)
4840 continue;
4841 if (!i)
4842 spec->multiout.dig_out_nid = dig_nid;
4843 else {
4844 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004845 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004846 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004847 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004848 }
4849 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004850 if (spec->autocfg.dig_in_pin)
4851 spec->dig_in_nid = ALC880_DIGIN_NID;
4852
Takashi Iwai603c4012008-07-30 15:01:44 +02004853 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004854 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004855
Takashi Iwaid88897e2008-10-31 15:01:37 +01004856 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004857
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004858 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004859 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004860
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004861 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4862
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004863 return 1;
4864}
4865
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004866/* additional initialization for auto-configuration model */
4867static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004868{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004869 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004870 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004871 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004872 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004873 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004874 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004875}
4876
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004877/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4878 * one of two digital mic pins, e.g. on ALC272
4879 */
4880static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004881{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004882 struct alc_spec *spec = codec->spec;
4883 int i;
4884
4885 for (i = 0; i < spec->num_adc_nids; i++) {
4886 hda_nid_t cap = spec->capsrc_nids ?
4887 spec->capsrc_nids[i] : spec->adc_nids[i];
4888 int iidx, eidx;
4889
4890 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4891 if (iidx < 0)
4892 continue;
4893 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4894 if (eidx < 0)
4895 continue;
4896 spec->int_mic.mux_idx = iidx;
4897 spec->ext_mic.mux_idx = eidx;
4898 if (spec->capsrc_nids)
4899 spec->capsrc_nids += i;
4900 spec->adc_nids += i;
4901 spec->num_adc_nids = 1;
4902 return;
4903 }
4904 snd_printd(KERN_INFO "hda_codec: %s: "
4905 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4906 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4907 spec->auto_mic = 0; /* disable auto-mic to be sure */
4908}
4909
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004910/* choose the ADC/MUX containing the input pin and initialize the setup */
4911static void fixup_single_adc(struct hda_codec *codec)
4912{
4913 struct alc_spec *spec = codec->spec;
4914 hda_nid_t pin;
4915 int i;
4916
4917 /* search for the input pin; there must be only one */
4918 for (i = 0; i < AUTO_PIN_LAST; i++) {
4919 if (spec->autocfg.input_pins[i]) {
4920 pin = spec->autocfg.input_pins[i];
4921 break;
4922 }
4923 }
4924 if (!pin)
4925 return;
4926
4927 /* set the default connection to that pin */
4928 for (i = 0; i < spec->num_adc_nids; i++) {
4929 hda_nid_t cap = spec->capsrc_nids ?
4930 spec->capsrc_nids[i] : spec->adc_nids[i];
4931 int idx;
4932
4933 idx = get_connection_index(codec, cap, pin);
4934 if (idx < 0)
4935 continue;
4936 /* use only this ADC */
4937 if (spec->capsrc_nids)
4938 spec->capsrc_nids += i;
4939 spec->adc_nids += i;
4940 spec->num_adc_nids = 1;
4941 /* select or unmute this route */
4942 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
4943 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
4944 HDA_AMP_MUTE, 0);
4945 } else {
4946 snd_hda_codec_write_cache(codec, cap, 0,
4947 AC_VERB_SET_CONNECT_SEL, idx);
4948 }
4949 return;
4950 }
4951}
4952
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004953static void set_capture_mixer(struct hda_codec *codec)
4954{
4955 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01004956 static struct snd_kcontrol_new *caps[2][3] = {
4957 { alc_capture_mixer_nosrc1,
4958 alc_capture_mixer_nosrc2,
4959 alc_capture_mixer_nosrc3 },
4960 { alc_capture_mixer1,
4961 alc_capture_mixer2,
4962 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004963 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004964 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004965 int mux = 0;
4966 if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004967 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004968 else if (spec->input_mux) {
4969 if (spec->input_mux->num_items > 1)
4970 mux = 1;
4971 else if (spec->input_mux->num_items == 1)
4972 fixup_single_adc(codec);
4973 }
Takashi Iwaia23b6882009-03-23 15:21:36 +01004974 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4975 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004976}
4977
Takashi Iwai67d634c2009-11-16 15:35:59 +01004978#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004979#define set_beep_amp(spec, nid, idx, dir) \
4980 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwai67d634c2009-11-16 15:35:59 +01004981#else
4982#define set_beep_amp(spec, nid, idx, dir) /* NOP */
4983#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004984
4985/*
4986 * OK, here we have finally the patch for ALC880
4987 */
4988
Linus Torvalds1da177e2005-04-16 15:20:36 -07004989static int patch_alc880(struct hda_codec *codec)
4990{
4991 struct alc_spec *spec;
4992 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004993 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004994
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004995 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004996 if (spec == NULL)
4997 return -ENOMEM;
4998
4999 codec->spec = spec;
5000
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005001 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5002 alc880_models,
5003 alc880_cfg_tbl);
5004 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005005 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5006 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005007 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005008 }
5009
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005010 if (board_config == ALC880_AUTO) {
5011 /* automatic parse from the BIOS config */
5012 err = alc880_parse_auto_config(codec);
5013 if (err < 0) {
5014 alc_free(codec);
5015 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005016 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005017 printk(KERN_INFO
5018 "hda_codec: Cannot set up configuration "
5019 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005020 board_config = ALC880_3ST;
5021 }
5022 }
5023
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005024 err = snd_hda_attach_beep_device(codec, 0x1);
5025 if (err < 0) {
5026 alc_free(codec);
5027 return err;
5028 }
5029
Kailang Yangdf694da2005-12-05 19:42:22 +01005030 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005031 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005032
Linus Torvalds1da177e2005-04-16 15:20:36 -07005033 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5034 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005035 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005036
Linus Torvalds1da177e2005-04-16 15:20:36 -07005037 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5038 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5039
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005040 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005041 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005042 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005043 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005044 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005045 if (wcap != AC_WID_AUD_IN) {
5046 spec->adc_nids = alc880_adc_nids_alt;
5047 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005048 } else {
5049 spec->adc_nids = alc880_adc_nids;
5050 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005051 }
5052 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005053 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005054 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005055
Takashi Iwai2134ea42008-01-10 16:53:55 +01005056 spec->vmaster_nid = 0x0c;
5057
Linus Torvalds1da177e2005-04-16 15:20:36 -07005058 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005059 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005060 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005061#ifdef CONFIG_SND_HDA_POWER_SAVE
5062 if (!spec->loopback.amplist)
5063 spec->loopback.amplist = alc880_loopbacks;
5064#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005065
5066 return 0;
5067}
5068
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005069
Linus Torvalds1da177e2005-04-16 15:20:36 -07005070/*
5071 * ALC260 support
5072 */
5073
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005074static hda_nid_t alc260_dac_nids[1] = {
5075 /* front */
5076 0x02,
5077};
5078
5079static hda_nid_t alc260_adc_nids[1] = {
5080 /* ADC0 */
5081 0x04,
5082};
5083
Kailang Yangdf694da2005-12-05 19:42:22 +01005084static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005085 /* ADC1 */
5086 0x05,
5087};
5088
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005089/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5090 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5091 */
5092static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005093 /* ADC0, ADC1 */
5094 0x04, 0x05
5095};
5096
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005097#define ALC260_DIGOUT_NID 0x03
5098#define ALC260_DIGIN_NID 0x06
5099
5100static struct hda_input_mux alc260_capture_source = {
5101 .num_items = 4,
5102 .items = {
5103 { "Mic", 0x0 },
5104 { "Front Mic", 0x1 },
5105 { "Line", 0x2 },
5106 { "CD", 0x4 },
5107 },
5108};
5109
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005110/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005111 * headphone jack and the internal CD lines since these are the only pins at
5112 * which audio can appear. For flexibility, also allow the option of
5113 * recording the mixer output on the second ADC (ADC0 doesn't have a
5114 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005115 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005116static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5117 {
5118 .num_items = 3,
5119 .items = {
5120 { "Mic/Line", 0x0 },
5121 { "CD", 0x4 },
5122 { "Headphone", 0x2 },
5123 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005124 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005125 {
5126 .num_items = 4,
5127 .items = {
5128 { "Mic/Line", 0x0 },
5129 { "CD", 0x4 },
5130 { "Headphone", 0x2 },
5131 { "Mixer", 0x5 },
5132 },
5133 },
5134
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005135};
5136
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005137/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5138 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005139 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005140static struct hda_input_mux alc260_acer_capture_sources[2] = {
5141 {
5142 .num_items = 4,
5143 .items = {
5144 { "Mic", 0x0 },
5145 { "Line", 0x2 },
5146 { "CD", 0x4 },
5147 { "Headphone", 0x5 },
5148 },
5149 },
5150 {
5151 .num_items = 5,
5152 .items = {
5153 { "Mic", 0x0 },
5154 { "Line", 0x2 },
5155 { "CD", 0x4 },
5156 { "Headphone", 0x6 },
5157 { "Mixer", 0x5 },
5158 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005159 },
5160};
Michael Schwingencc959482009-02-22 18:58:45 +01005161
5162/* Maxdata Favorit 100XS */
5163static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5164 {
5165 .num_items = 2,
5166 .items = {
5167 { "Line/Mic", 0x0 },
5168 { "CD", 0x4 },
5169 },
5170 },
5171 {
5172 .num_items = 3,
5173 .items = {
5174 { "Line/Mic", 0x0 },
5175 { "CD", 0x4 },
5176 { "Mixer", 0x5 },
5177 },
5178 },
5179};
5180
Linus Torvalds1da177e2005-04-16 15:20:36 -07005181/*
5182 * This is just place-holder, so there's something for alc_build_pcms to look
5183 * at when it calculates the maximum number of channels. ALC260 has no mixer
5184 * element which allows changing the channel mode, so the verb list is
5185 * never used.
5186 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005187static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005188 { 2, NULL },
5189};
5190
Kailang Yangdf694da2005-12-05 19:42:22 +01005191
5192/* Mixer combinations
5193 *
5194 * basic: base_output + input + pc_beep + capture
5195 * HP: base_output + input + capture_alt
5196 * HP_3013: hp_3013 + input + capture
5197 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005198 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005199 */
5200
5201static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005202 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005203 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005204 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5205 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5206 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5207 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5208 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005209};
Kailang Yangdf694da2005-12-05 19:42:22 +01005210
5211static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005212 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5213 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5214 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5215 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5216 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5217 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5218 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5219 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005220 { } /* end */
5221};
5222
Takashi Iwaibec15c32008-01-28 18:16:30 +01005223/* update HP, line and mono out pins according to the master switch */
5224static void alc260_hp_master_update(struct hda_codec *codec,
5225 hda_nid_t hp, hda_nid_t line,
5226 hda_nid_t mono)
5227{
5228 struct alc_spec *spec = codec->spec;
5229 unsigned int val = spec->master_sw ? PIN_HP : 0;
5230 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005231 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005232 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005233 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005234 val);
5235 /* mono (speaker) depending on the HP jack sense */
5236 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005237 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005238 val);
5239}
5240
5241static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5242 struct snd_ctl_elem_value *ucontrol)
5243{
5244 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5245 struct alc_spec *spec = codec->spec;
5246 *ucontrol->value.integer.value = spec->master_sw;
5247 return 0;
5248}
5249
5250static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5251 struct snd_ctl_elem_value *ucontrol)
5252{
5253 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5254 struct alc_spec *spec = codec->spec;
5255 int val = !!*ucontrol->value.integer.value;
5256 hda_nid_t hp, line, mono;
5257
5258 if (val == spec->master_sw)
5259 return 0;
5260 spec->master_sw = val;
5261 hp = (kcontrol->private_value >> 16) & 0xff;
5262 line = (kcontrol->private_value >> 8) & 0xff;
5263 mono = kcontrol->private_value & 0xff;
5264 alc260_hp_master_update(codec, hp, line, mono);
5265 return 1;
5266}
5267
5268static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5269 {
5270 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5271 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005272 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005273 .info = snd_ctl_boolean_mono_info,
5274 .get = alc260_hp_master_sw_get,
5275 .put = alc260_hp_master_sw_put,
5276 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5277 },
5278 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5279 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5280 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5281 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5282 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5283 HDA_OUTPUT),
5284 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5285 { } /* end */
5286};
5287
5288static struct hda_verb alc260_hp_unsol_verbs[] = {
5289 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5290 {},
5291};
5292
5293static void alc260_hp_automute(struct hda_codec *codec)
5294{
5295 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005296
Wu Fengguang864f92b2009-11-18 12:38:02 +08005297 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005298 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5299}
5300
5301static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5302{
5303 if ((res >> 26) == ALC880_HP_EVENT)
5304 alc260_hp_automute(codec);
5305}
5306
Kailang Yangdf694da2005-12-05 19:42:22 +01005307static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005308 {
5309 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5310 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005311 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005312 .info = snd_ctl_boolean_mono_info,
5313 .get = alc260_hp_master_sw_get,
5314 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005315 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005316 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005317 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5318 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5319 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5320 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5321 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5322 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005323 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5324 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005325 { } /* end */
5326};
5327
Kailang Yang3f878302008-08-26 13:02:23 +02005328static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5329 .ops = &snd_hda_bind_vol,
5330 .values = {
5331 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5332 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5333 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5334 0
5335 },
5336};
5337
5338static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5339 .ops = &snd_hda_bind_sw,
5340 .values = {
5341 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5342 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5343 0
5344 },
5345};
5346
5347static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5348 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5349 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5350 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5351 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5352 { } /* end */
5353};
5354
Takashi Iwaibec15c32008-01-28 18:16:30 +01005355static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5356 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5357 {},
5358};
5359
5360static void alc260_hp_3013_automute(struct hda_codec *codec)
5361{
5362 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005363
Wu Fengguang864f92b2009-11-18 12:38:02 +08005364 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005365 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005366}
5367
5368static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5369 unsigned int res)
5370{
5371 if ((res >> 26) == ALC880_HP_EVENT)
5372 alc260_hp_3013_automute(codec);
5373}
5374
Kailang Yang3f878302008-08-26 13:02:23 +02005375static void alc260_hp_3012_automute(struct hda_codec *codec)
5376{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005377 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005378
Kailang Yang3f878302008-08-26 13:02:23 +02005379 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5380 bits);
5381 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5382 bits);
5383 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5384 bits);
5385}
5386
5387static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5388 unsigned int res)
5389{
5390 if ((res >> 26) == ALC880_HP_EVENT)
5391 alc260_hp_3012_automute(codec);
5392}
5393
5394/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005395 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5396 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005397static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005398 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005399 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005400 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005401 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5402 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5403 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5404 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005405 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005406 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5407 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005408 { } /* end */
5409};
5410
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005411/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5412 * versions of the ALC260 don't act on requests to enable mic bias from NID
5413 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5414 * datasheet doesn't mention this restriction. At this stage it's not clear
5415 * whether this behaviour is intentional or is a hardware bug in chip
5416 * revisions available in early 2006. Therefore for now allow the
5417 * "Headphone Jack Mode" control to span all choices, but if it turns out
5418 * that the lack of mic bias for this NID is intentional we could change the
5419 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5420 *
5421 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5422 * don't appear to make the mic bias available from the "line" jack, even
5423 * though the NID used for this jack (0x14) can supply it. The theory is
5424 * that perhaps Acer have included blocking capacitors between the ALC260
5425 * and the output jack. If this turns out to be the case for all such
5426 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5427 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005428 *
5429 * The C20x Tablet series have a mono internal speaker which is controlled
5430 * via the chip's Mono sum widget and pin complex, so include the necessary
5431 * controls for such models. On models without a "mono speaker" the control
5432 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005433 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005434static struct snd_kcontrol_new alc260_acer_mixer[] = {
5435 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5436 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005437 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005438 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005439 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005440 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005441 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005442 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5443 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5444 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5445 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5446 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5447 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5448 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5449 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005450 { } /* end */
5451};
5452
Michael Schwingencc959482009-02-22 18:58:45 +01005453/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5454 */
5455static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5456 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5457 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5458 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5459 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5460 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5461 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5462 { } /* end */
5463};
5464
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005465/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5466 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5467 */
5468static struct snd_kcontrol_new alc260_will_mixer[] = {
5469 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5470 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5471 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5472 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5473 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5474 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5475 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5476 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5477 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5478 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005479 { } /* end */
5480};
5481
5482/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5483 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5484 */
5485static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5486 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5487 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5488 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5489 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5490 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5491 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5492 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5493 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5494 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5495 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5496 { } /* end */
5497};
5498
Kailang Yangdf694da2005-12-05 19:42:22 +01005499/*
5500 * initialization verbs
5501 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005502static struct hda_verb alc260_init_verbs[] = {
5503 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005504 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005505 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005506 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005507 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005508 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005509 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005510 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005511 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005512 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005513 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005514 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005515 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005516 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005517 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005518 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005519 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005520 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5521 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005522 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005523 /* set connection select to line in (default select for this ADC) */
5524 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005525 /* mute capture amp left and right */
5526 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5527 /* set connection select to line in (default select for this ADC) */
5528 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005529 /* set vol=0 Line-Out mixer amp left and right */
5530 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5531 /* unmute pin widget amp left and right (no gain on this amp) */
5532 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5533 /* set vol=0 HP mixer amp left and right */
5534 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5535 /* unmute pin widget amp left and right (no gain on this amp) */
5536 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5537 /* set vol=0 Mono mixer amp left and right */
5538 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5539 /* unmute pin widget amp left and right (no gain on this amp) */
5540 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5541 /* unmute LINE-2 out pin */
5542 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005543 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5544 * Line In 2 = 0x03
5545 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005546 /* mute analog inputs */
5547 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5548 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5549 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5550 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5551 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005552 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005553 /* mute Front out path */
5554 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5555 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5556 /* mute Headphone out path */
5557 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5558 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5559 /* mute Mono out path */
5560 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5561 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005562 { }
5563};
5564
Takashi Iwai474167d2006-05-17 17:17:43 +02005565#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005566static struct hda_verb alc260_hp_init_verbs[] = {
5567 /* Headphone and output */
5568 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5569 /* mono output */
5570 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5571 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5572 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5573 /* Mic2 (front panel) pin widget for input and vref at 80% */
5574 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5575 /* Line In pin widget for input */
5576 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5577 /* Line-2 pin widget for output */
5578 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5579 /* CD pin widget for input */
5580 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5581 /* unmute amp left and right */
5582 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5583 /* set connection select to line in (default select for this ADC) */
5584 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5585 /* unmute Line-Out mixer amp left and right (volume = 0) */
5586 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5587 /* mute pin widget amp left and right (no gain on this amp) */
5588 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5589 /* unmute HP mixer amp left and right (volume = 0) */
5590 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5591 /* mute pin widget amp left and right (no gain on this amp) */
5592 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005593 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5594 * Line In 2 = 0x03
5595 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005596 /* mute analog inputs */
5597 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5598 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5599 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5600 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5601 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005602 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5603 /* Unmute Front out path */
5604 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5605 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5606 /* Unmute Headphone out path */
5607 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5608 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5609 /* Unmute Mono out path */
5610 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5611 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5612 { }
5613};
Takashi Iwai474167d2006-05-17 17:17:43 +02005614#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005615
5616static struct hda_verb alc260_hp_3013_init_verbs[] = {
5617 /* Line out and output */
5618 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5619 /* mono output */
5620 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5621 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5622 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5623 /* Mic2 (front panel) pin widget for input and vref at 80% */
5624 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5625 /* Line In pin widget for input */
5626 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5627 /* Headphone pin widget for output */
5628 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5629 /* CD pin widget for input */
5630 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5631 /* unmute amp left and right */
5632 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5633 /* set connection select to line in (default select for this ADC) */
5634 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5635 /* unmute Line-Out mixer amp left and right (volume = 0) */
5636 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5637 /* mute pin widget amp left and right (no gain on this amp) */
5638 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5639 /* unmute HP mixer amp left and right (volume = 0) */
5640 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5641 /* mute pin widget amp left and right (no gain on this amp) */
5642 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005643 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5644 * Line In 2 = 0x03
5645 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005646 /* mute analog inputs */
5647 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5648 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5649 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5650 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5651 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005652 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5653 /* Unmute Front out path */
5654 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5655 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5656 /* Unmute Headphone out path */
5657 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5658 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5659 /* Unmute Mono out path */
5660 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5661 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5662 { }
5663};
5664
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005665/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005666 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5667 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005668 */
5669static struct hda_verb alc260_fujitsu_init_verbs[] = {
5670 /* Disable all GPIOs */
5671 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5672 /* Internal speaker is connected to headphone pin */
5673 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5674 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5675 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005676 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5677 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5678 /* Ensure all other unused pins are disabled and muted. */
5679 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5680 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005681 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005682 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005683 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005684 {0x13, 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)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005687
Jonathan Woithef7ace402006-02-28 11:46:14 +01005688 /* Disable digital (SPDIF) pins */
5689 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5690 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005691
Kailang Yangea1fb292008-08-26 12:58:38 +02005692 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005693 * when acting as an output.
5694 */
5695 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5696
5697 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005698 {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},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005707
Jonathan Woithef7ace402006-02-28 11:46:14 +01005708 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5709 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5710 /* Unmute Line1 pin widget output buffer since it starts as an output.
5711 * If the pin mode is changed by the user the pin mode control will
5712 * take care of enabling the pin's input/output buffers as needed.
5713 * Therefore there's no need to enable the input buffer at this
5714 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005715 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005716 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005717 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005718 * mixer ctrl)
5719 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005720 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005721
Jonathan Woithef7ace402006-02-28 11:46:14 +01005722 /* Mute capture amp left and right */
5723 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005724 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005725 * in (on mic1 pin)
5726 */
5727 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005728
Jonathan Woithef7ace402006-02-28 11:46:14 +01005729 /* Do the same for the second ADC: mute capture input amp and
5730 * set ADC connection to line in (on mic1 pin)
5731 */
5732 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5733 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005734
Jonathan Woithef7ace402006-02-28 11:46:14 +01005735 /* Mute all inputs to mixer widget (even unconnected ones) */
5736 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5737 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5738 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5739 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5740 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5741 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5742 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5743 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005744
5745 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005746};
5747
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005748/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5749 * similar laptops (adapted from Fujitsu init verbs).
5750 */
5751static struct hda_verb alc260_acer_init_verbs[] = {
5752 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5753 * the headphone jack. Turn this on and rely on the standard mute
5754 * methods whenever the user wants to turn these outputs off.
5755 */
5756 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5757 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5758 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5759 /* Internal speaker/Headphone jack is connected to Line-out pin */
5760 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5761 /* Internal microphone/Mic jack is connected to Mic1 pin */
5762 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5763 /* Line In jack is connected to Line1 pin */
5764 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005765 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5766 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005767 /* Ensure all other unused pins are disabled and muted. */
5768 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5769 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005770 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5771 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5772 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5773 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5774 /* Disable digital (SPDIF) pins */
5775 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5776 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5777
Kailang Yangea1fb292008-08-26 12:58:38 +02005778 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005779 * bus when acting as outputs.
5780 */
5781 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5782 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5783
5784 /* Start with output sum widgets muted and their output gains at min */
5785 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5786 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5787 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5788 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5789 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5790 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5791 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5792 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5793 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5794
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005795 /* Unmute Line-out pin widget amp left and right
5796 * (no equiv mixer ctrl)
5797 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005798 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005799 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5800 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005801 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5802 * inputs. If the pin mode is changed by the user the pin mode control
5803 * will take care of enabling the pin's input/output buffers as needed.
5804 * Therefore there's no need to enable the input buffer at this
5805 * stage.
5806 */
5807 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5808 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5809
5810 /* Mute capture amp left and right */
5811 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5812 /* Set ADC connection select to match default mixer setting - mic
5813 * (on mic1 pin)
5814 */
5815 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5816
5817 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005818 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005819 */
5820 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005821 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005822
5823 /* Mute all inputs to mixer widget (even unconnected ones) */
5824 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5825 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5826 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5827 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5828 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5829 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5830 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5831 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5832
5833 { }
5834};
5835
Michael Schwingencc959482009-02-22 18:58:45 +01005836/* Initialisation sequence for Maxdata Favorit 100XS
5837 * (adapted from Acer init verbs).
5838 */
5839static struct hda_verb alc260_favorit100_init_verbs[] = {
5840 /* GPIO 0 enables the output jack.
5841 * Turn this on and rely on the standard mute
5842 * methods whenever the user wants to turn these outputs off.
5843 */
5844 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5845 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5846 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5847 /* Line/Mic input jack is connected to Mic1 pin */
5848 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5849 /* Ensure all other unused pins are disabled and muted. */
5850 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5851 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5852 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5853 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5854 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5855 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5856 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5857 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5858 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5859 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5860 /* Disable digital (SPDIF) pins */
5861 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5862 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5863
5864 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5865 * bus when acting as outputs.
5866 */
5867 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5868 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5869
5870 /* Start with output sum widgets muted and their output gains at min */
5871 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5872 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5873 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5874 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5875 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5876 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5877 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5878 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5879 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5880
5881 /* Unmute Line-out pin widget amp left and right
5882 * (no equiv mixer ctrl)
5883 */
5884 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5885 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5886 * inputs. If the pin mode is changed by the user the pin mode control
5887 * will take care of enabling the pin's input/output buffers as needed.
5888 * Therefore there's no need to enable the input buffer at this
5889 * stage.
5890 */
5891 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5892
5893 /* Mute capture amp left and right */
5894 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5895 /* Set ADC connection select to match default mixer setting - mic
5896 * (on mic1 pin)
5897 */
5898 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5899
5900 /* Do similar with the second ADC: mute capture input amp and
5901 * set ADC connection to mic to match ALSA's default state.
5902 */
5903 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5904 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5905
5906 /* Mute all inputs to mixer widget (even unconnected ones) */
5907 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5908 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5909 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5910 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5911 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5912 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5913 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5914 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5915
5916 { }
5917};
5918
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005919static struct hda_verb alc260_will_verbs[] = {
5920 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5921 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5922 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5923 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5924 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5925 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5926 {}
5927};
5928
5929static struct hda_verb alc260_replacer_672v_verbs[] = {
5930 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5931 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5932 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5933
5934 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5935 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5936 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5937
5938 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5939 {}
5940};
5941
5942/* toggle speaker-output according to the hp-jack state */
5943static void alc260_replacer_672v_automute(struct hda_codec *codec)
5944{
5945 unsigned int present;
5946
5947 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08005948 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005949 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005950 snd_hda_codec_write_cache(codec, 0x01, 0,
5951 AC_VERB_SET_GPIO_DATA, 1);
5952 snd_hda_codec_write_cache(codec, 0x0f, 0,
5953 AC_VERB_SET_PIN_WIDGET_CONTROL,
5954 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005955 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005956 snd_hda_codec_write_cache(codec, 0x01, 0,
5957 AC_VERB_SET_GPIO_DATA, 0);
5958 snd_hda_codec_write_cache(codec, 0x0f, 0,
5959 AC_VERB_SET_PIN_WIDGET_CONTROL,
5960 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005961 }
5962}
5963
5964static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5965 unsigned int res)
5966{
5967 if ((res >> 26) == ALC880_HP_EVENT)
5968 alc260_replacer_672v_automute(codec);
5969}
5970
Kailang Yang3f878302008-08-26 13:02:23 +02005971static struct hda_verb alc260_hp_dc7600_verbs[] = {
5972 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5973 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5974 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5975 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5976 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5977 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5978 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5979 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5980 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5981 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5982 {}
5983};
5984
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005985/* Test configuration for debugging, modelled after the ALC880 test
5986 * configuration.
5987 */
5988#ifdef CONFIG_SND_DEBUG
5989static hda_nid_t alc260_test_dac_nids[1] = {
5990 0x02,
5991};
5992static hda_nid_t alc260_test_adc_nids[2] = {
5993 0x04, 0x05,
5994};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005995/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005996 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005997 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005998 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005999static struct hda_input_mux alc260_test_capture_sources[2] = {
6000 {
6001 .num_items = 7,
6002 .items = {
6003 { "MIC1 pin", 0x0 },
6004 { "MIC2 pin", 0x1 },
6005 { "LINE1 pin", 0x2 },
6006 { "LINE2 pin", 0x3 },
6007 { "CD pin", 0x4 },
6008 { "LINE-OUT pin", 0x5 },
6009 { "HP-OUT pin", 0x6 },
6010 },
6011 },
6012 {
6013 .num_items = 8,
6014 .items = {
6015 { "MIC1 pin", 0x0 },
6016 { "MIC2 pin", 0x1 },
6017 { "LINE1 pin", 0x2 },
6018 { "LINE2 pin", 0x3 },
6019 { "CD pin", 0x4 },
6020 { "Mixer", 0x5 },
6021 { "LINE-OUT pin", 0x6 },
6022 { "HP-OUT pin", 0x7 },
6023 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006024 },
6025};
6026static struct snd_kcontrol_new alc260_test_mixer[] = {
6027 /* Output driver widgets */
6028 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6029 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6030 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6031 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6032 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6033 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6034
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006035 /* Modes for retasking pin widgets
6036 * Note: the ALC260 doesn't seem to act on requests to enable mic
6037 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6038 * mention this restriction. At this stage it's not clear whether
6039 * this behaviour is intentional or is a hardware bug in chip
6040 * revisions available at least up until early 2006. Therefore for
6041 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6042 * choices, but if it turns out that the lack of mic bias for these
6043 * NIDs is intentional we could change their modes from
6044 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6045 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006046 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6047 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6048 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6049 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6050 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6051 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6052
6053 /* Loopback mixer controls */
6054 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6055 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6056 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6057 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6058 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6059 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6060 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6061 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6062 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6063 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006064 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6065 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6066 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6067 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006068
6069 /* Controls for GPIO pins, assuming they are configured as outputs */
6070 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6071 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6072 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6073 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6074
Jonathan Woithe92621f12006-02-28 11:47:47 +01006075 /* Switches to allow the digital IO pins to be enabled. The datasheet
6076 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006077 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006078 */
6079 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6080 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6081
Jonathan Woithef8225f62008-01-08 12:16:54 +01006082 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6083 * this output to turn on an external amplifier.
6084 */
6085 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6086 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6087
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006088 { } /* end */
6089};
6090static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006091 /* Enable all GPIOs as outputs with an initial value of 0 */
6092 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6093 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6094 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6095
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006096 /* Enable retasking pins as output, initially without power amp */
6097 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6098 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6099 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6100 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6101 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6102 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6103
Jonathan Woithe92621f12006-02-28 11:47:47 +01006104 /* Disable digital (SPDIF) pins initially, but users can enable
6105 * them via a mixer switch. In the case of SPDIF-out, this initverb
6106 * payload also sets the generation to 0, output to be in "consumer"
6107 * PCM format, copyright asserted, no pre-emphasis and no validity
6108 * control.
6109 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006110 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6111 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6112
Kailang Yangea1fb292008-08-26 12:58:38 +02006113 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006114 * OUT1 sum bus when acting as an output.
6115 */
6116 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6117 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6118 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6119 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6120
6121 /* Start with output sum widgets muted and their output gains at min */
6122 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6123 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6124 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6125 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6126 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6127 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6128 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6129 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6130 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6131
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006132 /* Unmute retasking pin widget output buffers since the default
6133 * state appears to be output. As the pin mode is changed by the
6134 * user the pin mode control will take care of enabling the pin's
6135 * input/output buffers as needed.
6136 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006137 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6138 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6139 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6140 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6141 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6142 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6143 /* Also unmute the mono-out pin widget */
6144 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6145
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006146 /* Mute capture amp left and right */
6147 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006148 /* Set ADC connection select to match default mixer setting (mic1
6149 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006150 */
6151 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6152
6153 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006154 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006155 */
6156 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6157 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6158
6159 /* Mute all inputs to mixer widget (even unconnected ones) */
6160 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6161 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6162 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6163 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6164 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6165 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6166 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6167 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6168
6169 { }
6170};
6171#endif
6172
Takashi Iwai63300792008-01-24 15:31:36 +01006173#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6174#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006175
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006176#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6177#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6178
Kailang Yangdf694da2005-12-05 19:42:22 +01006179/*
6180 * for BIOS auto-configuration
6181 */
6182
6183static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006184 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006185{
6186 hda_nid_t nid_vol;
6187 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006188 int err;
6189
6190 if (nid >= 0x0f && nid < 0x11) {
6191 nid_vol = nid - 0x7;
6192 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6193 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6194 } else if (nid == 0x11) {
6195 nid_vol = nid - 0x7;
6196 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6197 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6198 } else if (nid >= 0x12 && nid <= 0x15) {
6199 nid_vol = 0x08;
6200 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6201 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6202 } else
6203 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006204
Takashi Iwai863b4512008-10-21 17:01:47 +02006205 if (!(*vol_bits & (1 << nid_vol))) {
6206 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006207 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006208 if (err < 0)
6209 return err;
6210 *vol_bits |= (1 << nid_vol);
6211 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006212 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006213 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006214 return err;
6215 return 1;
6216}
6217
6218/* add playback controls from the parsed DAC table */
6219static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6220 const struct auto_pin_cfg *cfg)
6221{
6222 hda_nid_t nid;
6223 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006224 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006225
6226 spec->multiout.num_dacs = 1;
6227 spec->multiout.dac_nids = spec->private_dac_nids;
6228 spec->multiout.dac_nids[0] = 0x02;
6229
6230 nid = cfg->line_out_pins[0];
6231 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006232 const char *pfx;
6233 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6234 pfx = "Master";
6235 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6236 pfx = "Speaker";
6237 else
6238 pfx = "Front";
6239 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006240 if (err < 0)
6241 return err;
6242 }
6243
Takashi Iwai82bc9552006-03-21 11:24:42 +01006244 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006245 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006246 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006247 if (err < 0)
6248 return err;
6249 }
6250
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006251 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006252 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006253 err = alc260_add_playback_controls(spec, nid, "Headphone",
6254 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006255 if (err < 0)
6256 return err;
6257 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006258 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006259}
6260
6261/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006262static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006263 const struct auto_pin_cfg *cfg)
6264{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006265 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006266}
6267
6268static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6269 hda_nid_t nid, int pin_type,
6270 int sel_idx)
6271{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006272 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006273 /* need the manual connection? */
6274 if (nid >= 0x12) {
6275 int idx = nid - 0x12;
6276 snd_hda_codec_write(codec, idx + 0x0b, 0,
6277 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006278 }
6279}
6280
6281static void alc260_auto_init_multi_out(struct hda_codec *codec)
6282{
6283 struct alc_spec *spec = codec->spec;
6284 hda_nid_t nid;
6285
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006286 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006287 if (nid) {
6288 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6289 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6290 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006291
Takashi Iwai82bc9552006-03-21 11:24:42 +01006292 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006293 if (nid)
6294 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6295
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006296 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006297 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006298 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006299}
Kailang Yangdf694da2005-12-05 19:42:22 +01006300
6301#define ALC260_PIN_CD_NID 0x16
6302static void alc260_auto_init_analog_input(struct hda_codec *codec)
6303{
6304 struct alc_spec *spec = codec->spec;
6305 int i;
6306
6307 for (i = 0; i < AUTO_PIN_LAST; i++) {
6308 hda_nid_t nid = spec->autocfg.input_pins[i];
6309 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006310 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006311 if (nid != ALC260_PIN_CD_NID &&
6312 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006313 snd_hda_codec_write(codec, nid, 0,
6314 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006315 AMP_OUT_MUTE);
6316 }
6317 }
6318}
6319
6320/*
6321 * generic initialization of ADC, input mixers and output mixers
6322 */
6323static struct hda_verb alc260_volume_init_verbs[] = {
6324 /*
6325 * Unmute ADC0-1 and set the default input to mic-in
6326 */
6327 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6328 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6329 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6330 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006331
Kailang Yangdf694da2005-12-05 19:42:22 +01006332 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6333 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006334 * Note: PASD motherboards uses the Line In 2 as the input for
6335 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006336 */
6337 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006338 /* mute analog inputs */
6339 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6340 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6341 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6342 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6343 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006344
6345 /*
6346 * Set up output mixers (0x08 - 0x0a)
6347 */
6348 /* set vol=0 to output mixers */
6349 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6350 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6351 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6352 /* set up input amps for analog loopback */
6353 /* Amp Indices: DAC = 0, mixer = 1 */
6354 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6355 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6356 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6357 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6358 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6359 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006360
Kailang Yangdf694da2005-12-05 19:42:22 +01006361 { }
6362};
6363
6364static int alc260_parse_auto_config(struct hda_codec *codec)
6365{
6366 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006367 int err;
6368 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6369
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006370 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6371 alc260_ignore);
6372 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006373 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006374 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6375 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006376 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006377 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006378 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006379 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006380 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006381 return err;
6382
6383 spec->multiout.max_channels = 2;
6384
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006385 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006386 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006387 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006388 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006389
Takashi Iwaid88897e2008-10-31 15:01:37 +01006390 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006391
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006392 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006393 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006394
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006395 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6396
Kailang Yangdf694da2005-12-05 19:42:22 +01006397 return 1;
6398}
6399
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006400/* additional initialization for auto-configuration model */
6401static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006402{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006403 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006404 alc260_auto_init_multi_out(codec);
6405 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006406 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006407 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006408}
6409
Takashi Iwaicb53c622007-08-10 17:21:45 +02006410#ifdef CONFIG_SND_HDA_POWER_SAVE
6411static struct hda_amp_list alc260_loopbacks[] = {
6412 { 0x07, HDA_INPUT, 0 },
6413 { 0x07, HDA_INPUT, 1 },
6414 { 0x07, HDA_INPUT, 2 },
6415 { 0x07, HDA_INPUT, 3 },
6416 { 0x07, HDA_INPUT, 4 },
6417 { } /* end */
6418};
6419#endif
6420
Kailang Yangdf694da2005-12-05 19:42:22 +01006421/*
6422 * ALC260 configurations
6423 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006424static const char *alc260_models[ALC260_MODEL_LAST] = {
6425 [ALC260_BASIC] = "basic",
6426 [ALC260_HP] = "hp",
6427 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006428 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006429 [ALC260_FUJITSU_S702X] = "fujitsu",
6430 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006431 [ALC260_WILL] = "will",
6432 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006433 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006434#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006435 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006436#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006437 [ALC260_AUTO] = "auto",
6438};
6439
6440static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006441 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006442 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006443 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006444 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006445 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006446 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006447 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006448 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006449 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006450 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6451 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6452 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6453 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6454 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6455 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6456 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6457 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6458 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006459 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006460 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006461 {}
6462};
6463
Kailang Yangdf694da2005-12-05 19:42:22 +01006464static struct alc_config_preset alc260_presets[] = {
6465 [ALC260_BASIC] = {
6466 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006467 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006468 .init_verbs = { alc260_init_verbs },
6469 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6470 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006471 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006472 .adc_nids = alc260_adc_nids,
6473 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6474 .channel_mode = alc260_modes,
6475 .input_mux = &alc260_capture_source,
6476 },
6477 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006478 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006479 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006480 .init_verbs = { alc260_init_verbs,
6481 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006482 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6483 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006484 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6485 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006486 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6487 .channel_mode = alc260_modes,
6488 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006489 .unsol_event = alc260_hp_unsol_event,
6490 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006491 },
Kailang Yang3f878302008-08-26 13:02:23 +02006492 [ALC260_HP_DC7600] = {
6493 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006494 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006495 .init_verbs = { alc260_init_verbs,
6496 alc260_hp_dc7600_verbs },
6497 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6498 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006499 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6500 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006501 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6502 .channel_mode = alc260_modes,
6503 .input_mux = &alc260_capture_source,
6504 .unsol_event = alc260_hp_3012_unsol_event,
6505 .init_hook = alc260_hp_3012_automute,
6506 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006507 [ALC260_HP_3013] = {
6508 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006509 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006510 .init_verbs = { alc260_hp_3013_init_verbs,
6511 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006512 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6513 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006514 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6515 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006516 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6517 .channel_mode = alc260_modes,
6518 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006519 .unsol_event = alc260_hp_3013_unsol_event,
6520 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006521 },
6522 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006523 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006524 .init_verbs = { alc260_fujitsu_init_verbs },
6525 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6526 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006527 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6528 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006529 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6530 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006531 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6532 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006533 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006534 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006535 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006536 .init_verbs = { alc260_acer_init_verbs },
6537 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6538 .dac_nids = alc260_dac_nids,
6539 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6540 .adc_nids = alc260_dual_adc_nids,
6541 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6542 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006543 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6544 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006545 },
Michael Schwingencc959482009-02-22 18:58:45 +01006546 [ALC260_FAVORIT100] = {
6547 .mixers = { alc260_favorit100_mixer },
6548 .init_verbs = { alc260_favorit100_init_verbs },
6549 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6550 .dac_nids = alc260_dac_nids,
6551 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6552 .adc_nids = alc260_dual_adc_nids,
6553 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6554 .channel_mode = alc260_modes,
6555 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6556 .input_mux = alc260_favorit100_capture_sources,
6557 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006558 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006559 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006560 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6561 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6562 .dac_nids = alc260_dac_nids,
6563 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6564 .adc_nids = alc260_adc_nids,
6565 .dig_out_nid = ALC260_DIGOUT_NID,
6566 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6567 .channel_mode = alc260_modes,
6568 .input_mux = &alc260_capture_source,
6569 },
6570 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006571 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006572 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6573 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6574 .dac_nids = alc260_dac_nids,
6575 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6576 .adc_nids = alc260_adc_nids,
6577 .dig_out_nid = ALC260_DIGOUT_NID,
6578 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6579 .channel_mode = alc260_modes,
6580 .input_mux = &alc260_capture_source,
6581 .unsol_event = alc260_replacer_672v_unsol_event,
6582 .init_hook = alc260_replacer_672v_automute,
6583 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006584#ifdef CONFIG_SND_DEBUG
6585 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006586 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006587 .init_verbs = { alc260_test_init_verbs },
6588 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6589 .dac_nids = alc260_test_dac_nids,
6590 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6591 .adc_nids = alc260_test_adc_nids,
6592 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6593 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006594 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6595 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006596 },
6597#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006598};
6599
Linus Torvalds1da177e2005-04-16 15:20:36 -07006600static int patch_alc260(struct hda_codec *codec)
6601{
6602 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006603 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006604
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006605 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006606 if (spec == NULL)
6607 return -ENOMEM;
6608
6609 codec->spec = spec;
6610
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006611 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6612 alc260_models,
6613 alc260_cfg_tbl);
6614 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006615 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006616 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006617 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006618 }
6619
Kailang Yangdf694da2005-12-05 19:42:22 +01006620 if (board_config == ALC260_AUTO) {
6621 /* automatic parse from the BIOS config */
6622 err = alc260_parse_auto_config(codec);
6623 if (err < 0) {
6624 alc_free(codec);
6625 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006626 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006627 printk(KERN_INFO
6628 "hda_codec: Cannot set up configuration "
6629 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006630 board_config = ALC260_BASIC;
6631 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006632 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006633
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006634 err = snd_hda_attach_beep_device(codec, 0x1);
6635 if (err < 0) {
6636 alc_free(codec);
6637 return err;
6638 }
6639
Kailang Yangdf694da2005-12-05 19:42:22 +01006640 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006641 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006642
Linus Torvalds1da177e2005-04-16 15:20:36 -07006643 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6644 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6645
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006646 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6647 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6648
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006649 if (!spec->adc_nids && spec->input_mux) {
6650 /* check whether NID 0x04 is valid */
6651 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006652 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006653 /* get type */
6654 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6655 spec->adc_nids = alc260_adc_nids_alt;
6656 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6657 } else {
6658 spec->adc_nids = alc260_adc_nids;
6659 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6660 }
6661 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006662 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006663 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006664
Takashi Iwai2134ea42008-01-10 16:53:55 +01006665 spec->vmaster_nid = 0x08;
6666
Linus Torvalds1da177e2005-04-16 15:20:36 -07006667 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006668 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006669 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006670#ifdef CONFIG_SND_HDA_POWER_SAVE
6671 if (!spec->loopback.amplist)
6672 spec->loopback.amplist = alc260_loopbacks;
6673#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006674
6675 return 0;
6676}
6677
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006678
Linus Torvalds1da177e2005-04-16 15:20:36 -07006679/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006680 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006681 *
6682 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6683 * configuration. Each pin widget can choose any input DACs and a mixer.
6684 * Each ADC is connected from a mixer of all inputs. This makes possible
6685 * 6-channel independent captures.
6686 *
6687 * In addition, an independent DAC for the multi-playback (not used in this
6688 * driver yet).
6689 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006690#define ALC882_DIGOUT_NID 0x06
6691#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006692#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6693#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6694#define ALC1200_DIGOUT_NID 0x10
6695
Linus Torvalds1da177e2005-04-16 15:20:36 -07006696
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006697static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006698 { 8, NULL }
6699};
6700
Takashi Iwai4953550a2009-06-30 15:28:30 +02006701/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006702static hda_nid_t alc882_dac_nids[4] = {
6703 /* front, rear, clfe, rear_surr */
6704 0x02, 0x03, 0x04, 0x05
6705};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006706#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006707
Takashi Iwai4953550a2009-06-30 15:28:30 +02006708/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006709#define alc882_adc_nids alc880_adc_nids
6710#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006711#define alc883_adc_nids alc882_adc_nids_alt
6712static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6713static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6714#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006715
Takashi Iwaie1406342008-02-11 18:32:32 +01006716static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6717static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006718#define alc883_capsrc_nids alc882_capsrc_nids_alt
6719static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6720#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006721
Linus Torvalds1da177e2005-04-16 15:20:36 -07006722/* input MUX */
6723/* FIXME: should be a matrix-type input source selection */
6724
6725static struct hda_input_mux alc882_capture_source = {
6726 .num_items = 4,
6727 .items = {
6728 { "Mic", 0x0 },
6729 { "Front Mic", 0x1 },
6730 { "Line", 0x2 },
6731 { "CD", 0x4 },
6732 },
6733};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006734
Takashi Iwai4953550a2009-06-30 15:28:30 +02006735#define alc883_capture_source alc882_capture_source
6736
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006737static struct hda_input_mux alc889_capture_source = {
6738 .num_items = 3,
6739 .items = {
6740 { "Front Mic", 0x0 },
6741 { "Mic", 0x3 },
6742 { "Line", 0x2 },
6743 },
6744};
6745
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006746static struct hda_input_mux mb5_capture_source = {
6747 .num_items = 3,
6748 .items = {
6749 { "Mic", 0x1 },
6750 { "Line", 0x2 },
6751 { "CD", 0x4 },
6752 },
6753};
6754
Luke Yelaviche458b1f2010-02-12 16:28:29 +11006755static struct hda_input_mux macmini3_capture_source = {
6756 .num_items = 2,
6757 .items = {
6758 { "Line", 0x2 },
6759 { "CD", 0x4 },
6760 },
6761};
6762
Takashi Iwai4953550a2009-06-30 15:28:30 +02006763static struct hda_input_mux alc883_3stack_6ch_intel = {
6764 .num_items = 4,
6765 .items = {
6766 { "Mic", 0x1 },
6767 { "Front Mic", 0x0 },
6768 { "Line", 0x2 },
6769 { "CD", 0x4 },
6770 },
6771};
6772
6773static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6774 .num_items = 2,
6775 .items = {
6776 { "Mic", 0x1 },
6777 { "Line", 0x2 },
6778 },
6779};
6780
6781static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6782 .num_items = 4,
6783 .items = {
6784 { "Mic", 0x0 },
6785 { "iMic", 0x1 },
6786 { "Line", 0x2 },
6787 { "CD", 0x4 },
6788 },
6789};
6790
6791static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6792 .num_items = 2,
6793 .items = {
6794 { "Mic", 0x0 },
6795 { "Int Mic", 0x1 },
6796 },
6797};
6798
6799static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6800 .num_items = 3,
6801 .items = {
6802 { "Mic", 0x0 },
6803 { "Front Mic", 0x1 },
6804 { "Line", 0x4 },
6805 },
6806};
6807
6808static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6809 .num_items = 2,
6810 .items = {
6811 { "Mic", 0x0 },
6812 { "Line", 0x2 },
6813 },
6814};
6815
6816static struct hda_input_mux alc889A_mb31_capture_source = {
6817 .num_items = 2,
6818 .items = {
6819 { "Mic", 0x0 },
6820 /* Front Mic (0x01) unused */
6821 { "Line", 0x2 },
6822 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02006823 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006824 },
6825};
6826
6827/*
6828 * 2ch mode
6829 */
6830static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6831 { 2, NULL }
6832};
6833
Kailang Yangdf694da2005-12-05 19:42:22 +01006834/*
Kailang Yang272a5272007-05-14 11:00:38 +02006835 * 2ch mode
6836 */
6837static struct hda_verb alc882_3ST_ch2_init[] = {
6838 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6839 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6840 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6841 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6842 { } /* end */
6843};
6844
6845/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006846 * 4ch mode
6847 */
6848static struct hda_verb alc882_3ST_ch4_init[] = {
6849 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6850 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6851 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6852 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6853 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6854 { } /* end */
6855};
6856
6857/*
Kailang Yang272a5272007-05-14 11:00:38 +02006858 * 6ch mode
6859 */
6860static struct hda_verb alc882_3ST_ch6_init[] = {
6861 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6862 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6863 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6864 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6865 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6866 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6867 { } /* end */
6868};
6869
Takashi Iwai4953550a2009-06-30 15:28:30 +02006870static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006871 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006872 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006873 { 6, alc882_3ST_ch6_init },
6874};
6875
Takashi Iwai4953550a2009-06-30 15:28:30 +02006876#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6877
Kailang Yang272a5272007-05-14 11:00:38 +02006878/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04306879 * 2ch mode
6880 */
6881static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6882 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6883 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6884 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6885 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6886 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6887 { } /* end */
6888};
6889
6890/*
6891 * 4ch mode
6892 */
6893static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
6894 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6895 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6896 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6897 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6898 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6899 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6900 { } /* end */
6901};
6902
6903/*
6904 * 6ch mode
6905 */
6906static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
6907 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6908 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6909 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6910 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6911 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6912 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6913 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6914 { } /* end */
6915};
6916
6917static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
6918 { 2, alc883_3ST_ch2_clevo_init },
6919 { 4, alc883_3ST_ch4_clevo_init },
6920 { 6, alc883_3ST_ch6_clevo_init },
6921};
6922
6923
6924/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006925 * 6ch mode
6926 */
6927static struct hda_verb alc882_sixstack_ch6_init[] = {
6928 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6929 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6930 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6931 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6932 { } /* end */
6933};
6934
6935/*
6936 * 8ch mode
6937 */
6938static struct hda_verb alc882_sixstack_ch8_init[] = {
6939 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6940 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6941 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6942 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6943 { } /* end */
6944};
6945
6946static struct hda_channel_mode alc882_sixstack_modes[2] = {
6947 { 6, alc882_sixstack_ch6_init },
6948 { 8, alc882_sixstack_ch8_init },
6949};
6950
Takashi Iwai87350ad2007-08-16 18:19:38 +02006951/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006952 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006953 */
6954
6955/*
6956 * 2ch mode
6957 */
6958static struct hda_verb alc885_mbp_ch2_init[] = {
6959 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6960 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6961 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6962 { } /* end */
6963};
6964
6965/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006966 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02006967 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006968static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006969 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6970 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6971 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6972 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6973 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6974 { } /* end */
6975};
6976
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006977static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006978 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006979 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006980};
6981
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006982/*
6983 * 2ch
6984 * Speakers/Woofer/HP = Front
6985 * LineIn = Input
6986 */
6987static struct hda_verb alc885_mb5_ch2_init[] = {
6988 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6989 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6990 { } /* end */
6991};
6992
6993/*
6994 * 6ch mode
6995 * Speakers/HP = Front
6996 * Woofer = LFE
6997 * LineIn = Surround
6998 */
6999static struct hda_verb alc885_mb5_ch6_init[] = {
7000 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7001 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7002 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7003 { } /* end */
7004};
7005
7006static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7007 { 2, alc885_mb5_ch2_init },
7008 { 6, alc885_mb5_ch6_init },
7009};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007010
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007011/*
7012 * 2ch
7013 * Speakers/Woofer/HP = Front
7014 * LineIn = Input
7015 */
7016static struct hda_verb alc885_macmini3_ch2_init[] = {
7017 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7018 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7019 { } /* end */
7020};
7021
7022/*
7023 * 6ch mode
7024 * Speakers/HP = Front
7025 * Woofer = LFE
7026 * LineIn = Surround
7027 */
7028static struct hda_verb alc885_macmini3_ch6_init[] = {
7029 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7030 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7031 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7032 { } /* end */
7033};
7034
7035static struct hda_channel_mode alc885_macmini3_6ch_modes[2] = {
7036 { 2, alc885_mb5_ch2_init },
7037 { 6, alc885_mb5_ch6_init },
7038};
7039
Takashi Iwai4953550a2009-06-30 15:28:30 +02007040
7041/*
7042 * 2ch mode
7043 */
7044static struct hda_verb alc883_4ST_ch2_init[] = {
7045 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7046 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7047 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7048 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7049 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7050 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7051 { } /* end */
7052};
7053
7054/*
7055 * 4ch mode
7056 */
7057static struct hda_verb alc883_4ST_ch4_init[] = {
7058 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7059 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7060 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7061 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7062 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7063 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7064 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7065 { } /* end */
7066};
7067
7068/*
7069 * 6ch mode
7070 */
7071static struct hda_verb alc883_4ST_ch6_init[] = {
7072 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7073 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7074 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7075 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7076 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7077 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7078 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7079 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7080 { } /* end */
7081};
7082
7083/*
7084 * 8ch mode
7085 */
7086static struct hda_verb alc883_4ST_ch8_init[] = {
7087 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7088 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7089 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7090 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7091 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7092 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7093 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7094 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7095 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7096 { } /* end */
7097};
7098
7099static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7100 { 2, alc883_4ST_ch2_init },
7101 { 4, alc883_4ST_ch4_init },
7102 { 6, alc883_4ST_ch6_init },
7103 { 8, alc883_4ST_ch8_init },
7104};
7105
7106
7107/*
7108 * 2ch mode
7109 */
7110static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7111 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7112 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7113 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7114 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7115 { } /* end */
7116};
7117
7118/*
7119 * 4ch mode
7120 */
7121static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7122 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7123 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7124 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7125 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7126 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7127 { } /* end */
7128};
7129
7130/*
7131 * 6ch mode
7132 */
7133static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7134 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7135 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7136 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7137 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7138 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7139 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7140 { } /* end */
7141};
7142
7143static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7144 { 2, alc883_3ST_ch2_intel_init },
7145 { 4, alc883_3ST_ch4_intel_init },
7146 { 6, alc883_3ST_ch6_intel_init },
7147};
7148
7149/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007150 * 2ch mode
7151 */
7152static struct hda_verb alc889_ch2_intel_init[] = {
7153 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7154 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7155 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7156 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7157 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7158 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7159 { } /* end */
7160};
7161
7162/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007163 * 6ch mode
7164 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007165static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007166 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7167 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7168 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7169 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7170 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007171 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7172 { } /* end */
7173};
7174
7175/*
7176 * 8ch mode
7177 */
7178static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007179 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7180 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7181 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7182 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7183 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007184 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7185 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007186 { } /* end */
7187};
7188
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007189static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7190 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007191 { 6, alc889_ch6_intel_init },
7192 { 8, alc889_ch8_intel_init },
7193};
7194
7195/*
7196 * 6ch mode
7197 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007198static struct hda_verb alc883_sixstack_ch6_init[] = {
7199 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7200 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7201 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7202 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7203 { } /* end */
7204};
7205
7206/*
7207 * 8ch mode
7208 */
7209static struct hda_verb alc883_sixstack_ch8_init[] = {
7210 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7211 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7212 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7213 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7214 { } /* end */
7215};
7216
7217static struct hda_channel_mode alc883_sixstack_modes[2] = {
7218 { 6, alc883_sixstack_ch6_init },
7219 { 8, alc883_sixstack_ch8_init },
7220};
7221
7222
Linus Torvalds1da177e2005-04-16 15:20:36 -07007223/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7224 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7225 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007226static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007227 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007228 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007229 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007230 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007231 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7232 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007233 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7234 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007235 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007236 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007237 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7238 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7239 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7240 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7241 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7242 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007243 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007244 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7245 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007246 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007247 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007248 { } /* end */
7249};
7250
Takashi Iwai87350ad2007-08-16 18:19:38 +02007251static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007252 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7253 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7254 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7255 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7256 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007257 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7258 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007259 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7260 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007261 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007262 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7263 { } /* end */
7264};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007265
7266static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007267 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7268 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7269 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7270 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7271 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7272 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307273 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7274 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007275 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7276 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7277 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7278 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7279 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7280 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7281 { } /* end */
7282};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007283
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007284static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7285 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7286 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7287 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7288 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7289 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7290 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7291 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7292 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7293 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7294 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7295 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7296 { } /* end */
7297};
7298
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007299static struct snd_kcontrol_new alc885_imac91_mixer[] = {
7300 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7301 HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
7302 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
7303 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7304 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7305 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7306 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7307 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7308 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7309 { } /* end */
7310};
7311
7312
Kailang Yangbdd148a2007-05-08 15:19:08 +02007313static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7314 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7315 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7316 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7317 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7318 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7319 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7320 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7321 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7322 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007323 { } /* end */
7324};
7325
Kailang Yang272a5272007-05-14 11:00:38 +02007326static struct snd_kcontrol_new alc882_targa_mixer[] = {
7327 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7328 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7329 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7330 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7331 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7332 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7333 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7334 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7335 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007336 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007337 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7338 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007339 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007340 { } /* end */
7341};
7342
7343/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7344 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7345 */
7346static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7347 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7348 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7349 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7350 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7351 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7352 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7353 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7354 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7355 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7356 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7357 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7358 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007359 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007360 { } /* end */
7361};
7362
Takashi Iwai914759b2007-09-06 14:52:04 +02007363static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7364 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7365 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7366 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7367 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7368 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7369 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7370 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7371 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7372 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7373 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007374 { } /* end */
7375};
7376
Kailang Yangdf694da2005-12-05 19:42:22 +01007377static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7378 {
7379 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7380 .name = "Channel Mode",
7381 .info = alc_ch_mode_info,
7382 .get = alc_ch_mode_get,
7383 .put = alc_ch_mode_put,
7384 },
7385 { } /* end */
7386};
7387
Takashi Iwai4953550a2009-06-30 15:28:30 +02007388static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007389 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007390 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7391 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007392 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007393 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7394 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007395 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007396 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7397 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007398 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007399 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7400 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007401
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007402 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007403 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007404 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007405 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007406 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007407 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007408 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007409 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007410 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007411 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007412 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007413 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007414 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007415 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007416 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007417 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007418 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007419 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007420 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7421 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007422 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007423 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7424 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007425 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007426 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7427 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7428 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7429 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7430 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007431 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007432 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007433
7434 /* FIXME: use matrix-type input source selection */
7435 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007436 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007437 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007438 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007439 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007440 /* ADC2: mute amp left and right */
7441 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007442 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007443 /* ADC3: mute amp left and right */
7444 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007445 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007446
7447 { }
7448};
7449
Takashi Iwai4953550a2009-06-30 15:28:30 +02007450static struct hda_verb alc882_adc1_init_verbs[] = {
7451 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7452 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7453 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7454 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7455 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7456 /* ADC1: mute amp left and right */
7457 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7458 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7459 { }
7460};
7461
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007462static struct hda_verb alc882_eapd_verbs[] = {
7463 /* change to EAPD mode */
7464 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007465 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007466 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007467};
7468
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007469static struct hda_verb alc889_eapd_verbs[] = {
7470 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7471 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7472 { }
7473};
7474
Wu Fengguang6732bd02009-07-30 09:19:14 +02007475static struct hda_verb alc_hp15_unsol_verbs[] = {
7476 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7477 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7478 {}
7479};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007480
7481static struct hda_verb alc885_init_verbs[] = {
7482 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01007483 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7484 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007485 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007486 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7487 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007488 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007489 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7490 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007491 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007492 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7493 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007494
7495 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007496 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007497 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7498 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7499 /* Front Pin: output 0 (0x0c) */
7500 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7501 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7502 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7503 /* Rear Pin: output 1 (0x0d) */
7504 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7505 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7506 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7507 /* CLFE Pin: output 2 (0x0e) */
7508 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7509 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7510 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7511 /* Side Pin: output 3 (0x0f) */
7512 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7513 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7514 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7515 /* Mic (rear) pin: input vref at 80% */
7516 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7517 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7518 /* Front Mic pin: input vref at 80% */
7519 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7520 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7521 /* Line In pin: input */
7522 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7523 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7524
7525 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7526 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01007527 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007528 /* Input mixer2 */
7529 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007530 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01007531 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007532 /* ADC2: mute amp left and right */
7533 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7534 /* ADC3: mute amp left and right */
7535 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7536
7537 { }
7538};
7539
7540static struct hda_verb alc885_init_input_verbs[] = {
7541 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7542 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7543 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7544 { }
7545};
7546
7547
7548/* Unmute Selector 24h and set the default input to front mic */
7549static struct hda_verb alc889_init_input_verbs[] = {
7550 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7551 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7552 { }
7553};
7554
7555
Takashi Iwai4953550a2009-06-30 15:28:30 +02007556#define alc883_init_verbs alc882_base_init_verbs
7557
Tobin Davis9102cd12006-12-15 10:02:12 +01007558/* Mac Pro test */
7559static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7560 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7561 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7562 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7563 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7564 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007565 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007566 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7567 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007568 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007569 { } /* end */
7570};
7571
7572static struct hda_verb alc882_macpro_init_verbs[] = {
7573 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7574 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7575 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7576 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7577 /* Front Pin: output 0 (0x0c) */
7578 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7579 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7580 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7581 /* Front Mic pin: input vref at 80% */
7582 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7583 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7584 /* Speaker: output */
7585 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7586 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7587 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7588 /* Headphone output (output 0 - 0x0c) */
7589 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7590 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7591 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7592
7593 /* FIXME: use matrix-type input source selection */
7594 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7595 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7596 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7597 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7598 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7599 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7600 /* Input mixer2 */
7601 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7602 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7603 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7604 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7605 /* Input mixer3 */
7606 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7607 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7608 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7609 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7610 /* ADC1: mute amp left and right */
7611 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7612 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7613 /* ADC2: mute amp left and right */
7614 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7615 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7616 /* ADC3: mute amp left and right */
7617 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7618 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7619
7620 { }
7621};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007622
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007623/* Macbook 5,1 */
7624static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007625 /* DACs */
7626 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7627 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7628 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7629 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007630 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007631 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7632 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7633 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007634 /* Surround mixer */
7635 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7636 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7637 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7638 /* LFE mixer */
7639 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7640 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7641 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7642 /* HP mixer */
7643 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7644 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7645 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7646 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007647 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7648 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007649 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7650 /* LFE Pin (0x0e) */
7651 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7652 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7653 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7654 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007655 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7656 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007657 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10307658 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007659 /* Front Mic pin: input vref at 80% */
7660 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7661 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7662 /* Line In pin */
7663 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7664 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7665
7666 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7667 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7668 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7669 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7670 { }
7671};
7672
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007673/* Macmini 3,1 */
7674static struct hda_verb alc885_macmini3_init_verbs[] = {
7675 /* DACs */
7676 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7677 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7678 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7679 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7680 /* Front mixer */
7681 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7682 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7683 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7684 /* Surround mixer */
7685 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7686 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7687 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7688 /* LFE mixer */
7689 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7690 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7691 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7692 /* HP mixer */
7693 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7694 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7695 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7696 /* Front Pin (0x0c) */
7697 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7698 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7699 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7700 /* LFE Pin (0x0e) */
7701 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7702 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7703 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7704 /* HP Pin (0x0f) */
7705 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7706 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7707 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
7708 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7709 /* Line In pin */
7710 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7711 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7712
7713 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7714 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7715 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7716 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7717 { }
7718};
7719
Takashi Iwai87350ad2007-08-16 18:19:38 +02007720/* Macbook Pro rev3 */
7721static struct hda_verb alc885_mbp3_init_verbs[] = {
7722 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7723 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7724 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7725 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7726 /* Rear mixer */
7727 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7728 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7729 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007730 /* HP mixer */
7731 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7732 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7733 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007734 /* Front Pin: output 0 (0x0c) */
7735 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7736 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7737 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007738 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007739 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007740 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7741 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007742 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7743 /* Mic (rear) pin: input vref at 80% */
7744 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7745 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7746 /* Front Mic pin: input vref at 80% */
7747 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7748 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7749 /* Line In pin: use output 1 when in LineOut mode */
7750 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7751 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7752 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7753
7754 /* FIXME: use matrix-type input source selection */
7755 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7756 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7757 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7758 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7759 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7760 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7761 /* Input mixer2 */
7762 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7763 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7764 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7765 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7766 /* Input mixer3 */
7767 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7768 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7769 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7770 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7771 /* ADC1: mute amp left and right */
7772 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7773 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7774 /* ADC2: mute amp left and right */
7775 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7776 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7777 /* ADC3: mute amp left and right */
7778 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7779 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7780
7781 { }
7782};
7783
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007784/* iMac 9,1 */
7785static struct hda_verb alc885_imac91_init_verbs[] = {
7786 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
7787 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7788 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7789 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7790 /* Rear mixer */
7791 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7792 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7793 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7794 /* HP Pin: output 0 (0x0c) */
7795 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7796 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7797 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7798 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7799 /* Internal Speakers: output 0 (0x0d) */
7800 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7801 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7802 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7803 /* Mic (rear) pin: input vref at 80% */
7804 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7805 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7806 /* Front Mic pin: input vref at 80% */
7807 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7808 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7809 /* Line In pin: use output 1 when in LineOut mode */
7810 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7811 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7812 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7813
7814 /* FIXME: use matrix-type input source selection */
7815 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7816 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7817 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7818 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7819 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7820 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7821 /* Input mixer2 */
7822 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7823 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7824 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7825 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7826 /* Input mixer3 */
7827 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7828 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7829 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7830 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7831 /* ADC1: mute amp left and right */
7832 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7833 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7834 /* ADC2: mute amp left and right */
7835 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7836 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7837 /* ADC3: mute amp left and right */
7838 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7839 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7840
7841 { }
7842};
7843
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007844/* iMac 24 mixer. */
7845static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7846 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7847 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7848 { } /* end */
7849};
7850
7851/* iMac 24 init verbs. */
7852static struct hda_verb alc885_imac24_init_verbs[] = {
7853 /* Internal speakers: output 0 (0x0c) */
7854 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7855 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7856 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7857 /* Internal speakers: output 0 (0x0c) */
7858 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7859 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7860 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7861 /* Headphone: output 0 (0x0c) */
7862 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7863 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7864 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7865 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7866 /* Front Mic: input vref at 80% */
7867 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7868 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7869 { }
7870};
7871
7872/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007873static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007874{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007875 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007876
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007877 spec->autocfg.hp_pins[0] = 0x14;
7878 spec->autocfg.speaker_pins[0] = 0x18;
7879 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007880}
7881
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007882static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007883{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007884 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007885
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007886 spec->autocfg.hp_pins[0] = 0x15;
7887 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02007888}
7889
Alex Murraya76221d2010-01-13 23:15:03 +10307890static void alc885_mb5_automute(struct hda_codec *codec)
7891{
7892 unsigned int present;
7893
7894 present = snd_hda_codec_read(codec, 0x14, 0,
7895 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7896 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
7897 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7898 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
7899 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7900
7901}
7902
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007903static void alc885_macmini3_automute(struct hda_codec *codec)
7904{
7905 unsigned int present;
7906
7907 present = snd_hda_codec_read(codec, 0x14, 0,
7908 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7909 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
7910 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7911 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
7912 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7913}
7914
Alex Murraya76221d2010-01-13 23:15:03 +10307915static void alc885_mb5_unsol_event(struct hda_codec *codec,
7916 unsigned int res)
7917{
7918 /* Headphone insertion or removal. */
7919 if ((res >> 26) == ALC880_HP_EVENT)
7920 alc885_mb5_automute(codec);
7921}
7922
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007923static void alc885_macmini3_unsol_event(struct hda_codec *codec,
7924 unsigned int res)
7925{
7926 /* Headphone insertion or removal. */
7927 if ((res >> 26) == ALC880_HP_EVENT)
7928 alc885_mb5_automute(codec);
7929}
7930
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007931static void alc885_imac91_automute(struct hda_codec *codec)
7932{
7933 unsigned int present;
7934
7935 present = snd_hda_codec_read(codec, 0x14, 0,
7936 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7937 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7938 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7939 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
7940 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7941
7942}
7943
7944static void alc885_imac91_unsol_event(struct hda_codec *codec,
7945 unsigned int res)
7946{
7947 /* Headphone insertion or removal. */
7948 if ((res >> 26) == ALC880_HP_EVENT)
7949 alc885_imac91_automute(codec);
7950}
Takashi Iwai87350ad2007-08-16 18:19:38 +02007951
Kailang Yang272a5272007-05-14 11:00:38 +02007952static struct hda_verb alc882_targa_verbs[] = {
7953 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7954 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7955
7956 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7957 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007958
Kailang Yang272a5272007-05-14 11:00:38 +02007959 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7960 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7961 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7962
7963 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007964 { } /* end */
7965};
7966
7967/* toggle speaker-output according to the hp-jack state */
7968static void alc882_targa_automute(struct hda_codec *codec)
7969{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007970 struct alc_spec *spec = codec->spec;
7971 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007972 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007973 spec->jack_present ? 1 : 3);
7974}
7975
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007976static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007977{
7978 struct alc_spec *spec = codec->spec;
7979
7980 spec->autocfg.hp_pins[0] = 0x14;
7981 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02007982}
7983
7984static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7985{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007986 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007987 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007988}
7989
7990static struct hda_verb alc882_asus_a7j_verbs[] = {
7991 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7992 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7993
7994 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7995 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7996 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007997
Kailang Yang272a5272007-05-14 11:00:38 +02007998 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7999 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8000 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8001
8002 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8003 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8004 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8005 { } /* end */
8006};
8007
Takashi Iwai914759b2007-09-06 14:52:04 +02008008static struct hda_verb alc882_asus_a7m_verbs[] = {
8009 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8010 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8011
8012 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8013 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8014 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008015
Takashi Iwai914759b2007-09-06 14:52:04 +02008016 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8017 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8018 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8019
8020 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8021 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8022 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8023 { } /* end */
8024};
8025
Tobin Davis9102cd12006-12-15 10:02:12 +01008026static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8027{
8028 unsigned int gpiostate, gpiomask, gpiodir;
8029
8030 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8031 AC_VERB_GET_GPIO_DATA, 0);
8032
8033 if (!muted)
8034 gpiostate |= (1 << pin);
8035 else
8036 gpiostate &= ~(1 << pin);
8037
8038 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8039 AC_VERB_GET_GPIO_MASK, 0);
8040 gpiomask |= (1 << pin);
8041
8042 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8043 AC_VERB_GET_GPIO_DIRECTION, 0);
8044 gpiodir |= (1 << pin);
8045
8046
8047 snd_hda_codec_write(codec, codec->afg, 0,
8048 AC_VERB_SET_GPIO_MASK, gpiomask);
8049 snd_hda_codec_write(codec, codec->afg, 0,
8050 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8051
8052 msleep(1);
8053
8054 snd_hda_codec_write(codec, codec->afg, 0,
8055 AC_VERB_SET_GPIO_DATA, gpiostate);
8056}
8057
Takashi Iwai7debbe52007-08-16 15:01:03 +02008058/* set up GPIO at initialization */
8059static void alc885_macpro_init_hook(struct hda_codec *codec)
8060{
8061 alc882_gpio_mute(codec, 0, 0);
8062 alc882_gpio_mute(codec, 1, 0);
8063}
8064
8065/* set up GPIO and update auto-muting at initialization */
8066static void alc885_imac24_init_hook(struct hda_codec *codec)
8067{
8068 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008069 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008070}
8071
Kailang Yangdf694da2005-12-05 19:42:22 +01008072/*
8073 * generic initialization of ADC, input mixers and output mixers
8074 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008075static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008076 /*
8077 * Unmute ADC0-2 and set the default input to mic-in
8078 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008079 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8080 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8081 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8082 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8083
Kailang Yangdf694da2005-12-05 19:42:22 +01008084 /*
8085 * Set up output mixers (0x0c - 0x0f)
8086 */
8087 /* set vol=0 to output mixers */
8088 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8089 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8090 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8091 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8092 /* set up input amps for analog loopback */
8093 /* Amp Indices: DAC = 0, mixer = 1 */
8094 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8095 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8096 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8097 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8098 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8099 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8100 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8101 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8102 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8103 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8104
8105 /* FIXME: use matrix-type input source selection */
8106 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008107 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008108 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008109 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008110 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008111 { }
8112};
8113
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008114/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8115static struct hda_verb alc889A_mb31_ch2_init[] = {
8116 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8117 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8118 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8119 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8120 { } /* end */
8121};
8122
8123/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8124static struct hda_verb alc889A_mb31_ch4_init[] = {
8125 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8126 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8127 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8128 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8129 { } /* end */
8130};
8131
8132/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8133static struct hda_verb alc889A_mb31_ch5_init[] = {
8134 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8135 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8136 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8137 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8138 { } /* end */
8139};
8140
8141/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8142static struct hda_verb alc889A_mb31_ch6_init[] = {
8143 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8144 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8145 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8146 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8147 { } /* end */
8148};
8149
8150static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8151 { 2, alc889A_mb31_ch2_init },
8152 { 4, alc889A_mb31_ch4_init },
8153 { 5, alc889A_mb31_ch5_init },
8154 { 6, alc889A_mb31_ch6_init },
8155};
8156
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008157static struct hda_verb alc883_medion_eapd_verbs[] = {
8158 /* eanable EAPD on medion laptop */
8159 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8160 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8161 { }
8162};
8163
Takashi Iwai4953550a2009-06-30 15:28:30 +02008164#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008165
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008166static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8167 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8168 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8169 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8170 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8171 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8172 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8173 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8174 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8175 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8176 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8177 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8178 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8179 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008180 { } /* end */
8181};
8182
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008183static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008184 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8185 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8186 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8187 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8188 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8189 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8190 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8191 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8192 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8193 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008194 { } /* end */
8195};
8196
Jiang zhefb97dc62008-03-06 11:07:11 +01008197static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8198 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8199 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8200 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8201 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8202 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8203 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8204 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8205 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8206 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8207 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008208 { } /* end */
8209};
8210
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008211static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8212 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8213 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8214 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8215 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8216 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, 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 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008220 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008221 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8222 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008223 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008224 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008225 { } /* end */
8226};
8227
8228static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8229 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8230 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8231 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8232 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8233 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8234 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8235 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8236 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8237 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8238 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8239 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8240 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8241 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8242 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008243 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008244 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8245 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008246 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008247 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008248 { } /* end */
8249};
8250
Jiang zhe17bba1b2008-06-04 12:11:07 +02008251static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8252 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8253 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8254 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8255 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8256 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8257 HDA_OUTPUT),
8258 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8259 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8260 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8261 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8262 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8263 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8264 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8265 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8266 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8267 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8268 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8269 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8270 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8271 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008272 { } /* end */
8273};
8274
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008275static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8276 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8277 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8278 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8279 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8280 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8281 HDA_OUTPUT),
8282 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8283 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8284 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8285 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8286 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8287 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8288 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8289 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8290 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8291 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8292 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8293 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8294 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8295 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8296 { } /* end */
8297};
8298
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008299static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008300 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008301 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008302 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008303 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008304 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8305 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008306 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8307 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008308 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8309 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8310 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8311 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8312 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8313 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008314 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008315 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8316 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008317 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008318 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008319 { } /* end */
8320};
8321
Sasha Alexandrc2592492009-06-16 14:52:54 -04008322static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008323 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008324 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008325 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008326 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008327 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8328 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8329 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8330 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8331 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8332 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8333 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8334 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8335 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8336 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8337 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008338 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008339 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008340 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008341};
Kailang Yangccc656c2006-10-17 12:32:26 +02008342
Sasha Alexandrc2592492009-06-16 14:52:54 -04008343static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008344 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008345 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008346 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008347 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008348 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8349 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8350 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008351 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008352 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008353 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8354 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8355 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008356 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008357};
Kailang Yangccc656c2006-10-17 12:32:26 +02008358
Takashi Iwaib99dba32009-09-17 18:23:00 +02008359static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8360 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8361 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8362 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8363 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8364 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8365 { } /* end */
8366};
8367
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008368static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8369 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8370 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008371 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8372 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008373 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8374 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8375 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8376 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008377 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008378};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008379
Kailang Yang272a5272007-05-14 11:00:38 +02008380static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8381 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8382 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8383 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8384 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8385 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8386 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8387 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8388 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8389 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008390 { } /* end */
8391};
8392
8393static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8394 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8395 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8396 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8397 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8398 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8399 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8400 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8401 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8402 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008403 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008404};
Kailang Yang272a5272007-05-14 11:00:38 +02008405
Tobin Davis2880a862007-08-07 11:50:26 +02008406static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008407 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8408 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008409 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008410 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8411 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008412 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8413 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8414 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008415 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008416};
Tobin Davis2880a862007-08-07 11:50:26 +02008417
Tony Vroond2fd4b02009-06-21 00:40:10 +01008418static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8419 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8420 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8421 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8422 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008423 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8424 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008425 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8426 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8427 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8428 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8429 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8430 { } /* end */
8431};
8432
Kailang Yange2757d52008-08-26 13:17:46 +02008433static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8434 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8435 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8436 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8437 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8438 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8439 0x0d, 1, 0x0, HDA_OUTPUT),
8440 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8441 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8442 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8443 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8444 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008445 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8446 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8447 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8448 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8449 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8450 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8451 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8452 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8453 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8454 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008455 { } /* end */
8456};
8457
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008458static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8459 /* Output mixers */
8460 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8461 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8462 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8463 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8464 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8465 HDA_OUTPUT),
8466 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8467 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8468 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8469 /* Output switches */
8470 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8471 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8472 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8473 /* Boost mixers */
8474 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8475 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8476 /* Input mixers */
8477 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8478 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8479 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8480 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8481 { } /* end */
8482};
8483
Guido Günther3e1647c2009-06-05 00:47:26 +02008484static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8485 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8486 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8487 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8488 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8489 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8490 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8491 { } /* end */
8492};
8493
Kailang Yange2757d52008-08-26 13:17:46 +02008494static struct hda_bind_ctls alc883_bind_cap_vol = {
8495 .ops = &snd_hda_bind_vol,
8496 .values = {
8497 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8498 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8499 0
8500 },
8501};
8502
8503static struct hda_bind_ctls alc883_bind_cap_switch = {
8504 .ops = &snd_hda_bind_sw,
8505 .values = {
8506 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8507 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8508 0
8509 },
8510};
8511
8512static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8513 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8514 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8515 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8516 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8517 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8518 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8519 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8520 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008521 { } /* end */
8522};
8523
8524static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008525 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8526 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8527 {
8528 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8529 /* .name = "Capture Source", */
8530 .name = "Input Source",
8531 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008532 .info = alc_mux_enum_info,
8533 .get = alc_mux_enum_get,
8534 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008535 },
8536 { } /* end */
8537};
8538
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008539static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8540 {
8541 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8542 .name = "Channel Mode",
8543 .info = alc_ch_mode_info,
8544 .get = alc_ch_mode_get,
8545 .put = alc_ch_mode_put,
8546 },
8547 { } /* end */
8548};
8549
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008550/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008551static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008552{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008553 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008554
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008555 spec->autocfg.hp_pins[0] = 0x15;
8556 spec->autocfg.speaker_pins[0] = 0x14;
8557 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008558}
8559
8560/* auto-toggle front mic */
8561/*
8562static void alc883_mitac_mic_automute(struct hda_codec *codec)
8563{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008564 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008565
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008566 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8567}
8568*/
8569
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008570static struct hda_verb alc883_mitac_verbs[] = {
8571 /* HP */
8572 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8573 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8574 /* Subwoofer */
8575 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8576 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8577
8578 /* enable unsolicited event */
8579 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8580 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8581
8582 { } /* end */
8583};
8584
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308585static struct hda_verb alc883_clevo_m540r_verbs[] = {
8586 /* HP */
8587 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8588 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8589 /* Int speaker */
8590 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8591
8592 /* enable unsolicited event */
8593 /*
8594 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8595 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8596 */
8597
8598 { } /* end */
8599};
8600
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008601static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008602 /* HP */
8603 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8604 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8605 /* Int speaker */
8606 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8607 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8608
8609 /* enable unsolicited event */
8610 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008611 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008612
8613 { } /* end */
8614};
8615
Jiang zhefb97dc62008-03-06 11:07:11 +01008616static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8617 /* HP */
8618 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8619 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8620 /* Subwoofer */
8621 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8622 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8623
8624 /* enable unsolicited event */
8625 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8626
8627 { } /* end */
8628};
8629
Sasha Alexandrc2592492009-06-16 14:52:54 -04008630static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008631 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8632 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8633
8634 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8635 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008636
David Heidelberger64a8be72009-06-08 16:15:18 +02008637/* Connect Line-Out side jack (SPDIF) to Side */
8638 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8639 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8640 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8641/* Connect Mic jack to CLFE */
8642 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8643 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8644 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8645/* Connect Line-in jack to Surround */
8646 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8647 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8648 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8649/* Connect HP out jack to Front */
8650 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8651 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8652 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008653
8654 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008655
8656 { } /* end */
8657};
8658
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008659static struct hda_verb alc883_lenovo_101e_verbs[] = {
8660 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8661 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8662 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8663 { } /* end */
8664};
8665
Kailang Yang272a5272007-05-14 11:00:38 +02008666static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8667 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8668 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8669 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8670 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8671 { } /* end */
8672};
8673
8674static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8675 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8676 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8677 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8678 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8679 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8680 { } /* end */
8681};
8682
Kailang Yang189609a2007-08-20 11:31:23 +02008683static struct hda_verb alc883_haier_w66_verbs[] = {
8684 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8685 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8686
8687 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8688
8689 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8690 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8691 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8692 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8693 { } /* end */
8694};
8695
Kailang Yange2757d52008-08-26 13:17:46 +02008696static struct hda_verb alc888_lenovo_sky_verbs[] = {
8697 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8698 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8699 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8700 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8701 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8702 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8703 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8704 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8705 { } /* end */
8706};
8707
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008708static struct hda_verb alc888_6st_dell_verbs[] = {
8709 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8710 { }
8711};
8712
Guido Günther3e1647c2009-06-05 00:47:26 +02008713static struct hda_verb alc883_vaiott_verbs[] = {
8714 /* HP */
8715 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8716 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8717
8718 /* enable unsolicited event */
8719 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8720
8721 { } /* end */
8722};
8723
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008724static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008725{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008726 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008727
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008728 spec->autocfg.hp_pins[0] = 0x1b;
8729 spec->autocfg.speaker_pins[0] = 0x14;
8730 spec->autocfg.speaker_pins[1] = 0x16;
8731 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008732}
8733
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008734static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008735 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008736 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8737 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008738 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008739 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008740};
8741
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008742/*
8743 * 2ch mode
8744 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008745static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008746 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8747 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8748 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8749 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008750 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008751};
8752
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008753/*
8754 * 4ch mode
8755 */
8756static struct hda_verb alc888_3st_hp_4ch_init[] = {
8757 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8758 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8759 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8760 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8761 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8762 { } /* end */
8763};
8764
8765/*
8766 * 6ch mode
8767 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008768static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008769 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8770 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008771 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008772 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8773 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008774 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8775 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008776};
8777
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008778static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008779 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008780 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008781 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008782};
8783
Kailang Yang272a5272007-05-14 11:00:38 +02008784/* toggle front-jack and RCA according to the hp-jack state */
8785static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8786{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008787 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02008788
Takashi Iwai47fd8302007-08-10 17:11:07 +02008789 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8790 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8791 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8792 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008793}
8794
8795/* toggle RCA according to the front-jack state */
8796static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8797{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008798 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02008799
Takashi Iwai47fd8302007-08-10 17:11:07 +02008800 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8801 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008802}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008803
Kailang Yang272a5272007-05-14 11:00:38 +02008804static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8805 unsigned int res)
8806{
8807 if ((res >> 26) == ALC880_HP_EVENT)
8808 alc888_lenovo_ms7195_front_automute(codec);
8809 if ((res >> 26) == ALC880_FRONT_EVENT)
8810 alc888_lenovo_ms7195_rca_automute(codec);
8811}
8812
8813static struct hda_verb alc883_medion_md2_verbs[] = {
8814 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8815 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8816
8817 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8818
8819 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8820 { } /* end */
8821};
8822
8823/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008824static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008825{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008826 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008827
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008828 spec->autocfg.hp_pins[0] = 0x14;
8829 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008830}
8831
Kailang Yangccc656c2006-10-17 12:32:26 +02008832/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008833#define alc883_targa_init_hook alc882_targa_init_hook
8834#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008835
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008836static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8837{
8838 unsigned int present;
8839
Takashi Iwaid56757a2009-11-18 08:00:14 +01008840 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008841 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8842 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8843}
8844
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008845static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008846{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008847 struct alc_spec *spec = codec->spec;
8848
8849 spec->autocfg.hp_pins[0] = 0x15;
8850 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008851}
8852
8853static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8854{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008855 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008856 alc883_clevo_m720_mic_automute(codec);
8857}
8858
8859static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008860 unsigned int res)
8861{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008862 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008863 case ALC880_MIC_EVENT:
8864 alc883_clevo_m720_mic_automute(codec);
8865 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008866 default:
8867 alc_automute_amp_unsol_event(codec, res);
8868 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008869 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008870}
8871
Jiang zhefb97dc62008-03-06 11:07:11 +01008872/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008873static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008874{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008875 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008876
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008877 spec->autocfg.hp_pins[0] = 0x14;
8878 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01008879}
8880
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008881static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008882{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008883 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008884
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008885 spec->autocfg.hp_pins[0] = 0x1b;
8886 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02008887}
8888
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008889static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8890{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008891 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008892
Takashi Iwai47fd8302007-08-10 17:11:07 +02008893 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8894 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008895}
8896
8897static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8898{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008899 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008900
Takashi Iwai47fd8302007-08-10 17:11:07 +02008901 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8902 HDA_AMP_MUTE, bits);
8903 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8904 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008905}
8906
8907static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8908 unsigned int res)
8909{
8910 if ((res >> 26) == ALC880_HP_EVENT)
8911 alc883_lenovo_101e_all_automute(codec);
8912 if ((res >> 26) == ALC880_FRONT_EVENT)
8913 alc883_lenovo_101e_ispeaker_automute(codec);
8914}
8915
Takashi Iwai676a9b52007-08-16 15:23:35 +02008916/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008917static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008918{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008919 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008920
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008921 spec->autocfg.hp_pins[0] = 0x14;
8922 spec->autocfg.speaker_pins[0] = 0x15;
8923 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02008924}
8925
Kailang Yangd1a991a2007-08-15 16:21:59 +02008926static struct hda_verb alc883_acer_eapd_verbs[] = {
8927 /* HP Pin: output 0 (0x0c) */
8928 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8929 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8930 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8931 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008932 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8933 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008934 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008935 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8936 /* eanable EAPD on medion laptop */
8937 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8938 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008939 /* enable unsolicited event */
8940 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008941 { }
8942};
8943
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008944static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8945 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8946 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8947 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8948 { } /* end */
8949};
8950
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008951static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008952{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008953 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008954
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008955 spec->autocfg.hp_pins[0] = 0x1b;
8956 spec->autocfg.speaker_pins[0] = 0x14;
8957 spec->autocfg.speaker_pins[1] = 0x15;
8958 spec->autocfg.speaker_pins[2] = 0x16;
8959 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008960}
8961
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008962static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008963{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008964 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008965
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008966 spec->autocfg.hp_pins[0] = 0x1b;
8967 spec->autocfg.speaker_pins[0] = 0x14;
8968 spec->autocfg.speaker_pins[1] = 0x15;
8969 spec->autocfg.speaker_pins[2] = 0x16;
8970 spec->autocfg.speaker_pins[3] = 0x17;
8971 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02008972}
8973
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008974static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02008975{
8976 struct alc_spec *spec = codec->spec;
8977
8978 spec->autocfg.hp_pins[0] = 0x15;
8979 spec->autocfg.speaker_pins[0] = 0x14;
8980 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02008981}
8982
Kailang Yange2757d52008-08-26 13:17:46 +02008983static struct hda_verb alc888_asus_m90v_verbs[] = {
8984 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8985 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8986 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8987 /* enable unsolicited event */
8988 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8989 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8990 { } /* end */
8991};
8992
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008993static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008994{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008995 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008996
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008997 spec->autocfg.hp_pins[0] = 0x1b;
8998 spec->autocfg.speaker_pins[0] = 0x14;
8999 spec->autocfg.speaker_pins[1] = 0x15;
9000 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009001 spec->ext_mic.pin = 0x18;
9002 spec->int_mic.pin = 0x19;
9003 spec->ext_mic.mux_idx = 0;
9004 spec->int_mic.mux_idx = 1;
9005 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009006}
9007
9008static struct hda_verb alc888_asus_eee1601_verbs[] = {
9009 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9010 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9011 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9012 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9013 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9014 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9015 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9016 /* enable unsolicited event */
9017 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9018 { } /* end */
9019};
9020
Kailang Yange2757d52008-08-26 13:17:46 +02009021static void alc883_eee1601_inithook(struct hda_codec *codec)
9022{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009023 struct alc_spec *spec = codec->spec;
9024
9025 spec->autocfg.hp_pins[0] = 0x14;
9026 spec->autocfg.speaker_pins[0] = 0x1b;
9027 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009028}
9029
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009030static struct hda_verb alc889A_mb31_verbs[] = {
9031 /* Init rear pin (used as headphone output) */
9032 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9033 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9034 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9035 /* Init line pin (used as output in 4ch and 6ch mode) */
9036 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9037 /* Init line 2 pin (used as headphone out by default) */
9038 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9039 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9040 { } /* end */
9041};
9042
9043/* Mute speakers according to the headphone jack state */
9044static void alc889A_mb31_automute(struct hda_codec *codec)
9045{
9046 unsigned int present;
9047
9048 /* Mute only in 2ch or 4ch mode */
9049 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9050 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009051 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009052 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9053 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9054 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9055 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9056 }
9057}
9058
9059static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9060{
9061 if ((res >> 26) == ALC880_HP_EVENT)
9062 alc889A_mb31_automute(codec);
9063}
9064
Takashi Iwai4953550a2009-06-30 15:28:30 +02009065
Takashi Iwaicb53c622007-08-10 17:21:45 +02009066#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009067#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009068#endif
9069
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009070/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009071#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9072#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9073#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9074#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9075
9076static hda_nid_t alc883_slave_dig_outs[] = {
9077 ALC1200_DIGOUT_NID, 0,
9078};
9079
9080static hda_nid_t alc1200_slave_dig_outs[] = {
9081 ALC883_DIGOUT_NID, 0,
9082};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009083
9084/*
9085 * configuration and preset
9086 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009087static const char *alc882_models[ALC882_MODEL_LAST] = {
9088 [ALC882_3ST_DIG] = "3stack-dig",
9089 [ALC882_6ST_DIG] = "6stack-dig",
9090 [ALC882_ARIMA] = "arima",
9091 [ALC882_W2JC] = "w2jc",
9092 [ALC882_TARGA] = "targa",
9093 [ALC882_ASUS_A7J] = "asus-a7j",
9094 [ALC882_ASUS_A7M] = "asus-a7m",
9095 [ALC885_MACPRO] = "macpro",
9096 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009097 [ALC885_MACMINI3] = "macmini3",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009098 [ALC885_MBP3] = "mbp3",
9099 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009100 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009101 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009102 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9103 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009104 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009105 [ALC883_TARGA_DIG] = "targa-dig",
9106 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009107 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009108 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009109 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009110 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009111 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009112 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009113 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009114 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009115 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009116 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009117 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009118 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9119 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009120 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009121 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009122 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009123 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009124 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309125 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009126 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009127 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009128 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009129 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009130 [ALC889A_INTEL] = "intel-alc889a",
9131 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009132 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009133 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009134 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009135 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009136};
9137
Takashi Iwai4953550a2009-06-30 15:28:30 +02009138static struct snd_pci_quirk alc882_cfg_tbl[] = {
9139 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9140
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009141 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009142 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009143 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009144 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9145 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009146 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009147 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9148 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009149 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009150 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009151 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9152 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009153 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9154 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009155 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9156 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009157 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009158 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009159 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009160 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009161 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9162 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009163 /* default Acer -- disabled as it causes more problems.
9164 * model=auto should work fine now
9165 */
9166 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009167
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009168 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009169
Tobin Davisfebe3372007-06-12 11:27:46 +02009170 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009171 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9172 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009173 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009174 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009175 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009176
9177 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9178 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9179 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009180 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009181 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9182 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9183 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009184 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009185 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009186 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009187 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009188
9189 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009190 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009191 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009192 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009193 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9194 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009195 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009196 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009197 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9198
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009199 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9200 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9201 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009202 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009203 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009204 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009205 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009206 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009207 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9208 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9209 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9210 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9211 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9212 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009213 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009214 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9215 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9216 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009217 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009218 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9219 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009220 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009221 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009222 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009223 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009224 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009225 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009226 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009227 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009228
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009229 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009230 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9231 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309232 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009233 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009234 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009235 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009236 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009237 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009238 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009239 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009240 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009241 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009242 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009243 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9244 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009245 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009246 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009247 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009248 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009249 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009250
Jiang zhe17bba1b2008-06-04 12:11:07 +02009251 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9252 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009253 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009254 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9255 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9256 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009257 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009258
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009259 {}
9260};
9261
Takashi Iwai4953550a2009-06-30 15:28:30 +02009262/* codec SSID table for Intel Mac */
9263static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9264 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9265 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9266 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9267 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9268 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9269 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9270 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
9271 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9272 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9273 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009274 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009275 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009276 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9277 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009278 */
9279 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009280 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009281 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009282 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009283};
9284
Takashi Iwai4953550a2009-06-30 15:28:30 +02009285static struct alc_config_preset alc882_presets[] = {
9286 [ALC882_3ST_DIG] = {
9287 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009288 .init_verbs = { alc882_base_init_verbs,
9289 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009290 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9291 .dac_nids = alc882_dac_nids,
9292 .dig_out_nid = ALC882_DIGOUT_NID,
9293 .dig_in_nid = ALC882_DIGIN_NID,
9294 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9295 .channel_mode = alc882_ch_modes,
9296 .need_dac_fix = 1,
9297 .input_mux = &alc882_capture_source,
9298 },
9299 [ALC882_6ST_DIG] = {
9300 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009301 .init_verbs = { alc882_base_init_verbs,
9302 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009303 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9304 .dac_nids = alc882_dac_nids,
9305 .dig_out_nid = ALC882_DIGOUT_NID,
9306 .dig_in_nid = ALC882_DIGIN_NID,
9307 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9308 .channel_mode = alc882_sixstack_modes,
9309 .input_mux = &alc882_capture_source,
9310 },
9311 [ALC882_ARIMA] = {
9312 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009313 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9314 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009315 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9316 .dac_nids = alc882_dac_nids,
9317 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9318 .channel_mode = alc882_sixstack_modes,
9319 .input_mux = &alc882_capture_source,
9320 },
9321 [ALC882_W2JC] = {
9322 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009323 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9324 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009325 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9326 .dac_nids = alc882_dac_nids,
9327 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9328 .channel_mode = alc880_threestack_modes,
9329 .need_dac_fix = 1,
9330 .input_mux = &alc882_capture_source,
9331 .dig_out_nid = ALC882_DIGOUT_NID,
9332 },
9333 [ALC885_MBP3] = {
9334 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9335 .init_verbs = { alc885_mbp3_init_verbs,
9336 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009337 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009338 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009339 .hp_nid = 0x04,
9340 .channel_mode = alc885_mbp_4ch_modes,
9341 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009342 .input_mux = &alc882_capture_source,
9343 .dig_out_nid = ALC882_DIGOUT_NID,
9344 .dig_in_nid = ALC882_DIGIN_NID,
9345 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009346 .setup = alc885_mbp3_setup,
9347 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009348 },
9349 [ALC885_MB5] = {
9350 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9351 .init_verbs = { alc885_mb5_init_verbs,
9352 alc880_gpio1_init_verbs },
9353 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9354 .dac_nids = alc882_dac_nids,
9355 .channel_mode = alc885_mb5_6ch_modes,
9356 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9357 .input_mux = &mb5_capture_source,
9358 .dig_out_nid = ALC882_DIGOUT_NID,
9359 .dig_in_nid = ALC882_DIGIN_NID,
Alex Murraya76221d2010-01-13 23:15:03 +10309360 .unsol_event = alc885_mb5_unsol_event,
9361 .init_hook = alc885_mb5_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009362 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009363 [ALC885_MACMINI3] = {
9364 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
9365 .init_verbs = { alc885_macmini3_init_verbs,
9366 alc880_gpio1_init_verbs },
9367 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9368 .dac_nids = alc882_dac_nids,
9369 .channel_mode = alc885_macmini3_6ch_modes,
9370 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
9371 .input_mux = &macmini3_capture_source,
9372 .dig_out_nid = ALC882_DIGOUT_NID,
9373 .dig_in_nid = ALC882_DIGIN_NID,
9374 .unsol_event = alc885_macmini3_unsol_event,
9375 .init_hook = alc885_macmini3_automute,
9376 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009377 [ALC885_MACPRO] = {
9378 .mixers = { alc882_macpro_mixer },
9379 .init_verbs = { alc882_macpro_init_verbs },
9380 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9381 .dac_nids = alc882_dac_nids,
9382 .dig_out_nid = ALC882_DIGOUT_NID,
9383 .dig_in_nid = ALC882_DIGIN_NID,
9384 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9385 .channel_mode = alc882_ch_modes,
9386 .input_mux = &alc882_capture_source,
9387 .init_hook = alc885_macpro_init_hook,
9388 },
9389 [ALC885_IMAC24] = {
9390 .mixers = { alc885_imac24_mixer },
9391 .init_verbs = { alc885_imac24_init_verbs },
9392 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9393 .dac_nids = alc882_dac_nids,
9394 .dig_out_nid = ALC882_DIGOUT_NID,
9395 .dig_in_nid = ALC882_DIGIN_NID,
9396 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9397 .channel_mode = alc882_ch_modes,
9398 .input_mux = &alc882_capture_source,
9399 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009400 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009401 .init_hook = alc885_imac24_init_hook,
9402 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009403 [ALC885_IMAC91] = {
9404 .mixers = { alc885_imac91_mixer, alc882_chmode_mixer },
9405 .init_verbs = { alc885_imac91_init_verbs,
9406 alc880_gpio1_init_verbs },
9407 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9408 .dac_nids = alc882_dac_nids,
9409 .channel_mode = alc885_mbp_4ch_modes,
9410 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
9411 .input_mux = &alc882_capture_source,
9412 .dig_out_nid = ALC882_DIGOUT_NID,
9413 .dig_in_nid = ALC882_DIGIN_NID,
9414 .unsol_event = alc885_imac91_unsol_event,
9415 .init_hook = alc885_imac91_automute,
9416 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009417 [ALC882_TARGA] = {
9418 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009419 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009420 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009421 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9422 .dac_nids = alc882_dac_nids,
9423 .dig_out_nid = ALC882_DIGOUT_NID,
9424 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9425 .adc_nids = alc882_adc_nids,
9426 .capsrc_nids = alc882_capsrc_nids,
9427 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9428 .channel_mode = alc882_3ST_6ch_modes,
9429 .need_dac_fix = 1,
9430 .input_mux = &alc882_capture_source,
9431 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009432 .setup = alc882_targa_setup,
9433 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009434 },
9435 [ALC882_ASUS_A7J] = {
9436 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009437 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9438 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009439 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9440 .dac_nids = alc882_dac_nids,
9441 .dig_out_nid = ALC882_DIGOUT_NID,
9442 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9443 .adc_nids = alc882_adc_nids,
9444 .capsrc_nids = alc882_capsrc_nids,
9445 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9446 .channel_mode = alc882_3ST_6ch_modes,
9447 .need_dac_fix = 1,
9448 .input_mux = &alc882_capture_source,
9449 },
9450 [ALC882_ASUS_A7M] = {
9451 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009452 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9453 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009454 alc882_asus_a7m_verbs },
9455 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9456 .dac_nids = alc882_dac_nids,
9457 .dig_out_nid = ALC882_DIGOUT_NID,
9458 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9459 .channel_mode = alc880_threestack_modes,
9460 .need_dac_fix = 1,
9461 .input_mux = &alc882_capture_source,
9462 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009463 [ALC883_3ST_2ch_DIG] = {
9464 .mixers = { alc883_3ST_2ch_mixer },
9465 .init_verbs = { alc883_init_verbs },
9466 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9467 .dac_nids = alc883_dac_nids,
9468 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009469 .dig_in_nid = ALC883_DIGIN_NID,
9470 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9471 .channel_mode = alc883_3ST_2ch_modes,
9472 .input_mux = &alc883_capture_source,
9473 },
9474 [ALC883_3ST_6ch_DIG] = {
9475 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9476 .init_verbs = { alc883_init_verbs },
9477 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9478 .dac_nids = alc883_dac_nids,
9479 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009480 .dig_in_nid = ALC883_DIGIN_NID,
9481 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9482 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009483 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009484 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009485 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009486 [ALC883_3ST_6ch] = {
9487 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9488 .init_verbs = { alc883_init_verbs },
9489 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9490 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009491 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9492 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009493 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009494 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009495 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009496 [ALC883_3ST_6ch_INTEL] = {
9497 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9498 .init_verbs = { alc883_init_verbs },
9499 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9500 .dac_nids = alc883_dac_nids,
9501 .dig_out_nid = ALC883_DIGOUT_NID,
9502 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009503 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009504 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9505 .channel_mode = alc883_3ST_6ch_intel_modes,
9506 .need_dac_fix = 1,
9507 .input_mux = &alc883_3stack_6ch_intel,
9508 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009509 [ALC889A_INTEL] = {
9510 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009511 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9512 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009513 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9514 .dac_nids = alc883_dac_nids,
9515 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9516 .adc_nids = alc889_adc_nids,
9517 .dig_out_nid = ALC883_DIGOUT_NID,
9518 .dig_in_nid = ALC883_DIGIN_NID,
9519 .slave_dig_outs = alc883_slave_dig_outs,
9520 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9521 .channel_mode = alc889_8ch_intel_modes,
9522 .capsrc_nids = alc889_capsrc_nids,
9523 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009524 .setup = alc889_automute_setup,
9525 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009526 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009527 .need_dac_fix = 1,
9528 },
9529 [ALC889_INTEL] = {
9530 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9531 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009532 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009533 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9534 .dac_nids = alc883_dac_nids,
9535 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9536 .adc_nids = alc889_adc_nids,
9537 .dig_out_nid = ALC883_DIGOUT_NID,
9538 .dig_in_nid = ALC883_DIGIN_NID,
9539 .slave_dig_outs = alc883_slave_dig_outs,
9540 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9541 .channel_mode = alc889_8ch_intel_modes,
9542 .capsrc_nids = alc889_capsrc_nids,
9543 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009544 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009545 .init_hook = alc889_intel_init_hook,
9546 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009547 .need_dac_fix = 1,
9548 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009549 [ALC883_6ST_DIG] = {
9550 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9551 .init_verbs = { alc883_init_verbs },
9552 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9553 .dac_nids = alc883_dac_nids,
9554 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009555 .dig_in_nid = ALC883_DIGIN_NID,
9556 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9557 .channel_mode = alc883_sixstack_modes,
9558 .input_mux = &alc883_capture_source,
9559 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009560 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009561 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009562 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9563 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009564 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9565 .dac_nids = alc883_dac_nids,
9566 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009567 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9568 .channel_mode = alc883_3ST_6ch_modes,
9569 .need_dac_fix = 1,
9570 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009571 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009572 .setup = alc882_targa_setup,
9573 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009574 },
9575 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009576 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009577 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9578 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009579 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9580 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009581 .adc_nids = alc883_adc_nids_alt,
9582 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009583 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +02009584 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009585 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9586 .channel_mode = alc883_3ST_2ch_modes,
9587 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009588 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009589 .setup = alc882_targa_setup,
9590 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009591 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009592 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009593 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9594 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +02009595 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009596 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009597 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9598 .dac_nids = alc883_dac_nids,
9599 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9600 .adc_nids = alc883_adc_nids_rev,
9601 .capsrc_nids = alc883_capsrc_nids_rev,
9602 .dig_out_nid = ALC883_DIGOUT_NID,
9603 .dig_in_nid = ALC883_DIGIN_NID,
9604 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9605 .channel_mode = alc883_4ST_8ch_modes,
9606 .need_dac_fix = 1,
9607 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009608 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009609 .setup = alc882_targa_setup,
9610 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009611 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009612 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009613 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009614 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9615 * and the headphone jack. Turn this on and rely on the
9616 * standard mute methods whenever the user wants to turn
9617 * these outputs off.
9618 */
9619 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9620 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9621 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009622 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9623 .channel_mode = alc883_3ST_2ch_modes,
9624 .input_mux = &alc883_capture_source,
9625 },
Tobin Davis2880a862007-08-07 11:50:26 +02009626 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009627 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009628 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009629 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9630 .dac_nids = alc883_dac_nids,
9631 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009632 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9633 .channel_mode = alc883_3ST_2ch_modes,
9634 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009635 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009636 .setup = alc883_acer_aspire_setup,
9637 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009638 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009639 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009640 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009641 alc883_chmode_mixer },
9642 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9643 alc888_acer_aspire_4930g_verbs },
9644 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9645 .dac_nids = alc883_dac_nids,
9646 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9647 .adc_nids = alc883_adc_nids_rev,
9648 .capsrc_nids = alc883_capsrc_nids_rev,
9649 .dig_out_nid = ALC883_DIGOUT_NID,
9650 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9651 .channel_mode = alc883_3ST_6ch_modes,
9652 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +01009653 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009654 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009655 ARRAY_SIZE(alc888_2_capture_sources),
9656 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009657 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009658 .setup = alc888_acer_aspire_4930g_setup,
9659 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009660 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009661 [ALC888_ACER_ASPIRE_6530G] = {
9662 .mixers = { alc888_acer_aspire_6530_mixer },
9663 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9664 alc888_acer_aspire_6530g_verbs },
9665 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9666 .dac_nids = alc883_dac_nids,
9667 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9668 .adc_nids = alc883_adc_nids_rev,
9669 .capsrc_nids = alc883_capsrc_nids_rev,
9670 .dig_out_nid = ALC883_DIGOUT_NID,
9671 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9672 .channel_mode = alc883_3ST_2ch_modes,
9673 .num_mux_defs =
9674 ARRAY_SIZE(alc888_2_capture_sources),
9675 .input_mux = alc888_acer_aspire_6530_sources,
9676 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009677 .setup = alc888_acer_aspire_6530g_setup,
9678 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009679 },
Hector Martin3b315d72009-06-02 10:54:19 +02009680 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +01009681 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +02009682 alc883_chmode_mixer },
9683 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +01009684 alc889_acer_aspire_8930g_verbs,
9685 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +02009686 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9687 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009688 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9689 .adc_nids = alc889_adc_nids,
9690 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009691 .dig_out_nid = ALC883_DIGOUT_NID,
9692 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9693 .channel_mode = alc883_3ST_6ch_modes,
9694 .need_dac_fix = 1,
9695 .const_channel_count = 6,
9696 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009697 ARRAY_SIZE(alc889_capture_sources),
9698 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009699 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009700 .setup = alc889_acer_aspire_8930g_setup,
9701 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +01009702#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05009703 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +01009704#endif
Hector Martin3b315d72009-06-02 10:54:19 +02009705 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009706 [ALC888_ACER_ASPIRE_7730G] = {
9707 .mixers = { alc883_3ST_6ch_mixer,
9708 alc883_chmode_mixer },
9709 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9710 alc888_acer_aspire_7730G_verbs },
9711 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9712 .dac_nids = alc883_dac_nids,
9713 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9714 .adc_nids = alc883_adc_nids_rev,
9715 .capsrc_nids = alc883_capsrc_nids_rev,
9716 .dig_out_nid = ALC883_DIGOUT_NID,
9717 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9718 .channel_mode = alc883_3ST_6ch_modes,
9719 .need_dac_fix = 1,
9720 .const_channel_count = 6,
9721 .input_mux = &alc883_capture_source,
9722 .unsol_event = alc_automute_amp_unsol_event,
9723 .setup = alc888_acer_aspire_6530g_setup,
9724 .init_hook = alc_automute_amp,
9725 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009726 [ALC883_MEDION] = {
9727 .mixers = { alc883_fivestack_mixer,
9728 alc883_chmode_mixer },
9729 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009730 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009731 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9732 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009733 .adc_nids = alc883_adc_nids_alt,
9734 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009735 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02009736 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9737 .channel_mode = alc883_sixstack_modes,
9738 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009739 },
Kailang Yang272a5272007-05-14 11:00:38 +02009740 [ALC883_MEDION_MD2] = {
9741 .mixers = { alc883_medion_md2_mixer},
9742 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9743 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9744 .dac_nids = alc883_dac_nids,
9745 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009746 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9747 .channel_mode = alc883_3ST_2ch_modes,
9748 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009749 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009750 .setup = alc883_medion_md2_setup,
9751 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009752 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009753 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009754 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009755 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9756 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9757 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009758 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9759 .channel_mode = alc883_3ST_2ch_modes,
9760 .input_mux = &alc883_capture_source,
9761 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309762 [ALC883_CLEVO_M540R] = {
9763 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9764 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9765 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9766 .dac_nids = alc883_dac_nids,
9767 .dig_out_nid = ALC883_DIGOUT_NID,
9768 .dig_in_nid = ALC883_DIGIN_NID,
9769 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9770 .channel_mode = alc883_3ST_6ch_clevo_modes,
9771 .need_dac_fix = 1,
9772 .input_mux = &alc883_capture_source,
9773 /* This machine has the hardware HP auto-muting, thus
9774 * we need no software mute via unsol event
9775 */
9776 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009777 [ALC883_CLEVO_M720] = {
9778 .mixers = { alc883_clevo_m720_mixer },
9779 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009780 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9781 .dac_nids = alc883_dac_nids,
9782 .dig_out_nid = ALC883_DIGOUT_NID,
9783 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9784 .channel_mode = alc883_3ST_2ch_modes,
9785 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009786 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009787 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009788 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009789 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009790 [ALC883_LENOVO_101E_2ch] = {
9791 .mixers = { alc883_lenovo_101e_2ch_mixer},
9792 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9793 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9794 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009795 .adc_nids = alc883_adc_nids_alt,
9796 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009797 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009798 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9799 .channel_mode = alc883_3ST_2ch_modes,
9800 .input_mux = &alc883_lenovo_101e_capture_source,
9801 .unsol_event = alc883_lenovo_101e_unsol_event,
9802 .init_hook = alc883_lenovo_101e_all_automute,
9803 },
Kailang Yang272a5272007-05-14 11:00:38 +02009804 [ALC883_LENOVO_NB0763] = {
9805 .mixers = { alc883_lenovo_nb0763_mixer },
9806 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9807 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9808 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009809 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9810 .channel_mode = alc883_3ST_2ch_modes,
9811 .need_dac_fix = 1,
9812 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009813 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009814 .setup = alc883_medion_md2_setup,
9815 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009816 },
9817 [ALC888_LENOVO_MS7195_DIG] = {
9818 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9819 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9820 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9821 .dac_nids = alc883_dac_nids,
9822 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009823 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9824 .channel_mode = alc883_3ST_6ch_modes,
9825 .need_dac_fix = 1,
9826 .input_mux = &alc883_capture_source,
9827 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9828 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009829 },
9830 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009831 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009832 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9833 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9834 .dac_nids = alc883_dac_nids,
9835 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009836 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9837 .channel_mode = alc883_3ST_2ch_modes,
9838 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009839 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009840 .setup = alc883_haier_w66_setup,
9841 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009842 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009843 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009844 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009845 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009846 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9847 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009848 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9849 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009850 .need_dac_fix = 1,
9851 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009852 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009853 .setup = alc888_3st_hp_setup,
9854 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009855 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009856 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009857 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009858 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9859 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9860 .dac_nids = alc883_dac_nids,
9861 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009862 .dig_in_nid = ALC883_DIGIN_NID,
9863 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9864 .channel_mode = alc883_sixstack_modes,
9865 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009866 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009867 .setup = alc888_6st_dell_setup,
9868 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009869 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009870 [ALC883_MITAC] = {
9871 .mixers = { alc883_mitac_mixer },
9872 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9873 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9874 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009875 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9876 .channel_mode = alc883_3ST_2ch_modes,
9877 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009878 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009879 .setup = alc883_mitac_setup,
9880 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009881 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009882 [ALC883_FUJITSU_PI2515] = {
9883 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9884 .init_verbs = { alc883_init_verbs,
9885 alc883_2ch_fujitsu_pi2515_verbs},
9886 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9887 .dac_nids = alc883_dac_nids,
9888 .dig_out_nid = ALC883_DIGOUT_NID,
9889 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9890 .channel_mode = alc883_3ST_2ch_modes,
9891 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009892 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009893 .setup = alc883_2ch_fujitsu_pi2515_setup,
9894 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +01009895 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009896 [ALC888_FUJITSU_XA3530] = {
9897 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9898 .init_verbs = { alc883_init_verbs,
9899 alc888_fujitsu_xa3530_verbs },
9900 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9901 .dac_nids = alc883_dac_nids,
9902 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9903 .adc_nids = alc883_adc_nids_rev,
9904 .capsrc_nids = alc883_capsrc_nids_rev,
9905 .dig_out_nid = ALC883_DIGOUT_NID,
9906 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9907 .channel_mode = alc888_4ST_8ch_intel_modes,
9908 .num_mux_defs =
9909 ARRAY_SIZE(alc888_2_capture_sources),
9910 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009911 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009912 .setup = alc888_fujitsu_xa3530_setup,
9913 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009914 },
Kailang Yange2757d52008-08-26 13:17:46 +02009915 [ALC888_LENOVO_SKY] = {
9916 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9917 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9918 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9919 .dac_nids = alc883_dac_nids,
9920 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009921 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9922 .channel_mode = alc883_sixstack_modes,
9923 .need_dac_fix = 1,
9924 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009925 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009926 .setup = alc888_lenovo_sky_setup,
9927 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +02009928 },
9929 [ALC888_ASUS_M90V] = {
9930 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9931 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9932 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9933 .dac_nids = alc883_dac_nids,
9934 .dig_out_nid = ALC883_DIGOUT_NID,
9935 .dig_in_nid = ALC883_DIGIN_NID,
9936 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9937 .channel_mode = alc883_3ST_6ch_modes,
9938 .need_dac_fix = 1,
9939 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009940 .unsol_event = alc_sku_unsol_event,
9941 .setup = alc883_mode2_setup,
9942 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +02009943 },
9944 [ALC888_ASUS_EEE1601] = {
9945 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009946 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009947 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9948 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9949 .dac_nids = alc883_dac_nids,
9950 .dig_out_nid = ALC883_DIGOUT_NID,
9951 .dig_in_nid = ALC883_DIGIN_NID,
9952 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9953 .channel_mode = alc883_3ST_2ch_modes,
9954 .need_dac_fix = 1,
9955 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009956 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009957 .init_hook = alc883_eee1601_inithook,
9958 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009959 [ALC1200_ASUS_P5Q] = {
9960 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9961 .init_verbs = { alc883_init_verbs },
9962 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9963 .dac_nids = alc883_dac_nids,
9964 .dig_out_nid = ALC1200_DIGOUT_NID,
9965 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009966 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009967 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9968 .channel_mode = alc883_sixstack_modes,
9969 .input_mux = &alc883_capture_source,
9970 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009971 [ALC889A_MB31] = {
9972 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9973 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9974 alc880_gpio1_init_verbs },
9975 .adc_nids = alc883_adc_nids,
9976 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009977 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009978 .dac_nids = alc883_dac_nids,
9979 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9980 .channel_mode = alc889A_mb31_6ch_modes,
9981 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9982 .input_mux = &alc889A_mb31_capture_source,
9983 .dig_out_nid = ALC883_DIGOUT_NID,
9984 .unsol_event = alc889A_mb31_unsol_event,
9985 .init_hook = alc889A_mb31_automute,
9986 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009987 [ALC883_SONY_VAIO_TT] = {
9988 .mixers = { alc883_vaiott_mixer },
9989 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9990 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9991 .dac_nids = alc883_dac_nids,
9992 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9993 .channel_mode = alc883_3ST_2ch_modes,
9994 .input_mux = &alc883_capture_source,
9995 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009996 .setup = alc883_vaiott_setup,
9997 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +02009998 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009999};
10000
10001
10002/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010003 * Pin config fixes
10004 */
10005enum {
10006 PINFIX_ABIT_AW9D_MAX
10007};
10008
10009static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
10010 { 0x15, 0x01080104 }, /* side */
10011 { 0x16, 0x01011012 }, /* rear */
10012 { 0x17, 0x01016011 }, /* clfe */
10013 { }
10014};
10015
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010016static const struct alc_fixup alc882_fixups[] = {
10017 [PINFIX_ABIT_AW9D_MAX] = {
10018 .pins = alc882_abit_aw9d_pinfix
10019 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010020};
10021
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010022static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +020010023 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
10024 {}
10025};
10026
10027/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010028 * BIOS auto configuration
10029 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010030static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10031 const struct auto_pin_cfg *cfg)
10032{
10033 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10034}
10035
Takashi Iwai4953550a2009-06-30 15:28:30 +020010036static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010037 hda_nid_t nid, int pin_type,
10038 int dac_idx)
10039{
10040 /* set as output */
10041 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010042 int idx;
10043
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010044 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010045 if (spec->multiout.dac_nids[dac_idx] == 0x25)
10046 idx = 4;
10047 else
10048 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010049 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
10050
10051}
10052
Takashi Iwai4953550a2009-06-30 15:28:30 +020010053static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010054{
10055 struct alc_spec *spec = codec->spec;
10056 int i;
10057
10058 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010059 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010060 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010061 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010062 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010063 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010064 }
10065}
10066
Takashi Iwai4953550a2009-06-30 15:28:30 +020010067static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010068{
10069 struct alc_spec *spec = codec->spec;
10070 hda_nid_t pin;
10071
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010072 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010073 if (pin) /* connect to front */
10074 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010075 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010076 pin = spec->autocfg.speaker_pins[0];
10077 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010078 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010079}
10080
Takashi Iwai4953550a2009-06-30 15:28:30 +020010081static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010082{
10083 struct alc_spec *spec = codec->spec;
10084 int i;
10085
10086 for (i = 0; i < AUTO_PIN_LAST; i++) {
10087 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010088 if (!nid)
10089 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +020010090 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010091 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10092 snd_hda_codec_write(codec, nid, 0,
10093 AC_VERB_SET_AMP_GAIN_MUTE,
10094 AMP_OUT_MUTE);
10095 }
10096}
10097
10098static void alc882_auto_init_input_src(struct hda_codec *codec)
10099{
10100 struct alc_spec *spec = codec->spec;
10101 int c;
10102
10103 for (c = 0; c < spec->num_adc_nids; c++) {
10104 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10105 hda_nid_t nid = spec->capsrc_nids[c];
10106 unsigned int mux_idx;
10107 const struct hda_input_mux *imux;
10108 int conns, mute, idx, item;
10109
10110 conns = snd_hda_get_connections(codec, nid, conn_list,
10111 ARRAY_SIZE(conn_list));
10112 if (conns < 0)
10113 continue;
10114 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10115 imux = &spec->input_mux[mux_idx];
10116 for (idx = 0; idx < conns; idx++) {
10117 /* if the current connection is the selected one,
10118 * unmute it as default - otherwise mute it
10119 */
10120 mute = AMP_IN_MUTE(idx);
10121 for (item = 0; item < imux->num_items; item++) {
10122 if (imux->items[item].index == idx) {
10123 if (spec->cur_mux[c] == item)
10124 mute = AMP_IN_UNMUTE(idx);
10125 break;
10126 }
10127 }
10128 /* check if we have a selector or mixer
10129 * we could check for the widget type instead, but
10130 * just check for Amp-In presence (in case of mixer
10131 * without amp-in there is something wrong, this
10132 * function shouldn't be used or capsrc nid is wrong)
10133 */
10134 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010135 snd_hda_codec_write(codec, nid, 0,
10136 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010137 mute);
10138 else if (mute != AMP_IN_MUTE(idx))
10139 snd_hda_codec_write(codec, nid, 0,
10140 AC_VERB_SET_CONNECT_SEL,
10141 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010142 }
10143 }
10144}
10145
Takashi Iwai4953550a2009-06-30 15:28:30 +020010146/* add mic boosts if needed */
10147static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010148{
10149 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010150 int err;
10151 hda_nid_t nid;
10152
10153 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
10154 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10155 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10156 "Mic Boost",
10157 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10158 if (err < 0)
10159 return err;
10160 }
10161 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
10162 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10163 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10164 "Front Mic Boost",
10165 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10166 if (err < 0)
10167 return err;
10168 }
10169 return 0;
10170}
10171
10172/* almost identical with ALC880 parser... */
10173static int alc882_parse_auto_config(struct hda_codec *codec)
10174{
10175 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010176 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
10177 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010178
Takashi Iwai05f5f472009-08-25 13:10:18 +020010179 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10180 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010181 if (err < 0)
10182 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010183 if (!spec->autocfg.line_outs)
10184 return 0; /* can't find valid BIOS pin config */
10185
10186 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10187 if (err < 0)
10188 return err;
10189 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10190 if (err < 0)
10191 return err;
10192 err = alc880_auto_create_extra_out(spec,
10193 spec->autocfg.speaker_pins[0],
10194 "Speaker");
10195 if (err < 0)
10196 return err;
10197 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10198 "Headphone");
10199 if (err < 0)
10200 return err;
10201 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10202 if (err < 0)
10203 return err;
10204
10205 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10206
10207 /* check multiple SPDIF-out (for recent codecs) */
10208 for (i = 0; i < spec->autocfg.dig_outs; i++) {
10209 hda_nid_t dig_nid;
10210 err = snd_hda_get_connections(codec,
10211 spec->autocfg.dig_out_pins[i],
10212 &dig_nid, 1);
10213 if (err < 0)
10214 continue;
10215 if (!i)
10216 spec->multiout.dig_out_nid = dig_nid;
10217 else {
10218 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010219 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai05f5f472009-08-25 13:10:18 +020010220 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010221 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010222 }
10223 }
10224 if (spec->autocfg.dig_in_pin)
10225 spec->dig_in_nid = ALC880_DIGIN_NID;
10226
10227 if (spec->kctls.list)
10228 add_mixer(spec, spec->kctls.list);
10229
10230 add_verb(spec, alc883_auto_init_verbs);
10231 /* if ADC 0x07 is available, initialize it, too */
10232 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10233 add_verb(spec, alc882_adc1_init_verbs);
10234
10235 spec->num_mux_defs = 1;
10236 spec->input_mux = &spec->private_imux[0];
10237
10238 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
Takashi Iwai776e1842007-08-29 15:07:11 +020010239
10240 err = alc_auto_add_mic_boost(codec);
10241 if (err < 0)
10242 return err;
10243
Takashi Iwai776e1842007-08-29 15:07:11 +020010244 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010245}
10246
10247/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010248static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010249{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010250 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010251 alc882_auto_init_multi_out(codec);
10252 alc882_auto_init_hp_out(codec);
10253 alc882_auto_init_analog_input(codec);
10254 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010255 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010256 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010257}
10258
Takashi Iwai4953550a2009-06-30 15:28:30 +020010259static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010260{
10261 struct alc_spec *spec;
10262 int err, board_config;
10263
10264 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10265 if (spec == NULL)
10266 return -ENOMEM;
10267
10268 codec->spec = spec;
10269
Takashi Iwai4953550a2009-06-30 15:28:30 +020010270 switch (codec->vendor_id) {
10271 case 0x10ec0882:
10272 case 0x10ec0885:
10273 break;
10274 default:
10275 /* ALC883 and variants */
10276 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10277 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010278 }
10279
Takashi Iwai4953550a2009-06-30 15:28:30 +020010280 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10281 alc882_models,
10282 alc882_cfg_tbl);
10283
10284 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10285 board_config = snd_hda_check_board_codec_sid_config(codec,
10286 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10287
10288 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010289 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010290 codec->chip_name);
10291 board_config = ALC882_AUTO;
10292 }
10293
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010294 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010295
10296 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010297 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010298 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010299 if (err < 0) {
10300 alc_free(codec);
10301 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010302 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010303 printk(KERN_INFO
10304 "hda_codec: Cannot set up configuration "
10305 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010306 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010307 }
10308 }
10309
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010310 err = snd_hda_attach_beep_device(codec, 0x1);
10311 if (err < 0) {
10312 alc_free(codec);
10313 return err;
10314 }
10315
Takashi Iwai4953550a2009-06-30 15:28:30 +020010316 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010317 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010318
Takashi Iwai4953550a2009-06-30 15:28:30 +020010319 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10320 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10321 /* FIXME: setup DAC5 */
10322 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10323 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10324
10325 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10326 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10327
10328 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010329 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010330
10331 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010332 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010333 spec->num_adc_nids = 0;
10334 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010335 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010336 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010337 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010338 hda_nid_t nid = alc882_adc_nids[i];
10339 unsigned int wcap = get_wcaps(codec, nid);
10340 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010341 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010342 if (wcap != AC_WID_AUD_IN)
10343 continue;
10344 spec->private_adc_nids[spec->num_adc_nids] = nid;
10345 err = snd_hda_get_connections(codec, nid, &cap, 1);
10346 if (err < 0)
10347 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010348 err = snd_hda_get_connections(codec, cap, items,
10349 ARRAY_SIZE(items));
10350 if (err < 0)
10351 continue;
10352 for (j = 0; j < imux->num_items; j++)
10353 if (imux->items[j].index >= err)
10354 break;
10355 if (j < imux->num_items)
10356 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010357 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10358 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010359 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010360 spec->adc_nids = spec->private_adc_nids;
10361 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010362 }
10363
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010364 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010010365 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010366
Takashi Iwai2134ea42008-01-10 16:53:55 +010010367 spec->vmaster_nid = 0x0c;
10368
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010369 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010370 if (board_config == ALC882_AUTO)
10371 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010372#ifdef CONFIG_SND_HDA_POWER_SAVE
10373 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010374 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010375#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010376
10377 return 0;
10378}
10379
Takashi Iwai4953550a2009-06-30 15:28:30 +020010380
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010381/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010382 * ALC262 support
10383 */
10384
10385#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10386#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10387
10388#define alc262_dac_nids alc260_dac_nids
10389#define alc262_adc_nids alc882_adc_nids
10390#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010391#define alc262_capsrc_nids alc882_capsrc_nids
10392#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010393
10394#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010395#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010396
Kailang Yang4e555fe2008-08-26 13:05:55 +020010397static hda_nid_t alc262_dmic_adc_nids[1] = {
10398 /* ADC0 */
10399 0x09
10400};
10401
10402static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10403
Kailang Yangdf694da2005-12-05 19:42:22 +010010404static struct snd_kcontrol_new alc262_base_mixer[] = {
10405 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10406 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10407 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10408 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10409 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10410 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10411 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10412 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010413 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010414 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10415 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010416 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010417 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10418 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10419 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10420 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010421 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010422};
10423
Takashi Iwaice875f02008-01-28 18:17:43 +010010424/* update HP, line and mono-out pins according to the master switch */
10425static void alc262_hp_master_update(struct hda_codec *codec)
10426{
10427 struct alc_spec *spec = codec->spec;
10428 int val = spec->master_sw;
10429
10430 /* HP & line-out */
10431 snd_hda_codec_write_cache(codec, 0x1b, 0,
10432 AC_VERB_SET_PIN_WIDGET_CONTROL,
10433 val ? PIN_HP : 0);
10434 snd_hda_codec_write_cache(codec, 0x15, 0,
10435 AC_VERB_SET_PIN_WIDGET_CONTROL,
10436 val ? PIN_HP : 0);
10437 /* mono (speaker) depending on the HP jack sense */
10438 val = val && !spec->jack_present;
10439 snd_hda_codec_write_cache(codec, 0x16, 0,
10440 AC_VERB_SET_PIN_WIDGET_CONTROL,
10441 val ? PIN_OUT : 0);
10442}
10443
10444static void alc262_hp_bpc_automute(struct hda_codec *codec)
10445{
10446 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010447
10448 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010449 alc262_hp_master_update(codec);
10450}
10451
10452static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10453{
10454 if ((res >> 26) != ALC880_HP_EVENT)
10455 return;
10456 alc262_hp_bpc_automute(codec);
10457}
10458
10459static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10460{
10461 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010462
10463 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010464 alc262_hp_master_update(codec);
10465}
10466
10467static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10468 unsigned int res)
10469{
10470 if ((res >> 26) != ALC880_HP_EVENT)
10471 return;
10472 alc262_hp_wildwest_automute(codec);
10473}
10474
Takashi Iwaib72519b2009-05-08 14:31:55 +020010475#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010476
10477static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10478 struct snd_ctl_elem_value *ucontrol)
10479{
10480 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10481 struct alc_spec *spec = codec->spec;
10482 int val = !!*ucontrol->value.integer.value;
10483
10484 if (val == spec->master_sw)
10485 return 0;
10486 spec->master_sw = val;
10487 alc262_hp_master_update(codec);
10488 return 1;
10489}
10490
Takashi Iwaib72519b2009-05-08 14:31:55 +020010491#define ALC262_HP_MASTER_SWITCH \
10492 { \
10493 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10494 .name = "Master Playback Switch", \
10495 .info = snd_ctl_boolean_mono_info, \
10496 .get = alc262_hp_master_sw_get, \
10497 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010498 }, \
10499 { \
10500 .iface = NID_MAPPING, \
10501 .name = "Master Playback Switch", \
10502 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020010503 }
10504
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010505
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010506static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010507 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010508 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10509 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10510 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010511 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10512 HDA_OUTPUT),
10513 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10514 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010515 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10516 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010517 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010518 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10519 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010520 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010521 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10522 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10523 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10524 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010525 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10526 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10527 { } /* end */
10528};
10529
Kailang Yangcd7509a2007-01-26 18:33:17 +010010530static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010531 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010532 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10533 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10534 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10535 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010536 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10537 HDA_OUTPUT),
10538 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10539 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010540 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10541 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010542 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010543 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10544 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10545 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10546 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010547 { } /* end */
10548};
10549
10550static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10551 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10552 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010553 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010554 { } /* end */
10555};
10556
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010557/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010558static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010559{
10560 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010561
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010562 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010010563 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010564}
10565
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010566static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010567 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10568 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010569 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10570 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10571 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10572 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10573 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10574 { } /* end */
10575};
10576
10577static struct hda_verb alc262_hp_t5735_verbs[] = {
10578 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10579 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10580
10581 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10582 { }
10583};
10584
Kailang Yang8c427222008-01-10 13:03:59 +010010585static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010586 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10587 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010588 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10589 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010590 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10591 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10592 { } /* end */
10593};
10594
10595static struct hda_verb alc262_hp_rp5700_verbs[] = {
10596 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10597 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10598 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10599 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10600 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10601 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10602 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10603 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10604 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10605 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10606 {}
10607};
10608
10609static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10610 .num_items = 1,
10611 .items = {
10612 { "Line", 0x1 },
10613 },
10614};
10615
Takashi Iwai42171c12009-05-08 14:11:43 +020010616/* bind hp and internal speaker mute (with plug check) as master switch */
10617static void alc262_hippo_master_update(struct hda_codec *codec)
10618{
10619 struct alc_spec *spec = codec->spec;
10620 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10621 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10622 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10623 unsigned int mute;
10624
10625 /* HP */
10626 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10627 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10628 HDA_AMP_MUTE, mute);
10629 /* mute internal speaker per jack sense */
10630 if (spec->jack_present)
10631 mute = HDA_AMP_MUTE;
10632 if (line_nid)
10633 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10634 HDA_AMP_MUTE, mute);
10635 if (speaker_nid && speaker_nid != line_nid)
10636 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10637 HDA_AMP_MUTE, mute);
10638}
10639
10640#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10641
10642static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10643 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010644{
10645 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010646 struct alc_spec *spec = codec->spec;
10647 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010648
Takashi Iwai42171c12009-05-08 14:11:43 +020010649 if (val == spec->master_sw)
10650 return 0;
10651 spec->master_sw = val;
10652 alc262_hippo_master_update(codec);
10653 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010654}
Takashi Iwai5b319542007-07-26 11:49:22 +020010655
Takashi Iwai42171c12009-05-08 14:11:43 +020010656#define ALC262_HIPPO_MASTER_SWITCH \
10657 { \
10658 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10659 .name = "Master Playback Switch", \
10660 .info = snd_ctl_boolean_mono_info, \
10661 .get = alc262_hippo_master_sw_get, \
10662 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010663 }, \
10664 { \
10665 .iface = NID_MAPPING, \
10666 .name = "Master Playback Switch", \
10667 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
10668 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020010669 }
10670
10671static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10672 ALC262_HIPPO_MASTER_SWITCH,
10673 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10674 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10675 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10676 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10677 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10678 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10679 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10680 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10681 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10682 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10683 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10684 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10685 { } /* end */
10686};
10687
10688static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10689 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10690 ALC262_HIPPO_MASTER_SWITCH,
10691 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10692 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10693 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10694 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10695 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10696 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10697 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10698 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10699 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10700 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10701 { } /* end */
10702};
10703
10704/* mute/unmute internal speaker according to the hp jack and mute state */
10705static void alc262_hippo_automute(struct hda_codec *codec)
10706{
10707 struct alc_spec *spec = codec->spec;
10708 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020010709
Wu Fengguang864f92b2009-11-18 12:38:02 +080010710 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020010711 alc262_hippo_master_update(codec);
10712}
10713
10714static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10715{
10716 if ((res >> 26) != ALC880_HP_EVENT)
10717 return;
10718 alc262_hippo_automute(codec);
10719}
10720
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010721static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010722{
10723 struct alc_spec *spec = codec->spec;
10724
10725 spec->autocfg.hp_pins[0] = 0x15;
10726 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010727}
10728
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010729static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010730{
10731 struct alc_spec *spec = codec->spec;
10732
10733 spec->autocfg.hp_pins[0] = 0x1b;
10734 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010735}
10736
10737
Kailang Yang272a5272007-05-14 11:00:38 +020010738static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010739 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010740 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010741 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10742 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10743 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10744 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10745 { } /* end */
10746};
10747
Kailang Yang83c34212007-07-05 11:43:05 +020010748static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010749 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10750 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010751 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10752 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10753 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10754 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10755 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10756 { } /* end */
10757};
Kailang Yang272a5272007-05-14 11:00:38 +020010758
Tony Vroonba340e82009-02-02 19:01:30 +000010759static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10760 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10761 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10762 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10763 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10764 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10765 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10766 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10767 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10768 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10769 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10770 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10771 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10772 { } /* end */
10773};
10774
10775static struct hda_verb alc262_tyan_verbs[] = {
10776 /* Headphone automute */
10777 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10778 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10779 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10780
10781 /* P11 AUX_IN, white 4-pin connector */
10782 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10783 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10784 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10785 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10786
10787 {}
10788};
10789
10790/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010791static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010792{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010793 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010794
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010795 spec->autocfg.hp_pins[0] = 0x1b;
10796 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010797}
10798
Tony Vroonba340e82009-02-02 19:01:30 +000010799
Kailang Yangdf694da2005-12-05 19:42:22 +010010800#define alc262_capture_mixer alc882_capture_mixer
10801#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10802
10803/*
10804 * generic initialization of ADC, input mixers and output mixers
10805 */
10806static struct hda_verb alc262_init_verbs[] = {
10807 /*
10808 * Unmute ADC0-2 and set the default input to mic-in
10809 */
10810 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10811 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10812 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10813 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10814 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10815 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10816
Takashi Iwaicb53c622007-08-10 17:21:45 +020010817 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010818 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010819 * Note: PASD motherboards uses the Line In 2 as the input for
10820 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010821 */
10822 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010823 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10824 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10825 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10826 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10827 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010828
10829 /*
10830 * Set up output mixers (0x0c - 0x0e)
10831 */
10832 /* set vol=0 to output mixers */
10833 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10834 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10835 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10836 /* set up input amps for analog loopback */
10837 /* Amp Indices: DAC = 0, mixer = 1 */
10838 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10839 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10840 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10841 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10842 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10843 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10844
10845 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10846 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10847 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10848 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10849 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10850 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10851
10852 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10853 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10854 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10855 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10856 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010857
Kailang Yangdf694da2005-12-05 19:42:22 +010010858 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10859 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010860
Kailang Yangdf694da2005-12-05 19:42:22 +010010861 /* FIXME: use matrix-type input source selection */
10862 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10863 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10864 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10865 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10866 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10867 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10868 /* Input mixer2 */
10869 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10870 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10871 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10872 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10873 /* Input mixer3 */
10874 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10875 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10876 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010877 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010878
10879 { }
10880};
10881
Kailang Yang4e555fe2008-08-26 13:05:55 +020010882static struct hda_verb alc262_eapd_verbs[] = {
10883 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10884 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10885 { }
10886};
10887
Kailang Yangccc656c2006-10-17 12:32:26 +020010888static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10889 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10890 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10891 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10892
10893 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10894 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10895 {}
10896};
10897
Kailang Yang272a5272007-05-14 11:00:38 +020010898static struct hda_verb alc262_sony_unsol_verbs[] = {
10899 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10900 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10901 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10902
10903 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10904 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010905 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010906};
10907
Kailang Yang4e555fe2008-08-26 13:05:55 +020010908static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10909 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10910 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10911 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10912 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10913 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010914 { } /* end */
10915};
10916
10917static struct hda_verb alc262_toshiba_s06_verbs[] = {
10918 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10919 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10920 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10921 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10922 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10923 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10924 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10925 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10926 {}
10927};
10928
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010929static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020010930{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010931 struct alc_spec *spec = codec->spec;
10932
10933 spec->autocfg.hp_pins[0] = 0x15;
10934 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010935 spec->ext_mic.pin = 0x18;
10936 spec->ext_mic.mux_idx = 0;
10937 spec->int_mic.pin = 0x12;
10938 spec->int_mic.mux_idx = 9;
10939 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020010940}
10941
Takashi Iwai834be882006-03-01 14:16:17 +010010942/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010943 * nec model
10944 * 0x15 = headphone
10945 * 0x16 = internal speaker
10946 * 0x18 = external mic
10947 */
10948
10949static struct snd_kcontrol_new alc262_nec_mixer[] = {
10950 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10951 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10952
10953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10954 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10955 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10956
10957 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10958 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10959 { } /* end */
10960};
10961
10962static struct hda_verb alc262_nec_verbs[] = {
10963 /* Unmute Speaker */
10964 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10965
10966 /* Headphone */
10967 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10968 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10969
10970 /* External mic to headphone */
10971 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10972 /* External mic to speaker */
10973 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10974 {}
10975};
10976
10977/*
Takashi Iwai834be882006-03-01 14:16:17 +010010978 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010979 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10980 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010981 */
10982
10983#define ALC_HP_EVENT 0x37
10984
10985static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10986 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10987 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010988 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10989 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010990 {}
10991};
10992
Jiang zhe0e31daf2008-03-20 12:12:39 +010010993static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10994 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10995 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10996 {}
10997};
10998
Daniel T Chene2595322009-12-19 18:19:02 -050010999static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11000 /* Front Mic pin: input vref at 50% */
11001 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11002 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11003 {}
11004};
11005
Takashi Iwai834be882006-03-01 14:16:17 +010011006static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011007 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011008 .items = {
11009 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011010 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011011 { "CD", 0x4 },
11012 },
11013};
11014
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011015static struct hda_input_mux alc262_HP_capture_source = {
11016 .num_items = 5,
11017 .items = {
11018 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011019 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011020 { "Line", 0x2 },
11021 { "CD", 0x4 },
11022 { "AUX IN", 0x6 },
11023 },
11024};
11025
zhejiangaccbe492007-08-31 12:36:05 +020011026static struct hda_input_mux alc262_HP_D7000_capture_source = {
11027 .num_items = 4,
11028 .items = {
11029 { "Mic", 0x0 },
11030 { "Front Mic", 0x2 },
11031 { "Line", 0x1 },
11032 { "CD", 0x4 },
11033 },
11034};
11035
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011036/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011037static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11038{
11039 struct alc_spec *spec = codec->spec;
11040 unsigned int mute;
11041
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011042 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011043 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11044 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011045 spec->sense_updated = 1;
11046 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011047 /* unmute internal speaker only if both HPs are unplugged and
11048 * master switch is on
11049 */
11050 if (spec->jack_present)
11051 mute = HDA_AMP_MUTE;
11052 else
Takashi Iwai834be882006-03-01 14:16:17 +010011053 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011054 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11055 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011056}
11057
11058/* unsolicited event for HP jack sensing */
11059static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11060 unsigned int res)
11061{
11062 if ((res >> 26) != ALC_HP_EVENT)
11063 return;
11064 alc262_fujitsu_automute(codec, 1);
11065}
11066
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011067static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11068{
11069 alc262_fujitsu_automute(codec, 1);
11070}
11071
Takashi Iwai834be882006-03-01 14:16:17 +010011072/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011073static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11074 .ops = &snd_hda_bind_vol,
11075 .values = {
11076 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11077 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11078 0
11079 },
11080};
Takashi Iwai834be882006-03-01 14:16:17 +010011081
Jiang zhe0e31daf2008-03-20 12:12:39 +010011082/* mute/unmute internal speaker according to the hp jack and mute state */
11083static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11084{
11085 struct alc_spec *spec = codec->spec;
11086 unsigned int mute;
11087
11088 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011089 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011090 spec->sense_updated = 1;
11091 }
11092 if (spec->jack_present) {
11093 /* mute internal speaker */
11094 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11095 HDA_AMP_MUTE, HDA_AMP_MUTE);
11096 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11097 HDA_AMP_MUTE, HDA_AMP_MUTE);
11098 } else {
11099 /* unmute internal speaker if necessary */
11100 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11101 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11102 HDA_AMP_MUTE, mute);
11103 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11104 HDA_AMP_MUTE, mute);
11105 }
11106}
11107
11108/* unsolicited event for HP jack sensing */
11109static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11110 unsigned int res)
11111{
11112 if ((res >> 26) != ALC_HP_EVENT)
11113 return;
11114 alc262_lenovo_3000_automute(codec, 1);
11115}
11116
Takashi Iwai8de56b72009-07-24 16:51:47 +020011117static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11118 int dir, int idx, long *valp)
11119{
11120 int i, change = 0;
11121
11122 for (i = 0; i < 2; i++, valp++)
11123 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11124 HDA_AMP_MUTE,
11125 *valp ? 0 : HDA_AMP_MUTE);
11126 return change;
11127}
11128
Takashi Iwai834be882006-03-01 14:16:17 +010011129/* bind hp and internal speaker mute (with plug check) */
11130static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11131 struct snd_ctl_elem_value *ucontrol)
11132{
11133 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11134 long *valp = ucontrol->value.integer.value;
11135 int change;
11136
Takashi Iwai8de56b72009-07-24 16:51:47 +020011137 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11138 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011139 if (change)
11140 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011141 return change;
11142}
11143
11144static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011145 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011146 {
11147 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11148 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011149 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011150 .info = snd_hda_mixer_amp_switch_info,
11151 .get = snd_hda_mixer_amp_switch_get,
11152 .put = alc262_fujitsu_master_sw_put,
11153 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11154 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011155 {
11156 .iface = NID_MAPPING,
11157 .name = "Master Playback Switch",
11158 .private_value = 0x1b,
11159 },
Takashi Iwai834be882006-03-01 14:16:17 +010011160 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11161 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11162 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11163 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11164 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011165 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11166 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11167 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011168 { } /* end */
11169};
11170
Jiang zhe0e31daf2008-03-20 12:12:39 +010011171/* bind hp and internal speaker mute (with plug check) */
11172static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11173 struct snd_ctl_elem_value *ucontrol)
11174{
11175 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11176 long *valp = ucontrol->value.integer.value;
11177 int change;
11178
Takashi Iwai8de56b72009-07-24 16:51:47 +020011179 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011180 if (change)
11181 alc262_lenovo_3000_automute(codec, 0);
11182 return change;
11183}
11184
11185static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11186 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11187 {
11188 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11189 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011190 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011191 .info = snd_hda_mixer_amp_switch_info,
11192 .get = snd_hda_mixer_amp_switch_get,
11193 .put = alc262_lenovo_3000_master_sw_put,
11194 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11195 },
11196 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11197 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11198 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11199 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11200 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11201 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11202 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11203 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11204 { } /* end */
11205};
11206
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011207static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11208 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011209 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011210 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11211 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11212 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11213 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11214 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11215 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11216 { } /* end */
11217};
11218
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011219/* additional init verbs for Benq laptops */
11220static struct hda_verb alc262_EAPD_verbs[] = {
11221 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11222 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11223 {}
11224};
11225
Kailang Yang83c34212007-07-05 11:43:05 +020011226static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11227 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11228 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11229
11230 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11231 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11232 {}
11233};
11234
Tobin Davisf651b502007-10-26 12:40:47 +020011235/* Samsung Q1 Ultra Vista model setup */
11236static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011237 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11238 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011239 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11240 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11241 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011242 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011243 { } /* end */
11244};
11245
11246static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011247 /* output mixer */
11248 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11249 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11250 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11251 /* speaker */
11252 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11253 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11254 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11255 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11256 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011257 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011258 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11259 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11260 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11261 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11262 /* internal mic */
11263 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11264 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11265 /* ADC, choose mic */
11266 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11267 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11268 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11269 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11270 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11271 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11272 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11273 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11274 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11275 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011276 {}
11277};
11278
Tobin Davisf651b502007-10-26 12:40:47 +020011279/* mute/unmute internal speaker according to the hp jack and mute state */
11280static void alc262_ultra_automute(struct hda_codec *codec)
11281{
11282 struct alc_spec *spec = codec->spec;
11283 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011284
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011285 mute = 0;
11286 /* auto-mute only when HP is used as HP */
11287 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011288 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011289 if (spec->jack_present)
11290 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011291 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011292 /* mute/unmute internal speaker */
11293 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11294 HDA_AMP_MUTE, mute);
11295 /* mute/unmute HP */
11296 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11297 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011298}
11299
11300/* unsolicited event for HP jack sensing */
11301static void alc262_ultra_unsol_event(struct hda_codec *codec,
11302 unsigned int res)
11303{
11304 if ((res >> 26) != ALC880_HP_EVENT)
11305 return;
11306 alc262_ultra_automute(codec);
11307}
11308
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011309static struct hda_input_mux alc262_ultra_capture_source = {
11310 .num_items = 2,
11311 .items = {
11312 { "Mic", 0x1 },
11313 { "Headphone", 0x7 },
11314 },
11315};
11316
11317static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11318 struct snd_ctl_elem_value *ucontrol)
11319{
11320 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11321 struct alc_spec *spec = codec->spec;
11322 int ret;
11323
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011324 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011325 if (!ret)
11326 return 0;
11327 /* reprogram the HP pin as mic or HP according to the input source */
11328 snd_hda_codec_write_cache(codec, 0x15, 0,
11329 AC_VERB_SET_PIN_WIDGET_CONTROL,
11330 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11331 alc262_ultra_automute(codec); /* mute/unmute HP */
11332 return ret;
11333}
11334
11335static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11336 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11337 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11338 {
11339 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11340 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011341 .info = alc_mux_enum_info,
11342 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011343 .put = alc262_ultra_mux_enum_put,
11344 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011345 {
11346 .iface = NID_MAPPING,
11347 .name = "Capture Source",
11348 .private_value = 0x15,
11349 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011350 { } /* end */
11351};
11352
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011353/* We use two mixers depending on the output pin; 0x16 is a mono output
11354 * and thus it's bound with a different mixer.
11355 * This function returns which mixer amp should be used.
11356 */
11357static int alc262_check_volbit(hda_nid_t nid)
11358{
11359 if (!nid)
11360 return 0;
11361 else if (nid == 0x16)
11362 return 2;
11363 else
11364 return 1;
11365}
11366
11367static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
11368 const char *pfx, int *vbits)
11369{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011370 unsigned long val;
11371 int vbit;
11372
11373 vbit = alc262_check_volbit(nid);
11374 if (!vbit)
11375 return 0;
11376 if (*vbits & vbit) /* a volume control for this mixer already there */
11377 return 0;
11378 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011379 if (vbit == 2)
11380 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11381 else
11382 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011383 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011384}
11385
11386static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
11387 const char *pfx)
11388{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011389 unsigned long val;
11390
11391 if (!nid)
11392 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011393 if (nid == 0x16)
11394 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11395 else
11396 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011397 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011398}
11399
Kailang Yangdf694da2005-12-05 19:42:22 +010011400/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011401static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11402 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011403{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011404 const char *pfx;
11405 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010011406 int err;
11407
11408 spec->multiout.num_dacs = 1; /* only use one dac */
11409 spec->multiout.dac_nids = spec->private_dac_nids;
11410 spec->multiout.dac_nids[0] = 2;
11411
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011412 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11413 pfx = "Master";
11414 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11415 pfx = "Speaker";
11416 else
11417 pfx = "Front";
11418 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11419 if (err < 0)
11420 return err;
11421 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11422 if (err < 0)
11423 return err;
11424 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11425 if (err < 0)
11426 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011427
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011428 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11429 alc262_check_volbit(cfg->speaker_pins[0]) |
11430 alc262_check_volbit(cfg->hp_pins[0]);
11431 if (vbits == 1 || vbits == 2)
11432 pfx = "Master"; /* only one mixer is used */
11433 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11434 pfx = "Speaker";
11435 else
11436 pfx = "Front";
11437 vbits = 0;
11438 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11439 if (err < 0)
11440 return err;
11441 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11442 &vbits);
11443 if (err < 0)
11444 return err;
11445 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11446 &vbits);
11447 if (err < 0)
11448 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011449 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011450}
11451
Takashi Iwai05f5f472009-08-25 13:10:18 +020011452#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010011453 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011454
11455/*
11456 * generic initialization of ADC, input mixers and output mixers
11457 */
11458static struct hda_verb alc262_volume_init_verbs[] = {
11459 /*
11460 * Unmute ADC0-2 and set the default input to mic-in
11461 */
11462 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11463 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11464 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11465 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11466 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11467 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11468
Takashi Iwaicb53c622007-08-10 17:21:45 +020011469 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011470 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011471 * Note: PASD motherboards uses the Line In 2 as the input for
11472 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011473 */
11474 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011475 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11476 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11477 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11478 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11479 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011480
11481 /*
11482 * Set up output mixers (0x0c - 0x0f)
11483 */
11484 /* set vol=0 to output mixers */
11485 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11486 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11487 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011488
Kailang Yangdf694da2005-12-05 19:42:22 +010011489 /* set up input amps for analog loopback */
11490 /* Amp Indices: DAC = 0, mixer = 1 */
11491 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11492 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11493 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11494 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11495 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11496 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11497
11498 /* FIXME: use matrix-type input source selection */
11499 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11500 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11501 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11502 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11503 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11504 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11505 /* Input mixer2 */
11506 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11507 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11508 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11509 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11510 /* Input mixer3 */
11511 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11512 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11513 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11514 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11515
11516 { }
11517};
11518
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011519static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11520 /*
11521 * Unmute ADC0-2 and set the default input to mic-in
11522 */
11523 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11524 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11525 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11526 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11527 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11528 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11529
Takashi Iwaicb53c622007-08-10 17:21:45 +020011530 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011531 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011532 * Note: PASD motherboards uses the Line In 2 as the input for
11533 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011534 */
11535 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011536 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11537 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11538 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11539 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11540 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11541 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11542 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011543
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011544 /*
11545 * Set up output mixers (0x0c - 0x0e)
11546 */
11547 /* set vol=0 to output mixers */
11548 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11549 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11550 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11551
11552 /* set up input amps for analog loopback */
11553 /* Amp Indices: DAC = 0, mixer = 1 */
11554 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11555 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11556 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11557 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11558 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11559 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11560
Takashi Iwaice875f02008-01-28 18:17:43 +010011561 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011562 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11563 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11564
11565 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11566 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11567
11568 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11569 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11570
11571 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11572 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11573 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11574 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11575 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11576
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011577 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011578 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11579 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011580 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011581 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11582 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11583
11584
11585 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011586 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11587 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011588 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011589 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11590 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11591 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11592 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11593 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11594 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11595 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11596 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011597 /* Input mixer2 */
11598 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011599 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11600 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11601 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11602 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11603 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11604 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11605 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11606 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011607 /* Input mixer3 */
11608 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011609 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11610 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11611 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11612 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11613 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11614 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11615 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11616 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011617
Takashi Iwaice875f02008-01-28 18:17:43 +010011618 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11619
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011620 { }
11621};
11622
Kailang Yangcd7509a2007-01-26 18:33:17 +010011623static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11624 /*
11625 * Unmute ADC0-2 and set the default input to mic-in
11626 */
11627 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11628 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11629 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11630 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11631 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11632 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11633
Takashi Iwaicb53c622007-08-10 17:21:45 +020011634 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011635 * mixer widget
11636 * Note: PASD motherboards uses the Line In 2 as the input for front
11637 * panel mic (mic 2)
11638 */
11639 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11644 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11645 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11646 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11647 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011648 /*
11649 * Set up output mixers (0x0c - 0x0e)
11650 */
11651 /* set vol=0 to output mixers */
11652 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11653 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11654 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11655
11656 /* set up input amps for analog loopback */
11657 /* Amp Indices: DAC = 0, mixer = 1 */
11658 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11659 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11660 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11661 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11662 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11663 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11664
11665
11666 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11667 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11668 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11669 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11670 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11671 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11672 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11673
11674 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11675 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11676
11677 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11678 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11679
11680 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11681 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11682 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11683 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11684 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11685 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11686
11687 /* FIXME: use matrix-type input source selection */
11688 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11689 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11690 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11691 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11692 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11693 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11694 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11695 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11696 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11697 /* Input mixer2 */
11698 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11699 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11700 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11701 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11702 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11703 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11704 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11705 /* Input mixer3 */
11706 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11707 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11708 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11709 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11710 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11711 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11712 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11713
Takashi Iwaice875f02008-01-28 18:17:43 +010011714 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11715
Kailang Yangcd7509a2007-01-26 18:33:17 +010011716 { }
11717};
11718
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011719static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11720
11721 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11722 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11723 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11724
11725 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11726 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11727 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11728 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11729
11730 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11731 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11732 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11733 {}
11734};
11735
11736
Takashi Iwaicb53c622007-08-10 17:21:45 +020011737#ifdef CONFIG_SND_HDA_POWER_SAVE
11738#define alc262_loopbacks alc880_loopbacks
11739#endif
11740
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011741/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011742#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11743#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11744#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11745#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11746
11747/*
11748 * BIOS auto configuration
11749 */
11750static int alc262_parse_auto_config(struct hda_codec *codec)
11751{
11752 struct alc_spec *spec = codec->spec;
11753 int err;
11754 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11755
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011756 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11757 alc262_ignore);
11758 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011759 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011760 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011761 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011762 spec->multiout.max_channels = 2;
11763 spec->no_analog = 1;
11764 goto dig_only;
11765 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011766 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011767 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011768 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11769 if (err < 0)
11770 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011771 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011772 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011773 return err;
11774
11775 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11776
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011777 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011778 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011779 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011780 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011781 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011782 if (spec->autocfg.dig_in_pin)
11783 spec->dig_in_nid = ALC262_DIGIN_NID;
11784
Takashi Iwai603c4012008-07-30 15:01:44 +020011785 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011786 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011787
Takashi Iwaid88897e2008-10-31 15:01:37 +010011788 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011789 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011790 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011791
Takashi Iwai776e1842007-08-29 15:07:11 +020011792 err = alc_auto_add_mic_boost(codec);
11793 if (err < 0)
11794 return err;
11795
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011796 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11797
Kailang Yangdf694da2005-12-05 19:42:22 +010011798 return 1;
11799}
11800
11801#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11802#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11803#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011804#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011805
11806
11807/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011808static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011809{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011810 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011811 alc262_auto_init_multi_out(codec);
11812 alc262_auto_init_hp_out(codec);
11813 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011814 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011815 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011816 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011817}
11818
11819/*
11820 * configuration and preset
11821 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011822static const char *alc262_models[ALC262_MODEL_LAST] = {
11823 [ALC262_BASIC] = "basic",
11824 [ALC262_HIPPO] = "hippo",
11825 [ALC262_HIPPO_1] = "hippo_1",
11826 [ALC262_FUJITSU] = "fujitsu",
11827 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011828 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011829 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011830 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011831 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011832 [ALC262_BENQ_T31] = "benq-t31",
11833 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011834 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011835 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011836 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011837 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011838 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011839 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011840 [ALC262_AUTO] = "auto",
11841};
11842
11843static struct snd_pci_quirk alc262_cfg_tbl[] = {
11844 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011845 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011846 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11847 ALC262_HP_BPC),
11848 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11849 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011850 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11851 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011852 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011853 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011854 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011855 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011856 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011857 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011858 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011859 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011860 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11861 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11862 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011863 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11864 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011865 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011866 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011867 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011868 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011869 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011870 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050011871 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010011872 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011873#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010011874 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11875 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011876#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090011877 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011878 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011879 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011880 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011881 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011882 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011883 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11884 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011885 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011886 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011887 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011888 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011889 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011890 {}
11891};
11892
11893static struct alc_config_preset alc262_presets[] = {
11894 [ALC262_BASIC] = {
11895 .mixers = { alc262_base_mixer },
11896 .init_verbs = { alc262_init_verbs },
11897 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11898 .dac_nids = alc262_dac_nids,
11899 .hp_nid = 0x03,
11900 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11901 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011902 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011903 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011904 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011905 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011906 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011907 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11908 .dac_nids = alc262_dac_nids,
11909 .hp_nid = 0x03,
11910 .dig_out_nid = ALC262_DIGOUT_NID,
11911 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11912 .channel_mode = alc262_modes,
11913 .input_mux = &alc262_capture_source,
11914 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011915 .setup = alc262_hippo_setup,
11916 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011917 },
11918 [ALC262_HIPPO_1] = {
11919 .mixers = { alc262_hippo1_mixer },
11920 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11921 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11922 .dac_nids = alc262_dac_nids,
11923 .hp_nid = 0x02,
11924 .dig_out_nid = ALC262_DIGOUT_NID,
11925 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11926 .channel_mode = alc262_modes,
11927 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011928 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011929 .setup = alc262_hippo1_setup,
11930 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011931 },
Takashi Iwai834be882006-03-01 14:16:17 +010011932 [ALC262_FUJITSU] = {
11933 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011934 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11935 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011936 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11937 .dac_nids = alc262_dac_nids,
11938 .hp_nid = 0x03,
11939 .dig_out_nid = ALC262_DIGOUT_NID,
11940 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11941 .channel_mode = alc262_modes,
11942 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011943 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011944 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011945 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011946 [ALC262_HP_BPC] = {
11947 .mixers = { alc262_HP_BPC_mixer },
11948 .init_verbs = { alc262_HP_BPC_init_verbs },
11949 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11950 .dac_nids = alc262_dac_nids,
11951 .hp_nid = 0x03,
11952 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11953 .channel_mode = alc262_modes,
11954 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011955 .unsol_event = alc262_hp_bpc_unsol_event,
11956 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011957 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011958 [ALC262_HP_BPC_D7000_WF] = {
11959 .mixers = { alc262_HP_BPC_WildWest_mixer },
11960 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11961 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11962 .dac_nids = alc262_dac_nids,
11963 .hp_nid = 0x03,
11964 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11965 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011966 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011967 .unsol_event = alc262_hp_wildwest_unsol_event,
11968 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011969 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011970 [ALC262_HP_BPC_D7000_WL] = {
11971 .mixers = { alc262_HP_BPC_WildWest_mixer,
11972 alc262_HP_BPC_WildWest_option_mixer },
11973 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11974 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11975 .dac_nids = alc262_dac_nids,
11976 .hp_nid = 0x03,
11977 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11978 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011979 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011980 .unsol_event = alc262_hp_wildwest_unsol_event,
11981 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011982 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011983 [ALC262_HP_TC_T5735] = {
11984 .mixers = { alc262_hp_t5735_mixer },
11985 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11986 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11987 .dac_nids = alc262_dac_nids,
11988 .hp_nid = 0x03,
11989 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11990 .channel_mode = alc262_modes,
11991 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010011992 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011993 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010011994 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010011995 },
11996 [ALC262_HP_RP5700] = {
11997 .mixers = { alc262_hp_rp5700_mixer },
11998 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11999 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12000 .dac_nids = alc262_dac_nids,
12001 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12002 .channel_mode = alc262_modes,
12003 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012004 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012005 [ALC262_BENQ_ED8] = {
12006 .mixers = { alc262_base_mixer },
12007 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12008 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12009 .dac_nids = alc262_dac_nids,
12010 .hp_nid = 0x03,
12011 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12012 .channel_mode = alc262_modes,
12013 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012014 },
Kailang Yang272a5272007-05-14 11:00:38 +020012015 [ALC262_SONY_ASSAMD] = {
12016 .mixers = { alc262_sony_mixer },
12017 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12018 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12019 .dac_nids = alc262_dac_nids,
12020 .hp_nid = 0x02,
12021 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12022 .channel_mode = alc262_modes,
12023 .input_mux = &alc262_capture_source,
12024 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012025 .setup = alc262_hippo_setup,
12026 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012027 },
12028 [ALC262_BENQ_T31] = {
12029 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012030 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12031 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012032 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12033 .dac_nids = alc262_dac_nids,
12034 .hp_nid = 0x03,
12035 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12036 .channel_mode = alc262_modes,
12037 .input_mux = &alc262_capture_source,
12038 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012039 .setup = alc262_hippo_setup,
12040 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012041 },
Tobin Davisf651b502007-10-26 12:40:47 +020012042 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012043 .mixers = { alc262_ultra_mixer },
12044 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012045 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012046 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12047 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012048 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12049 .channel_mode = alc262_modes,
12050 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012051 .adc_nids = alc262_adc_nids, /* ADC0 */
12052 .capsrc_nids = alc262_capsrc_nids,
12053 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012054 .unsol_event = alc262_ultra_unsol_event,
12055 .init_hook = alc262_ultra_automute,
12056 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012057 [ALC262_LENOVO_3000] = {
12058 .mixers = { alc262_lenovo_3000_mixer },
12059 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012060 alc262_lenovo_3000_unsol_verbs,
12061 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012062 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12063 .dac_nids = alc262_dac_nids,
12064 .hp_nid = 0x03,
12065 .dig_out_nid = ALC262_DIGOUT_NID,
12066 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12067 .channel_mode = alc262_modes,
12068 .input_mux = &alc262_fujitsu_capture_source,
12069 .unsol_event = alc262_lenovo_3000_unsol_event,
12070 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012071 [ALC262_NEC] = {
12072 .mixers = { alc262_nec_mixer },
12073 .init_verbs = { alc262_nec_verbs },
12074 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12075 .dac_nids = alc262_dac_nids,
12076 .hp_nid = 0x03,
12077 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12078 .channel_mode = alc262_modes,
12079 .input_mux = &alc262_capture_source,
12080 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012081 [ALC262_TOSHIBA_S06] = {
12082 .mixers = { alc262_toshiba_s06_mixer },
12083 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12084 alc262_eapd_verbs },
12085 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12086 .capsrc_nids = alc262_dmic_capsrc_nids,
12087 .dac_nids = alc262_dac_nids,
12088 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012089 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012090 .dig_out_nid = ALC262_DIGOUT_NID,
12091 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12092 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012093 .unsol_event = alc_sku_unsol_event,
12094 .setup = alc262_toshiba_s06_setup,
12095 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012096 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012097 [ALC262_TOSHIBA_RX1] = {
12098 .mixers = { alc262_toshiba_rx1_mixer },
12099 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12100 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12101 .dac_nids = alc262_dac_nids,
12102 .hp_nid = 0x03,
12103 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12104 .channel_mode = alc262_modes,
12105 .input_mux = &alc262_capture_source,
12106 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012107 .setup = alc262_hippo_setup,
12108 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012109 },
Tony Vroonba340e82009-02-02 19:01:30 +000012110 [ALC262_TYAN] = {
12111 .mixers = { alc262_tyan_mixer },
12112 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12113 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12114 .dac_nids = alc262_dac_nids,
12115 .hp_nid = 0x02,
12116 .dig_out_nid = ALC262_DIGOUT_NID,
12117 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12118 .channel_mode = alc262_modes,
12119 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012120 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012121 .setup = alc262_tyan_setup,
12122 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012123 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012124};
12125
12126static int patch_alc262(struct hda_codec *codec)
12127{
12128 struct alc_spec *spec;
12129 int board_config;
12130 int err;
12131
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012132 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012133 if (spec == NULL)
12134 return -ENOMEM;
12135
12136 codec->spec = spec;
12137#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012138 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12139 * under-run
12140 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012141 {
12142 int tmp;
12143 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12144 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12145 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12146 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12147 }
12148#endif
12149
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012150 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12151
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012152 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12153 alc262_models,
12154 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012155
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012156 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012157 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12158 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012159 board_config = ALC262_AUTO;
12160 }
12161
12162 if (board_config == ALC262_AUTO) {
12163 /* automatic parse from the BIOS config */
12164 err = alc262_parse_auto_config(codec);
12165 if (err < 0) {
12166 alc_free(codec);
12167 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012168 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012169 printk(KERN_INFO
12170 "hda_codec: Cannot set up configuration "
12171 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012172 board_config = ALC262_BASIC;
12173 }
12174 }
12175
Takashi Iwai07eba612009-02-19 08:06:35 +010012176 if (!spec->no_analog) {
12177 err = snd_hda_attach_beep_device(codec, 0x1);
12178 if (err < 0) {
12179 alc_free(codec);
12180 return err;
12181 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012182 }
12183
Kailang Yangdf694da2005-12-05 19:42:22 +010012184 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012185 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012186
Kailang Yangdf694da2005-12-05 19:42:22 +010012187 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12188 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012189
Kailang Yangdf694da2005-12-05 19:42:22 +010012190 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12191 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12192
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012193 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012194 int i;
12195 /* check whether the digital-mic has to be supported */
12196 for (i = 0; i < spec->input_mux->num_items; i++) {
12197 if (spec->input_mux->items[i].index >= 9)
12198 break;
12199 }
12200 if (i < spec->input_mux->num_items) {
12201 /* use only ADC0 */
12202 spec->adc_nids = alc262_dmic_adc_nids;
12203 spec->num_adc_nids = 1;
12204 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012205 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012206 /* all analog inputs */
12207 /* check whether NID 0x07 is valid */
12208 unsigned int wcap = get_wcaps(codec, 0x07);
12209
12210 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012211 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012212 if (wcap != AC_WID_AUD_IN) {
12213 spec->adc_nids = alc262_adc_nids_alt;
12214 spec->num_adc_nids =
12215 ARRAY_SIZE(alc262_adc_nids_alt);
12216 spec->capsrc_nids = alc262_capsrc_nids_alt;
12217 } else {
12218 spec->adc_nids = alc262_adc_nids;
12219 spec->num_adc_nids =
12220 ARRAY_SIZE(alc262_adc_nids);
12221 spec->capsrc_nids = alc262_capsrc_nids;
12222 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012223 }
12224 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012225 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012226 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010012227 if (!spec->no_analog)
12228 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012229
Takashi Iwai2134ea42008-01-10 16:53:55 +010012230 spec->vmaster_nid = 0x0c;
12231
Kailang Yangdf694da2005-12-05 19:42:22 +010012232 codec->patch_ops = alc_patch_ops;
12233 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012234 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012235#ifdef CONFIG_SND_HDA_POWER_SAVE
12236 if (!spec->loopback.amplist)
12237 spec->loopback.amplist = alc262_loopbacks;
12238#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012239
Kailang Yangdf694da2005-12-05 19:42:22 +010012240 return 0;
12241}
12242
Kailang Yangdf694da2005-12-05 19:42:22 +010012243/*
Kailang Yanga361d842007-06-05 12:30:55 +020012244 * ALC268 channel source setting (2 channel)
12245 */
12246#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12247#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012248
Kailang Yanga361d842007-06-05 12:30:55 +020012249static hda_nid_t alc268_dac_nids[2] = {
12250 /* front, hp */
12251 0x02, 0x03
12252};
12253
12254static hda_nid_t alc268_adc_nids[2] = {
12255 /* ADC0-1 */
12256 0x08, 0x07
12257};
12258
12259static hda_nid_t alc268_adc_nids_alt[1] = {
12260 /* ADC0 */
12261 0x08
12262};
12263
Takashi Iwaie1406342008-02-11 18:32:32 +010012264static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12265
Kailang Yanga361d842007-06-05 12:30:55 +020012266static struct snd_kcontrol_new alc268_base_mixer[] = {
12267 /* output mixer control */
12268 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12269 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12270 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12271 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012272 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12273 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12274 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012275 { }
12276};
12277
Takashi Iwai42171c12009-05-08 14:11:43 +020012278static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12279 /* output mixer control */
12280 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12281 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12282 ALC262_HIPPO_MASTER_SWITCH,
12283 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12284 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12285 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12286 { }
12287};
12288
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012289/* bind Beep switches of both NID 0x0f and 0x10 */
12290static struct hda_bind_ctls alc268_bind_beep_sw = {
12291 .ops = &snd_hda_bind_sw,
12292 .values = {
12293 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12294 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12295 0
12296 },
12297};
12298
12299static struct snd_kcontrol_new alc268_beep_mixer[] = {
12300 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12301 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12302 { }
12303};
12304
Kailang Yangd1a991a2007-08-15 16:21:59 +020012305static struct hda_verb alc268_eapd_verbs[] = {
12306 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12307 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12308 { }
12309};
12310
Takashi Iwaid2738092007-08-16 14:59:45 +020012311/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012312static struct hda_verb alc268_toshiba_verbs[] = {
12313 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12314 { } /* end */
12315};
12316
12317/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012318/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012319static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12320 .ops = &snd_hda_bind_vol,
12321 .values = {
12322 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12323 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12324 0
12325 },
12326};
12327
Takashi Iwai889c4392007-08-23 18:56:52 +020012328/* mute/unmute internal speaker according to the hp jack and mute state */
12329static void alc268_acer_automute(struct hda_codec *codec, int force)
12330{
12331 struct alc_spec *spec = codec->spec;
12332 unsigned int mute;
12333
12334 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012335 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012336 spec->sense_updated = 1;
12337 }
12338 if (spec->jack_present)
12339 mute = HDA_AMP_MUTE; /* mute internal speaker */
12340 else /* unmute internal speaker if necessary */
12341 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12342 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12343 HDA_AMP_MUTE, mute);
12344}
12345
12346
12347/* bind hp and internal speaker mute (with plug check) */
12348static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12349 struct snd_ctl_elem_value *ucontrol)
12350{
12351 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12352 long *valp = ucontrol->value.integer.value;
12353 int change;
12354
Takashi Iwai8de56b72009-07-24 16:51:47 +020012355 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012356 if (change)
12357 alc268_acer_automute(codec, 0);
12358 return change;
12359}
Takashi Iwaid2738092007-08-16 14:59:45 +020012360
Kailang Yang8ef355d2008-08-26 13:10:22 +020012361static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12362 /* output mixer control */
12363 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12364 {
12365 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12366 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012367 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012368 .info = snd_hda_mixer_amp_switch_info,
12369 .get = snd_hda_mixer_amp_switch_get,
12370 .put = alc268_acer_master_sw_put,
12371 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12372 },
12373 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12374 { }
12375};
12376
Takashi Iwaid2738092007-08-16 14:59:45 +020012377static struct snd_kcontrol_new alc268_acer_mixer[] = {
12378 /* output mixer control */
12379 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12380 {
12381 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12382 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012383 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020012384 .info = snd_hda_mixer_amp_switch_info,
12385 .get = snd_hda_mixer_amp_switch_get,
12386 .put = alc268_acer_master_sw_put,
12387 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12388 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012389 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12390 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12391 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012392 { }
12393};
12394
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012395static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12396 /* output mixer control */
12397 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12398 {
12399 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12400 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012401 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012402 .info = snd_hda_mixer_amp_switch_info,
12403 .get = snd_hda_mixer_amp_switch_get,
12404 .put = alc268_acer_master_sw_put,
12405 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12406 },
12407 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12408 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12409 { }
12410};
12411
Kailang Yang8ef355d2008-08-26 13:10:22 +020012412static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12413 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12414 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12415 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12416 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12417 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12418 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12419 { }
12420};
12421
Takashi Iwaid2738092007-08-16 14:59:45 +020012422static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012423 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12424 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012425 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12426 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012427 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12428 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012429 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12430 { }
12431};
12432
12433/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012434#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012435#define alc268_toshiba_setup alc262_hippo_setup
12436#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012437
12438static void alc268_acer_unsol_event(struct hda_codec *codec,
12439 unsigned int res)
12440{
Takashi Iwai889c4392007-08-23 18:56:52 +020012441 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012442 return;
12443 alc268_acer_automute(codec, 1);
12444}
12445
Takashi Iwai889c4392007-08-23 18:56:52 +020012446static void alc268_acer_init_hook(struct hda_codec *codec)
12447{
12448 alc268_acer_automute(codec, 1);
12449}
12450
Kailang Yang8ef355d2008-08-26 13:10:22 +020012451/* toggle speaker-output according to the hp-jack state */
12452static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12453{
12454 unsigned int present;
12455 unsigned char bits;
12456
Wu Fengguang864f92b2009-11-18 12:38:02 +080012457 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012458 bits = present ? AMP_IN_MUTE(0) : 0;
12459 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
12460 AMP_IN_MUTE(0), bits);
12461 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
12462 AMP_IN_MUTE(0), bits);
12463}
12464
Kailang Yang8ef355d2008-08-26 13:10:22 +020012465static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12466 unsigned int res)
12467{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012468 switch (res >> 26) {
12469 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012470 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012471 break;
12472 case ALC880_MIC_EVENT:
12473 alc_mic_automute(codec);
12474 break;
12475 }
12476}
12477
12478static void alc268_acer_lc_setup(struct hda_codec *codec)
12479{
12480 struct alc_spec *spec = codec->spec;
12481 spec->ext_mic.pin = 0x18;
12482 spec->ext_mic.mux_idx = 0;
12483 spec->int_mic.pin = 0x12;
12484 spec->int_mic.mux_idx = 6;
12485 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012486}
12487
12488static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12489{
12490 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012491 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012492}
12493
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012494static struct snd_kcontrol_new alc268_dell_mixer[] = {
12495 /* output mixer control */
12496 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12497 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12498 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12499 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12500 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12501 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12502 { }
12503};
12504
12505static struct hda_verb alc268_dell_verbs[] = {
12506 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12507 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12508 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012509 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012510 { }
12511};
12512
12513/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012514static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012515{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012516 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012517
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012518 spec->autocfg.hp_pins[0] = 0x15;
12519 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012520 spec->ext_mic.pin = 0x18;
12521 spec->ext_mic.mux_idx = 0;
12522 spec->int_mic.pin = 0x19;
12523 spec->int_mic.mux_idx = 1;
12524 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012525}
12526
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012527static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12528 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12529 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12530 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12531 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12532 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12533 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12534 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12535 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12536 { }
12537};
12538
12539static struct hda_verb alc267_quanta_il1_verbs[] = {
12540 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12541 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12542 { }
12543};
12544
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012545static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012546{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012547 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012548 spec->autocfg.hp_pins[0] = 0x15;
12549 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012550 spec->ext_mic.pin = 0x18;
12551 spec->ext_mic.mux_idx = 0;
12552 spec->int_mic.pin = 0x19;
12553 spec->int_mic.mux_idx = 1;
12554 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012555}
12556
Kailang Yanga361d842007-06-05 12:30:55 +020012557/*
12558 * generic initialization of ADC, input mixers and output mixers
12559 */
12560static struct hda_verb alc268_base_init_verbs[] = {
12561 /* Unmute DAC0-1 and set vol = 0 */
12562 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012563 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012564
12565 /*
12566 * Set up output mixers (0x0c - 0x0e)
12567 */
12568 /* set vol=0 to output mixers */
12569 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012570 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12571
12572 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12573 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12574
12575 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12576 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12577 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12578 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12579 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12580 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12581 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12582 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12583
12584 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12585 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12586 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12587 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012588 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012589
12590 /* set PCBEEP vol = 0, mute connections */
12591 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12592 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12593 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012594
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012595 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012596
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012597 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12598 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12599 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12600 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012601
Kailang Yanga361d842007-06-05 12:30:55 +020012602 { }
12603};
12604
12605/*
12606 * generic initialization of ADC, input mixers and output mixers
12607 */
12608static struct hda_verb alc268_volume_init_verbs[] = {
12609 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012610 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12611 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012612
12613 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12614 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12615 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12616 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12617 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12618
Kailang Yanga361d842007-06-05 12:30:55 +020012619 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012620 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12621 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12622
12623 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012624 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012625
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012626 /* set PCBEEP vol = 0, mute connections */
12627 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12628 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12629 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012630
12631 { }
12632};
12633
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012634static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12635 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12636 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12637 { } /* end */
12638};
12639
Kailang Yanga361d842007-06-05 12:30:55 +020012640static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12641 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12642 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012643 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012644 { } /* end */
12645};
12646
12647static struct snd_kcontrol_new alc268_capture_mixer[] = {
12648 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12649 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12650 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12651 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012652 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012653 { } /* end */
12654};
12655
12656static struct hda_input_mux alc268_capture_source = {
12657 .num_items = 4,
12658 .items = {
12659 { "Mic", 0x0 },
12660 { "Front Mic", 0x1 },
12661 { "Line", 0x2 },
12662 { "CD", 0x3 },
12663 },
12664};
12665
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012666static struct hda_input_mux alc268_acer_capture_source = {
12667 .num_items = 3,
12668 .items = {
12669 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012670 { "Internal Mic", 0x1 },
12671 { "Line", 0x2 },
12672 },
12673};
12674
12675static struct hda_input_mux alc268_acer_dmic_capture_source = {
12676 .num_items = 3,
12677 .items = {
12678 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012679 { "Internal Mic", 0x6 },
12680 { "Line", 0x2 },
12681 },
12682};
12683
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012684#ifdef CONFIG_SND_DEBUG
12685static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012686 /* Volume widgets */
12687 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12688 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12689 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12690 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12691 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12692 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12693 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12694 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12695 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12696 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12697 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12698 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12699 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012700 /* The below appears problematic on some hardwares */
12701 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012702 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12703 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12704 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12705 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12706
12707 /* Modes for retasking pin widgets */
12708 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12709 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12710 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12711 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12712
12713 /* Controls for GPIO pins, assuming they are configured as outputs */
12714 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12715 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12716 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12717 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12718
12719 /* Switches to allow the digital SPDIF output pin to be enabled.
12720 * The ALC268 does not have an SPDIF input.
12721 */
12722 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12723
12724 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12725 * this output to turn on an external amplifier.
12726 */
12727 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12728 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12729
12730 { } /* end */
12731};
12732#endif
12733
Kailang Yanga361d842007-06-05 12:30:55 +020012734/* create input playback/capture controls for the given pin */
12735static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12736 const char *ctlname, int idx)
12737{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012738 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012739 int err;
12740
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012741 switch (nid) {
12742 case 0x14:
12743 case 0x16:
12744 dac = 0x02;
12745 break;
12746 case 0x15:
Takashi Iwai4feabef2010-01-19 15:38:44 +010012747 case 0x21:
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012748 dac = 0x03;
12749 break;
12750 default:
12751 return 0;
12752 }
12753 if (spec->multiout.dac_nids[0] != dac &&
12754 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012755 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012756 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012757 HDA_OUTPUT));
12758 if (err < 0)
12759 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012760 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12761 }
12762
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012763 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012764 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020012765 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012766 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012767 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012768 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012769 if (err < 0)
12770 return err;
12771 return 0;
12772}
12773
12774/* add playback controls from the parsed DAC table */
12775static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12776 const struct auto_pin_cfg *cfg)
12777{
12778 hda_nid_t nid;
12779 int err;
12780
Kailang Yanga361d842007-06-05 12:30:55 +020012781 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012782
12783 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012784 if (nid) {
12785 const char *name;
12786 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12787 name = "Speaker";
12788 else
12789 name = "Front";
12790 err = alc268_new_analog_output(spec, nid, name, 0);
12791 if (err < 0)
12792 return err;
12793 }
Kailang Yanga361d842007-06-05 12:30:55 +020012794
12795 nid = cfg->speaker_pins[0];
12796 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012797 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020012798 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12799 if (err < 0)
12800 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012801 } else {
12802 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12803 if (err < 0)
12804 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012805 }
12806 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012807 if (nid) {
12808 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12809 if (err < 0)
12810 return err;
12811 }
Kailang Yanga361d842007-06-05 12:30:55 +020012812
12813 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12814 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012815 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012816 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012817 if (err < 0)
12818 return err;
12819 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012820 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012821}
12822
12823/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020012824static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020012825 const struct auto_pin_cfg *cfg)
12826{
Takashi Iwai05f5f472009-08-25 13:10:18 +020012827 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020012828}
12829
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012830static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12831 hda_nid_t nid, int pin_type)
12832{
12833 int idx;
12834
12835 alc_set_pin_output(codec, nid, pin_type);
12836 if (nid == 0x14 || nid == 0x16)
12837 idx = 0;
12838 else
12839 idx = 1;
12840 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12841}
12842
12843static void alc268_auto_init_multi_out(struct hda_codec *codec)
12844{
12845 struct alc_spec *spec = codec->spec;
12846 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12847 if (nid) {
12848 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12849 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12850 }
12851}
12852
12853static void alc268_auto_init_hp_out(struct hda_codec *codec)
12854{
12855 struct alc_spec *spec = codec->spec;
12856 hda_nid_t pin;
12857
12858 pin = spec->autocfg.hp_pins[0];
12859 if (pin)
12860 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12861 pin = spec->autocfg.speaker_pins[0];
12862 if (pin)
12863 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12864}
12865
Kailang Yanga361d842007-06-05 12:30:55 +020012866static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12867{
12868 struct alc_spec *spec = codec->spec;
12869 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12870 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12871 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12872 unsigned int dac_vol1, dac_vol2;
12873
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012874 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020012875 snd_hda_codec_write(codec, speaker_nid, 0,
12876 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012877 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012878 snd_hda_codec_write(codec, 0x0f, 0,
12879 AC_VERB_SET_AMP_GAIN_MUTE,
12880 AMP_IN_UNMUTE(1));
12881 snd_hda_codec_write(codec, 0x10, 0,
12882 AC_VERB_SET_AMP_GAIN_MUTE,
12883 AMP_IN_UNMUTE(1));
12884 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012885 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012886 snd_hda_codec_write(codec, 0x0f, 0,
12887 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12888 snd_hda_codec_write(codec, 0x10, 0,
12889 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12890 }
12891
12892 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012893 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012894 dac_vol2 = AMP_OUT_ZERO;
12895 else if (line_nid == 0x15)
12896 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012897 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012898 dac_vol2 = AMP_OUT_ZERO;
12899 else if (hp_nid == 0x15)
12900 dac_vol1 = AMP_OUT_ZERO;
12901 if (line_nid != 0x16 || hp_nid != 0x16 ||
12902 spec->autocfg.line_out_pins[1] != 0x16 ||
12903 spec->autocfg.line_out_pins[2] != 0x16)
12904 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12905
12906 snd_hda_codec_write(codec, 0x02, 0,
12907 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12908 snd_hda_codec_write(codec, 0x03, 0,
12909 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12910}
12911
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012912/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012913#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12914#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012915#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012916#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12917
12918/*
12919 * BIOS auto configuration
12920 */
12921static int alc268_parse_auto_config(struct hda_codec *codec)
12922{
12923 struct alc_spec *spec = codec->spec;
12924 int err;
12925 static hda_nid_t alc268_ignore[] = { 0 };
12926
12927 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12928 alc268_ignore);
12929 if (err < 0)
12930 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012931 if (!spec->autocfg.line_outs) {
12932 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12933 spec->multiout.max_channels = 2;
12934 spec->no_analog = 1;
12935 goto dig_only;
12936 }
Kailang Yanga361d842007-06-05 12:30:55 +020012937 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012938 }
Kailang Yanga361d842007-06-05 12:30:55 +020012939 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12940 if (err < 0)
12941 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012942 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020012943 if (err < 0)
12944 return err;
12945
12946 spec->multiout.max_channels = 2;
12947
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012948 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012949 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012950 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012951 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012952 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12953 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012954 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012955 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012956
Takashi Iwai892981f2009-03-02 08:04:35 +010012957 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012958 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012959
Takashi Iwaid88897e2008-10-31 15:01:37 +010012960 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012961 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012962 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012963
Takashi Iwai776e1842007-08-29 15:07:11 +020012964 err = alc_auto_add_mic_boost(codec);
12965 if (err < 0)
12966 return err;
12967
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012968 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12969
Kailang Yanga361d842007-06-05 12:30:55 +020012970 return 1;
12971}
12972
Kailang Yanga361d842007-06-05 12:30:55 +020012973#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12974
12975/* init callback for auto-configuration model -- overriding the default init */
12976static void alc268_auto_init(struct hda_codec *codec)
12977{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012978 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012979 alc268_auto_init_multi_out(codec);
12980 alc268_auto_init_hp_out(codec);
12981 alc268_auto_init_mono_speaker_out(codec);
12982 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012983 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012984 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012985}
12986
12987/*
12988 * configuration and preset
12989 */
12990static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012991 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012992 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012993 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012994 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012995 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012996 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012997 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012998 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012999#ifdef CONFIG_SND_DEBUG
13000 [ALC268_TEST] = "test",
13001#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013002 [ALC268_AUTO] = "auto",
13003};
13004
13005static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013006 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013007 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013008 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013009 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013010 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013011 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13012 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013013 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013014 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13015 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013016 /* almost compatible with toshiba but with optional digital outs;
13017 * auto-probing seems working fine
13018 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013019 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013020 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013021 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013022 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013023 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013024 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013025 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013026 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020013027 {}
13028};
13029
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013030/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13031static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13032 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13033 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13034 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13035 ALC268_TOSHIBA),
13036 {}
13037};
13038
Kailang Yanga361d842007-06-05 12:30:55 +020013039static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013040 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013041 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13042 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013043 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13044 alc267_quanta_il1_verbs },
13045 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13046 .dac_nids = alc268_dac_nids,
13047 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13048 .adc_nids = alc268_adc_nids_alt,
13049 .hp_nid = 0x03,
13050 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13051 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013052 .unsol_event = alc_sku_unsol_event,
13053 .setup = alc267_quanta_il1_setup,
13054 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013055 },
Kailang Yanga361d842007-06-05 12:30:55 +020013056 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013057 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13058 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013059 .init_verbs = { alc268_base_init_verbs },
13060 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13061 .dac_nids = alc268_dac_nids,
13062 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13063 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013064 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013065 .hp_nid = 0x03,
13066 .dig_out_nid = ALC268_DIGOUT_NID,
13067 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13068 .channel_mode = alc268_modes,
13069 .input_mux = &alc268_capture_source,
13070 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013071 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013072 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013073 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013074 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13075 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013076 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13077 .dac_nids = alc268_dac_nids,
13078 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13079 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013080 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013081 .hp_nid = 0x03,
13082 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13083 .channel_mode = alc268_modes,
13084 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013085 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013086 .setup = alc268_toshiba_setup,
13087 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013088 },
13089 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013090 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013091 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013092 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13093 alc268_acer_verbs },
13094 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13095 .dac_nids = alc268_dac_nids,
13096 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13097 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013098 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013099 .hp_nid = 0x02,
13100 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13101 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013102 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013103 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013104 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013105 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013106 [ALC268_ACER_DMIC] = {
13107 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13108 alc268_beep_mixer },
13109 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13110 alc268_acer_verbs },
13111 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13112 .dac_nids = alc268_dac_nids,
13113 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13114 .adc_nids = alc268_adc_nids_alt,
13115 .capsrc_nids = alc268_capsrc_nids,
13116 .hp_nid = 0x02,
13117 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13118 .channel_mode = alc268_modes,
13119 .input_mux = &alc268_acer_dmic_capture_source,
13120 .unsol_event = alc268_acer_unsol_event,
13121 .init_hook = alc268_acer_init_hook,
13122 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013123 [ALC268_ACER_ASPIRE_ONE] = {
13124 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013125 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013126 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013127 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13128 alc268_acer_aspire_one_verbs },
13129 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13130 .dac_nids = alc268_dac_nids,
13131 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13132 .adc_nids = alc268_adc_nids_alt,
13133 .capsrc_nids = alc268_capsrc_nids,
13134 .hp_nid = 0x03,
13135 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13136 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013137 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013138 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013139 .init_hook = alc268_acer_lc_init_hook,
13140 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013141 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013142 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13143 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013144 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13145 alc268_dell_verbs },
13146 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13147 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013148 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13149 .adc_nids = alc268_adc_nids_alt,
13150 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013151 .hp_nid = 0x02,
13152 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13153 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013154 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013155 .setup = alc268_dell_setup,
13156 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013157 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013158 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013159 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13160 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013161 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13162 alc268_toshiba_verbs },
13163 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13164 .dac_nids = alc268_dac_nids,
13165 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13166 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013167 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013168 .hp_nid = 0x03,
13169 .dig_out_nid = ALC268_DIGOUT_NID,
13170 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13171 .channel_mode = alc268_modes,
13172 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013173 .setup = alc268_toshiba_setup,
13174 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013175 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013176#ifdef CONFIG_SND_DEBUG
13177 [ALC268_TEST] = {
13178 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13179 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13180 alc268_volume_init_verbs },
13181 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13182 .dac_nids = alc268_dac_nids,
13183 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13184 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013185 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013186 .hp_nid = 0x03,
13187 .dig_out_nid = ALC268_DIGOUT_NID,
13188 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13189 .channel_mode = alc268_modes,
13190 .input_mux = &alc268_capture_source,
13191 },
13192#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013193};
13194
13195static int patch_alc268(struct hda_codec *codec)
13196{
13197 struct alc_spec *spec;
13198 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013199 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013200
Julia Lawallef86f582009-12-19 08:18:03 +010013201 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013202 if (spec == NULL)
13203 return -ENOMEM;
13204
13205 codec->spec = spec;
13206
13207 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13208 alc268_models,
13209 alc268_cfg_tbl);
13210
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013211 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13212 board_config = snd_hda_check_board_codec_sid_config(codec,
13213 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
13214
Kailang Yanga361d842007-06-05 12:30:55 +020013215 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013216 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13217 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013218 board_config = ALC268_AUTO;
13219 }
13220
13221 if (board_config == ALC268_AUTO) {
13222 /* automatic parse from the BIOS config */
13223 err = alc268_parse_auto_config(codec);
13224 if (err < 0) {
13225 alc_free(codec);
13226 return err;
13227 } else if (!err) {
13228 printk(KERN_INFO
13229 "hda_codec: Cannot set up configuration "
13230 "from BIOS. Using base mode...\n");
13231 board_config = ALC268_3ST;
13232 }
13233 }
13234
13235 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013236 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013237
Kailang Yanga361d842007-06-05 12:30:55 +020013238 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13239 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013240 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013241
Kailang Yanga361d842007-06-05 12:30:55 +020013242 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13243
Takashi Iwai22971e32009-02-10 11:56:44 +010013244 has_beep = 0;
13245 for (i = 0; i < spec->num_mixers; i++) {
13246 if (spec->mixers[i] == alc268_beep_mixer) {
13247 has_beep = 1;
13248 break;
13249 }
13250 }
13251
13252 if (has_beep) {
13253 err = snd_hda_attach_beep_device(codec, 0x1);
13254 if (err < 0) {
13255 alc_free(codec);
13256 return err;
13257 }
13258 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13259 /* override the amp caps for beep generator */
13260 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013261 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13262 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13263 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13264 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013265 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013266
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013267 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013268 /* check whether NID 0x07 is valid */
13269 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013270 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013271
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013272 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013273 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013274 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013275 if (spec->auto_mic ||
13276 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013277 spec->adc_nids = alc268_adc_nids_alt;
13278 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013279 if (spec->auto_mic)
13280 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013281 if (spec->auto_mic || spec->input_mux->num_items == 1)
13282 add_mixer(spec, alc268_capture_nosrc_mixer);
13283 else
13284 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013285 } else {
13286 spec->adc_nids = alc268_adc_nids;
13287 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013288 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013289 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013290 /* set default input source */
13291 for (i = 0; i < spec->num_adc_nids; i++)
13292 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13293 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013294 i < spec->num_mux_defs ?
13295 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013296 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013297 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013298
13299 spec->vmaster_nid = 0x02;
13300
Kailang Yanga361d842007-06-05 12:30:55 +020013301 codec->patch_ops = alc_patch_ops;
13302 if (board_config == ALC268_AUTO)
13303 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013304
Kailang Yanga361d842007-06-05 12:30:55 +020013305 return 0;
13306}
13307
13308/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013309 * ALC269 channel source setting (2 channel)
13310 */
13311#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13312
13313#define alc269_dac_nids alc260_dac_nids
13314
13315static hda_nid_t alc269_adc_nids[1] = {
13316 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013317 0x08,
13318};
13319
Takashi Iwaie01bf502008-08-21 16:25:07 +020013320static hda_nid_t alc269_capsrc_nids[1] = {
13321 0x23,
13322};
13323
Kailang Yang84898e82010-02-04 14:16:14 +010013324static hda_nid_t alc269vb_adc_nids[1] = {
13325 /* ADC1 */
13326 0x09,
13327};
13328
13329static hda_nid_t alc269vb_capsrc_nids[1] = {
13330 0x22,
13331};
13332
Takashi Iwaie01bf502008-08-21 16:25:07 +020013333/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
13334 * not a mux!
13335 */
13336
Kailang Yangf6a92242007-12-13 16:52:54 +010013337#define alc269_modes alc260_modes
13338#define alc269_capture_source alc880_lg_lw_capture_source
13339
13340static struct snd_kcontrol_new alc269_base_mixer[] = {
13341 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13342 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13343 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13344 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13345 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13346 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13347 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13348 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13349 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13350 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13351 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13352 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13353 { } /* end */
13354};
13355
Kailang Yang60db6b52008-08-26 13:13:00 +020013356static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13357 /* output mixer control */
13358 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13359 {
13360 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13361 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013362 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020013363 .info = snd_hda_mixer_amp_switch_info,
13364 .get = snd_hda_mixer_amp_switch_get,
13365 .put = alc268_acer_master_sw_put,
13366 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13367 },
13368 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13369 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13370 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13371 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13372 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13373 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013374 { }
13375};
13376
Tony Vroon64154832008-11-06 15:08:49 +000013377static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13378 /* output mixer control */
13379 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13380 {
13381 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13382 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013383 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000013384 .info = snd_hda_mixer_amp_switch_info,
13385 .get = snd_hda_mixer_amp_switch_get,
13386 .put = alc268_acer_master_sw_put,
13387 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13388 },
13389 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13390 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13391 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13392 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13393 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13394 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13395 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13396 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13397 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013398 { }
13399};
13400
Kailang Yang84898e82010-02-04 14:16:14 +010013401static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013402 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013403 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013404 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013405 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013406 { } /* end */
13407};
13408
Kailang Yang84898e82010-02-04 14:16:14 +010013409static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
13410 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13411 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13412 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13413 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13414 { } /* end */
13415};
13416
Kailang Yangf6a92242007-12-13 16:52:54 +010013417/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010013418static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
13419 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13420 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
13421 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13422 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13423 { } /* end */
13424};
13425
13426static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020013427 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13428 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013429 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13430 { } /* end */
13431};
13432
Kailang Yang84898e82010-02-04 14:16:14 +010013433static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
13434 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13435 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13436 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13437 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13438 { } /* end */
13439};
13440
13441static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
13442 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13443 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13444 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13445 { } /* end */
13446};
13447
Takashi Iwai26f5df22008-11-03 17:39:46 +010013448/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010013449#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013450
Kailang Yang60db6b52008-08-26 13:13:00 +020013451static struct hda_verb alc269_quanta_fl1_verbs[] = {
13452 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13453 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13454 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13455 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13456 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13457 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13458 { }
13459};
13460
Tony Vroon64154832008-11-06 15:08:49 +000013461static struct hda_verb alc269_lifebook_verbs[] = {
13462 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13463 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13464 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13465 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13466 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13467 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13468 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13469 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13470 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13471 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13472 { }
13473};
13474
Kailang Yang60db6b52008-08-26 13:13:00 +020013475/* toggle speaker-output according to the hp-jack state */
13476static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13477{
13478 unsigned int present;
13479 unsigned char bits;
13480
Wu Fengguang864f92b2009-11-18 12:38:02 +080013481 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang60db6b52008-08-26 13:13:00 +020013482 bits = present ? AMP_IN_MUTE(0) : 0;
13483 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13484 AMP_IN_MUTE(0), bits);
13485 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13486 AMP_IN_MUTE(0), bits);
13487
13488 snd_hda_codec_write(codec, 0x20, 0,
13489 AC_VERB_SET_COEF_INDEX, 0x0c);
13490 snd_hda_codec_write(codec, 0x20, 0,
13491 AC_VERB_SET_PROC_COEF, 0x680);
13492
13493 snd_hda_codec_write(codec, 0x20, 0,
13494 AC_VERB_SET_COEF_INDEX, 0x0c);
13495 snd_hda_codec_write(codec, 0x20, 0,
13496 AC_VERB_SET_PROC_COEF, 0x480);
13497}
13498
Tony Vroon64154832008-11-06 15:08:49 +000013499/* toggle speaker-output according to the hp-jacks state */
13500static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13501{
13502 unsigned int present;
13503 unsigned char bits;
13504
13505 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013506 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013507
13508 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013509 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013510
13511 bits = present ? AMP_IN_MUTE(0) : 0;
13512 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13513 AMP_IN_MUTE(0), bits);
13514 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13515 AMP_IN_MUTE(0), bits);
13516
13517 snd_hda_codec_write(codec, 0x20, 0,
13518 AC_VERB_SET_COEF_INDEX, 0x0c);
13519 snd_hda_codec_write(codec, 0x20, 0,
13520 AC_VERB_SET_PROC_COEF, 0x680);
13521
13522 snd_hda_codec_write(codec, 0x20, 0,
13523 AC_VERB_SET_COEF_INDEX, 0x0c);
13524 snd_hda_codec_write(codec, 0x20, 0,
13525 AC_VERB_SET_PROC_COEF, 0x480);
13526}
13527
Tony Vroon64154832008-11-06 15:08:49 +000013528static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13529{
13530 unsigned int present_laptop;
13531 unsigned int present_dock;
13532
Wu Fengguang864f92b2009-11-18 12:38:02 +080013533 present_laptop = snd_hda_jack_detect(codec, 0x18);
13534 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000013535
13536 /* Laptop mic port overrides dock mic port, design decision */
13537 if (present_dock)
13538 snd_hda_codec_write(codec, 0x23, 0,
13539 AC_VERB_SET_CONNECT_SEL, 0x3);
13540 if (present_laptop)
13541 snd_hda_codec_write(codec, 0x23, 0,
13542 AC_VERB_SET_CONNECT_SEL, 0x0);
13543 if (!present_dock && !present_laptop)
13544 snd_hda_codec_write(codec, 0x23, 0,
13545 AC_VERB_SET_CONNECT_SEL, 0x1);
13546}
13547
Kailang Yang60db6b52008-08-26 13:13:00 +020013548static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13549 unsigned int res)
13550{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013551 switch (res >> 26) {
13552 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013553 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013554 break;
13555 case ALC880_MIC_EVENT:
13556 alc_mic_automute(codec);
13557 break;
13558 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013559}
13560
Tony Vroon64154832008-11-06 15:08:49 +000013561static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13562 unsigned int res)
13563{
13564 if ((res >> 26) == ALC880_HP_EVENT)
13565 alc269_lifebook_speaker_automute(codec);
13566 if ((res >> 26) == ALC880_MIC_EVENT)
13567 alc269_lifebook_mic_autoswitch(codec);
13568}
13569
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013570static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13571{
13572 struct alc_spec *spec = codec->spec;
13573 spec->ext_mic.pin = 0x18;
13574 spec->ext_mic.mux_idx = 0;
13575 spec->int_mic.pin = 0x19;
13576 spec->int_mic.mux_idx = 1;
13577 spec->auto_mic = 1;
13578}
13579
Kailang Yang60db6b52008-08-26 13:13:00 +020013580static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13581{
13582 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013583 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013584}
13585
Tony Vroon64154832008-11-06 15:08:49 +000013586static void alc269_lifebook_init_hook(struct hda_codec *codec)
13587{
13588 alc269_lifebook_speaker_automute(codec);
13589 alc269_lifebook_mic_autoswitch(codec);
13590}
13591
Kailang Yang84898e82010-02-04 14:16:14 +010013592static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013593 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13594 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13595 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13596 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13597 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13598 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13599 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13600 {}
13601};
13602
Kailang Yang84898e82010-02-04 14:16:14 +010013603static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013604 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13605 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13606 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13607 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13608 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13609 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13610 {}
13611};
13612
Kailang Yang84898e82010-02-04 14:16:14 +010013613static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
13614 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13615 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
13616 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13617 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13618 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13619 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13620 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13621 {}
13622};
13623
13624static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
13625 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13626 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
13627 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13628 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13629 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13630 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13631 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13632 {}
13633};
13634
Kailang Yang60db6b52008-08-26 13:13:00 +020013635/* toggle speaker-output according to the hp-jack state */
13636static void alc269_speaker_automute(struct hda_codec *codec)
13637{
Kailang Yangebb83ee2009-12-17 12:23:00 +010013638 struct alc_spec *spec = codec->spec;
13639 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020013640 unsigned int present;
13641 unsigned char bits;
13642
Kailang Yangebb83ee2009-12-17 12:23:00 +010013643 present = snd_hda_jack_detect(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020013644 bits = present ? AMP_IN_MUTE(0) : 0;
13645 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13646 AMP_IN_MUTE(0), bits);
13647 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13648 AMP_IN_MUTE(0), bits);
13649}
13650
Kailang Yang60db6b52008-08-26 13:13:00 +020013651/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010013652static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013653 unsigned int res)
13654{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013655 switch (res >> 26) {
13656 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013657 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013658 break;
13659 case ALC880_MIC_EVENT:
13660 alc_mic_automute(codec);
13661 break;
13662 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013663}
13664
Kailang Yang84898e82010-02-04 14:16:14 +010013665static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013666{
13667 struct alc_spec *spec = codec->spec;
13668 spec->ext_mic.pin = 0x18;
13669 spec->ext_mic.mux_idx = 0;
13670 spec->int_mic.pin = 0x12;
13671 spec->int_mic.mux_idx = 5;
13672 spec->auto_mic = 1;
13673}
13674
Kailang Yang84898e82010-02-04 14:16:14 +010013675static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
13676{
13677 struct alc_spec *spec = codec->spec;
13678 spec->ext_mic.pin = 0x18;
13679 spec->ext_mic.mux_idx = 0;
13680 spec->int_mic.pin = 0x12;
13681 spec->int_mic.mux_idx = 6;
13682 spec->auto_mic = 1;
13683}
13684
13685static void alc269_laptop_amic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013686{
13687 struct alc_spec *spec = codec->spec;
13688 spec->ext_mic.pin = 0x18;
13689 spec->ext_mic.mux_idx = 0;
13690 spec->int_mic.pin = 0x19;
13691 spec->int_mic.mux_idx = 1;
13692 spec->auto_mic = 1;
13693}
13694
Kailang Yang84898e82010-02-04 14:16:14 +010013695static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013696{
13697 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013698 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013699}
13700
Kailang Yangf6a92242007-12-13 16:52:54 +010013701/*
13702 * generic initialization of ADC, input mixers and output mixers
13703 */
13704static struct hda_verb alc269_init_verbs[] = {
13705 /*
13706 * Unmute ADC0 and set the default input to mic-in
13707 */
Kailang Yang84898e82010-02-04 14:16:14 +010013708 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013709
13710 /*
Kailang Yang84898e82010-02-04 14:16:14 +010013711 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010013712 */
13713 /* set vol=0 to output mixers */
13714 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13715 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13716
13717 /* set up input amps for analog loopback */
13718 /* Amp Indices: DAC = 0, mixer = 1 */
13719 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13720 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13721 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13722 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13723 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13724 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13725
13726 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13727 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13728 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13729 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13730 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13731 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13732 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13733
13734 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13735 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010013736
Kailang Yang84898e82010-02-04 14:16:14 +010013737 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010013738 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13739 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010013740 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010013741
13742 /* set EAPD */
13743 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010013744 { }
13745};
13746
13747static struct hda_verb alc269vb_init_verbs[] = {
13748 /*
13749 * Unmute ADC0 and set the default input to mic-in
13750 */
13751 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13752
13753 /*
13754 * Set up output mixers (0x02 - 0x03)
13755 */
13756 /* set vol=0 to output mixers */
13757 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13758 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13759
13760 /* set up input amps for analog loopback */
13761 /* Amp Indices: DAC = 0, mixer = 1 */
13762 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13763 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13764 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13765 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13766 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13767 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13768
13769 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13770 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13771 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13772 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13773 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13774 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13775 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13776
13777 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13778 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13779
13780 /* FIXME: use Mux-type input source selection */
13781 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13782 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
13783 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
13784
13785 /* set EAPD */
13786 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010013787 { }
13788};
13789
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013790#define alc269_auto_create_multi_out_ctls \
13791 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020013792#define alc269_auto_create_input_ctls \
13793 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013794
13795#ifdef CONFIG_SND_HDA_POWER_SAVE
13796#define alc269_loopbacks alc880_loopbacks
13797#endif
13798
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013799/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013800#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13801#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13802#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13803#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13804
Takashi Iwaif03d3112009-03-05 14:18:16 +010013805static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13806 .substreams = 1,
13807 .channels_min = 2,
13808 .channels_max = 8,
13809 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13810 /* NID is set in alc_build_pcms */
13811 .ops = {
13812 .open = alc880_playback_pcm_open,
13813 .prepare = alc880_playback_pcm_prepare,
13814 .cleanup = alc880_playback_pcm_cleanup
13815 },
13816};
13817
13818static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13819 .substreams = 1,
13820 .channels_min = 2,
13821 .channels_max = 2,
13822 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13823 /* NID is set in alc_build_pcms */
13824};
13825
Kailang Yangf6a92242007-12-13 16:52:54 +010013826/*
13827 * BIOS auto configuration
13828 */
13829static int alc269_parse_auto_config(struct hda_codec *codec)
13830{
13831 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013832 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013833 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
Kailang Yang84898e82010-02-04 14:16:14 +010013834 hda_nid_t real_capsrc_nids;
Kailang Yangf6a92242007-12-13 16:52:54 +010013835
13836 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13837 alc269_ignore);
13838 if (err < 0)
13839 return err;
13840
13841 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13842 if (err < 0)
13843 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013844 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010013845 if (err < 0)
13846 return err;
13847
13848 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13849
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013850 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013851 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13852
Takashi Iwai603c4012008-07-30 15:01:44 +020013853 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013854 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013855
Kailang Yang84898e82010-02-04 14:16:14 +010013856 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) {
13857 add_verb(spec, alc269vb_init_verbs);
13858 real_capsrc_nids = alc269vb_capsrc_nids[0];
13859 alc_ssid_check(codec, 0x21, 0x1b, 0x14);
13860 } else {
13861 add_verb(spec, alc269_init_verbs);
13862 real_capsrc_nids = alc269_capsrc_nids[0];
13863 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13864 }
13865
Kailang Yangf6a92242007-12-13 16:52:54 +010013866 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013867 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013868 /* set default input source */
Kailang Yang84898e82010-02-04 14:16:14 +010013869 snd_hda_codec_write_cache(codec, real_capsrc_nids,
Takashi Iwaie01bf502008-08-21 16:25:07 +020013870 0, AC_VERB_SET_CONNECT_SEL,
13871 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013872
13873 err = alc_auto_add_mic_boost(codec);
13874 if (err < 0)
13875 return err;
13876
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013877 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013878 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013879
Kailang Yangf6a92242007-12-13 16:52:54 +010013880 return 1;
13881}
13882
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013883#define alc269_auto_init_multi_out alc268_auto_init_multi_out
13884#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010013885#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13886
13887
13888/* init callback for auto-configuration model -- overriding the default init */
13889static void alc269_auto_init(struct hda_codec *codec)
13890{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013891 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013892 alc269_auto_init_multi_out(codec);
13893 alc269_auto_init_hp_out(codec);
13894 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013895 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013896 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013897}
13898
13899/*
13900 * configuration and preset
13901 */
13902static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013903 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013904 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010013905 [ALC269_AMIC] = "laptop-amic",
13906 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000013907 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020013908 [ALC269_LIFEBOOK] = "lifebook",
13909 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010013910};
13911
13912static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013913 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013914 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010013915 ALC269_AMIC),
13916 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
13917 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
13918 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
13919 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
13920 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
13921 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
13922 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
13923 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
13924 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
13925 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
13926 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
13927 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
13928 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
13929 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
13930 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
13931 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
13932 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
13933 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
13934 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
13935 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
13936 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
13937 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
13938 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
13939 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
13940 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
13941 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
13942 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
13943 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
13944 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
13945 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
13946 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
13947 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
13948 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
13949 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
13950 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
13951 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020013952 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010013953 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020013954 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010013955 ALC269_DMIC),
13956 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
13957 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013958 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013959 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013960 {}
13961};
13962
13963static struct alc_config_preset alc269_presets[] = {
13964 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013965 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013966 .init_verbs = { alc269_init_verbs },
13967 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13968 .dac_nids = alc269_dac_nids,
13969 .hp_nid = 0x03,
13970 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13971 .channel_mode = alc269_modes,
13972 .input_mux = &alc269_capture_source,
13973 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013974 [ALC269_QUANTA_FL1] = {
13975 .mixers = { alc269_quanta_fl1_mixer },
13976 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13977 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13978 .dac_nids = alc269_dac_nids,
13979 .hp_nid = 0x03,
13980 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13981 .channel_mode = alc269_modes,
13982 .input_mux = &alc269_capture_source,
13983 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013984 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020013985 .init_hook = alc269_quanta_fl1_init_hook,
13986 },
Kailang Yang84898e82010-02-04 14:16:14 +010013987 [ALC269_AMIC] = {
13988 .mixers = { alc269_laptop_mixer },
13989 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013990 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010013991 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020013992 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13993 .dac_nids = alc269_dac_nids,
13994 .hp_nid = 0x03,
13995 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13996 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010013997 .unsol_event = alc269_laptop_unsol_event,
13998 .setup = alc269_laptop_amic_setup,
13999 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014000 },
Kailang Yang84898e82010-02-04 14:16:14 +010014001 [ALC269_DMIC] = {
14002 .mixers = { alc269_laptop_mixer },
14003 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014004 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014005 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014006 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14007 .dac_nids = alc269_dac_nids,
14008 .hp_nid = 0x03,
14009 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14010 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014011 .unsol_event = alc269_laptop_unsol_event,
14012 .setup = alc269_laptop_dmic_setup,
14013 .init_hook = alc269_laptop_inithook,
14014 },
14015 [ALC269VB_AMIC] = {
14016 .mixers = { alc269vb_laptop_mixer },
14017 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14018 .init_verbs = { alc269vb_init_verbs,
14019 alc269vb_laptop_amic_init_verbs },
14020 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14021 .dac_nids = alc269_dac_nids,
14022 .hp_nid = 0x03,
14023 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14024 .channel_mode = alc269_modes,
14025 .unsol_event = alc269_laptop_unsol_event,
14026 .setup = alc269_laptop_amic_setup,
14027 .init_hook = alc269_laptop_inithook,
14028 },
14029 [ALC269VB_DMIC] = {
14030 .mixers = { alc269vb_laptop_mixer },
14031 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14032 .init_verbs = { alc269vb_init_verbs,
14033 alc269vb_laptop_dmic_init_verbs },
14034 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14035 .dac_nids = alc269_dac_nids,
14036 .hp_nid = 0x03,
14037 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14038 .channel_mode = alc269_modes,
14039 .unsol_event = alc269_laptop_unsol_event,
14040 .setup = alc269vb_laptop_dmic_setup,
14041 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014042 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014043 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014044 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014045 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014046 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014047 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014048 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14049 .dac_nids = alc269_dac_nids,
14050 .hp_nid = 0x03,
14051 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14052 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014053 .unsol_event = alc269_laptop_unsol_event,
14054 .setup = alc269_laptop_dmic_setup,
14055 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014056 },
Tony Vroon64154832008-11-06 15:08:49 +000014057 [ALC269_LIFEBOOK] = {
14058 .mixers = { alc269_lifebook_mixer },
14059 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14060 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14061 .dac_nids = alc269_dac_nids,
14062 .hp_nid = 0x03,
14063 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14064 .channel_mode = alc269_modes,
14065 .input_mux = &alc269_capture_source,
14066 .unsol_event = alc269_lifebook_unsol_event,
14067 .init_hook = alc269_lifebook_init_hook,
14068 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014069};
14070
14071static int patch_alc269(struct hda_codec *codec)
14072{
14073 struct alc_spec *spec;
14074 int board_config;
14075 int err;
Kailang Yang84898e82010-02-04 14:16:14 +010014076 int is_alc269vb = 0;
Kailang Yangf6a92242007-12-13 16:52:54 +010014077
14078 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14079 if (spec == NULL)
14080 return -ENOMEM;
14081
14082 codec->spec = spec;
14083
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020014084 alc_fix_pll_init(codec, 0x20, 0x04, 15);
14085
Kailang Yang274693f2009-12-03 10:07:50 +010014086 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
14087 kfree(codec->chip_name);
14088 codec->chip_name = kstrdup("ALC259", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010014089 if (!codec->chip_name) {
14090 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010014091 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010014092 }
Kailang Yang84898e82010-02-04 14:16:14 +010014093 is_alc269vb = 1;
Kailang Yang274693f2009-12-03 10:07:50 +010014094 }
14095
Kailang Yangf6a92242007-12-13 16:52:54 +010014096 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
14097 alc269_models,
14098 alc269_cfg_tbl);
14099
14100 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014101 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14102 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010014103 board_config = ALC269_AUTO;
14104 }
14105
14106 if (board_config == ALC269_AUTO) {
14107 /* automatic parse from the BIOS config */
14108 err = alc269_parse_auto_config(codec);
14109 if (err < 0) {
14110 alc_free(codec);
14111 return err;
14112 } else if (!err) {
14113 printk(KERN_INFO
14114 "hda_codec: Cannot set up configuration "
14115 "from BIOS. Using base mode...\n");
14116 board_config = ALC269_BASIC;
14117 }
14118 }
14119
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014120 err = snd_hda_attach_beep_device(codec, 0x1);
14121 if (err < 0) {
14122 alc_free(codec);
14123 return err;
14124 }
14125
Kailang Yangf6a92242007-12-13 16:52:54 +010014126 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014127 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010014128
Kailang Yang84898e82010-02-04 14:16:14 +010014129 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010014130 /* Due to a hardware problem on Lenovo Ideadpad, we need to
14131 * fix the sample rate of analog I/O to 44.1kHz
14132 */
14133 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
14134 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
14135 } else {
14136 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14137 spec->stream_analog_capture = &alc269_pcm_analog_capture;
14138 }
Kailang Yangf6a92242007-12-13 16:52:54 +010014139 spec->stream_digital_playback = &alc269_pcm_digital_playback;
14140 spec->stream_digital_capture = &alc269_pcm_digital_capture;
14141
Kailang Yang84898e82010-02-04 14:16:14 +010014142 if (!is_alc269vb) {
14143 spec->adc_nids = alc269_adc_nids;
14144 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
14145 spec->capsrc_nids = alc269_capsrc_nids;
14146 } else {
14147 spec->adc_nids = alc269vb_adc_nids;
14148 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
14149 spec->capsrc_nids = alc269vb_capsrc_nids;
14150 }
14151
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014152 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014153 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014154 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010014155
Takashi Iwai100d5eb2009-08-10 11:55:51 +020014156 spec->vmaster_nid = 0x02;
14157
Kailang Yangf6a92242007-12-13 16:52:54 +010014158 codec->patch_ops = alc_patch_ops;
14159 if (board_config == ALC269_AUTO)
14160 spec->init_hook = alc269_auto_init;
14161#ifdef CONFIG_SND_HDA_POWER_SAVE
14162 if (!spec->loopback.amplist)
14163 spec->loopback.amplist = alc269_loopbacks;
14164#endif
14165
14166 return 0;
14167}
14168
14169/*
Kailang Yangdf694da2005-12-05 19:42:22 +010014170 * ALC861 channel source setting (2/6 channel selection for 3-stack)
14171 */
14172
14173/*
14174 * set the path ways for 2 channel output
14175 * need to set the codec line out and mic 1 pin widgets to inputs
14176 */
14177static struct hda_verb alc861_threestack_ch2_init[] = {
14178 /* set pin widget 1Ah (line in) for input */
14179 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014180 /* set pin widget 18h (mic1/2) for input, for mic also enable
14181 * the vref
14182 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014183 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14184
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014185 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14186#if 0
14187 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14188 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14189#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014190 { } /* end */
14191};
14192/*
14193 * 6ch mode
14194 * need to set the codec line out and mic 1 pin widgets to outputs
14195 */
14196static struct hda_verb alc861_threestack_ch6_init[] = {
14197 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14198 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14199 /* set pin widget 18h (mic1) for output (CLFE)*/
14200 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14201
14202 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014203 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014204
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014205 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14206#if 0
14207 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14208 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14209#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014210 { } /* end */
14211};
14212
14213static struct hda_channel_mode alc861_threestack_modes[2] = {
14214 { 2, alc861_threestack_ch2_init },
14215 { 6, alc861_threestack_ch6_init },
14216};
Takashi Iwai22309c32006-08-09 16:57:28 +020014217/* Set mic1 as input and unmute the mixer */
14218static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
14219 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14220 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14221 { } /* end */
14222};
14223/* Set mic1 as output and mute mixer */
14224static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
14225 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14226 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14227 { } /* end */
14228};
14229
14230static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
14231 { 2, alc861_uniwill_m31_ch2_init },
14232 { 4, alc861_uniwill_m31_ch4_init },
14233};
Kailang Yangdf694da2005-12-05 19:42:22 +010014234
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014235/* Set mic1 and line-in as input and unmute the mixer */
14236static struct hda_verb alc861_asus_ch2_init[] = {
14237 /* set pin widget 1Ah (line in) for input */
14238 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014239 /* set pin widget 18h (mic1/2) for input, for mic also enable
14240 * the vref
14241 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014242 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14243
14244 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14245#if 0
14246 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14247 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14248#endif
14249 { } /* end */
14250};
14251/* Set mic1 nad line-in as output and mute mixer */
14252static struct hda_verb alc861_asus_ch6_init[] = {
14253 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14254 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14255 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14256 /* set pin widget 18h (mic1) for output (CLFE)*/
14257 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14258 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14259 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
14260 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
14261
14262 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14263#if 0
14264 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14265 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14266#endif
14267 { } /* end */
14268};
14269
14270static struct hda_channel_mode alc861_asus_modes[2] = {
14271 { 2, alc861_asus_ch2_init },
14272 { 6, alc861_asus_ch6_init },
14273};
14274
Kailang Yangdf694da2005-12-05 19:42:22 +010014275/* patch-ALC861 */
14276
14277static struct snd_kcontrol_new alc861_base_mixer[] = {
14278 /* output mixer control */
14279 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14280 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14281 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14282 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14283 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14284
14285 /*Input mixer control */
14286 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14287 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14288 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14289 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14290 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14291 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14292 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14293 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14294 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14295 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014296
Kailang Yangdf694da2005-12-05 19:42:22 +010014297 { } /* end */
14298};
14299
14300static struct snd_kcontrol_new alc861_3ST_mixer[] = {
14301 /* output mixer control */
14302 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14303 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14304 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14305 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14306 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14307
14308 /* Input mixer control */
14309 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14310 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14311 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14312 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14313 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14314 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14315 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14316 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14317 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14318 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014319
Kailang Yangdf694da2005-12-05 19:42:22 +010014320 {
14321 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14322 .name = "Channel Mode",
14323 .info = alc_ch_mode_info,
14324 .get = alc_ch_mode_get,
14325 .put = alc_ch_mode_put,
14326 .private_value = ARRAY_SIZE(alc861_threestack_modes),
14327 },
14328 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014329};
14330
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014331static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014332 /* output mixer control */
14333 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14334 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14335 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014336
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014337 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014338};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014339
Takashi Iwai22309c32006-08-09 16:57:28 +020014340static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
14341 /* output mixer control */
14342 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14343 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14344 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14345 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14346 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14347
14348 /* Input mixer control */
14349 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14350 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14351 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14352 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14353 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14354 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14355 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14356 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14357 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14358 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014359
Takashi Iwai22309c32006-08-09 16:57:28 +020014360 {
14361 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14362 .name = "Channel Mode",
14363 .info = alc_ch_mode_info,
14364 .get = alc_ch_mode_get,
14365 .put = alc_ch_mode_put,
14366 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
14367 },
14368 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014369};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014370
14371static struct snd_kcontrol_new alc861_asus_mixer[] = {
14372 /* output mixer control */
14373 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14374 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14375 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14376 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14377 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14378
14379 /* Input mixer control */
14380 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14381 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14382 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14383 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14384 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14385 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14386 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14387 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14388 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014389 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
14390
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014391 {
14392 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14393 .name = "Channel Mode",
14394 .info = alc_ch_mode_info,
14395 .get = alc_ch_mode_get,
14396 .put = alc_ch_mode_put,
14397 .private_value = ARRAY_SIZE(alc861_asus_modes),
14398 },
14399 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014400};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014401
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014402/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014403static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014404 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14405 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014406 { }
14407};
14408
Kailang Yangdf694da2005-12-05 19:42:22 +010014409/*
14410 * generic initialization of ADC, input mixers and output mixers
14411 */
14412static struct hda_verb alc861_base_init_verbs[] = {
14413 /*
14414 * Unmute ADC0 and set the default input to mic-in
14415 */
14416 /* port-A for surround (rear panel) */
14417 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14418 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
14419 /* port-B for mic-in (rear panel) with vref */
14420 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14421 /* port-C for line-in (rear panel) */
14422 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14423 /* port-D for Front */
14424 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14425 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14426 /* port-E for HP out (front panel) */
14427 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14428 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014429 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014430 /* port-F for mic-in (front panel) with vref */
14431 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14432 /* port-G for CLFE (rear panel) */
14433 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14434 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
14435 /* port-H for side (rear panel) */
14436 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14437 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
14438 /* CD-in */
14439 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14440 /* route front mic to ADC1*/
14441 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14442 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014443
Kailang Yangdf694da2005-12-05 19:42:22 +010014444 /* Unmute DAC0~3 & spdif out*/
14445 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14446 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14447 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14448 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14449 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014450
Kailang Yangdf694da2005-12-05 19:42:22 +010014451 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14452 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14453 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14454 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14455 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014456
Kailang Yangdf694da2005-12-05 19:42:22 +010014457 /* Unmute Stereo Mixer 15 */
14458 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14459 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14460 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014461 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014462
14463 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14464 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14465 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14466 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14467 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14468 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14469 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14470 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014471 /* hp used DAC 3 (Front) */
14472 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014473 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14474
14475 { }
14476};
14477
14478static struct hda_verb alc861_threestack_init_verbs[] = {
14479 /*
14480 * Unmute ADC0 and set the default input to mic-in
14481 */
14482 /* port-A for surround (rear panel) */
14483 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14484 /* port-B for mic-in (rear panel) with vref */
14485 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14486 /* port-C for line-in (rear panel) */
14487 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14488 /* port-D for Front */
14489 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14490 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14491 /* port-E for HP out (front panel) */
14492 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14493 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014494 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014495 /* port-F for mic-in (front panel) with vref */
14496 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14497 /* port-G for CLFE (rear panel) */
14498 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14499 /* port-H for side (rear panel) */
14500 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14501 /* CD-in */
14502 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14503 /* route front mic to ADC1*/
14504 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14505 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14506 /* Unmute DAC0~3 & spdif out*/
14507 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14508 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14509 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14510 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14511 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014512
Kailang Yangdf694da2005-12-05 19:42:22 +010014513 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14514 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14515 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14516 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14517 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014518
Kailang Yangdf694da2005-12-05 19:42:22 +010014519 /* Unmute Stereo Mixer 15 */
14520 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14521 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14522 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014523 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014524
14525 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14526 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14527 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14528 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14529 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14530 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14531 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14532 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014533 /* hp used DAC 3 (Front) */
14534 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014535 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14536 { }
14537};
Takashi Iwai22309c32006-08-09 16:57:28 +020014538
14539static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
14540 /*
14541 * Unmute ADC0 and set the default input to mic-in
14542 */
14543 /* port-A for surround (rear panel) */
14544 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14545 /* port-B for mic-in (rear panel) with vref */
14546 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14547 /* port-C for line-in (rear panel) */
14548 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14549 /* port-D for Front */
14550 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14551 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14552 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014553 /* this has to be set to VREF80 */
14554 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014555 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014556 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014557 /* port-F for mic-in (front panel) with vref */
14558 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14559 /* port-G for CLFE (rear panel) */
14560 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14561 /* port-H for side (rear panel) */
14562 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14563 /* CD-in */
14564 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14565 /* route front mic to ADC1*/
14566 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14567 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14568 /* Unmute DAC0~3 & spdif out*/
14569 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14570 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14571 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14572 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14573 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014574
Takashi Iwai22309c32006-08-09 16:57:28 +020014575 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14576 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14577 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14578 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14579 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014580
Takashi Iwai22309c32006-08-09 16:57:28 +020014581 /* Unmute Stereo Mixer 15 */
14582 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14583 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14584 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014585 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014586
14587 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14588 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14589 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14590 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14591 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14592 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14593 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14594 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014595 /* hp used DAC 3 (Front) */
14596 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014597 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14598 { }
14599};
14600
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014601static struct hda_verb alc861_asus_init_verbs[] = {
14602 /*
14603 * Unmute ADC0 and set the default input to mic-in
14604 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014605 /* port-A for surround (rear panel)
14606 * according to codec#0 this is the HP jack
14607 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014608 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14609 /* route front PCM to HP */
14610 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14611 /* port-B for mic-in (rear panel) with vref */
14612 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14613 /* port-C for line-in (rear panel) */
14614 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14615 /* port-D for Front */
14616 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14617 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14618 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014619 /* this has to be set to VREF80 */
14620 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014621 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014622 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014623 /* port-F for mic-in (front panel) with vref */
14624 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14625 /* port-G for CLFE (rear panel) */
14626 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14627 /* port-H for side (rear panel) */
14628 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14629 /* CD-in */
14630 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14631 /* route front mic to ADC1*/
14632 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14633 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14634 /* Unmute DAC0~3 & spdif out*/
14635 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14636 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14637 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14638 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14639 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14640 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14641 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14642 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14643 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14644 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014645
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014646 /* Unmute Stereo Mixer 15 */
14647 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14648 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14649 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014650 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014651
14652 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14653 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14654 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14655 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14656 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14657 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14658 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14659 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014660 /* hp used DAC 3 (Front) */
14661 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014662 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14663 { }
14664};
14665
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014666/* additional init verbs for ASUS laptops */
14667static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14668 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14669 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14670 { }
14671};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014672
Kailang Yangdf694da2005-12-05 19:42:22 +010014673/*
14674 * generic initialization of ADC, input mixers and output mixers
14675 */
14676static struct hda_verb alc861_auto_init_verbs[] = {
14677 /*
14678 * Unmute ADC0 and set the default input to mic-in
14679 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014680 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014681 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014682
Kailang Yangdf694da2005-12-05 19:42:22 +010014683 /* Unmute DAC0~3 & spdif out*/
14684 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14685 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14686 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14687 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14688 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014689
Kailang Yangdf694da2005-12-05 19:42:22 +010014690 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14691 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14692 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14693 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14694 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014695
Kailang Yangdf694da2005-12-05 19:42:22 +010014696 /* Unmute Stereo Mixer 15 */
14697 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14698 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14699 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14700 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14701
Takashi Iwai1c209302009-07-22 15:17:45 +020014702 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14703 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14704 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14705 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14706 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14707 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14708 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14709 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014710
14711 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14712 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014713 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14714 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014715 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14716 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014717 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14718 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014719
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014720 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014721
14722 { }
14723};
14724
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014725static struct hda_verb alc861_toshiba_init_verbs[] = {
14726 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014727
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014728 { }
14729};
14730
14731/* toggle speaker-output according to the hp-jack state */
14732static void alc861_toshiba_automute(struct hda_codec *codec)
14733{
Wu Fengguang864f92b2009-11-18 12:38:02 +080014734 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014735
Takashi Iwai47fd8302007-08-10 17:11:07 +020014736 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14737 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14738 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14739 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014740}
14741
14742static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14743 unsigned int res)
14744{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014745 if ((res >> 26) == ALC880_HP_EVENT)
14746 alc861_toshiba_automute(codec);
14747}
14748
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014749/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014750#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14751#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14752#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14753#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14754
14755
14756#define ALC861_DIGOUT_NID 0x07
14757
14758static struct hda_channel_mode alc861_8ch_modes[1] = {
14759 { 8, NULL }
14760};
14761
14762static hda_nid_t alc861_dac_nids[4] = {
14763 /* front, surround, clfe, side */
14764 0x03, 0x06, 0x05, 0x04
14765};
14766
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014767static hda_nid_t alc660_dac_nids[3] = {
14768 /* front, clfe, surround */
14769 0x03, 0x05, 0x06
14770};
14771
Kailang Yangdf694da2005-12-05 19:42:22 +010014772static hda_nid_t alc861_adc_nids[1] = {
14773 /* ADC0-2 */
14774 0x08,
14775};
14776
14777static struct hda_input_mux alc861_capture_source = {
14778 .num_items = 5,
14779 .items = {
14780 { "Mic", 0x0 },
14781 { "Front Mic", 0x3 },
14782 { "Line", 0x1 },
14783 { "CD", 0x4 },
14784 { "Mixer", 0x5 },
14785 },
14786};
14787
Takashi Iwai1c209302009-07-22 15:17:45 +020014788static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14789{
14790 struct alc_spec *spec = codec->spec;
14791 hda_nid_t mix, srcs[5];
14792 int i, j, num;
14793
14794 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14795 return 0;
14796 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14797 if (num < 0)
14798 return 0;
14799 for (i = 0; i < num; i++) {
14800 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014801 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014802 if (type != AC_WID_AUD_OUT)
14803 continue;
14804 for (j = 0; j < spec->multiout.num_dacs; j++)
14805 if (spec->multiout.dac_nids[j] == srcs[i])
14806 break;
14807 if (j >= spec->multiout.num_dacs)
14808 return srcs[i];
14809 }
14810 return 0;
14811}
14812
Kailang Yangdf694da2005-12-05 19:42:22 +010014813/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014814static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014815 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014816{
Takashi Iwai1c209302009-07-22 15:17:45 +020014817 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014818 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014819 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014820
14821 spec->multiout.dac_nids = spec->private_dac_nids;
14822 for (i = 0; i < cfg->line_outs; i++) {
14823 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014824 dac = alc861_look_for_dac(codec, nid);
14825 if (!dac)
14826 continue;
14827 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014828 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014829 return 0;
14830}
14831
Takashi Iwai1c209302009-07-22 15:17:45 +020014832static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14833 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014834{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020014835 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020014836 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14837}
14838
14839/* add playback controls from the parsed DAC table */
14840static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14841 const struct auto_pin_cfg *cfg)
14842{
14843 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014844 static const char *chname[4] = {
14845 "Front", "Surround", NULL /*CLFE*/, "Side"
14846 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014847 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014848 int i, err;
14849
14850 if (cfg->line_outs == 1) {
14851 const char *pfx = NULL;
14852 if (!cfg->hp_outs)
14853 pfx = "Master";
14854 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14855 pfx = "Speaker";
14856 if (pfx) {
14857 nid = spec->multiout.dac_nids[0];
14858 return alc861_create_out_sw(codec, pfx, nid, 3);
14859 }
14860 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014861
14862 for (i = 0; i < cfg->line_outs; i++) {
14863 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014864 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014865 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014866 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014867 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014868 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014869 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014870 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014871 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014872 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014873 return err;
14874 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014875 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014876 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014877 return err;
14878 }
14879 }
14880 return 0;
14881}
14882
Takashi Iwai1c209302009-07-22 15:17:45 +020014883static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014884{
Takashi Iwai1c209302009-07-22 15:17:45 +020014885 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014886 int err;
14887 hda_nid_t nid;
14888
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014889 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014890 return 0;
14891
14892 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014893 nid = alc861_look_for_dac(codec, pin);
14894 if (nid) {
14895 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14896 if (err < 0)
14897 return err;
14898 spec->multiout.hp_nid = nid;
14899 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014900 }
14901 return 0;
14902}
14903
14904/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020014905static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014906 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014907{
Takashi Iwai05f5f472009-08-25 13:10:18 +020014908 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014909}
14910
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014911static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14912 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014913 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014914{
Takashi Iwai1c209302009-07-22 15:17:45 +020014915 hda_nid_t mix, srcs[5];
14916 int i, num;
14917
Jacek Luczak564c5be2008-05-03 18:41:23 +020014918 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14919 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014920 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014921 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014922 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14923 return;
14924 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14925 if (num < 0)
14926 return;
14927 for (i = 0; i < num; i++) {
14928 unsigned int mute;
14929 if (srcs[i] == dac || srcs[i] == 0x15)
14930 mute = AMP_IN_UNMUTE(i);
14931 else
14932 mute = AMP_IN_MUTE(i);
14933 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14934 mute);
14935 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014936}
14937
14938static void alc861_auto_init_multi_out(struct hda_codec *codec)
14939{
14940 struct alc_spec *spec = codec->spec;
14941 int i;
14942
14943 for (i = 0; i < spec->autocfg.line_outs; i++) {
14944 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014945 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014946 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014947 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014948 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014949 }
14950}
14951
14952static void alc861_auto_init_hp_out(struct hda_codec *codec)
14953{
14954 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014955
Takashi Iwai15870f02009-10-05 08:25:13 +020014956 if (spec->autocfg.hp_outs)
14957 alc861_auto_set_output_and_unmute(codec,
14958 spec->autocfg.hp_pins[0],
14959 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014960 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020014961 if (spec->autocfg.speaker_outs)
14962 alc861_auto_set_output_and_unmute(codec,
14963 spec->autocfg.speaker_pins[0],
14964 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020014965 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014966}
14967
14968static void alc861_auto_init_analog_input(struct hda_codec *codec)
14969{
14970 struct alc_spec *spec = codec->spec;
14971 int i;
14972
14973 for (i = 0; i < AUTO_PIN_LAST; i++) {
14974 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014975 if (nid >= 0x0c && nid <= 0x11)
14976 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014977 }
14978}
14979
14980/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014981/* return 1 if successful, 0 if the proper config is not found,
14982 * or a negative error code
14983 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014984static int alc861_parse_auto_config(struct hda_codec *codec)
14985{
14986 struct alc_spec *spec = codec->spec;
14987 int err;
14988 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14989
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014990 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14991 alc861_ignore);
14992 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014993 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014994 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014995 return 0; /* can't find valid BIOS pin config */
14996
Takashi Iwai1c209302009-07-22 15:17:45 +020014997 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014998 if (err < 0)
14999 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015000 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015001 if (err < 0)
15002 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015003 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015004 if (err < 0)
15005 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015006 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015007 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015008 return err;
15009
15010 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15011
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015012 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015013 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
15014
Takashi Iwai603c4012008-07-30 15:01:44 +020015015 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015016 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010015017
Takashi Iwaid88897e2008-10-31 15:01:37 +010015018 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010015019
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020015020 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015021 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010015022
15023 spec->adc_nids = alc861_adc_nids;
15024 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015025 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015026
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015027 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
15028
Kailang Yangdf694da2005-12-05 19:42:22 +010015029 return 1;
15030}
15031
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015032/* additional initialization for auto-configuration model */
15033static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010015034{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015035 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015036 alc861_auto_init_multi_out(codec);
15037 alc861_auto_init_hp_out(codec);
15038 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015039 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015040 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015041}
15042
Takashi Iwaicb53c622007-08-10 17:21:45 +020015043#ifdef CONFIG_SND_HDA_POWER_SAVE
15044static struct hda_amp_list alc861_loopbacks[] = {
15045 { 0x15, HDA_INPUT, 0 },
15046 { 0x15, HDA_INPUT, 1 },
15047 { 0x15, HDA_INPUT, 2 },
15048 { 0x15, HDA_INPUT, 3 },
15049 { } /* end */
15050};
15051#endif
15052
Kailang Yangdf694da2005-12-05 19:42:22 +010015053
15054/*
15055 * configuration and preset
15056 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015057static const char *alc861_models[ALC861_MODEL_LAST] = {
15058 [ALC861_3ST] = "3stack",
15059 [ALC660_3ST] = "3stack-660",
15060 [ALC861_3ST_DIG] = "3stack-dig",
15061 [ALC861_6ST_DIG] = "6stack-dig",
15062 [ALC861_UNIWILL_M31] = "uniwill-m31",
15063 [ALC861_TOSHIBA] = "toshiba",
15064 [ALC861_ASUS] = "asus",
15065 [ALC861_ASUS_LAPTOP] = "asus-laptop",
15066 [ALC861_AUTO] = "auto",
15067};
15068
15069static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010015070 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015071 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15072 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15073 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015074 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020015075 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010015076 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020015077 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
15078 * Any other models that need this preset?
15079 */
15080 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020015081 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
15082 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015083 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
15084 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
15085 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
15086 /* FIXME: the below seems conflict */
15087 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
15088 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
15089 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010015090 {}
15091};
15092
15093static struct alc_config_preset alc861_presets[] = {
15094 [ALC861_3ST] = {
15095 .mixers = { alc861_3ST_mixer },
15096 .init_verbs = { alc861_threestack_init_verbs },
15097 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15098 .dac_nids = alc861_dac_nids,
15099 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15100 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015101 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015102 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15103 .adc_nids = alc861_adc_nids,
15104 .input_mux = &alc861_capture_source,
15105 },
15106 [ALC861_3ST_DIG] = {
15107 .mixers = { alc861_base_mixer },
15108 .init_verbs = { alc861_threestack_init_verbs },
15109 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15110 .dac_nids = alc861_dac_nids,
15111 .dig_out_nid = ALC861_DIGOUT_NID,
15112 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15113 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015114 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015115 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15116 .adc_nids = alc861_adc_nids,
15117 .input_mux = &alc861_capture_source,
15118 },
15119 [ALC861_6ST_DIG] = {
15120 .mixers = { alc861_base_mixer },
15121 .init_verbs = { alc861_base_init_verbs },
15122 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15123 .dac_nids = alc861_dac_nids,
15124 .dig_out_nid = ALC861_DIGOUT_NID,
15125 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
15126 .channel_mode = alc861_8ch_modes,
15127 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15128 .adc_nids = alc861_adc_nids,
15129 .input_mux = &alc861_capture_source,
15130 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015131 [ALC660_3ST] = {
15132 .mixers = { alc861_3ST_mixer },
15133 .init_verbs = { alc861_threestack_init_verbs },
15134 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
15135 .dac_nids = alc660_dac_nids,
15136 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15137 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015138 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015139 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15140 .adc_nids = alc861_adc_nids,
15141 .input_mux = &alc861_capture_source,
15142 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015143 [ALC861_UNIWILL_M31] = {
15144 .mixers = { alc861_uniwill_m31_mixer },
15145 .init_verbs = { alc861_uniwill_m31_init_verbs },
15146 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15147 .dac_nids = alc861_dac_nids,
15148 .dig_out_nid = ALC861_DIGOUT_NID,
15149 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
15150 .channel_mode = alc861_uniwill_m31_modes,
15151 .need_dac_fix = 1,
15152 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15153 .adc_nids = alc861_adc_nids,
15154 .input_mux = &alc861_capture_source,
15155 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015156 [ALC861_TOSHIBA] = {
15157 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015158 .init_verbs = { alc861_base_init_verbs,
15159 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015160 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15161 .dac_nids = alc861_dac_nids,
15162 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15163 .channel_mode = alc883_3ST_2ch_modes,
15164 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15165 .adc_nids = alc861_adc_nids,
15166 .input_mux = &alc861_capture_source,
15167 .unsol_event = alc861_toshiba_unsol_event,
15168 .init_hook = alc861_toshiba_automute,
15169 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015170 [ALC861_ASUS] = {
15171 .mixers = { alc861_asus_mixer },
15172 .init_verbs = { alc861_asus_init_verbs },
15173 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15174 .dac_nids = alc861_dac_nids,
15175 .dig_out_nid = ALC861_DIGOUT_NID,
15176 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
15177 .channel_mode = alc861_asus_modes,
15178 .need_dac_fix = 1,
15179 .hp_nid = 0x06,
15180 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15181 .adc_nids = alc861_adc_nids,
15182 .input_mux = &alc861_capture_source,
15183 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015184 [ALC861_ASUS_LAPTOP] = {
15185 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
15186 .init_verbs = { alc861_asus_init_verbs,
15187 alc861_asus_laptop_init_verbs },
15188 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15189 .dac_nids = alc861_dac_nids,
15190 .dig_out_nid = ALC861_DIGOUT_NID,
15191 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15192 .channel_mode = alc883_3ST_2ch_modes,
15193 .need_dac_fix = 1,
15194 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15195 .adc_nids = alc861_adc_nids,
15196 .input_mux = &alc861_capture_source,
15197 },
15198};
Kailang Yangdf694da2005-12-05 19:42:22 +010015199
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015200/* Pin config fixes */
15201enum {
15202 PINFIX_FSC_AMILO_PI1505,
15203};
15204
15205static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = {
15206 { 0x0b, 0x0221101f }, /* HP */
15207 { 0x0f, 0x90170310 }, /* speaker */
15208 { }
15209};
15210
15211static const struct alc_fixup alc861_fixups[] = {
15212 [PINFIX_FSC_AMILO_PI1505] = {
15213 .pins = alc861_fsc_amilo_pi1505_pinfix
15214 },
15215};
15216
15217static struct snd_pci_quirk alc861_fixup_tbl[] = {
15218 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
15219 {}
15220};
Kailang Yangdf694da2005-12-05 19:42:22 +010015221
15222static int patch_alc861(struct hda_codec *codec)
15223{
15224 struct alc_spec *spec;
15225 int board_config;
15226 int err;
15227
Robert P. J. Daydc041e02006-12-19 14:44:15 +010015228 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010015229 if (spec == NULL)
15230 return -ENOMEM;
15231
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015232 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015233
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015234 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
15235 alc861_models,
15236 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015237
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015238 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015239 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15240 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010015241 board_config = ALC861_AUTO;
15242 }
15243
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015244 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups);
15245
Kailang Yangdf694da2005-12-05 19:42:22 +010015246 if (board_config == ALC861_AUTO) {
15247 /* automatic parse from the BIOS config */
15248 err = alc861_parse_auto_config(codec);
15249 if (err < 0) {
15250 alc_free(codec);
15251 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015252 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015253 printk(KERN_INFO
15254 "hda_codec: Cannot set up configuration "
15255 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010015256 board_config = ALC861_3ST_DIG;
15257 }
15258 }
15259
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015260 err = snd_hda_attach_beep_device(codec, 0x23);
15261 if (err < 0) {
15262 alc_free(codec);
15263 return err;
15264 }
15265
Kailang Yangdf694da2005-12-05 19:42:22 +010015266 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015267 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015268
Kailang Yangdf694da2005-12-05 19:42:22 +010015269 spec->stream_analog_playback = &alc861_pcm_analog_playback;
15270 spec->stream_analog_capture = &alc861_pcm_analog_capture;
15271
Kailang Yangdf694da2005-12-05 19:42:22 +010015272 spec->stream_digital_playback = &alc861_pcm_digital_playback;
15273 spec->stream_digital_capture = &alc861_pcm_digital_capture;
15274
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010015275 if (!spec->cap_mixer)
15276 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015277 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
15278
Takashi Iwai2134ea42008-01-10 16:53:55 +010015279 spec->vmaster_nid = 0x03;
15280
Kailang Yangdf694da2005-12-05 19:42:22 +010015281 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050015282 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015283 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015284#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050015285 spec->power_hook = alc_power_eapd;
15286#endif
15287 }
15288#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020015289 if (!spec->loopback.amplist)
15290 spec->loopback.amplist = alc861_loopbacks;
15291#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020015292
Kailang Yangdf694da2005-12-05 19:42:22 +010015293 return 0;
15294}
15295
15296/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015297 * ALC861-VD support
15298 *
15299 * Based on ALC882
15300 *
15301 * In addition, an independent DAC
15302 */
15303#define ALC861VD_DIGOUT_NID 0x06
15304
15305static hda_nid_t alc861vd_dac_nids[4] = {
15306 /* front, surr, clfe, side surr */
15307 0x02, 0x03, 0x04, 0x05
15308};
15309
15310/* dac_nids for ALC660vd are in a different order - according to
15311 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015312 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015313 * of ALC660vd codecs, but for now there is only 3stack mixer
15314 * - and it is the same as in 861vd.
15315 * adc_nids in ALC660vd are (is) the same as in 861vd
15316 */
15317static hda_nid_t alc660vd_dac_nids[3] = {
15318 /* front, rear, clfe, rear_surr */
15319 0x02, 0x04, 0x03
15320};
15321
15322static hda_nid_t alc861vd_adc_nids[1] = {
15323 /* ADC0 */
15324 0x09,
15325};
15326
Takashi Iwaie1406342008-02-11 18:32:32 +010015327static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
15328
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015329/* input MUX */
15330/* FIXME: should be a matrix-type input source selection */
15331static struct hda_input_mux alc861vd_capture_source = {
15332 .num_items = 4,
15333 .items = {
15334 { "Mic", 0x0 },
15335 { "Front Mic", 0x1 },
15336 { "Line", 0x2 },
15337 { "CD", 0x4 },
15338 },
15339};
15340
Kailang Yang272a5272007-05-14 11:00:38 +020015341static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010015342 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020015343 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010015344 { "Ext Mic", 0x0 },
15345 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020015346 },
15347};
15348
Kailang Yangd1a991a2007-08-15 16:21:59 +020015349static struct hda_input_mux alc861vd_hp_capture_source = {
15350 .num_items = 2,
15351 .items = {
15352 { "Front Mic", 0x0 },
15353 { "ATAPI Mic", 0x1 },
15354 },
15355};
15356
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015357/*
15358 * 2ch mode
15359 */
15360static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
15361 { 2, NULL }
15362};
15363
15364/*
15365 * 6ch mode
15366 */
15367static struct hda_verb alc861vd_6stack_ch6_init[] = {
15368 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15369 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15370 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15371 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15372 { } /* end */
15373};
15374
15375/*
15376 * 8ch mode
15377 */
15378static struct hda_verb alc861vd_6stack_ch8_init[] = {
15379 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15380 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15381 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15382 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15383 { } /* end */
15384};
15385
15386static struct hda_channel_mode alc861vd_6stack_modes[2] = {
15387 { 6, alc861vd_6stack_ch6_init },
15388 { 8, alc861vd_6stack_ch8_init },
15389};
15390
15391static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
15392 {
15393 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15394 .name = "Channel Mode",
15395 .info = alc_ch_mode_info,
15396 .get = alc_ch_mode_get,
15397 .put = alc_ch_mode_put,
15398 },
15399 { } /* end */
15400};
15401
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015402/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15403 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15404 */
15405static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
15406 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15407 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15408
15409 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15410 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
15411
15412 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
15413 HDA_OUTPUT),
15414 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
15415 HDA_OUTPUT),
15416 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
15417 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
15418
15419 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
15420 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
15421
15422 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15423
15424 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15425 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15426 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15427
15428 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15429 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15430 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15431
15432 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15433 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15434
15435 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15436 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15437
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015438 { } /* end */
15439};
15440
15441static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
15442 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15443 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15444
15445 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15446
15447 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15448 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15449 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15450
15451 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15452 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15453 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15454
15455 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15456 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15457
15458 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15459 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15460
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015461 { } /* end */
15462};
15463
Kailang Yangbdd148a2007-05-08 15:19:08 +020015464static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
15465 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15466 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
15467 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15468
15469 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15470
15471 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15472 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15473 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15474
15475 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15476 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15477 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15478
15479 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15480 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15481
15482 { } /* end */
15483};
15484
Tobin Davisb419f342008-03-07 11:57:51 +010015485/* Pin assignment: Speaker=0x14, HP = 0x15,
15486 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020015487 */
15488static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010015489 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15490 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015491 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15492 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010015493 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
15494 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15495 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15496 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
15497 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15498 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015499 { } /* end */
15500};
15501
Kailang Yangd1a991a2007-08-15 16:21:59 +020015502/* Pin assignment: Speaker=0x14, Line-out = 0x15,
15503 * Front Mic=0x18, ATAPI Mic = 0x19,
15504 */
15505static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
15506 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15507 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15508 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15509 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
15510 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15511 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15512 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15513 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015514
Kailang Yangd1a991a2007-08-15 16:21:59 +020015515 { } /* end */
15516};
15517
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015518/*
15519 * generic initialization of ADC, input mixers and output mixers
15520 */
15521static struct hda_verb alc861vd_volume_init_verbs[] = {
15522 /*
15523 * Unmute ADC0 and set the default input to mic-in
15524 */
15525 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15526 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15527
15528 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
15529 * the analog-loopback mixer widget
15530 */
15531 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015532 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15533 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15534 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15535 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15536 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015537
15538 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020015539 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15540 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15541 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015542 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015543
15544 /*
15545 * Set up output mixers (0x02 - 0x05)
15546 */
15547 /* set vol=0 to output mixers */
15548 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15549 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15550 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15551 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15552
15553 /* set up input amps for analog loopback */
15554 /* Amp Indices: DAC = 0, mixer = 1 */
15555 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15556 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15557 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15558 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15559 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15560 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15561 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15562 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15563
15564 { }
15565};
15566
15567/*
15568 * 3-stack pin configuration:
15569 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
15570 */
15571static struct hda_verb alc861vd_3stack_init_verbs[] = {
15572 /*
15573 * Set pin mode and muting
15574 */
15575 /* set front pin widgets 0x14 for output */
15576 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15577 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15578 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15579
15580 /* Mic (rear) pin: input vref at 80% */
15581 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15582 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15583 /* Front Mic pin: input vref at 80% */
15584 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15585 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15586 /* Line In pin: input */
15587 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15588 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15589 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15590 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15591 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15592 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15593 /* CD pin widget for input */
15594 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15595
15596 { }
15597};
15598
15599/*
15600 * 6-stack pin configuration:
15601 */
15602static struct hda_verb alc861vd_6stack_init_verbs[] = {
15603 /*
15604 * Set pin mode and muting
15605 */
15606 /* set front pin widgets 0x14 for output */
15607 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15608 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15609 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15610
15611 /* Rear Pin: output 1 (0x0d) */
15612 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15613 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15614 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15615 /* CLFE Pin: output 2 (0x0e) */
15616 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15617 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15618 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15619 /* Side Pin: output 3 (0x0f) */
15620 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15621 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15622 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15623
15624 /* Mic (rear) pin: input vref at 80% */
15625 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15626 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15627 /* Front Mic pin: input vref at 80% */
15628 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15629 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15630 /* Line In pin: input */
15631 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15632 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15633 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15634 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15635 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15636 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15637 /* CD pin widget for input */
15638 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15639
15640 { }
15641};
15642
Kailang Yangbdd148a2007-05-08 15:19:08 +020015643static struct hda_verb alc861vd_eapd_verbs[] = {
15644 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15645 { }
15646};
15647
Kailang Yangf9423e72008-05-27 12:32:25 +020015648static struct hda_verb alc660vd_eapd_verbs[] = {
15649 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15650 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15651 { }
15652};
15653
Kailang Yangbdd148a2007-05-08 15:19:08 +020015654static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15655 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15656 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15657 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15658 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015659 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015660 {}
15661};
15662
Kailang Yangbdd148a2007-05-08 15:19:08 +020015663static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15664{
15665 unsigned int present;
15666 unsigned char bits;
15667
Wu Fengguang864f92b2009-11-18 12:38:02 +080015668 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020015669 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080015670
Takashi Iwai47fd8302007-08-10 17:11:07 +020015671 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15672 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015673}
15674
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015675static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015676{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015677 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015678 spec->autocfg.hp_pins[0] = 0x1b;
15679 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015680}
15681
15682static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15683{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015684 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015685 alc861vd_lenovo_mic_automute(codec);
15686}
15687
15688static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15689 unsigned int res)
15690{
15691 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015692 case ALC880_MIC_EVENT:
15693 alc861vd_lenovo_mic_automute(codec);
15694 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015695 default:
15696 alc_automute_amp_unsol_event(codec, res);
15697 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015698 }
15699}
15700
Kailang Yang272a5272007-05-14 11:00:38 +020015701static struct hda_verb alc861vd_dallas_verbs[] = {
15702 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15703 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15704 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15705 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15706
15707 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15708 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15709 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15710 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15711 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15712 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15713 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15714 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015715
Kailang Yang272a5272007-05-14 11:00:38 +020015716 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15717 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15718 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15719 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15720 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15721 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15722 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15723 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15724
15725 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15726 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15727 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15728 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15729 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15730 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15731 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15732 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15733
15734 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15735 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15736 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15737 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15738
15739 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015740 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015741 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15742
15743 { } /* end */
15744};
15745
15746/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015747static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015748{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015749 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015750
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015751 spec->autocfg.hp_pins[0] = 0x15;
15752 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020015753}
15754
Takashi Iwaicb53c622007-08-10 17:21:45 +020015755#ifdef CONFIG_SND_HDA_POWER_SAVE
15756#define alc861vd_loopbacks alc880_loopbacks
15757#endif
15758
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015759/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015760#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15761#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15762#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15763#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15764
15765/*
15766 * configuration and preset
15767 */
15768static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15769 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015770 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015771 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015772 [ALC861VD_3ST] = "3stack",
15773 [ALC861VD_3ST_DIG] = "3stack-digout",
15774 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015775 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015776 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015777 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015778 [ALC861VD_AUTO] = "auto",
15779};
15780
15781static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015782 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15783 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015784 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015785 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010015786 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015787 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015788 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015789 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015790 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015791 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015792 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015793 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015794 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015795 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015796 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015797 {}
15798};
15799
15800static struct alc_config_preset alc861vd_presets[] = {
15801 [ALC660VD_3ST] = {
15802 .mixers = { alc861vd_3st_mixer },
15803 .init_verbs = { alc861vd_volume_init_verbs,
15804 alc861vd_3stack_init_verbs },
15805 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15806 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015807 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15808 .channel_mode = alc861vd_3stack_2ch_modes,
15809 .input_mux = &alc861vd_capture_source,
15810 },
Mike Crash6963f842007-06-25 12:12:51 +020015811 [ALC660VD_3ST_DIG] = {
15812 .mixers = { alc861vd_3st_mixer },
15813 .init_verbs = { alc861vd_volume_init_verbs,
15814 alc861vd_3stack_init_verbs },
15815 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15816 .dac_nids = alc660vd_dac_nids,
15817 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015818 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15819 .channel_mode = alc861vd_3stack_2ch_modes,
15820 .input_mux = &alc861vd_capture_source,
15821 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015822 [ALC861VD_3ST] = {
15823 .mixers = { alc861vd_3st_mixer },
15824 .init_verbs = { alc861vd_volume_init_verbs,
15825 alc861vd_3stack_init_verbs },
15826 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15827 .dac_nids = alc861vd_dac_nids,
15828 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15829 .channel_mode = alc861vd_3stack_2ch_modes,
15830 .input_mux = &alc861vd_capture_source,
15831 },
15832 [ALC861VD_3ST_DIG] = {
15833 .mixers = { alc861vd_3st_mixer },
15834 .init_verbs = { alc861vd_volume_init_verbs,
15835 alc861vd_3stack_init_verbs },
15836 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15837 .dac_nids = alc861vd_dac_nids,
15838 .dig_out_nid = ALC861VD_DIGOUT_NID,
15839 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15840 .channel_mode = alc861vd_3stack_2ch_modes,
15841 .input_mux = &alc861vd_capture_source,
15842 },
15843 [ALC861VD_6ST_DIG] = {
15844 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15845 .init_verbs = { alc861vd_volume_init_verbs,
15846 alc861vd_6stack_init_verbs },
15847 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15848 .dac_nids = alc861vd_dac_nids,
15849 .dig_out_nid = ALC861VD_DIGOUT_NID,
15850 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15851 .channel_mode = alc861vd_6stack_modes,
15852 .input_mux = &alc861vd_capture_source,
15853 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015854 [ALC861VD_LENOVO] = {
15855 .mixers = { alc861vd_lenovo_mixer },
15856 .init_verbs = { alc861vd_volume_init_verbs,
15857 alc861vd_3stack_init_verbs,
15858 alc861vd_eapd_verbs,
15859 alc861vd_lenovo_unsol_verbs },
15860 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15861 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015862 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15863 .channel_mode = alc861vd_3stack_2ch_modes,
15864 .input_mux = &alc861vd_capture_source,
15865 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015866 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015867 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015868 },
Kailang Yang272a5272007-05-14 11:00:38 +020015869 [ALC861VD_DALLAS] = {
15870 .mixers = { alc861vd_dallas_mixer },
15871 .init_verbs = { alc861vd_dallas_verbs },
15872 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15873 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015874 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15875 .channel_mode = alc861vd_3stack_2ch_modes,
15876 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015877 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015878 .setup = alc861vd_dallas_setup,
15879 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015880 },
15881 [ALC861VD_HP] = {
15882 .mixers = { alc861vd_hp_mixer },
15883 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15884 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15885 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015886 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015887 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15888 .channel_mode = alc861vd_3stack_2ch_modes,
15889 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015890 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015891 .setup = alc861vd_dallas_setup,
15892 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020015893 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015894 [ALC660VD_ASUS_V1S] = {
15895 .mixers = { alc861vd_lenovo_mixer },
15896 .init_verbs = { alc861vd_volume_init_verbs,
15897 alc861vd_3stack_init_verbs,
15898 alc861vd_eapd_verbs,
15899 alc861vd_lenovo_unsol_verbs },
15900 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15901 .dac_nids = alc660vd_dac_nids,
15902 .dig_out_nid = ALC861VD_DIGOUT_NID,
15903 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15904 .channel_mode = alc861vd_3stack_2ch_modes,
15905 .input_mux = &alc861vd_capture_source,
15906 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015907 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015908 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015909 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015910};
15911
15912/*
15913 * BIOS auto configuration
15914 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015915static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15916 const struct auto_pin_cfg *cfg)
15917{
Takashi Iwai9c0afc82010-01-12 14:00:11 +010015918 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x22, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020015919}
15920
15921
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015922static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15923 hda_nid_t nid, int pin_type, int dac_idx)
15924{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015925 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015926}
15927
15928static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15929{
15930 struct alc_spec *spec = codec->spec;
15931 int i;
15932
15933 for (i = 0; i <= HDA_SIDE; i++) {
15934 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015935 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015936 if (nid)
15937 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015938 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015939 }
15940}
15941
15942
15943static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15944{
15945 struct alc_spec *spec = codec->spec;
15946 hda_nid_t pin;
15947
15948 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015949 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015950 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015951 pin = spec->autocfg.speaker_pins[0];
15952 if (pin)
15953 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015954}
15955
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015956#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15957
15958static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15959{
15960 struct alc_spec *spec = codec->spec;
15961 int i;
15962
15963 for (i = 0; i < AUTO_PIN_LAST; i++) {
15964 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020015965 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015966 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015967 if (nid != ALC861VD_PIN_CD_NID &&
15968 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015969 snd_hda_codec_write(codec, nid, 0,
15970 AC_VERB_SET_AMP_GAIN_MUTE,
15971 AMP_OUT_MUTE);
15972 }
15973 }
15974}
15975
Takashi Iwaif511b012008-08-15 16:46:42 +020015976#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15977
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015978#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15979#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15980
15981/* add playback controls from the parsed DAC table */
15982/* Based on ALC880 version. But ALC861VD has separate,
15983 * different NIDs for mute/unmute switch and volume control */
15984static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15985 const struct auto_pin_cfg *cfg)
15986{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015987 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15988 hda_nid_t nid_v, nid_s;
15989 int i, err;
15990
15991 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015992 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015993 continue;
15994 nid_v = alc861vd_idx_to_mixer_vol(
15995 alc880_dac_to_idx(
15996 spec->multiout.dac_nids[i]));
15997 nid_s = alc861vd_idx_to_mixer_switch(
15998 alc880_dac_to_idx(
15999 spec->multiout.dac_nids[i]));
16000
16001 if (i == 2) {
16002 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016003 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16004 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016005 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
16006 HDA_OUTPUT));
16007 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016008 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016009 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16010 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016011 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
16012 HDA_OUTPUT));
16013 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016014 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016015 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16016 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016017 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
16018 HDA_INPUT));
16019 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016020 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016021 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16022 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016023 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
16024 HDA_INPUT));
16025 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016026 return err;
16027 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016028 const char *pfx;
16029 if (cfg->line_outs == 1 &&
16030 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
16031 if (!cfg->hp_pins)
16032 pfx = "Speaker";
16033 else
16034 pfx = "PCM";
16035 } else
16036 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016037 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016038 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
16039 HDA_OUTPUT));
16040 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016041 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016042 if (cfg->line_outs == 1 &&
16043 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
16044 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016045 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016046 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016047 HDA_INPUT));
16048 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016049 return err;
16050 }
16051 }
16052 return 0;
16053}
16054
16055/* add playback controls for speaker and HP outputs */
16056/* Based on ALC880 version. But ALC861VD has separate,
16057 * different NIDs for mute/unmute switch and volume control */
16058static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
16059 hda_nid_t pin, const char *pfx)
16060{
16061 hda_nid_t nid_v, nid_s;
16062 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016063
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016064 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016065 return 0;
16066
16067 if (alc880_is_fixed_pin(pin)) {
16068 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16069 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016070 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016071 spec->multiout.hp_nid = nid_v;
16072 else
16073 spec->multiout.extra_out_nid[0] = nid_v;
16074 /* control HP volume/switch on the output mixer amp */
16075 nid_v = alc861vd_idx_to_mixer_vol(
16076 alc880_fixed_pin_idx(pin));
16077 nid_s = alc861vd_idx_to_mixer_switch(
16078 alc880_fixed_pin_idx(pin));
16079
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016080 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016081 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
16082 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016083 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016084 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016085 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
16086 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016087 return err;
16088 } else if (alc880_is_multi_pin(pin)) {
16089 /* set manual connection */
16090 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016091 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016092 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16093 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016094 return err;
16095 }
16096 return 0;
16097}
16098
16099/* parse the BIOS configuration and set up the alc_spec
16100 * return 1 if successful, 0 if the proper config is not found,
16101 * or a negative error code
16102 * Based on ALC880 version - had to change it to override
16103 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
16104static int alc861vd_parse_auto_config(struct hda_codec *codec)
16105{
16106 struct alc_spec *spec = codec->spec;
16107 int err;
16108 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
16109
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016110 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16111 alc861vd_ignore);
16112 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016113 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016114 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016115 return 0; /* can't find valid BIOS pin config */
16116
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016117 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16118 if (err < 0)
16119 return err;
16120 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
16121 if (err < 0)
16122 return err;
16123 err = alc861vd_auto_create_extra_out(spec,
16124 spec->autocfg.speaker_pins[0],
16125 "Speaker");
16126 if (err < 0)
16127 return err;
16128 err = alc861vd_auto_create_extra_out(spec,
16129 spec->autocfg.hp_pins[0],
16130 "Headphone");
16131 if (err < 0)
16132 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016133 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016134 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016135 return err;
16136
16137 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16138
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016139 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016140 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
16141
Takashi Iwai603c4012008-07-30 15:01:44 +020016142 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016143 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016144
Takashi Iwaid88897e2008-10-31 15:01:37 +010016145 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016146
16147 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016148 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016149
Takashi Iwai776e1842007-08-29 15:07:11 +020016150 err = alc_auto_add_mic_boost(codec);
16151 if (err < 0)
16152 return err;
16153
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016154 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
16155
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016156 return 1;
16157}
16158
16159/* additional initialization for auto-configuration model */
16160static void alc861vd_auto_init(struct hda_codec *codec)
16161{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016162 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016163 alc861vd_auto_init_multi_out(codec);
16164 alc861vd_auto_init_hp_out(codec);
16165 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016166 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016167 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016168 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016169}
16170
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016171enum {
16172 ALC660VD_FIX_ASUS_GPIO1
16173};
16174
16175/* reset GPIO1 */
16176static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
16177 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
16178 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
16179 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
16180 { }
16181};
16182
16183static const struct alc_fixup alc861vd_fixups[] = {
16184 [ALC660VD_FIX_ASUS_GPIO1] = {
16185 .verbs = alc660vd_fix_asus_gpio1_verbs,
16186 },
16187};
16188
16189static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
16190 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
16191 {}
16192};
16193
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016194static int patch_alc861vd(struct hda_codec *codec)
16195{
16196 struct alc_spec *spec;
16197 int err, board_config;
16198
16199 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16200 if (spec == NULL)
16201 return -ENOMEM;
16202
16203 codec->spec = spec;
16204
16205 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
16206 alc861vd_models,
16207 alc861vd_cfg_tbl);
16208
16209 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016210 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16211 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016212 board_config = ALC861VD_AUTO;
16213 }
16214
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016215 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups);
16216
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016217 if (board_config == ALC861VD_AUTO) {
16218 /* automatic parse from the BIOS config */
16219 err = alc861vd_parse_auto_config(codec);
16220 if (err < 0) {
16221 alc_free(codec);
16222 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016223 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016224 printk(KERN_INFO
16225 "hda_codec: Cannot set up configuration "
16226 "from BIOS. Using base mode...\n");
16227 board_config = ALC861VD_3ST;
16228 }
16229 }
16230
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016231 err = snd_hda_attach_beep_device(codec, 0x23);
16232 if (err < 0) {
16233 alc_free(codec);
16234 return err;
16235 }
16236
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016237 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016238 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016239
Kailang Yang2f893282008-05-27 12:14:47 +020016240 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020016241 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010016242 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020016243 }
16244
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016245 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
16246 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
16247
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016248 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
16249 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
16250
Takashi Iwaidd704692009-08-11 08:45:11 +020016251 if (!spec->adc_nids) {
16252 spec->adc_nids = alc861vd_adc_nids;
16253 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
16254 }
16255 if (!spec->capsrc_nids)
16256 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016257
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016258 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016259 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016260
Takashi Iwai2134ea42008-01-10 16:53:55 +010016261 spec->vmaster_nid = 0x02;
16262
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016263 codec->patch_ops = alc_patch_ops;
16264
16265 if (board_config == ALC861VD_AUTO)
16266 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016267#ifdef CONFIG_SND_HDA_POWER_SAVE
16268 if (!spec->loopback.amplist)
16269 spec->loopback.amplist = alc861vd_loopbacks;
16270#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016271
16272 return 0;
16273}
16274
16275/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016276 * ALC662 support
16277 *
16278 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
16279 * configuration. Each pin widget can choose any input DACs and a mixer.
16280 * Each ADC is connected from a mixer of all inputs. This makes possible
16281 * 6-channel independent captures.
16282 *
16283 * In addition, an independent DAC for the multi-playback (not used in this
16284 * driver yet).
16285 */
16286#define ALC662_DIGOUT_NID 0x06
16287#define ALC662_DIGIN_NID 0x0a
16288
16289static hda_nid_t alc662_dac_nids[4] = {
16290 /* front, rear, clfe, rear_surr */
16291 0x02, 0x03, 0x04
16292};
16293
Kailang Yang622e84c2009-04-21 07:39:04 +020016294static hda_nid_t alc272_dac_nids[2] = {
16295 0x02, 0x03
16296};
16297
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016298static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016299 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016300 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016301};
Takashi Iwaie1406342008-02-11 18:32:32 +010016302
Kailang Yang622e84c2009-04-21 07:39:04 +020016303static hda_nid_t alc272_adc_nids[1] = {
16304 /* ADC1-2 */
16305 0x08,
16306};
16307
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016308static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020016309static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
16310
Takashi Iwaie1406342008-02-11 18:32:32 +010016311
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016312/* input MUX */
16313/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016314static struct hda_input_mux alc662_capture_source = {
16315 .num_items = 4,
16316 .items = {
16317 { "Mic", 0x0 },
16318 { "Front Mic", 0x1 },
16319 { "Line", 0x2 },
16320 { "CD", 0x4 },
16321 },
16322};
16323
16324static struct hda_input_mux alc662_lenovo_101e_capture_source = {
16325 .num_items = 2,
16326 .items = {
16327 { "Mic", 0x1 },
16328 { "Line", 0x2 },
16329 },
16330};
Kailang Yang291702f2007-10-16 14:28:03 +020016331
Kailang Yang6dda9f42008-05-27 12:05:31 +020016332static struct hda_input_mux alc663_capture_source = {
16333 .num_items = 3,
16334 .items = {
16335 { "Mic", 0x0 },
16336 { "Front Mic", 0x1 },
16337 { "Line", 0x2 },
16338 },
16339};
16340
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016341#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020016342static struct hda_input_mux alc272_nc10_capture_source = {
16343 .num_items = 16,
16344 .items = {
16345 { "Autoselect Mic", 0x0 },
16346 { "Internal Mic", 0x1 },
16347 { "In-0x02", 0x2 },
16348 { "In-0x03", 0x3 },
16349 { "In-0x04", 0x4 },
16350 { "In-0x05", 0x5 },
16351 { "In-0x06", 0x6 },
16352 { "In-0x07", 0x7 },
16353 { "In-0x08", 0x8 },
16354 { "In-0x09", 0x9 },
16355 { "In-0x0a", 0x0a },
16356 { "In-0x0b", 0x0b },
16357 { "In-0x0c", 0x0c },
16358 { "In-0x0d", 0x0d },
16359 { "In-0x0e", 0x0e },
16360 { "In-0x0f", 0x0f },
16361 },
16362};
16363#endif
16364
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016365/*
16366 * 2ch mode
16367 */
16368static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
16369 { 2, NULL }
16370};
16371
16372/*
16373 * 2ch mode
16374 */
16375static struct hda_verb alc662_3ST_ch2_init[] = {
16376 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
16377 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16378 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
16379 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16380 { } /* end */
16381};
16382
16383/*
16384 * 6ch mode
16385 */
16386static struct hda_verb alc662_3ST_ch6_init[] = {
16387 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16388 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16389 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
16390 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16391 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16392 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
16393 { } /* end */
16394};
16395
16396static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
16397 { 2, alc662_3ST_ch2_init },
16398 { 6, alc662_3ST_ch6_init },
16399};
16400
16401/*
16402 * 2ch mode
16403 */
16404static struct hda_verb alc662_sixstack_ch6_init[] = {
16405 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16406 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16407 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16408 { } /* end */
16409};
16410
16411/*
16412 * 6ch mode
16413 */
16414static struct hda_verb alc662_sixstack_ch8_init[] = {
16415 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16416 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16417 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16418 { } /* end */
16419};
16420
16421static struct hda_channel_mode alc662_5stack_modes[2] = {
16422 { 2, alc662_sixstack_ch6_init },
16423 { 6, alc662_sixstack_ch8_init },
16424};
16425
16426/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16427 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16428 */
16429
16430static struct snd_kcontrol_new alc662_base_mixer[] = {
16431 /* output mixer control */
16432 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016433 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016434 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016435 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016436 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16437 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016438 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16439 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016440 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16441
16442 /*Input mixer control */
16443 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
16444 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
16445 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
16446 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
16447 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
16448 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
16449 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
16450 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016451 { } /* end */
16452};
16453
16454static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
16455 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016456 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016457 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16458 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16459 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16460 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16461 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16462 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16463 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16464 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16465 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016466 { } /* end */
16467};
16468
16469static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
16470 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016471 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016472 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016473 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016474 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16475 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016476 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16477 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016478 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16479 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16480 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16481 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16482 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16483 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16484 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16485 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16486 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016487 { } /* end */
16488};
16489
16490static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
16491 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16492 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010016493 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16494 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016495 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16496 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16497 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16498 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16499 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016500 { } /* end */
16501};
16502
Kailang Yang291702f2007-10-16 14:28:03 +020016503static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016504 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16505 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020016506
16507 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
16508 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16509 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16510
16511 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16512 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16513 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16514 { } /* end */
16515};
16516
Kailang Yang8c427222008-01-10 13:03:59 +010016517static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016518 ALC262_HIPPO_MASTER_SWITCH,
16519 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016520 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016521 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16522 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016523 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
16524 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16525 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16526 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16527 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16528 { } /* end */
16529};
16530
Kailang Yangf1d4e282008-08-26 14:03:29 +020016531static struct hda_bind_ctls alc663_asus_bind_master_vol = {
16532 .ops = &snd_hda_bind_vol,
16533 .values = {
16534 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16535 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
16536 0
16537 },
16538};
16539
16540static struct hda_bind_ctls alc663_asus_one_bind_switch = {
16541 .ops = &snd_hda_bind_sw,
16542 .values = {
16543 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16544 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16545 0
16546 },
16547};
16548
Kailang Yang6dda9f42008-05-27 12:05:31 +020016549static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016550 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16551 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
16552 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16553 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16554 { } /* end */
16555};
16556
16557static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
16558 .ops = &snd_hda_bind_sw,
16559 .values = {
16560 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16561 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16562 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16563 0
16564 },
16565};
16566
16567static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
16568 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16569 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
16570 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16571 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16572 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16573 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16574
16575 { } /* end */
16576};
16577
16578static struct hda_bind_ctls alc663_asus_four_bind_switch = {
16579 .ops = &snd_hda_bind_sw,
16580 .values = {
16581 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16582 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16583 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16584 0
16585 },
16586};
16587
16588static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
16589 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16590 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
16591 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16592 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16593 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16594 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16595 { } /* end */
16596};
16597
16598static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016599 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16600 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016601 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16602 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16603 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16604 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16605 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16606 { } /* end */
16607};
16608
16609static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
16610 .ops = &snd_hda_bind_vol,
16611 .values = {
16612 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16613 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16614 0
16615 },
16616};
16617
16618static struct hda_bind_ctls alc663_asus_two_bind_switch = {
16619 .ops = &snd_hda_bind_sw,
16620 .values = {
16621 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16622 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
16623 0
16624 },
16625};
16626
16627static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16628 HDA_BIND_VOL("Master Playback Volume",
16629 &alc663_asus_two_bind_master_vol),
16630 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16631 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016632 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16633 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16634 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016635 { } /* end */
16636};
16637
16638static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16639 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16640 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16641 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16642 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16643 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16644 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016645 { } /* end */
16646};
16647
16648static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16649 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16650 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16651 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16652 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16653 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16654
16655 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16656 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16657 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16658 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16659 { } /* end */
16660};
16661
16662static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16663 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16664 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16665 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16666
16667 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16668 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16669 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16670 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16671 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16672 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16673 { } /* end */
16674};
16675
Kailang Yangebb83ee2009-12-17 12:23:00 +010016676static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
16677 .ops = &snd_hda_bind_sw,
16678 .values = {
16679 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16680 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16681 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16682 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16683 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16684 0
16685 },
16686};
16687
16688static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
16689 .ops = &snd_hda_bind_sw,
16690 .values = {
16691 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16692 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16693 0
16694 },
16695};
16696
16697static struct snd_kcontrol_new alc663_mode7_mixer[] = {
16698 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16699 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16700 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16701 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16702 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16703 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16704 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16705 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16706 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16707 { } /* end */
16708};
16709
16710static struct snd_kcontrol_new alc663_mode8_mixer[] = {
16711 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16712 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16713 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16714 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16715 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16716 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16717 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16718 { } /* end */
16719};
16720
16721
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016722static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16723 {
16724 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16725 .name = "Channel Mode",
16726 .info = alc_ch_mode_info,
16727 .get = alc_ch_mode_get,
16728 .put = alc_ch_mode_put,
16729 },
16730 { } /* end */
16731};
16732
16733static struct hda_verb alc662_init_verbs[] = {
16734 /* ADC: mute amp left and right */
16735 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16736 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016737
Kailang Yangb60dd392007-09-20 12:50:29 +020016738 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16739 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16740 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16741 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16742 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16743 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016744
16745 /* Front Pin: output 0 (0x0c) */
16746 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16747 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16748
16749 /* Rear Pin: output 1 (0x0d) */
16750 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16751 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16752
16753 /* CLFE Pin: output 2 (0x0e) */
16754 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16755 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16756
16757 /* Mic (rear) pin: input vref at 80% */
16758 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16759 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16760 /* Front Mic pin: input vref at 80% */
16761 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16762 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16763 /* Line In pin: input */
16764 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16765 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16766 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16767 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16768 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16769 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16770 /* CD pin widget for input */
16771 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16772
16773 /* FIXME: use matrix-type input source selection */
16774 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16775 /* Input mixer */
16776 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016777 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016778
16779 /* always trun on EAPD */
16780 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16781 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16782
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016783 { }
16784};
16785
Kailang Yangcec27c82010-02-04 14:18:18 +010016786static struct hda_verb alc663_init_verbs[] = {
16787 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16788 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16789 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16790 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16791 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16792 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16793 { }
16794};
16795
16796static struct hda_verb alc272_init_verbs[] = {
16797 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16798 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16799 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16800 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16801 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16802 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16803 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16804 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16805 { }
16806};
16807
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016808static struct hda_verb alc662_sue_init_verbs[] = {
16809 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16810 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016811 {}
16812};
16813
16814static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16815 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16816 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16817 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016818};
16819
Kailang Yang8c427222008-01-10 13:03:59 +010016820/* Set Unsolicited Event*/
16821static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16822 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16823 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16824 {}
16825};
16826
Kailang Yang6dda9f42008-05-27 12:05:31 +020016827static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016828 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16829 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016830 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16831 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016832 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16833 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16834 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016835 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16836 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16837 {}
16838};
16839
Kailang Yangf1d4e282008-08-26 14:03:29 +020016840static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16841 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16842 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16843 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16844 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16845 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16846 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16847 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16848 {}
16849};
16850
16851static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16852 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16853 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16854 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16855 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16856 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16857 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16858 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16859 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16860 {}
16861};
16862
16863static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16864 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16865 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16866 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16867 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16868 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16869 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16870 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16871 {}
16872};
16873
16874static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16875 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16876 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16877 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16878 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16879 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16880 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16881 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16882 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16883 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16884 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16885 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16886 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16887 {}
16888};
16889
16890static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16891 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16892 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16893 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16894 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16895 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16896 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16897 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16898 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16899 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16900 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16901 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16902 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16903 {}
16904};
16905
Kailang Yang6dda9f42008-05-27 12:05:31 +020016906static struct hda_verb alc663_g71v_init_verbs[] = {
16907 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16908 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16909 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16910
16911 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16912 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16913 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16914
16915 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16916 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16917 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16918 {}
16919};
16920
16921static struct hda_verb alc663_g50v_init_verbs[] = {
16922 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16923 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16924 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16925
16926 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16927 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16928 {}
16929};
16930
Kailang Yangf1d4e282008-08-26 14:03:29 +020016931static struct hda_verb alc662_ecs_init_verbs[] = {
16932 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16933 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16934 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16935 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16936 {}
16937};
16938
Kailang Yang622e84c2009-04-21 07:39:04 +020016939static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16940 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16941 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16942 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16943 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16944 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16945 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16946 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16947 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16948 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16949 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16950 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16951 {}
16952};
16953
16954static struct hda_verb alc272_dell_init_verbs[] = {
16955 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16956 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16957 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16958 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16959 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16960 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16961 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16962 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16963 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16964 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16965 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16966 {}
16967};
16968
Kailang Yangebb83ee2009-12-17 12:23:00 +010016969static struct hda_verb alc663_mode7_init_verbs[] = {
16970 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16971 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16972 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16973 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16974 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16975 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16976 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
16977 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16978 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16979 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16980 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16981 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16982 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16983 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16984 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16985 {}
16986};
16987
16988static struct hda_verb alc663_mode8_init_verbs[] = {
16989 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16990 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16991 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16992 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16993 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16994 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16995 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16996 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16997 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16998 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16999 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17000 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17001 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17002 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17003 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17004 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17005 {}
17006};
17007
Kailang Yangf1d4e282008-08-26 14:03:29 +020017008static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
17009 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
17010 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
17011 { } /* end */
17012};
17013
Kailang Yang622e84c2009-04-21 07:39:04 +020017014static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
17015 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
17016 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
17017 { } /* end */
17018};
17019
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017020static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
17021{
17022 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017023 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017024
Wu Fengguang864f92b2009-11-18 12:38:02 +080017025 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017026 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017027
Takashi Iwai47fd8302007-08-10 17:11:07 +020017028 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17029 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017030}
17031
17032static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
17033{
17034 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017035 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017036
Wu Fengguang864f92b2009-11-18 12:38:02 +080017037 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017038 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017039
Takashi Iwai47fd8302007-08-10 17:11:07 +020017040 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17041 HDA_AMP_MUTE, bits);
17042 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17043 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017044}
17045
17046static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
17047 unsigned int res)
17048{
17049 if ((res >> 26) == ALC880_HP_EVENT)
17050 alc662_lenovo_101e_all_automute(codec);
17051 if ((res >> 26) == ALC880_FRONT_EVENT)
17052 alc662_lenovo_101e_ispeaker_automute(codec);
17053}
17054
Kailang Yang291702f2007-10-16 14:28:03 +020017055/* unsolicited event for HP jack sensing */
17056static void alc662_eeepc_unsol_event(struct hda_codec *codec,
17057 unsigned int res)
17058{
Kailang Yang291702f2007-10-16 14:28:03 +020017059 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017060 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020017061 else
17062 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020017063}
17064
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017065static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020017066{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017067 struct alc_spec *spec = codec->spec;
17068
17069 alc262_hippo1_setup(codec);
17070 spec->ext_mic.pin = 0x18;
17071 spec->ext_mic.mux_idx = 0;
17072 spec->int_mic.pin = 0x19;
17073 spec->int_mic.mux_idx = 1;
17074 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020017075}
17076
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017077static void alc662_eeepc_inithook(struct hda_codec *codec)
17078{
17079 alc262_hippo_automute(codec);
17080 alc_mic_automute(codec);
17081}
17082
17083static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010017084{
Takashi Iwai42171c12009-05-08 14:11:43 +020017085 struct alc_spec *spec = codec->spec;
17086
17087 spec->autocfg.hp_pins[0] = 0x14;
17088 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010017089}
17090
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017091#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
17092
Kailang Yang6dda9f42008-05-27 12:05:31 +020017093static void alc663_m51va_speaker_automute(struct hda_codec *codec)
17094{
17095 unsigned int present;
17096 unsigned char bits;
17097
Wu Fengguang864f92b2009-11-18 12:38:02 +080017098 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017099 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020017100 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17101 AMP_IN_MUTE(0), bits);
17102 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17103 AMP_IN_MUTE(0), bits);
17104}
17105
17106static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
17107{
17108 unsigned int present;
17109 unsigned char bits;
17110
Wu Fengguang864f92b2009-11-18 12:38:02 +080017111 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017112 bits = present ? HDA_AMP_MUTE : 0;
17113 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17114 AMP_IN_MUTE(0), bits);
17115 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17116 AMP_IN_MUTE(0), bits);
17117 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
17118 AMP_IN_MUTE(0), bits);
17119 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
17120 AMP_IN_MUTE(0), bits);
17121}
17122
17123static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
17124{
17125 unsigned int present;
17126 unsigned char bits;
17127
Wu Fengguang864f92b2009-11-18 12:38:02 +080017128 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017129 bits = present ? HDA_AMP_MUTE : 0;
17130 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17131 AMP_IN_MUTE(0), bits);
17132 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17133 AMP_IN_MUTE(0), bits);
17134 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
17135 AMP_IN_MUTE(0), bits);
17136 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
17137 AMP_IN_MUTE(0), bits);
17138}
17139
17140static void alc662_f5z_speaker_automute(struct hda_codec *codec)
17141{
17142 unsigned int present;
17143 unsigned char bits;
17144
Wu Fengguang864f92b2009-11-18 12:38:02 +080017145 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017146 bits = present ? 0 : PIN_OUT;
17147 snd_hda_codec_write(codec, 0x14, 0,
17148 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
17149}
17150
17151static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
17152{
17153 unsigned int present1, present2;
17154
Wu Fengguang864f92b2009-11-18 12:38:02 +080017155 present1 = snd_hda_jack_detect(codec, 0x21);
17156 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017157
17158 if (present1 || present2) {
17159 snd_hda_codec_write_cache(codec, 0x14, 0,
17160 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17161 } else {
17162 snd_hda_codec_write_cache(codec, 0x14, 0,
17163 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17164 }
17165}
17166
17167static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
17168{
17169 unsigned int present1, present2;
17170
Wu Fengguang864f92b2009-11-18 12:38:02 +080017171 present1 = snd_hda_jack_detect(codec, 0x1b);
17172 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017173
17174 if (present1 || present2) {
17175 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17176 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
17177 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17178 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
17179 } else {
17180 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17181 AMP_IN_MUTE(0), 0);
17182 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17183 AMP_IN_MUTE(0), 0);
17184 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020017185}
17186
Kailang Yangebb83ee2009-12-17 12:23:00 +010017187static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
17188{
17189 unsigned int present1, present2;
17190
17191 present1 = snd_hda_codec_read(codec, 0x1b, 0,
17192 AC_VERB_GET_PIN_SENSE, 0)
17193 & AC_PINSENSE_PRESENCE;
17194 present2 = snd_hda_codec_read(codec, 0x21, 0,
17195 AC_VERB_GET_PIN_SENSE, 0)
17196 & AC_PINSENSE_PRESENCE;
17197
17198 if (present1 || present2) {
17199 snd_hda_codec_write_cache(codec, 0x14, 0,
17200 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17201 snd_hda_codec_write_cache(codec, 0x17, 0,
17202 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17203 } else {
17204 snd_hda_codec_write_cache(codec, 0x14, 0,
17205 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17206 snd_hda_codec_write_cache(codec, 0x17, 0,
17207 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17208 }
17209}
17210
17211static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
17212{
17213 unsigned int present1, present2;
17214
17215 present1 = snd_hda_codec_read(codec, 0x21, 0,
17216 AC_VERB_GET_PIN_SENSE, 0)
17217 & AC_PINSENSE_PRESENCE;
17218 present2 = snd_hda_codec_read(codec, 0x15, 0,
17219 AC_VERB_GET_PIN_SENSE, 0)
17220 & AC_PINSENSE_PRESENCE;
17221
17222 if (present1 || present2) {
17223 snd_hda_codec_write_cache(codec, 0x14, 0,
17224 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17225 snd_hda_codec_write_cache(codec, 0x17, 0,
17226 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17227 } else {
17228 snd_hda_codec_write_cache(codec, 0x14, 0,
17229 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17230 snd_hda_codec_write_cache(codec, 0x17, 0,
17231 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17232 }
17233}
17234
Kailang Yang6dda9f42008-05-27 12:05:31 +020017235static void alc663_m51va_unsol_event(struct hda_codec *codec,
17236 unsigned int res)
17237{
17238 switch (res >> 26) {
17239 case ALC880_HP_EVENT:
17240 alc663_m51va_speaker_automute(codec);
17241 break;
17242 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017243 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017244 break;
17245 }
17246}
17247
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017248static void alc663_m51va_setup(struct hda_codec *codec)
17249{
17250 struct alc_spec *spec = codec->spec;
17251 spec->ext_mic.pin = 0x18;
17252 spec->ext_mic.mux_idx = 0;
17253 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010017254 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017255 spec->auto_mic = 1;
17256}
17257
Kailang Yang6dda9f42008-05-27 12:05:31 +020017258static void alc663_m51va_inithook(struct hda_codec *codec)
17259{
17260 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017261 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017262}
17263
Kailang Yangf1d4e282008-08-26 14:03:29 +020017264/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017265#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010017266
17267static void alc663_mode1_setup(struct hda_codec *codec)
17268{
17269 struct alc_spec *spec = codec->spec;
17270 spec->ext_mic.pin = 0x18;
17271 spec->ext_mic.mux_idx = 0;
17272 spec->int_mic.pin = 0x19;
17273 spec->int_mic.mux_idx = 1;
17274 spec->auto_mic = 1;
17275}
17276
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017277#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020017278
Kailang Yangf1d4e282008-08-26 14:03:29 +020017279/* ***************** Mode2 ******************************/
17280static void alc662_mode2_unsol_event(struct hda_codec *codec,
17281 unsigned int res)
17282{
17283 switch (res >> 26) {
17284 case ALC880_HP_EVENT:
17285 alc662_f5z_speaker_automute(codec);
17286 break;
17287 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017288 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017289 break;
17290 }
17291}
17292
Kailang Yangebb83ee2009-12-17 12:23:00 +010017293#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017294
Kailang Yangf1d4e282008-08-26 14:03:29 +020017295static void alc662_mode2_inithook(struct hda_codec *codec)
17296{
17297 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017298 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017299}
17300/* ***************** Mode3 ******************************/
17301static void alc663_mode3_unsol_event(struct hda_codec *codec,
17302 unsigned int res)
17303{
17304 switch (res >> 26) {
17305 case ALC880_HP_EVENT:
17306 alc663_two_hp_m1_speaker_automute(codec);
17307 break;
17308 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017309 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017310 break;
17311 }
17312}
17313
Kailang Yangebb83ee2009-12-17 12:23:00 +010017314#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017315
Kailang Yangf1d4e282008-08-26 14:03:29 +020017316static void alc663_mode3_inithook(struct hda_codec *codec)
17317{
17318 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017319 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017320}
17321/* ***************** Mode4 ******************************/
17322static void alc663_mode4_unsol_event(struct hda_codec *codec,
17323 unsigned int res)
17324{
17325 switch (res >> 26) {
17326 case ALC880_HP_EVENT:
17327 alc663_21jd_two_speaker_automute(codec);
17328 break;
17329 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017330 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017331 break;
17332 }
17333}
17334
Kailang Yangebb83ee2009-12-17 12:23:00 +010017335#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017336
Kailang Yangf1d4e282008-08-26 14:03:29 +020017337static void alc663_mode4_inithook(struct hda_codec *codec)
17338{
17339 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017340 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017341}
17342/* ***************** Mode5 ******************************/
17343static void alc663_mode5_unsol_event(struct hda_codec *codec,
17344 unsigned int res)
17345{
17346 switch (res >> 26) {
17347 case ALC880_HP_EVENT:
17348 alc663_15jd_two_speaker_automute(codec);
17349 break;
17350 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017351 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017352 break;
17353 }
17354}
17355
Kailang Yangebb83ee2009-12-17 12:23:00 +010017356#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017357
Kailang Yangf1d4e282008-08-26 14:03:29 +020017358static void alc663_mode5_inithook(struct hda_codec *codec)
17359{
17360 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017361 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017362}
17363/* ***************** Mode6 ******************************/
17364static void alc663_mode6_unsol_event(struct hda_codec *codec,
17365 unsigned int res)
17366{
17367 switch (res >> 26) {
17368 case ALC880_HP_EVENT:
17369 alc663_two_hp_m2_speaker_automute(codec);
17370 break;
17371 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017372 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017373 break;
17374 }
17375}
17376
Kailang Yangebb83ee2009-12-17 12:23:00 +010017377#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017378
Kailang Yangf1d4e282008-08-26 14:03:29 +020017379static void alc663_mode6_inithook(struct hda_codec *codec)
17380{
17381 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017382 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017383}
17384
Kailang Yangebb83ee2009-12-17 12:23:00 +010017385/* ***************** Mode7 ******************************/
17386static void alc663_mode7_unsol_event(struct hda_codec *codec,
17387 unsigned int res)
17388{
17389 switch (res >> 26) {
17390 case ALC880_HP_EVENT:
17391 alc663_two_hp_m7_speaker_automute(codec);
17392 break;
17393 case ALC880_MIC_EVENT:
17394 alc_mic_automute(codec);
17395 break;
17396 }
17397}
17398
17399#define alc663_mode7_setup alc663_mode1_setup
17400
17401static void alc663_mode7_inithook(struct hda_codec *codec)
17402{
17403 alc663_two_hp_m7_speaker_automute(codec);
17404 alc_mic_automute(codec);
17405}
17406
17407/* ***************** Mode8 ******************************/
17408static void alc663_mode8_unsol_event(struct hda_codec *codec,
17409 unsigned int res)
17410{
17411 switch (res >> 26) {
17412 case ALC880_HP_EVENT:
17413 alc663_two_hp_m8_speaker_automute(codec);
17414 break;
17415 case ALC880_MIC_EVENT:
17416 alc_mic_automute(codec);
17417 break;
17418 }
17419}
17420
17421#define alc663_mode8_setup alc663_m51va_setup
17422
17423static void alc663_mode8_inithook(struct hda_codec *codec)
17424{
17425 alc663_two_hp_m8_speaker_automute(codec);
17426 alc_mic_automute(codec);
17427}
17428
Kailang Yang6dda9f42008-05-27 12:05:31 +020017429static void alc663_g71v_hp_automute(struct hda_codec *codec)
17430{
17431 unsigned int present;
17432 unsigned char bits;
17433
Wu Fengguang864f92b2009-11-18 12:38:02 +080017434 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017435 bits = present ? HDA_AMP_MUTE : 0;
17436 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17437 HDA_AMP_MUTE, bits);
17438 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17439 HDA_AMP_MUTE, bits);
17440}
17441
17442static void alc663_g71v_front_automute(struct hda_codec *codec)
17443{
17444 unsigned int present;
17445 unsigned char bits;
17446
Wu Fengguang864f92b2009-11-18 12:38:02 +080017447 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017448 bits = present ? HDA_AMP_MUTE : 0;
17449 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17450 HDA_AMP_MUTE, bits);
17451}
17452
17453static void alc663_g71v_unsol_event(struct hda_codec *codec,
17454 unsigned int res)
17455{
17456 switch (res >> 26) {
17457 case ALC880_HP_EVENT:
17458 alc663_g71v_hp_automute(codec);
17459 break;
17460 case ALC880_FRONT_EVENT:
17461 alc663_g71v_front_automute(codec);
17462 break;
17463 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017464 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017465 break;
17466 }
17467}
17468
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017469#define alc663_g71v_setup alc663_m51va_setup
17470
Kailang Yang6dda9f42008-05-27 12:05:31 +020017471static void alc663_g71v_inithook(struct hda_codec *codec)
17472{
17473 alc663_g71v_front_automute(codec);
17474 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017475 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017476}
17477
17478static void alc663_g50v_unsol_event(struct hda_codec *codec,
17479 unsigned int res)
17480{
17481 switch (res >> 26) {
17482 case ALC880_HP_EVENT:
17483 alc663_m51va_speaker_automute(codec);
17484 break;
17485 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017486 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017487 break;
17488 }
17489}
17490
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017491#define alc663_g50v_setup alc663_m51va_setup
17492
Kailang Yang6dda9f42008-05-27 12:05:31 +020017493static void alc663_g50v_inithook(struct hda_codec *codec)
17494{
17495 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017496 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017497}
17498
Kailang Yangf1d4e282008-08-26 14:03:29 +020017499static struct snd_kcontrol_new alc662_ecs_mixer[] = {
17500 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020017501 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017502
17503 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
17504 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
17505 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
17506
17507 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17508 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17509 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17510 { } /* end */
17511};
17512
Chris Pockelé9541ba12009-05-12 08:08:53 +020017513static struct snd_kcontrol_new alc272_nc10_mixer[] = {
17514 /* Master Playback automatically created from Speaker and Headphone */
17515 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17516 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17517 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17518 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17519
17520 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17521 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17522 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
17523
17524 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17525 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17526 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
17527 { } /* end */
17528};
17529
Takashi Iwaicb53c622007-08-10 17:21:45 +020017530#ifdef CONFIG_SND_HDA_POWER_SAVE
17531#define alc662_loopbacks alc880_loopbacks
17532#endif
17533
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017534
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017535/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017536#define alc662_pcm_analog_playback alc880_pcm_analog_playback
17537#define alc662_pcm_analog_capture alc880_pcm_analog_capture
17538#define alc662_pcm_digital_playback alc880_pcm_digital_playback
17539#define alc662_pcm_digital_capture alc880_pcm_digital_capture
17540
17541/*
17542 * configuration and preset
17543 */
17544static const char *alc662_models[ALC662_MODEL_LAST] = {
17545 [ALC662_3ST_2ch_DIG] = "3stack-dig",
17546 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
17547 [ALC662_3ST_6ch] = "3stack-6ch",
17548 [ALC662_5ST_DIG] = "6stack-dig",
17549 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020017550 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010017551 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017552 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020017553 [ALC663_ASUS_M51VA] = "m51va",
17554 [ALC663_ASUS_G71V] = "g71v",
17555 [ALC663_ASUS_H13] = "h13",
17556 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017557 [ALC663_ASUS_MODE1] = "asus-mode1",
17558 [ALC662_ASUS_MODE2] = "asus-mode2",
17559 [ALC663_ASUS_MODE3] = "asus-mode3",
17560 [ALC663_ASUS_MODE4] = "asus-mode4",
17561 [ALC663_ASUS_MODE5] = "asus-mode5",
17562 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010017563 [ALC663_ASUS_MODE7] = "asus-mode7",
17564 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020017565 [ALC272_DELL] = "dell",
17566 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020017567 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017568 [ALC662_AUTO] = "auto",
17569};
17570
17571static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010017572 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020017573 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
17574 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017575 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
17576 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010017577 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017578 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
17579 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
17580 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
17581 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017582 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
17583 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017584 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017585 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
17586 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
17587 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
17588 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
17589 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017590 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017591 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
17592 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017593 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
17594 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
17595 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
17596 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017597 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017598 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
17599 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
17600 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017601 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
17602 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
17603 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
17604 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017605 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017606 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
17607 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017608 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017609 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
17610 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
17611 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017612 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010017613 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017614 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
17615 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017616 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
17617 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
17618 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017619 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017620 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
17621 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017622 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017623 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020017624 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017625 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
17626 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
17627 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017628 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017629 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
17630 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010017631 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020017632 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010017633 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017634 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030017635 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
17636 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010017637 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020017638 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030017639 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
17640 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020017641 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020017642 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017643 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020017644 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020017645 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017646 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
17647 ALC663_ASUS_H13),
David Santinoli7aee6742009-12-09 12:34:26 +010017648 SND_PCI_QUIRK(0x8086, 0xd604, "Intel mobo", ALC662_3ST_2ch_DIG),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017649 {}
17650};
17651
17652static struct alc_config_preset alc662_presets[] = {
17653 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017654 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017655 .init_verbs = { alc662_init_verbs },
17656 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17657 .dac_nids = alc662_dac_nids,
17658 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017659 .dig_in_nid = ALC662_DIGIN_NID,
17660 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17661 .channel_mode = alc662_3ST_2ch_modes,
17662 .input_mux = &alc662_capture_source,
17663 },
17664 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017665 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017666 .init_verbs = { alc662_init_verbs },
17667 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17668 .dac_nids = alc662_dac_nids,
17669 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017670 .dig_in_nid = ALC662_DIGIN_NID,
17671 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17672 .channel_mode = alc662_3ST_6ch_modes,
17673 .need_dac_fix = 1,
17674 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017675 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017676 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017677 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017678 .init_verbs = { alc662_init_verbs },
17679 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17680 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017681 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17682 .channel_mode = alc662_3ST_6ch_modes,
17683 .need_dac_fix = 1,
17684 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017685 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017686 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017687 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017688 .init_verbs = { alc662_init_verbs },
17689 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17690 .dac_nids = alc662_dac_nids,
17691 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017692 .dig_in_nid = ALC662_DIGIN_NID,
17693 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
17694 .channel_mode = alc662_5stack_modes,
17695 .input_mux = &alc662_capture_source,
17696 },
17697 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017698 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017699 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
17700 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17701 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017702 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17703 .channel_mode = alc662_3ST_2ch_modes,
17704 .input_mux = &alc662_lenovo_101e_capture_source,
17705 .unsol_event = alc662_lenovo_101e_unsol_event,
17706 .init_hook = alc662_lenovo_101e_all_automute,
17707 },
Kailang Yang291702f2007-10-16 14:28:03 +020017708 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017709 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020017710 .init_verbs = { alc662_init_verbs,
17711 alc662_eeepc_sue_init_verbs },
17712 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17713 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020017714 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17715 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020017716 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017717 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020017718 .init_hook = alc662_eeepc_inithook,
17719 },
Kailang Yang8c427222008-01-10 13:03:59 +010017720 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017721 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010017722 alc662_chmode_mixer },
17723 .init_verbs = { alc662_init_verbs,
17724 alc662_eeepc_ep20_sue_init_verbs },
17725 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17726 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010017727 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17728 .channel_mode = alc662_3ST_6ch_modes,
17729 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020017730 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017731 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010017732 .init_hook = alc662_eeepc_ep20_inithook,
17733 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017734 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017735 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017736 .init_verbs = { alc662_init_verbs,
17737 alc662_ecs_init_verbs },
17738 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17739 .dac_nids = alc662_dac_nids,
17740 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17741 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017742 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017743 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017744 .init_hook = alc662_eeepc_inithook,
17745 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017746 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017747 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017748 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17749 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17750 .dac_nids = alc662_dac_nids,
17751 .dig_out_nid = ALC662_DIGOUT_NID,
17752 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17753 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017754 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017755 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017756 .init_hook = alc663_m51va_inithook,
17757 },
17758 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017759 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017760 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
17761 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17762 .dac_nids = alc662_dac_nids,
17763 .dig_out_nid = ALC662_DIGOUT_NID,
17764 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17765 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017766 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017767 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017768 .init_hook = alc663_g71v_inithook,
17769 },
17770 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017771 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017772 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17773 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17774 .dac_nids = alc662_dac_nids,
17775 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17776 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017777 .unsol_event = alc663_m51va_unsol_event,
17778 .init_hook = alc663_m51va_inithook,
17779 },
17780 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017781 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017782 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17783 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17784 .dac_nids = alc662_dac_nids,
17785 .dig_out_nid = ALC662_DIGOUT_NID,
17786 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17787 .channel_mode = alc662_3ST_6ch_modes,
17788 .input_mux = &alc663_capture_source,
17789 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017790 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017791 .init_hook = alc663_g50v_inithook,
17792 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017793 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017794 .mixers = { alc663_m51va_mixer },
17795 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017796 .init_verbs = { alc662_init_verbs,
17797 alc663_21jd_amic_init_verbs },
17798 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17799 .hp_nid = 0x03,
17800 .dac_nids = alc662_dac_nids,
17801 .dig_out_nid = ALC662_DIGOUT_NID,
17802 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17803 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017804 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017805 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017806 .init_hook = alc663_mode1_inithook,
17807 },
17808 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017809 .mixers = { alc662_1bjd_mixer },
17810 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017811 .init_verbs = { alc662_init_verbs,
17812 alc662_1bjd_amic_init_verbs },
17813 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17814 .dac_nids = alc662_dac_nids,
17815 .dig_out_nid = ALC662_DIGOUT_NID,
17816 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17817 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017818 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017819 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017820 .init_hook = alc662_mode2_inithook,
17821 },
17822 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017823 .mixers = { alc663_two_hp_m1_mixer },
17824 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017825 .init_verbs = { alc662_init_verbs,
17826 alc663_two_hp_amic_m1_init_verbs },
17827 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17828 .hp_nid = 0x03,
17829 .dac_nids = alc662_dac_nids,
17830 .dig_out_nid = ALC662_DIGOUT_NID,
17831 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17832 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017833 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017834 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017835 .init_hook = alc663_mode3_inithook,
17836 },
17837 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017838 .mixers = { alc663_asus_21jd_clfe_mixer },
17839 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017840 .init_verbs = { alc662_init_verbs,
17841 alc663_21jd_amic_init_verbs},
17842 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17843 .hp_nid = 0x03,
17844 .dac_nids = alc662_dac_nids,
17845 .dig_out_nid = ALC662_DIGOUT_NID,
17846 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17847 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017848 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017849 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017850 .init_hook = alc663_mode4_inithook,
17851 },
17852 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017853 .mixers = { alc663_asus_15jd_clfe_mixer },
17854 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017855 .init_verbs = { alc662_init_verbs,
17856 alc663_15jd_amic_init_verbs },
17857 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17858 .hp_nid = 0x03,
17859 .dac_nids = alc662_dac_nids,
17860 .dig_out_nid = ALC662_DIGOUT_NID,
17861 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17862 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017863 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017864 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017865 .init_hook = alc663_mode5_inithook,
17866 },
17867 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017868 .mixers = { alc663_two_hp_m2_mixer },
17869 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017870 .init_verbs = { alc662_init_verbs,
17871 alc663_two_hp_amic_m2_init_verbs },
17872 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17873 .hp_nid = 0x03,
17874 .dac_nids = alc662_dac_nids,
17875 .dig_out_nid = ALC662_DIGOUT_NID,
17876 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17877 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017878 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017879 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017880 .init_hook = alc663_mode6_inithook,
17881 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010017882 [ALC663_ASUS_MODE7] = {
17883 .mixers = { alc663_mode7_mixer },
17884 .cap_mixer = alc662_auto_capture_mixer,
17885 .init_verbs = { alc662_init_verbs,
17886 alc663_mode7_init_verbs },
17887 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17888 .hp_nid = 0x03,
17889 .dac_nids = alc662_dac_nids,
17890 .dig_out_nid = ALC662_DIGOUT_NID,
17891 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17892 .channel_mode = alc662_3ST_2ch_modes,
17893 .unsol_event = alc663_mode7_unsol_event,
17894 .setup = alc663_mode7_setup,
17895 .init_hook = alc663_mode7_inithook,
17896 },
17897 [ALC663_ASUS_MODE8] = {
17898 .mixers = { alc663_mode8_mixer },
17899 .cap_mixer = alc662_auto_capture_mixer,
17900 .init_verbs = { alc662_init_verbs,
17901 alc663_mode8_init_verbs },
17902 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17903 .hp_nid = 0x03,
17904 .dac_nids = alc662_dac_nids,
17905 .dig_out_nid = ALC662_DIGOUT_NID,
17906 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17907 .channel_mode = alc662_3ST_2ch_modes,
17908 .unsol_event = alc663_mode8_unsol_event,
17909 .setup = alc663_mode8_setup,
17910 .init_hook = alc663_mode8_inithook,
17911 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017912 [ALC272_DELL] = {
17913 .mixers = { alc663_m51va_mixer },
17914 .cap_mixer = alc272_auto_capture_mixer,
17915 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17916 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17917 .dac_nids = alc662_dac_nids,
17918 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17919 .adc_nids = alc272_adc_nids,
17920 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17921 .capsrc_nids = alc272_capsrc_nids,
17922 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017923 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017924 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017925 .init_hook = alc663_m51va_inithook,
17926 },
17927 [ALC272_DELL_ZM1] = {
17928 .mixers = { alc663_m51va_mixer },
17929 .cap_mixer = alc662_auto_capture_mixer,
17930 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17931 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17932 .dac_nids = alc662_dac_nids,
17933 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17934 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017935 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020017936 .capsrc_nids = alc662_capsrc_nids,
17937 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017938 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017939 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017940 .init_hook = alc663_m51va_inithook,
17941 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017942 [ALC272_SAMSUNG_NC10] = {
17943 .mixers = { alc272_nc10_mixer },
17944 .init_verbs = { alc662_init_verbs,
17945 alc663_21jd_amic_init_verbs },
17946 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17947 .dac_nids = alc272_dac_nids,
17948 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17949 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017950 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020017951 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017952 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020017953 .init_hook = alc663_mode4_inithook,
17954 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017955};
17956
17957
17958/*
17959 * BIOS auto configuration
17960 */
17961
Takashi Iwai7085ec12009-10-02 09:03:58 +020017962/* convert from MIX nid to DAC */
17963static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
17964{
17965 if (nid == 0x0f)
17966 return 0x02;
17967 else if (nid >= 0x0c && nid <= 0x0e)
17968 return nid - 0x0c + 0x02;
17969 else
17970 return 0;
17971}
17972
17973/* get MIX nid connected to the given pin targeted to DAC */
17974static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
17975 hda_nid_t dac)
17976{
17977 hda_nid_t mix[4];
17978 int i, num;
17979
17980 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
17981 for (i = 0; i < num; i++) {
17982 if (alc662_mix_to_dac(mix[i]) == dac)
17983 return mix[i];
17984 }
17985 return 0;
17986}
17987
17988/* look for an empty DAC slot */
17989static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
17990{
17991 struct alc_spec *spec = codec->spec;
17992 hda_nid_t srcs[5];
17993 int i, j, num;
17994
17995 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
17996 if (num < 0)
17997 return 0;
17998 for (i = 0; i < num; i++) {
17999 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
18000 if (!nid)
18001 continue;
18002 for (j = 0; j < spec->multiout.num_dacs; j++)
18003 if (spec->multiout.dac_nids[j] == nid)
18004 break;
18005 if (j >= spec->multiout.num_dacs)
18006 return nid;
18007 }
18008 return 0;
18009}
18010
18011/* fill in the dac_nids table from the parsed pin configuration */
18012static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18013 const struct auto_pin_cfg *cfg)
18014{
18015 struct alc_spec *spec = codec->spec;
18016 int i;
18017 hda_nid_t dac;
18018
18019 spec->multiout.dac_nids = spec->private_dac_nids;
18020 for (i = 0; i < cfg->line_outs; i++) {
18021 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
18022 if (!dac)
18023 continue;
18024 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
18025 }
18026 return 0;
18027}
18028
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018029static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018030 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018031{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018032 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018033 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18034}
18035
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018036static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018037 hda_nid_t nid, unsigned int chs)
18038{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018039 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018040 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
18041}
18042
18043#define alc662_add_stereo_vol(spec, pfx, nid) \
18044 alc662_add_vol_ctl(spec, pfx, nid, 3)
18045#define alc662_add_stereo_sw(spec, pfx, nid) \
18046 alc662_add_sw_ctl(spec, pfx, nid, 3)
18047
18048/* add playback controls from the parsed DAC table */
18049static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
18050 const struct auto_pin_cfg *cfg)
18051{
18052 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018053 static const char *chname[4] = {
18054 "Front", "Surround", NULL /*CLFE*/, "Side"
18055 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020018056 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018057 int i, err;
18058
18059 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018060 nid = spec->multiout.dac_nids[i];
18061 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018062 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018063 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
18064 if (!mix)
18065 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018066 if (i == 2) {
18067 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018068 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018069 if (err < 0)
18070 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018071 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018072 if (err < 0)
18073 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018074 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018075 if (err < 0)
18076 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018077 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018078 if (err < 0)
18079 return err;
18080 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018081 const char *pfx;
18082 if (cfg->line_outs == 1 &&
18083 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018084 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018085 pfx = "Speaker";
18086 else
18087 pfx = "PCM";
18088 } else
18089 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018090 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018091 if (err < 0)
18092 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018093 if (cfg->line_outs == 1 &&
18094 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
18095 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020018096 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018097 if (err < 0)
18098 return err;
18099 }
18100 }
18101 return 0;
18102}
18103
18104/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018105/* return DAC nid if any new DAC is assigned */
18106static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018107 const char *pfx)
18108{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018109 struct alc_spec *spec = codec->spec;
18110 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018111 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018112
18113 if (!pin)
18114 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018115 nid = alc662_look_for_dac(codec, pin);
18116 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018117 /* the corresponding DAC is already occupied */
18118 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
18119 return 0; /* no way */
18120 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018121 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018122 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
18123 }
18124
18125 mix = alc662_dac_to_mix(codec, pin, nid);
18126 if (!mix)
18127 return 0;
18128 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
18129 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020018130 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018131 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
18132 if (err < 0)
18133 return err;
18134 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018135}
18136
18137/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020018138#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020018139 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018140
18141static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
18142 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018143 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018144{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018145 int i, num;
18146 hda_nid_t srcs[4];
18147
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018148 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018149 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018150 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
18151 if (num <= 1)
18152 return;
18153 for (i = 0; i < num; i++) {
18154 if (alc662_mix_to_dac(srcs[i]) != dac)
18155 continue;
18156 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
18157 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018158 }
18159}
18160
18161static void alc662_auto_init_multi_out(struct hda_codec *codec)
18162{
18163 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018164 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018165 int i;
18166
18167 for (i = 0; i <= HDA_SIDE; i++) {
18168 hda_nid_t nid = spec->autocfg.line_out_pins[i];
18169 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020018170 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018171 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018172 }
18173}
18174
18175static void alc662_auto_init_hp_out(struct hda_codec *codec)
18176{
18177 struct alc_spec *spec = codec->spec;
18178 hda_nid_t pin;
18179
18180 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018181 if (pin)
18182 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
18183 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018184 pin = spec->autocfg.speaker_pins[0];
18185 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018186 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
18187 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018188}
18189
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018190#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
18191
18192static void alc662_auto_init_analog_input(struct hda_codec *codec)
18193{
18194 struct alc_spec *spec = codec->spec;
18195 int i;
18196
18197 for (i = 0; i < AUTO_PIN_LAST; i++) {
18198 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020018199 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010018200 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010018201 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010018202 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018203 snd_hda_codec_write(codec, nid, 0,
18204 AC_VERB_SET_AMP_GAIN_MUTE,
18205 AMP_OUT_MUTE);
18206 }
18207 }
18208}
18209
Takashi Iwaif511b012008-08-15 16:46:42 +020018210#define alc662_auto_init_input_src alc882_auto_init_input_src
18211
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018212static int alc662_parse_auto_config(struct hda_codec *codec)
18213{
18214 struct alc_spec *spec = codec->spec;
18215 int err;
18216 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
18217
18218 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
18219 alc662_ignore);
18220 if (err < 0)
18221 return err;
18222 if (!spec->autocfg.line_outs)
18223 return 0; /* can't find valid BIOS pin config */
18224
Takashi Iwai7085ec12009-10-02 09:03:58 +020018225 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018226 if (err < 0)
18227 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018228 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018229 if (err < 0)
18230 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018231 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018232 spec->autocfg.speaker_pins[0],
18233 "Speaker");
18234 if (err < 0)
18235 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018236 if (err)
18237 spec->multiout.extra_out_nid[0] = err;
18238 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018239 "Headphone");
18240 if (err < 0)
18241 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018242 if (err)
18243 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020018244 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018245 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018246 return err;
18247
18248 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
18249
Takashi Iwai0852d7a2009-02-11 11:35:15 +010018250 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018251 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
18252
Takashi Iwai603c4012008-07-30 15:01:44 +020018253 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010018254 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018255
18256 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020018257 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020018258
Kailang Yangcec27c82010-02-04 14:18:18 +010018259 add_verb(spec, alc662_init_verbs);
18260 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18261 codec->vendor_id == 0x10ec0665)
18262 add_verb(spec, alc663_init_verbs);
18263
18264 if (codec->vendor_id == 0x10ec0272)
18265 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020018266
18267 err = alc_auto_add_mic_boost(codec);
18268 if (err < 0)
18269 return err;
18270
Takashi Iwai4a79ba32009-04-22 16:31:35 +020018271 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
18272
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018273 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018274}
18275
18276/* additional initialization for auto-configuration model */
18277static void alc662_auto_init(struct hda_codec *codec)
18278{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018279 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018280 alc662_auto_init_multi_out(codec);
18281 alc662_auto_init_hp_out(codec);
18282 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020018283 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018284 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020018285 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018286}
18287
18288static int patch_alc662(struct hda_codec *codec)
18289{
18290 struct alc_spec *spec;
18291 int err, board_config;
18292
18293 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
18294 if (!spec)
18295 return -ENOMEM;
18296
18297 codec->spec = spec;
18298
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020018299 alc_fix_pll_init(codec, 0x20, 0x04, 15);
18300
Kailang Yang274693f2009-12-03 10:07:50 +010018301 if (alc_read_coef_idx(codec, 0)==0x8020){
18302 kfree(codec->chip_name);
18303 codec->chip_name = kstrdup("ALC661", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018304 if (!codec->chip_name) {
18305 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018306 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018307 }
Kailang Yang274693f2009-12-03 10:07:50 +010018308 }
18309
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018310 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
18311 alc662_models,
18312 alc662_cfg_tbl);
18313 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020018314 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
18315 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018316 board_config = ALC662_AUTO;
18317 }
18318
18319 if (board_config == ALC662_AUTO) {
18320 /* automatic parse from the BIOS config */
18321 err = alc662_parse_auto_config(codec);
18322 if (err < 0) {
18323 alc_free(codec);
18324 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018325 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018326 printk(KERN_INFO
18327 "hda_codec: Cannot set up configuration "
18328 "from BIOS. Using base mode...\n");
18329 board_config = ALC662_3ST_2ch_DIG;
18330 }
18331 }
18332
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090018333 err = snd_hda_attach_beep_device(codec, 0x1);
18334 if (err < 0) {
18335 alc_free(codec);
18336 return err;
18337 }
18338
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018339 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020018340 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018341
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018342 spec->stream_analog_playback = &alc662_pcm_analog_playback;
18343 spec->stream_analog_capture = &alc662_pcm_analog_capture;
18344
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018345 spec->stream_digital_playback = &alc662_pcm_digital_playback;
18346 spec->stream_digital_capture = &alc662_pcm_digital_capture;
18347
Takashi Iwaidd704692009-08-11 08:45:11 +020018348 if (!spec->adc_nids) {
18349 spec->adc_nids = alc662_adc_nids;
18350 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
18351 }
18352 if (!spec->capsrc_nids)
18353 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018354
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018355 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018356 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018357
Kailang Yangcec27c82010-02-04 14:18:18 +010018358 switch (codec->vendor_id) {
18359 case 0x10ec0662:
18360 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
18361 break;
18362 case 0x10ec0272:
18363 case 0x10ec0663:
18364 case 0x10ec0665:
18365 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
18366 break;
18367 case 0x10ec0273:
18368 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
18369 break;
18370 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010018371 spec->vmaster_nid = 0x02;
18372
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018373 codec->patch_ops = alc_patch_ops;
18374 if (board_config == ALC662_AUTO)
18375 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020018376#ifdef CONFIG_SND_HDA_POWER_SAVE
18377 if (!spec->loopback.amplist)
18378 spec->loopback.amplist = alc662_loopbacks;
18379#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018380
18381 return 0;
18382}
18383
Kailang Yang274693f2009-12-03 10:07:50 +010018384static int patch_alc888(struct hda_codec *codec)
18385{
18386 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
18387 kfree(codec->chip_name);
18388 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018389 if (!codec->chip_name) {
18390 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018391 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018392 }
18393 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018394 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018395 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018396}
18397
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018398/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070018399 * patch entries
18400 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018401static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070018402 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018403 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018404 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020018405 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018406 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018407 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020018408 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018409 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018410 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018411 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018412 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
18413 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
18414 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018415 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018416 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018417 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
18418 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018419 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010018420 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018421 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018422 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018423 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020018424 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018425 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020018426 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018427 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018428 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018429 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020018430 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018431 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018432 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018433 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018434 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018435 {} /* terminator */
18436};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018437
18438MODULE_ALIAS("snd-hda-codec-id:10ec*");
18439
18440MODULE_LICENSE("GPL");
18441MODULE_DESCRIPTION("Realtek HD-audio codec");
18442
18443static struct hda_codec_preset_list realtek_list = {
18444 .preset = snd_hda_preset_realtek,
18445 .owner = THIS_MODULE,
18446};
18447
18448static int __init patch_realtek_init(void)
18449{
18450 return snd_hda_add_codec_preset(&realtek_list);
18451}
18452
18453static void __exit patch_realtek_exit(void)
18454{
18455 snd_hda_delete_codec_preset(&realtek_list);
18456}
18457
18458module_init(patch_realtek_init)
18459module_exit(patch_realtek_exit)