blob: 8cebe26532235ffb1e295794ea6b26b9104f13d2 [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 Yangf53281e2008-07-18 12:36:43 +0200134 ALC269_ASUS_EEEPC_P703,
135 ALC269_ASUS_EEEPC_P901,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100136 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000137 ALC269_LIFEBOOK,
Kailang Yangf6a92242007-12-13 16:52:54 +0100138 ALC269_AUTO,
139 ALC269_MODEL_LAST /* last tag */
140};
141
Kailang Yangdf694da2005-12-05 19:42:22 +0100142/* ALC861 models */
143enum {
144 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200145 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100146 ALC861_3ST_DIG,
147 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200148 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200149 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200150 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100151 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100152 ALC861_AUTO,
153 ALC861_MODEL_LAST,
154};
155
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100156/* ALC861-VD models */
157enum {
158 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200159 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100160 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100161 ALC861VD_3ST,
162 ALC861VD_3ST_DIG,
163 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200164 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200165 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200166 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100167 ALC861VD_AUTO,
168 ALC861VD_MODEL_LAST,
169};
170
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200171/* ALC662 models */
172enum {
173 ALC662_3ST_2ch_DIG,
174 ALC662_3ST_6ch_DIG,
175 ALC662_3ST_6ch,
176 ALC662_5ST_DIG,
177 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200178 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100179 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200180 ALC663_ASUS_M51VA,
181 ALC663_ASUS_G71V,
182 ALC663_ASUS_H13,
183 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200184 ALC662_ECS,
185 ALC663_ASUS_MODE1,
186 ALC662_ASUS_MODE2,
187 ALC663_ASUS_MODE3,
188 ALC663_ASUS_MODE4,
189 ALC663_ASUS_MODE5,
190 ALC663_ASUS_MODE6,
Kailang Yang622e84c2009-04-21 07:39:04 +0200191 ALC272_DELL,
192 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200193 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200194 ALC662_AUTO,
195 ALC662_MODEL_LAST,
196};
197
Kailang Yangdf694da2005-12-05 19:42:22 +0100198/* ALC882 models */
199enum {
200 ALC882_3ST_DIG,
201 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200202 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200203 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200204 ALC882_TARGA,
205 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200206 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100207 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200208 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200209 ALC885_MB5,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200210 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200211 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100212 ALC882_MODEL_LAST,
213};
214
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200215/* ALC883 models */
216enum {
217 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,
Hector Martin3b315d72009-06-02 10:54:19 +0200227 ALC888_ACER_ASPIRE_8930G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200228 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200229 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100230 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200231 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200232 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200233 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200234 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200235 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200236 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100237 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100238 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100239 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100240 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800241 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200242 ALC883_3ST_6ch_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200243 ALC888_ASUS_M90V,
244 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200245 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100246 ALC1200_ASUS_P5Q,
Guido Günther3e1647c52009-06-05 00:47:26 +0200247 ALC883_SONY_VAIO_TT,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200248 ALC883_AUTO,
249 ALC883_MODEL_LAST,
250};
251
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200252/* styles of capture selection */
253enum {
254 CAPT_MUX = 0, /* only mux based */
255 CAPT_MIX, /* only mixer based */
256 CAPT_1MUX_MIX, /* first mux and other mixers */
257};
258
Kailang Yangdf694da2005-12-05 19:42:22 +0100259/* for GPIO Poll */
260#define GPIO_MASK 0x03
261
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200262/* extra amp-initialization sequence types */
263enum {
264 ALC_INIT_NONE,
265 ALC_INIT_DEFAULT,
266 ALC_INIT_GPIO1,
267 ALC_INIT_GPIO2,
268 ALC_INIT_GPIO3,
269};
270
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271struct alc_spec {
272 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100273 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100275 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100276 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277
Kailang Yangdf694da2005-12-05 19:42:22 +0100278 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200279 * don't forget NULL
280 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200281 */
282 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283
Takashi Iwai812a2cc2009-05-16 10:00:49 +0200284 char stream_name_analog[16]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 struct hda_pcm_stream *stream_analog_playback;
286 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100287 struct hda_pcm_stream *stream_analog_alt_playback;
288 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289
Takashi Iwai812a2cc2009-05-16 10:00:49 +0200290 char stream_name_digital[16]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 struct hda_pcm_stream *stream_digital_playback;
292 struct hda_pcm_stream *stream_digital_capture;
293
294 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200295 struct hda_multi_out multiout; /* playback set-up
296 * max_channels, dacs must be set
297 * dig_out_nid and hp_nid are optional
298 */
Takashi Iwai63300792008-01-24 15:31:36 +0100299 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100300 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100301 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302
303 /* capture */
304 unsigned int num_adc_nids;
305 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100306 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200307 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200308 int capture_style; /* capture style (CAPT_*) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309
310 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200311 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 const struct hda_input_mux *input_mux;
313 unsigned int cur_mux[3];
314
315 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100316 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200318 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200319 int const_channel_count;
320 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321
322 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100323 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200324
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200325 /* dynamic controls, init_verbs and input_mux */
326 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200327 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200328 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200329 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100330
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100331 /* hooks */
332 void (*init_hook)(struct hda_codec *codec);
333 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
334
Takashi Iwai834be882006-03-01 14:16:17 +0100335 /* for pin sensing */
336 unsigned int sense_updated: 1;
337 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100338 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200339
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100340 /* other flags */
341 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200342 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100343
Takashi Iwai2134ea42008-01-10 16:53:55 +0100344 /* for virtual master */
345 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200346#ifdef CONFIG_SND_HDA_POWER_SAVE
347 struct hda_loopback_check loopback;
348#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200349
350 /* for PLL fix */
351 hda_nid_t pll_nid;
352 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100353};
354
355/*
356 * configuration template - to be copied to the spec instance
357 */
358struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200359 struct snd_kcontrol_new *mixers[5]; /* should be identical size
360 * with spec
361 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100362 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100363 const struct hda_verb *init_verbs[5];
364 unsigned int num_dacs;
365 hda_nid_t *dac_nids;
366 hda_nid_t dig_out_nid; /* optional */
367 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800368 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100369 unsigned int num_adc_nids;
370 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100371 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100372 hda_nid_t dig_in_nid;
373 unsigned int num_channel_mode;
374 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200375 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200376 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200377 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100378 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100379 void (*unsol_event)(struct hda_codec *, unsigned int);
380 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200381#ifdef CONFIG_SND_HDA_POWER_SAVE
382 struct hda_amp_list *loopbacks;
383#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384};
385
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386
387/*
388 * input MUX handling
389 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200390static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
391 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392{
393 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
394 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200395 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
396 if (mux_idx >= spec->num_mux_defs)
397 mux_idx = 0;
398 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399}
400
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200401static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
402 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403{
404 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
405 struct alc_spec *spec = codec->spec;
406 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
407
408 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
409 return 0;
410}
411
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200412static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
413 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414{
415 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
416 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100417 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100419 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100420 hda_nid_t nid = spec->capsrc_nids ?
421 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422
Takashi Iwaicd896c32008-11-18 12:36:33 +0100423 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
424 imux = &spec->input_mux[mux_idx];
425
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200426 if (spec->capture_style &&
427 !(spec->capture_style == CAPT_1MUX_MIX && !adc_idx)) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100428 /* Matrix-mixer style (e.g. ALC882) */
429 unsigned int *cur_val = &spec->cur_mux[adc_idx];
430 unsigned int i, idx;
431
432 idx = ucontrol->value.enumerated.item[0];
433 if (idx >= imux->num_items)
434 idx = imux->num_items - 1;
435 if (*cur_val == idx)
436 return 0;
437 for (i = 0; i < imux->num_items; i++) {
438 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
439 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
440 imux->items[i].index,
441 HDA_AMP_MUTE, v);
442 }
443 *cur_val = idx;
444 return 1;
445 } else {
446 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100447 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100448 &spec->cur_mux[adc_idx]);
449 }
450}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200451
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452/*
453 * channel mode setting
454 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200455static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
456 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457{
458 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
459 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100460 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
461 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462}
463
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200464static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
465 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466{
467 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
468 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100469 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200470 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200471 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472}
473
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200474static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
475 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476{
477 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
478 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200479 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
480 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200481 &spec->ext_channel_count);
482 if (err >= 0 && !spec->const_channel_count) {
483 spec->multiout.max_channels = spec->ext_channel_count;
484 if (spec->need_dac_fix)
485 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
486 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200487 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488}
489
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100491 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200492 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100493 * being part of a format specifier. Maximum allowed length of a value is
494 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100495 *
496 * Note: some retasking pin complexes seem to ignore requests for input
497 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
498 * are requested. Therefore order this list so that this behaviour will not
499 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200500 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
501 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200502 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100503static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100504 "Mic 50pc bias", "Mic 80pc bias",
505 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100506};
507static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100508 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100509};
510/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200511 * in the pin being assumed to be exclusively an input or an output pin. In
512 * addition, "input" pins may or may not process the mic bias option
513 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
514 * accept requests for bias as of chip versions up to March 2006) and/or
515 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100516 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200517#define ALC_PIN_DIR_IN 0x00
518#define ALC_PIN_DIR_OUT 0x01
519#define ALC_PIN_DIR_INOUT 0x02
520#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
521#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100522
Kailang Yangea1fb292008-08-26 12:58:38 +0200523/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100524 * For each direction the minimum and maximum values are given.
525 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200526static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100527 { 0, 2 }, /* ALC_PIN_DIR_IN */
528 { 3, 4 }, /* ALC_PIN_DIR_OUT */
529 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200530 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
531 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100532};
533#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
534#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
535#define alc_pin_mode_n_items(_dir) \
536 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
537
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200538static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
539 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200540{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100541 unsigned int item_num = uinfo->value.enumerated.item;
542 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
543
544 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200545 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100546 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
547
548 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
549 item_num = alc_pin_mode_min(dir);
550 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200551 return 0;
552}
553
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200554static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
555 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200556{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100557 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200558 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
559 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100560 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200561 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200562 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
563 AC_VERB_GET_PIN_WIDGET_CONTROL,
564 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200565
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100566 /* Find enumerated value for current pinctl setting */
567 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200568 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100569 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200570 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100571 return 0;
572}
573
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200574static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
575 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100576{
577 signed int change;
578 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
579 hda_nid_t nid = kcontrol->private_value & 0xffff;
580 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
581 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200582 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
583 AC_VERB_GET_PIN_WIDGET_CONTROL,
584 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100585
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200586 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100587 val = alc_pin_mode_min(dir);
588
589 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100590 if (change) {
591 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200592 snd_hda_codec_write_cache(codec, nid, 0,
593 AC_VERB_SET_PIN_WIDGET_CONTROL,
594 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100595
Kailang Yangea1fb292008-08-26 12:58:38 +0200596 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100597 * for the requested pin mode. Enum values of 2 or less are
598 * input modes.
599 *
600 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200601 * reduces noise slightly (particularly on input) so we'll
602 * do it. However, having both input and output buffers
603 * enabled simultaneously doesn't seem to be problematic if
604 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100605 */
606 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200607 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
608 HDA_AMP_MUTE, HDA_AMP_MUTE);
609 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
610 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100611 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200612 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
613 HDA_AMP_MUTE, HDA_AMP_MUTE);
614 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
615 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100616 }
617 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200618 return change;
619}
620
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100621#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200622 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100623 .info = alc_pin_mode_info, \
624 .get = alc_pin_mode_get, \
625 .put = alc_pin_mode_put, \
626 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100627
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100628/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
629 * together using a mask with more than one bit set. This control is
630 * currently used only by the ALC260 test model. At this stage they are not
631 * needed for any "production" models.
632 */
633#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200634#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200635
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200636static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
637 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100638{
639 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
640 hda_nid_t nid = kcontrol->private_value & 0xffff;
641 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
642 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200643 unsigned int val = snd_hda_codec_read(codec, nid, 0,
644 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100645
646 *valp = (val & mask) != 0;
647 return 0;
648}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200649static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
650 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100651{
652 signed int change;
653 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
654 hda_nid_t nid = kcontrol->private_value & 0xffff;
655 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
656 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200657 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
658 AC_VERB_GET_GPIO_DATA,
659 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100660
661 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200662 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
663 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100664 gpio_data &= ~mask;
665 else
666 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200667 snd_hda_codec_write_cache(codec, nid, 0,
668 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100669
670 return change;
671}
672#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
673 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
674 .info = alc_gpio_data_info, \
675 .get = alc_gpio_data_get, \
676 .put = alc_gpio_data_put, \
677 .private_value = nid | (mask<<16) }
678#endif /* CONFIG_SND_DEBUG */
679
Jonathan Woithe92621f12006-02-28 11:47:47 +0100680/* A switch control to allow the enabling of the digital IO pins on the
681 * ALC260. This is incredibly simplistic; the intention of this control is
682 * to provide something in the test model allowing digital outputs to be
683 * identified if present. If models are found which can utilise these
684 * outputs a more complete mixer control can be devised for those models if
685 * necessary.
686 */
687#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200688#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200689
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200690static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
691 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100692{
693 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
694 hda_nid_t nid = kcontrol->private_value & 0xffff;
695 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
696 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200697 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100698 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100699
700 *valp = (val & mask) != 0;
701 return 0;
702}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200703static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
704 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100705{
706 signed int change;
707 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
708 hda_nid_t nid = kcontrol->private_value & 0xffff;
709 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
710 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200711 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100712 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200713 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100714
715 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200716 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100717 if (val==0)
718 ctrl_data &= ~mask;
719 else
720 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200721 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
722 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100723
724 return change;
725}
726#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
727 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
728 .info = alc_spdif_ctrl_info, \
729 .get = alc_spdif_ctrl_get, \
730 .put = alc_spdif_ctrl_put, \
731 .private_value = nid | (mask<<16) }
732#endif /* CONFIG_SND_DEBUG */
733
Jonathan Woithef8225f62008-01-08 12:16:54 +0100734/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
735 * Again, this is only used in the ALC26x test models to help identify when
736 * the EAPD line must be asserted for features to work.
737 */
738#ifdef CONFIG_SND_DEBUG
739#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
740
741static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
742 struct snd_ctl_elem_value *ucontrol)
743{
744 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
745 hda_nid_t nid = kcontrol->private_value & 0xffff;
746 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
747 long *valp = ucontrol->value.integer.value;
748 unsigned int val = snd_hda_codec_read(codec, nid, 0,
749 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
750
751 *valp = (val & mask) != 0;
752 return 0;
753}
754
755static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
756 struct snd_ctl_elem_value *ucontrol)
757{
758 int change;
759 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
760 hda_nid_t nid = kcontrol->private_value & 0xffff;
761 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
762 long val = *ucontrol->value.integer.value;
763 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
764 AC_VERB_GET_EAPD_BTLENABLE,
765 0x00);
766
767 /* Set/unset the masked control bit(s) as needed */
768 change = (!val ? 0 : mask) != (ctrl_data & mask);
769 if (!val)
770 ctrl_data &= ~mask;
771 else
772 ctrl_data |= mask;
773 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
774 ctrl_data);
775
776 return change;
777}
778
779#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
780 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
781 .info = alc_eapd_ctrl_info, \
782 .get = alc_eapd_ctrl_get, \
783 .put = alc_eapd_ctrl_put, \
784 .private_value = nid | (mask<<16) }
785#endif /* CONFIG_SND_DEBUG */
786
Kailang Yangdf694da2005-12-05 19:42:22 +0100787/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100788 * set up the input pin config (depending on the given auto-pin type)
789 */
790static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
791 int auto_pin_type)
792{
793 unsigned int val = PIN_IN;
794
795 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
796 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100797 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100798 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
799 if (pincap & AC_PINCAP_VREF_80)
800 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200801 else if (pincap & AC_PINCAP_VREF_50)
802 val = PIN_VREF50;
803 else if (pincap & AC_PINCAP_VREF_100)
804 val = PIN_VREF100;
805 else if (pincap & AC_PINCAP_VREF_GRD)
806 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100807 }
808 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
809}
810
811/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100812 */
813static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
814{
815 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
816 return;
817 spec->mixers[spec->num_mixers++] = mix;
818}
819
820static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
821{
822 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
823 return;
824 spec->init_verbs[spec->num_init_verbs++] = verb;
825}
826
Takashi Iwaidaead532008-11-28 12:55:36 +0100827#ifdef CONFIG_PROC_FS
828/*
829 * hook for proc
830 */
831static void print_realtek_coef(struct snd_info_buffer *buffer,
832 struct hda_codec *codec, hda_nid_t nid)
833{
834 int coeff;
835
836 if (nid != 0x20)
837 return;
838 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
839 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
840 coeff = snd_hda_codec_read(codec, nid, 0,
841 AC_VERB_GET_COEF_INDEX, 0);
842 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
843}
844#else
845#define print_realtek_coef NULL
846#endif
847
Takashi Iwaid88897e2008-10-31 15:01:37 +0100848/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100849 * set up from the preset table
850 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200851static void setup_preset(struct alc_spec *spec,
852 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100853{
854 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
893 spec->loopback.amplist = preset->loopbacks;
894#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100895}
896
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200897/* Enable GPIO mask and set output */
898static struct hda_verb alc_gpio1_init_verbs[] = {
899 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
900 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
901 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
902 { }
903};
904
905static struct hda_verb alc_gpio2_init_verbs[] = {
906 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
907 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
908 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
909 { }
910};
911
Kailang Yangbdd148a2007-05-08 15:19:08 +0200912static struct hda_verb alc_gpio3_init_verbs[] = {
913 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
914 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
915 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
916 { }
917};
918
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200919/*
920 * Fix hardware PLL issue
921 * On some codecs, the analog PLL gating control must be off while
922 * the default value is 1.
923 */
924static void alc_fix_pll(struct hda_codec *codec)
925{
926 struct alc_spec *spec = codec->spec;
927 unsigned int val;
928
929 if (!spec->pll_nid)
930 return;
931 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
932 spec->pll_coef_idx);
933 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
934 AC_VERB_GET_PROC_COEF, 0);
935 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
936 spec->pll_coef_idx);
937 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
938 val & ~(1 << spec->pll_coef_bit));
939}
940
941static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
942 unsigned int coef_idx, unsigned int coef_bit)
943{
944 struct alc_spec *spec = codec->spec;
945 spec->pll_nid = nid;
946 spec->pll_coef_idx = coef_idx;
947 spec->pll_coef_bit = coef_bit;
948 alc_fix_pll(codec);
949}
950
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200951static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200952{
953 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200954 unsigned int present;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200955 unsigned int nid = spec->autocfg.hp_pins[0];
956 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200957
958 /* need to execute and sync at first */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200959 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
960 present = snd_hda_codec_read(codec, nid, 0,
Kailang Yangc9b58002007-10-16 14:30:01 +0200961 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200962 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
963 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
964 nid = spec->autocfg.speaker_pins[i];
965 if (!nid)
966 break;
967 snd_hda_codec_write(codec, nid, 0,
968 AC_VERB_SET_PIN_WIDGET_CONTROL,
969 spec->jack_present ? 0 : PIN_OUT);
970 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200971}
972
Sasha Alexandrdef319f2009-06-16 16:00:15 -0400973#if 0 /* it's broken in some cases -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200974static void alc_mic_automute(struct hda_codec *codec)
975{
976 struct alc_spec *spec = codec->spec;
977 unsigned int present;
978 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
979 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
980 unsigned int mix_nid = spec->capsrc_nids[0];
981 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
982
983 capsrc_idx_mic = mic_nid - 0x18;
984 capsrc_idx_fmic = fmic_nid - 0x18;
985 present = snd_hda_codec_read(codec, mic_nid, 0,
986 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
987 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
988 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
989 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
990 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
991 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
992 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
993}
Takashi Iwai4605b712008-10-31 14:18:24 +0100994#else
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100995#define alc_mic_automute(codec) do {} while(0) /* NOP */
Takashi Iwai4605b712008-10-31 14:18:24 +0100996#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200997
Kailang Yangc9b58002007-10-16 14:30:01 +0200998/* unsolicited event for HP jack sensing */
999static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1000{
1001 if (codec->vendor_id == 0x10ec0880)
1002 res >>= 28;
1003 else
1004 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001005 switch (res) {
1006 case ALC880_HP_EVENT:
1007 alc_automute_pin(codec);
1008 break;
1009 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001010 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001011 break;
1012 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001013}
1014
1015static void alc_inithook(struct hda_codec *codec)
1016{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001017 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001018 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001019}
1020
Kailang Yangf9423e72008-05-27 12:32:25 +02001021/* additional initialization for ALC888 variants */
1022static void alc888_coef_init(struct hda_codec *codec)
1023{
1024 unsigned int tmp;
1025
1026 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1027 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1028 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001029 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001030 /* alc888S-VC */
1031 snd_hda_codec_read(codec, 0x20, 0,
1032 AC_VERB_SET_PROC_COEF, 0x830);
1033 else
1034 /* alc888-VB */
1035 snd_hda_codec_read(codec, 0x20, 0,
1036 AC_VERB_SET_PROC_COEF, 0x3030);
1037}
1038
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001039static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001040{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001041 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001042
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001043 switch (type) {
1044 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001045 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1046 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001047 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001048 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1049 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001050 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001051 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1052 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001053 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001054 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001055 case 0x10ec0260:
1056 snd_hda_codec_write(codec, 0x0f, 0,
1057 AC_VERB_SET_EAPD_BTLENABLE, 2);
1058 snd_hda_codec_write(codec, 0x10, 0,
1059 AC_VERB_SET_EAPD_BTLENABLE, 2);
1060 break;
1061 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001062 case 0x10ec0267:
1063 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001064 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001065 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001066 case 0x10ec0660:
1067 case 0x10ec0662:
1068 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001069 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001070 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001071 snd_hda_codec_write(codec, 0x14, 0,
1072 AC_VERB_SET_EAPD_BTLENABLE, 2);
1073 snd_hda_codec_write(codec, 0x15, 0,
1074 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001075 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001076 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001077 switch (codec->vendor_id) {
1078 case 0x10ec0260:
1079 snd_hda_codec_write(codec, 0x1a, 0,
1080 AC_VERB_SET_COEF_INDEX, 7);
1081 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1082 AC_VERB_GET_PROC_COEF, 0);
1083 snd_hda_codec_write(codec, 0x1a, 0,
1084 AC_VERB_SET_COEF_INDEX, 7);
1085 snd_hda_codec_write(codec, 0x1a, 0,
1086 AC_VERB_SET_PROC_COEF,
1087 tmp | 0x2010);
1088 break;
1089 case 0x10ec0262:
1090 case 0x10ec0880:
1091 case 0x10ec0882:
1092 case 0x10ec0883:
1093 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001094 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001095 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001096 snd_hda_codec_write(codec, 0x20, 0,
1097 AC_VERB_SET_COEF_INDEX, 7);
1098 tmp = snd_hda_codec_read(codec, 0x20, 0,
1099 AC_VERB_GET_PROC_COEF, 0);
1100 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001101 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001102 snd_hda_codec_write(codec, 0x20, 0,
1103 AC_VERB_SET_PROC_COEF,
1104 tmp | 0x2010);
1105 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001106 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001107 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001108 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001109 case 0x10ec0267:
1110 case 0x10ec0268:
1111 snd_hda_codec_write(codec, 0x20, 0,
1112 AC_VERB_SET_COEF_INDEX, 7);
1113 tmp = snd_hda_codec_read(codec, 0x20, 0,
1114 AC_VERB_GET_PROC_COEF, 0);
1115 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001116 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001117 snd_hda_codec_write(codec, 0x20, 0,
1118 AC_VERB_SET_PROC_COEF,
1119 tmp | 0x3000);
1120 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001121 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001122 break;
1123 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001124}
Kailang Yangea1fb292008-08-26 12:58:38 +02001125
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001126static void alc_init_auto_hp(struct hda_codec *codec)
1127{
1128 struct alc_spec *spec = codec->spec;
1129
1130 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001131 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001132
Kailang Yangc9b58002007-10-16 14:30:01 +02001133 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001134 if (spec->autocfg.line_out_pins[0] &&
1135 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001136 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001137 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001138 else
1139 return;
1140 }
1141
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001142 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1143 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001144 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1145 AC_VERB_SET_UNSOLICITED_ENABLE,
1146 AC_USRSP_EN | ALC880_HP_EVENT);
1147 spec->unsol_event = alc_sku_unsol_event;
1148}
1149
1150/* check subsystem ID and set up device-specific initialization;
1151 * return 1 if initialized, 0 if invalid SSID
1152 */
1153/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1154 * 31 ~ 16 : Manufacture ID
1155 * 15 ~ 8 : SKU ID
1156 * 7 ~ 0 : Assembly ID
1157 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1158 */
1159static int alc_subsystem_id(struct hda_codec *codec,
1160 hda_nid_t porta, hda_nid_t porte,
1161 hda_nid_t portd)
1162{
1163 unsigned int ass, tmp, i;
1164 unsigned nid;
1165 struct alc_spec *spec = codec->spec;
1166
1167 ass = codec->subsystem_id & 0xffff;
1168 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1169 goto do_sku;
1170
1171 /* invalid SSID, check the special NID pin defcfg instead */
1172 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001173 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001174 * 29~21 : reserve
1175 * 20 : PCBEEP input
1176 * 19~16 : Check sum (15:1)
1177 * 15~1 : Custom
1178 * 0 : override
1179 */
1180 nid = 0x1d;
1181 if (codec->vendor_id == 0x10ec0260)
1182 nid = 0x17;
1183 ass = snd_hda_codec_get_pincfg(codec, nid);
1184 snd_printd("realtek: No valid SSID, "
1185 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001186 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001187 if (!(ass & 1) && !(ass & 0x100000))
1188 return 0;
1189 if ((ass >> 30) != 1) /* no physical connection */
1190 return 0;
1191
1192 /* check sum */
1193 tmp = 0;
1194 for (i = 1; i < 16; i++) {
1195 if ((ass >> i) & 1)
1196 tmp++;
1197 }
1198 if (((ass >> 16) & 0xf) != tmp)
1199 return 0;
1200do_sku:
1201 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1202 ass & 0xffff, codec->vendor_id);
1203 /*
1204 * 0 : override
1205 * 1 : Swap Jack
1206 * 2 : 0 --> Desktop, 1 --> Laptop
1207 * 3~5 : External Amplifier control
1208 * 7~6 : Reserved
1209 */
1210 tmp = (ass & 0x38) >> 3; /* external Amp control */
1211 switch (tmp) {
1212 case 1:
1213 spec->init_amp = ALC_INIT_GPIO1;
1214 break;
1215 case 3:
1216 spec->init_amp = ALC_INIT_GPIO2;
1217 break;
1218 case 7:
1219 spec->init_amp = ALC_INIT_GPIO3;
1220 break;
1221 case 5:
1222 spec->init_amp = ALC_INIT_DEFAULT;
1223 break;
1224 }
1225
1226 /* is laptop or Desktop and enable the function "Mute internal speaker
1227 * when the external headphone out jack is plugged"
1228 */
1229 if (!(ass & 0x8000))
1230 return 1;
1231 /*
1232 * 10~8 : Jack location
1233 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1234 * 14~13: Resvered
1235 * 15 : 1 --> enable the function "Mute internal speaker
1236 * when the external headphone out jack is plugged"
1237 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001238 if (!spec->autocfg.hp_pins[0]) {
1239 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1240 if (tmp == 0)
1241 spec->autocfg.hp_pins[0] = porta;
1242 else if (tmp == 1)
1243 spec->autocfg.hp_pins[0] = porte;
1244 else if (tmp == 2)
1245 spec->autocfg.hp_pins[0] = portd;
1246 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001247 return 1;
Kailang Yangc9b58002007-10-16 14:30:01 +02001248 }
1249
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001250 alc_init_auto_hp(codec);
1251 return 1;
1252}
Kailang Yangea1fb292008-08-26 12:58:38 +02001253
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001254static void alc_ssid_check(struct hda_codec *codec,
1255 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1256{
1257 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1258 struct alc_spec *spec = codec->spec;
1259 snd_printd("realtek: "
1260 "Enable default setup for auto mode as fallback\n");
1261 spec->init_amp = ALC_INIT_DEFAULT;
1262 alc_init_auto_hp(codec);
1263 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001264}
1265
Takashi Iwai41e41f12005-06-08 14:48:49 +02001266/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001267 * Fix-up pin default configurations
1268 */
1269
1270struct alc_pincfg {
1271 hda_nid_t nid;
1272 u32 val;
1273};
1274
1275static void alc_fix_pincfg(struct hda_codec *codec,
1276 const struct snd_pci_quirk *quirk,
1277 const struct alc_pincfg **pinfix)
1278{
1279 const struct alc_pincfg *cfg;
1280
1281 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1282 if (!quirk)
1283 return;
1284
1285 cfg = pinfix[quirk->value];
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001286 for (; cfg->nid; cfg++)
1287 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001288}
1289
1290/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001291 * ALC888
1292 */
1293
1294/*
1295 * 2ch mode
1296 */
1297static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1298/* Mic-in jack as mic in */
1299 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1300 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1301/* Line-in jack as Line in */
1302 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1303 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1304/* Line-Out as Front */
1305 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1306 { } /* end */
1307};
1308
1309/*
1310 * 4ch mode
1311 */
1312static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1313/* Mic-in jack as mic in */
1314 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1315 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1316/* Line-in jack as Surround */
1317 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1318 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1319/* Line-Out as Front */
1320 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1321 { } /* end */
1322};
1323
1324/*
1325 * 6ch mode
1326 */
1327static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1328/* Mic-in jack as CLFE */
1329 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1330 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1331/* Line-in jack as Surround */
1332 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1333 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1334/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1335 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1336 { } /* end */
1337};
1338
1339/*
1340 * 8ch mode
1341 */
1342static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1343/* Mic-in jack as CLFE */
1344 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1345 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1346/* Line-in jack as Surround */
1347 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1348 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1349/* Line-Out as Side */
1350 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1351 { } /* end */
1352};
1353
1354static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1355 { 2, alc888_4ST_ch2_intel_init },
1356 { 4, alc888_4ST_ch4_intel_init },
1357 { 6, alc888_4ST_ch6_intel_init },
1358 { 8, alc888_4ST_ch8_intel_init },
1359};
1360
1361/*
1362 * ALC888 Fujitsu Siemens Amillo xa3530
1363 */
1364
1365static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1366/* Front Mic: set to PIN_IN (empty by default) */
1367 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1368/* Connect Internal HP to Front */
1369 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1370 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1371 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1372/* Connect Bass HP to Front */
1373 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1374 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1375 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1376/* Connect Line-Out side jack (SPDIF) to Side */
1377 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1378 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1379 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1380/* Connect Mic jack to CLFE */
1381 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1382 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1383 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1384/* Connect Line-in jack to Surround */
1385 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1386 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1387 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1388/* Connect HP out jack to Front */
1389 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1390 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1391 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1392/* Enable unsolicited event for HP jack and Line-out jack */
1393 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1394 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1395 {}
1396};
1397
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001398static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001399{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001400 struct alc_spec *spec = codec->spec;
1401 unsigned int val, mute;
1402 hda_nid_t nid;
1403 int i;
1404
1405 spec->jack_present = 0;
1406 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1407 nid = spec->autocfg.hp_pins[i];
1408 if (!nid)
1409 break;
1410 val = snd_hda_codec_read(codec, nid, 0,
1411 AC_VERB_GET_PIN_SENSE, 0);
1412 if (val & AC_PINSENSE_PRESENCE) {
1413 spec->jack_present = 1;
1414 break;
1415 }
1416 }
1417
1418 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001419 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001420 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1421 nid = spec->autocfg.speaker_pins[i];
1422 if (!nid)
1423 break;
1424 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1425 HDA_AMP_MUTE, mute);
1426 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001427}
1428
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001429static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1430 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001431{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001432 if (codec->vendor_id == 0x10ec0880)
1433 res >>= 28;
1434 else
1435 res >>= 26;
1436 if (res == ALC880_HP_EVENT)
1437 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001438}
1439
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001440static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec)
1441{
1442 struct alc_spec *spec = codec->spec;
1443
1444 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1445 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1446 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1447 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1448 alc_automute_amp(codec);
1449}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001450
1451/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001452 * ALC888 Acer Aspire 4930G model
1453 */
1454
1455static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1456/* Front Mic: set to PIN_IN (empty by default) */
1457 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1458/* Unselect Front Mic by default in input mixer 3 */
1459 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001460/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001461 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1462/* Connect Internal HP to front */
1463 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1464 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1465 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1466/* Connect HP out to front */
1467 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1468 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1469 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1470 { }
1471};
1472
Hector Martin3b315d72009-06-02 10:54:19 +02001473/*
Hector Martin018df412009-06-04 00:13:40 +02001474 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001475 */
1476
Hector Martin018df412009-06-04 00:13:40 +02001477static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001478/* Front Mic: set to PIN_IN (empty by default) */
1479 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1480/* Unselect Front Mic by default in input mixer 3 */
1481 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1482/* Enable unsolicited event for HP jack */
1483 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1484/* Connect Internal Front to Front */
1485 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1486 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1487 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1488/* Connect Internal Rear to Rear */
1489 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1490 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1491 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1492/* Connect Internal CLFE to CLFE */
1493 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1494 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1495 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1496/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001497 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001498 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1499 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1500/* Enable all DACs */
1501/* DAC DISABLE/MUTE 1? */
1502/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1503 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1504 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1505/* DAC DISABLE/MUTE 2? */
1506/* some bit here disables the other DACs. Init=0x4900 */
1507 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1508 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1509/* Enable amplifiers */
1510 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1511 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
Hector Martin018df412009-06-04 00:13:40 +02001512/* DMIC fix
1513 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1514 * which makes the stereo useless. However, either the mic or the ALC889
1515 * makes the signal become a difference/sum signal instead of standard
1516 * stereo, which is annoying. So instead we flip this bit which makes the
1517 * codec replicate the sum signal to both channels, turning it into a
1518 * normal mono mic.
1519 */
1520/* DMIC_CONTROL? Init value = 0x0001 */
1521 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1522 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001523 { }
1524};
1525
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001526static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001527 /* Front mic only available on one ADC */
1528 {
1529 .num_items = 4,
1530 .items = {
1531 { "Mic", 0x0 },
1532 { "Line", 0x2 },
1533 { "CD", 0x4 },
1534 { "Front Mic", 0xb },
1535 },
1536 },
1537 {
1538 .num_items = 3,
1539 .items = {
1540 { "Mic", 0x0 },
1541 { "Line", 0x2 },
1542 { "CD", 0x4 },
1543 },
1544 }
1545};
1546
Hector Martin018df412009-06-04 00:13:40 +02001547static struct hda_input_mux alc889_capture_sources[3] = {
1548 /* Digital mic only available on first "ADC" */
1549 {
1550 .num_items = 5,
1551 .items = {
1552 { "Mic", 0x0 },
1553 { "Line", 0x2 },
1554 { "CD", 0x4 },
1555 { "Front Mic", 0xb },
1556 { "Input Mix", 0xa },
1557 },
1558 },
1559 {
1560 .num_items = 4,
1561 .items = {
1562 { "Mic", 0x0 },
1563 { "Line", 0x2 },
1564 { "CD", 0x4 },
1565 { "Input Mix", 0xa },
1566 },
1567 },
1568 {
1569 .num_items = 4,
1570 .items = {
1571 { "Mic", 0x0 },
1572 { "Line", 0x2 },
1573 { "CD", 0x4 },
1574 { "Input Mix", 0xa },
1575 },
1576 }
1577};
1578
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001579static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001580 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1581 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1582 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1583 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1584 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1585 HDA_OUTPUT),
1586 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1587 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1588 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1589 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1590 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1591 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1592 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1593 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1594 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1595 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1596 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1597 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001598 { } /* end */
1599};
1600
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001601static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001602{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001603 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001604
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001605 spec->autocfg.hp_pins[0] = 0x15;
1606 spec->autocfg.speaker_pins[0] = 0x14;
1607 alc_automute_amp(codec);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001608}
1609
Hector Martin018df412009-06-04 00:13:40 +02001610static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001611{
1612 struct alc_spec *spec = codec->spec;
1613
1614 spec->autocfg.hp_pins[0] = 0x15;
1615 spec->autocfg.speaker_pins[0] = 0x14;
1616 spec->autocfg.speaker_pins[1] = 0x16;
1617 spec->autocfg.speaker_pins[2] = 0x1b;
1618 alc_automute_amp(codec);
1619}
1620
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001621/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001622 * ALC880 3-stack model
1623 *
1624 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001625 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1626 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001627 */
1628
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001629static hda_nid_t alc880_dac_nids[4] = {
1630 /* front, rear, clfe, rear_surr */
1631 0x02, 0x05, 0x04, 0x03
1632};
1633
1634static hda_nid_t alc880_adc_nids[3] = {
1635 /* ADC0-2 */
1636 0x07, 0x08, 0x09,
1637};
1638
1639/* The datasheet says the node 0x07 is connected from inputs,
1640 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001641 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001642 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001643static hda_nid_t alc880_adc_nids_alt[2] = {
1644 /* ADC1-2 */
1645 0x08, 0x09,
1646};
1647
1648#define ALC880_DIGOUT_NID 0x06
1649#define ALC880_DIGIN_NID 0x0a
1650
1651static struct hda_input_mux alc880_capture_source = {
1652 .num_items = 4,
1653 .items = {
1654 { "Mic", 0x0 },
1655 { "Front Mic", 0x3 },
1656 { "Line", 0x2 },
1657 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001658 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001659};
1660
1661/* channel source setting (2/6 channel selection for 3-stack) */
1662/* 2ch mode */
1663static struct hda_verb alc880_threestack_ch2_init[] = {
1664 /* set line-in to input, mute it */
1665 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1666 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1667 /* set mic-in to input vref 80%, mute it */
1668 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1669 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001670 { } /* end */
1671};
1672
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001673/* 6ch mode */
1674static struct hda_verb alc880_threestack_ch6_init[] = {
1675 /* set line-in to output, unmute it */
1676 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1677 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1678 /* set mic-in to output, unmute it */
1679 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1680 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1681 { } /* end */
1682};
1683
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001684static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001685 { 2, alc880_threestack_ch2_init },
1686 { 6, alc880_threestack_ch6_init },
1687};
1688
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001689static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001690 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001691 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001692 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001693 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001694 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1695 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001696 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1697 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001698 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1699 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1700 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1701 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1702 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1703 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1704 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1705 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001706 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001707 {
1708 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1709 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001710 .info = alc_ch_mode_info,
1711 .get = alc_ch_mode_get,
1712 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001713 },
1714 { } /* end */
1715};
1716
1717/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001718static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1719 struct snd_ctl_elem_info *uinfo)
1720{
1721 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1722 struct alc_spec *spec = codec->spec;
1723 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001724
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001725 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001726 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1727 HDA_INPUT);
1728 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001729 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001730 return err;
1731}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001732
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001733static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1734 unsigned int size, unsigned int __user *tlv)
1735{
1736 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1737 struct alc_spec *spec = codec->spec;
1738 int err;
1739
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001740 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001741 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1742 HDA_INPUT);
1743 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001744 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001745 return err;
1746}
1747
1748typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1749 struct snd_ctl_elem_value *ucontrol);
1750
1751static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1752 struct snd_ctl_elem_value *ucontrol,
1753 getput_call_t func)
1754{
1755 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1756 struct alc_spec *spec = codec->spec;
1757 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1758 int err;
1759
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001760 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001761 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1762 3, 0, HDA_INPUT);
1763 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001764 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001765 return err;
1766}
1767
1768static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1769 struct snd_ctl_elem_value *ucontrol)
1770{
1771 return alc_cap_getput_caller(kcontrol, ucontrol,
1772 snd_hda_mixer_amp_volume_get);
1773}
1774
1775static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1776 struct snd_ctl_elem_value *ucontrol)
1777{
1778 return alc_cap_getput_caller(kcontrol, ucontrol,
1779 snd_hda_mixer_amp_volume_put);
1780}
1781
1782/* capture mixer elements */
1783#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1784
1785static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1786 struct snd_ctl_elem_value *ucontrol)
1787{
1788 return alc_cap_getput_caller(kcontrol, ucontrol,
1789 snd_hda_mixer_amp_switch_get);
1790}
1791
1792static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1793 struct snd_ctl_elem_value *ucontrol)
1794{
1795 return alc_cap_getput_caller(kcontrol, ucontrol,
1796 snd_hda_mixer_amp_switch_put);
1797}
1798
Takashi Iwaia23b6882009-03-23 15:21:36 +01001799#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001800 { \
1801 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1802 .name = "Capture Switch", \
1803 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1804 .count = num, \
1805 .info = alc_cap_sw_info, \
1806 .get = alc_cap_sw_get, \
1807 .put = alc_cap_sw_put, \
1808 }, \
1809 { \
1810 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1811 .name = "Capture Volume", \
1812 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1813 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1814 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1815 .count = num, \
1816 .info = alc_cap_vol_info, \
1817 .get = alc_cap_vol_get, \
1818 .put = alc_cap_vol_put, \
1819 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001820 }
1821
1822#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001823 { \
1824 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1825 /* .name = "Capture Source", */ \
1826 .name = "Input Source", \
1827 .count = num, \
1828 .info = alc_mux_enum_info, \
1829 .get = alc_mux_enum_get, \
1830 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001831 }
1832
1833#define DEFINE_CAPMIX(num) \
1834static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1835 _DEFINE_CAPMIX(num), \
1836 _DEFINE_CAPSRC(num), \
1837 { } /* end */ \
1838}
1839
1840#define DEFINE_CAPMIX_NOSRC(num) \
1841static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1842 _DEFINE_CAPMIX(num), \
1843 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001844}
1845
1846/* up to three ADCs */
1847DEFINE_CAPMIX(1);
1848DEFINE_CAPMIX(2);
1849DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01001850DEFINE_CAPMIX_NOSRC(1);
1851DEFINE_CAPMIX_NOSRC(2);
1852DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001853
1854/*
1855 * ALC880 5-stack model
1856 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001857 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1858 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001859 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1860 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1861 */
1862
1863/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001864static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001865 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001866 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001867 { } /* end */
1868};
1869
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001870/* channel source setting (6/8 channel selection for 5-stack) */
1871/* 6ch mode */
1872static struct hda_verb alc880_fivestack_ch6_init[] = {
1873 /* set line-in to input, mute it */
1874 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1875 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001876 { } /* end */
1877};
1878
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001879/* 8ch mode */
1880static struct hda_verb alc880_fivestack_ch8_init[] = {
1881 /* set line-in to output, unmute it */
1882 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1883 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1884 { } /* end */
1885};
1886
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001887static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001888 { 6, alc880_fivestack_ch6_init },
1889 { 8, alc880_fivestack_ch8_init },
1890};
1891
1892
1893/*
1894 * ALC880 6-stack model
1895 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001896 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1897 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001898 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1899 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1900 */
1901
1902static hda_nid_t alc880_6st_dac_nids[4] = {
1903 /* front, rear, clfe, rear_surr */
1904 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001905};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001906
1907static struct hda_input_mux alc880_6stack_capture_source = {
1908 .num_items = 4,
1909 .items = {
1910 { "Mic", 0x0 },
1911 { "Front Mic", 0x1 },
1912 { "Line", 0x2 },
1913 { "CD", 0x4 },
1914 },
1915};
1916
1917/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001918static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001919 { 8, NULL },
1920};
1921
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001922static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001923 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001924 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001925 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001926 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001927 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1928 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001929 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1930 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001931 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001932 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001933 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1934 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1935 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1936 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1937 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1938 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1939 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1940 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001941 {
1942 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1943 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001944 .info = alc_ch_mode_info,
1945 .get = alc_ch_mode_get,
1946 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001947 },
1948 { } /* end */
1949};
1950
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001951
1952/*
1953 * ALC880 W810 model
1954 *
1955 * W810 has rear IO for:
1956 * Front (DAC 02)
1957 * Surround (DAC 03)
1958 * Center/LFE (DAC 04)
1959 * Digital out (06)
1960 *
1961 * The system also has a pair of internal speakers, and a headphone jack.
1962 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001963 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001964 * There is a variable resistor to control the speaker or headphone
1965 * volume. This is a hardware-only device without a software API.
1966 *
1967 * Plugging headphones in will disable the internal speakers. This is
1968 * implemented in hardware, not via the driver using jack sense. In
1969 * a similar fashion, plugging into the rear socket marked "front" will
1970 * disable both the speakers and headphones.
1971 *
1972 * For input, there's a microphone jack, and an "audio in" jack.
1973 * These may not do anything useful with this driver yet, because I
1974 * haven't setup any initialization verbs for these yet...
1975 */
1976
1977static hda_nid_t alc880_w810_dac_nids[3] = {
1978 /* front, rear/surround, clfe */
1979 0x02, 0x03, 0x04
1980};
1981
1982/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001983static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001984 { 6, NULL }
1985};
1986
1987/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001988static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001989 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001990 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001991 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001992 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001993 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1994 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001995 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1996 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001997 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1998 { } /* end */
1999};
2000
2001
2002/*
2003 * Z710V model
2004 *
2005 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002006 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2007 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002008 */
2009
2010static hda_nid_t alc880_z71v_dac_nids[1] = {
2011 0x02
2012};
2013#define ALC880_Z71V_HP_DAC 0x03
2014
2015/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002016static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002017 { 2, NULL }
2018};
2019
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002020static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002021 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002022 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002023 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002024 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002025 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2026 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2027 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2028 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2029 { } /* end */
2030};
2031
2032
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002033/*
2034 * ALC880 F1734 model
2035 *
2036 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2037 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2038 */
2039
2040static hda_nid_t alc880_f1734_dac_nids[1] = {
2041 0x03
2042};
2043#define ALC880_F1734_HP_DAC 0x02
2044
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002045static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002046 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002047 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002048 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2049 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002050 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2051 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002052 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2053 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002054 { } /* end */
2055};
2056
Takashi Iwai937b4162008-02-11 14:52:36 +01002057static struct hda_input_mux alc880_f1734_capture_source = {
2058 .num_items = 2,
2059 .items = {
2060 { "Mic", 0x1 },
2061 { "CD", 0x4 },
2062 },
2063};
2064
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002065
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002066/*
2067 * ALC880 ASUS model
2068 *
2069 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2070 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2071 * Mic = 0x18, Line = 0x1a
2072 */
2073
2074#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2075#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2076
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002077static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002078 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002079 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002080 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002081 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002082 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2083 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002084 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2085 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002086 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2087 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2088 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2089 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2090 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2091 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002092 {
2093 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2094 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002095 .info = alc_ch_mode_info,
2096 .get = alc_ch_mode_get,
2097 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002098 },
2099 { } /* end */
2100};
2101
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002102/*
2103 * ALC880 ASUS W1V model
2104 *
2105 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2106 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2107 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2108 */
2109
2110/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002111static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002112 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2113 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002114 { } /* end */
2115};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002116
Kailang Yangdf694da2005-12-05 19:42:22 +01002117/* TCL S700 */
2118static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2119 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2120 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2121 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2122 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2123 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2124 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2125 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2126 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2127 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002128 { } /* end */
2129};
2130
Kailang Yangccc656c2006-10-17 12:32:26 +02002131/* Uniwill */
2132static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002133 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2134 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2135 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2136 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +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),
2139 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),
2141 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2142 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2143 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2144 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2145 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2146 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2147 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2148 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002149 {
2150 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2151 .name = "Channel Mode",
2152 .info = alc_ch_mode_info,
2153 .get = alc_ch_mode_get,
2154 .put = alc_ch_mode_put,
2155 },
2156 { } /* end */
2157};
2158
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002159static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2160 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2161 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2162 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2163 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2164 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2165 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2166 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2167 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2168 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2169 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2170 { } /* end */
2171};
2172
Kailang Yangccc656c2006-10-17 12:32:26 +02002173static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002174 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2175 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2176 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2177 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002178 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2179 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2180 { } /* end */
2181};
2182
Linus Torvalds1da177e2005-04-16 15:20:36 -07002183/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002184 * virtual master controls
2185 */
2186
2187/*
2188 * slave controls for virtual master
2189 */
2190static const char *alc_slave_vols[] = {
2191 "Front Playback Volume",
2192 "Surround Playback Volume",
2193 "Center Playback Volume",
2194 "LFE Playback Volume",
2195 "Side Playback Volume",
2196 "Headphone Playback Volume",
2197 "Speaker Playback Volume",
2198 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002199 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002200 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002201 NULL,
2202};
2203
2204static const char *alc_slave_sws[] = {
2205 "Front Playback Switch",
2206 "Surround Playback Switch",
2207 "Center Playback Switch",
2208 "LFE Playback Switch",
2209 "Side Playback Switch",
2210 "Headphone Playback Switch",
2211 "Speaker Playback Switch",
2212 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002213 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002214 NULL,
2215};
2216
2217/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002218 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002219 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002220
2221static void alc_free_kctls(struct hda_codec *codec);
2222
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002223/* additional beep mixers; the actual parameters are overwritten at build */
2224static struct snd_kcontrol_new alc_beep_mixer[] = {
2225 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2226 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2227 { } /* end */
2228};
2229
Linus Torvalds1da177e2005-04-16 15:20:36 -07002230static int alc_build_controls(struct hda_codec *codec)
2231{
2232 struct alc_spec *spec = codec->spec;
2233 int err;
2234 int i;
2235
2236 for (i = 0; i < spec->num_mixers; i++) {
2237 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2238 if (err < 0)
2239 return err;
2240 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002241 if (spec->cap_mixer) {
2242 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2243 if (err < 0)
2244 return err;
2245 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002246 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002247 err = snd_hda_create_spdif_out_ctls(codec,
2248 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002249 if (err < 0)
2250 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002251 if (!spec->no_analog) {
2252 err = snd_hda_create_spdif_share_sw(codec,
2253 &spec->multiout);
2254 if (err < 0)
2255 return err;
2256 spec->multiout.share_spdif = 1;
2257 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002258 }
2259 if (spec->dig_in_nid) {
2260 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2261 if (err < 0)
2262 return err;
2263 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002264
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002265 /* create beep controls if needed */
2266 if (spec->beep_amp) {
2267 struct snd_kcontrol_new *knew;
2268 for (knew = alc_beep_mixer; knew->name; knew++) {
2269 struct snd_kcontrol *kctl;
2270 kctl = snd_ctl_new1(knew, codec);
2271 if (!kctl)
2272 return -ENOMEM;
2273 kctl->private_value = spec->beep_amp;
2274 err = snd_hda_ctl_add(codec, kctl);
2275 if (err < 0)
2276 return err;
2277 }
2278 }
2279
Takashi Iwai2134ea42008-01-10 16:53:55 +01002280 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002281 if (!spec->no_analog &&
2282 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002283 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002284 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002285 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002286 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002287 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002288 if (err < 0)
2289 return err;
2290 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002291 if (!spec->no_analog &&
2292 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002293 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2294 NULL, alc_slave_sws);
2295 if (err < 0)
2296 return err;
2297 }
2298
Takashi Iwai603c4012008-07-30 15:01:44 +02002299 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002300 return 0;
2301}
2302
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002303
Linus Torvalds1da177e2005-04-16 15:20:36 -07002304/*
2305 * initialize the codec volumes, etc
2306 */
2307
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002308/*
2309 * generic initialization of ADC, input mixers and output mixers
2310 */
2311static struct hda_verb alc880_volume_init_verbs[] = {
2312 /*
2313 * Unmute ADC0-2 and set the default input to mic-in
2314 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002315 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002316 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002317 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002318 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002319 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002320 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002321
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002322 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2323 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002324 * Note: PASD motherboards uses the Line In 2 as the input for front
2325 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002326 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002327 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002328 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2329 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2330 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2331 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2332 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2333 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2334 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002335
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002336 /*
2337 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002338 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002339 /* set vol=0 to output mixers */
2340 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2341 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2342 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2343 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2344 /* set up input amps for analog loopback */
2345 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002346 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2347 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002348 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2349 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002350 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2351 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002352 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2353 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002354
2355 { }
2356};
2357
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002358/*
2359 * 3-stack pin configuration:
2360 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2361 */
2362static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2363 /*
2364 * preset connection lists of input pins
2365 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2366 */
2367 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2368 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2369 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2370
2371 /*
2372 * Set pin mode and muting
2373 */
2374 /* set front pin widgets 0x14 for output */
2375 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2376 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2377 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2378 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2379 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2380 /* Mic2 (as headphone out) for HP output */
2381 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2382 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2383 /* Line In pin widget for input */
2384 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2385 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2386 /* Line2 (as front mic) pin widget for input and vref at 80% */
2387 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2388 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2389 /* CD pin widget for input */
2390 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2391
2392 { }
2393};
2394
2395/*
2396 * 5-stack pin configuration:
2397 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2398 * line-in/side = 0x1a, f-mic = 0x1b
2399 */
2400static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2401 /*
2402 * preset connection lists of input pins
2403 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2404 */
2405 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2406 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2407
2408 /*
2409 * Set pin mode and muting
2410 */
2411 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002412 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2413 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2414 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2415 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002416 /* unmute pins for output (no gain on this amp) */
2417 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2418 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2419 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2420 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2421
Linus Torvalds1da177e2005-04-16 15:20:36 -07002422 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002423 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002424 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2425 /* Mic2 (as headphone out) for HP output */
2426 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002427 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002428 /* Line In pin widget for input */
2429 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2430 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2431 /* Line2 (as front mic) pin widget for input and vref at 80% */
2432 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2433 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2434 /* CD pin widget for input */
2435 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002436
2437 { }
2438};
2439
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002440/*
2441 * W810 pin configuration:
2442 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2443 */
2444static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002445 /* hphone/speaker input selector: front DAC */
2446 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2447
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002448 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2449 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2450 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2451 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2452 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2453 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2454
2455 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002456 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002457
Linus Torvalds1da177e2005-04-16 15:20:36 -07002458 { }
2459};
2460
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002461/*
2462 * Z71V pin configuration:
2463 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2464 */
2465static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002466 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002467 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002468 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002469 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002470
Takashi Iwai16ded522005-06-10 19:58:24 +02002471 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002472 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002473 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002474 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002475
2476 { }
2477};
2478
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002479/*
2480 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002481 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2482 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002483 */
2484static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2485 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2486
Takashi Iwai16ded522005-06-10 19:58:24 +02002487 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002488 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002489 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002490 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002491 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002492 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002493 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002494 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2495
Takashi Iwai16ded522005-06-10 19:58:24 +02002496 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002497 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002498 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002499 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002500 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002501 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002502 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002503 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002504 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002505
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002506 { }
2507};
Takashi Iwai16ded522005-06-10 19:58:24 +02002508
Kailang Yangccc656c2006-10-17 12:32:26 +02002509/*
2510 * Uniwill pin configuration:
2511 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2512 * line = 0x1a
2513 */
2514static struct hda_verb alc880_uniwill_init_verbs[] = {
2515 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2516
2517 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2518 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2519 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2520 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2521 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2522 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2523 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2524 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2525 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2526 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2527 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2528 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2529 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2530 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2531
2532 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2533 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2534 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2535 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2536 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2537 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2538 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2539 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2540 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2541
2542 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2543 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2544
2545 { }
2546};
2547
2548/*
2549* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002550* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002551 */
2552static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2553 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2554
2555 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2556 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2557 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2558 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2559 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2560 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2561 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2562 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2563 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2564 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2565 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2566 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2567
2568 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2569 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2570 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2571 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2572 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2573 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2574
2575 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2576 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2577
2578 { }
2579};
2580
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002581static struct hda_verb alc880_beep_init_verbs[] = {
2582 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2583 { }
2584};
2585
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002586/* auto-toggle front mic */
2587static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2588{
2589 unsigned int present;
2590 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002591
2592 present = snd_hda_codec_read(codec, 0x18, 0,
2593 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002594 bits = present ? HDA_AMP_MUTE : 0;
2595 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002596}
2597
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002598static void alc880_uniwill_init_hook(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002599{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002600 struct alc_spec *spec = codec->spec;
2601
2602 spec->autocfg.hp_pins[0] = 0x14;
2603 spec->autocfg.speaker_pins[0] = 0x15;
2604 spec->autocfg.speaker_pins[0] = 0x16;
2605 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002606 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002607}
2608
2609static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2610 unsigned int res)
2611{
2612 /* Looks like the unsol event is incompatible with the standard
2613 * definition. 4bit tag is placed at 28 bit!
2614 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002615 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002616 case ALC880_MIC_EVENT:
2617 alc880_uniwill_mic_automute(codec);
2618 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002619 default:
2620 alc_automute_amp_unsol_event(codec, res);
2621 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002622 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002623}
2624
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002625static void alc880_uniwill_p53_init_hook(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002626{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002627 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002628
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002629 spec->autocfg.hp_pins[0] = 0x14;
2630 spec->autocfg.speaker_pins[0] = 0x15;
2631 alc_automute_amp(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002632}
2633
2634static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2635{
2636 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002637
Kailang Yangccc656c2006-10-17 12:32:26 +02002638 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002639 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2640 present &= HDA_AMP_VOLMASK;
2641 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2642 HDA_AMP_VOLMASK, present);
2643 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2644 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002645}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002646
Kailang Yangccc656c2006-10-17 12:32:26 +02002647static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2648 unsigned int res)
2649{
2650 /* Looks like the unsol event is incompatible with the standard
2651 * definition. 4bit tag is placed at 28 bit!
2652 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002653 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002654 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002655 else
2656 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002657}
2658
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002659/*
2660 * F1734 pin configuration:
2661 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2662 */
2663static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002664 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002665 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2666 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2667 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2668 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2669
2670 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2671 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2672 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2673 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2674
2675 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2676 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002677 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002678 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2679 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2680 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2681 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2682 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2683 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002684
Takashi Iwai937b4162008-02-11 14:52:36 +01002685 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2686 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2687
Takashi Iwai16ded522005-06-10 19:58:24 +02002688 { }
2689};
2690
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002691/*
2692 * ASUS pin configuration:
2693 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2694 */
2695static struct hda_verb alc880_pin_asus_init_verbs[] = {
2696 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2697 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2698 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2699 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2700
2701 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2702 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2703 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2704 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2705 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2706 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2707 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2708 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2709
2710 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2711 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2712 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2713 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2714 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2715 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2716 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2717 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2718 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002719
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002720 { }
2721};
2722
2723/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002724#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2725#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02002726#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002727
Kailang Yangdf694da2005-12-05 19:42:22 +01002728/* Clevo m520g init */
2729static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2730 /* headphone output */
2731 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2732 /* line-out */
2733 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2734 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2735 /* Line-in */
2736 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2737 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2738 /* CD */
2739 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2740 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2741 /* Mic1 (rear panel) */
2742 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2743 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2744 /* Mic2 (front panel) */
2745 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2746 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2747 /* headphone */
2748 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2749 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2750 /* change to EAPD mode */
2751 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2752 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2753
2754 { }
2755};
2756
2757static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002758 /* change to EAPD mode */
2759 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2760 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2761
Kailang Yangdf694da2005-12-05 19:42:22 +01002762 /* Headphone output */
2763 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2764 /* Front output*/
2765 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2766 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2767
2768 /* Line In pin widget for input */
2769 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2770 /* CD pin widget for input */
2771 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2772 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2773 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2774
2775 /* change to EAPD mode */
2776 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2777 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2778
2779 { }
2780};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002781
2782/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002783 * LG m1 express dual
2784 *
2785 * Pin assignment:
2786 * Rear Line-In/Out (blue): 0x14
2787 * Build-in Mic-In: 0x15
2788 * Speaker-out: 0x17
2789 * HP-Out (green): 0x1b
2790 * Mic-In/Out (red): 0x19
2791 * SPDIF-Out: 0x1e
2792 */
2793
2794/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2795static hda_nid_t alc880_lg_dac_nids[3] = {
2796 0x05, 0x02, 0x03
2797};
2798
2799/* seems analog CD is not working */
2800static struct hda_input_mux alc880_lg_capture_source = {
2801 .num_items = 3,
2802 .items = {
2803 { "Mic", 0x1 },
2804 { "Line", 0x5 },
2805 { "Internal Mic", 0x6 },
2806 },
2807};
2808
2809/* 2,4,6 channel modes */
2810static struct hda_verb alc880_lg_ch2_init[] = {
2811 /* set line-in and mic-in to input */
2812 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2813 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2814 { }
2815};
2816
2817static struct hda_verb alc880_lg_ch4_init[] = {
2818 /* set line-in to out and mic-in to input */
2819 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2820 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2821 { }
2822};
2823
2824static struct hda_verb alc880_lg_ch6_init[] = {
2825 /* set line-in and mic-in to output */
2826 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2827 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2828 { }
2829};
2830
2831static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2832 { 2, alc880_lg_ch2_init },
2833 { 4, alc880_lg_ch4_init },
2834 { 6, alc880_lg_ch6_init },
2835};
2836
2837static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002838 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2839 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002840 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2841 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2842 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2843 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2844 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2845 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2846 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2847 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2848 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2849 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2850 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2851 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2852 {
2853 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2854 .name = "Channel Mode",
2855 .info = alc_ch_mode_info,
2856 .get = alc_ch_mode_get,
2857 .put = alc_ch_mode_put,
2858 },
2859 { } /* end */
2860};
2861
2862static struct hda_verb alc880_lg_init_verbs[] = {
2863 /* set capture source to mic-in */
2864 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2865 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2866 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2867 /* mute all amp mixer inputs */
2868 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002869 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2870 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002871 /* line-in to input */
2872 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2873 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2874 /* built-in mic */
2875 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2876 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2877 /* speaker-out */
2878 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2879 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2880 /* mic-in to input */
2881 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2882 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2883 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2884 /* HP-out */
2885 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2886 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2887 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2888 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002889 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002890 { }
2891};
2892
2893/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002894static void alc880_lg_init_hook(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002895{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002896 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002897
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002898 spec->autocfg.hp_pins[0] = 0x1b;
2899 spec->autocfg.speaker_pins[0] = 0x17;
2900 alc_automute_amp(codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002901}
2902
2903/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002904 * LG LW20
2905 *
2906 * Pin assignment:
2907 * Speaker-out: 0x14
2908 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002909 * Built-in Mic-In: 0x19
2910 * Line-In: 0x1b
2911 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002912 * SPDIF-Out: 0x1e
2913 */
2914
Takashi Iwaid6815182006-03-23 16:06:23 +01002915static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002916 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002917 .items = {
2918 { "Mic", 0x0 },
2919 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002920 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002921 },
2922};
2923
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002924#define alc880_lg_lw_modes alc880_threestack_modes
2925
Takashi Iwaid6815182006-03-23 16:06:23 +01002926static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002927 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2928 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2929 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2930 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2931 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2932 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2933 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2934 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2935 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2936 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002937 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2938 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2939 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2940 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002941 {
2942 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2943 .name = "Channel Mode",
2944 .info = alc_ch_mode_info,
2945 .get = alc_ch_mode_get,
2946 .put = alc_ch_mode_put,
2947 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002948 { } /* end */
2949};
2950
2951static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002952 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2953 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2954 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2955
Takashi Iwaid6815182006-03-23 16:06:23 +01002956 /* set capture source to mic-in */
2957 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2958 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2959 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002960 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002961 /* speaker-out */
2962 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2963 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2964 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002965 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2966 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2967 /* mic-in to input */
2968 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2969 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2970 /* built-in mic */
2971 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2972 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2973 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002974 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01002975 { }
2976};
2977
2978/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002979static void alc880_lg_lw_init_hook(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01002980{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002981 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01002982
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002983 spec->autocfg.hp_pins[0] = 0x1b;
2984 spec->autocfg.speaker_pins[0] = 0x14;
2985 alc_automute_amp(codec);
Takashi Iwaid6815182006-03-23 16:06:23 +01002986}
2987
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002988static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2989 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2990 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2991 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2992 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2993 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2994 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2995 { } /* end */
2996};
2997
2998static struct hda_input_mux alc880_medion_rim_capture_source = {
2999 .num_items = 2,
3000 .items = {
3001 { "Mic", 0x0 },
3002 { "Internal Mic", 0x1 },
3003 },
3004};
3005
3006static struct hda_verb alc880_medion_rim_init_verbs[] = {
3007 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3008
3009 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3010 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3011
3012 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3013 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3014 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3015 /* Mic2 (as headphone out) for HP output */
3016 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3017 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3018 /* Internal Speaker */
3019 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3020 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3021
3022 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3023 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3024
3025 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3026 { }
3027};
3028
3029/* toggle speaker-output according to the hp-jack state */
3030static void alc880_medion_rim_automute(struct hda_codec *codec)
3031{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003032 struct alc_spec *spec = codec->spec;
3033 alc_automute_amp(codec);
3034 /* toggle EAPD */
3035 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003036 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3037 else
3038 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3039}
3040
3041static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3042 unsigned int res)
3043{
3044 /* Looks like the unsol event is incompatible with the standard
3045 * definition. 4bit tag is placed at 28 bit!
3046 */
3047 if ((res >> 28) == ALC880_HP_EVENT)
3048 alc880_medion_rim_automute(codec);
3049}
3050
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003051static void alc880_medion_rim_init_hook(struct hda_codec *codec)
3052{
3053 struct alc_spec *spec = codec->spec;
3054
3055 spec->autocfg.hp_pins[0] = 0x14;
3056 spec->autocfg.speaker_pins[0] = 0x1b;
3057 alc880_medion_rim_automute(codec);
3058}
3059
Takashi Iwaicb53c622007-08-10 17:21:45 +02003060#ifdef CONFIG_SND_HDA_POWER_SAVE
3061static struct hda_amp_list alc880_loopbacks[] = {
3062 { 0x0b, HDA_INPUT, 0 },
3063 { 0x0b, HDA_INPUT, 1 },
3064 { 0x0b, HDA_INPUT, 2 },
3065 { 0x0b, HDA_INPUT, 3 },
3066 { 0x0b, HDA_INPUT, 4 },
3067 { } /* end */
3068};
3069
3070static struct hda_amp_list alc880_lg_loopbacks[] = {
3071 { 0x0b, HDA_INPUT, 1 },
3072 { 0x0b, HDA_INPUT, 6 },
3073 { 0x0b, HDA_INPUT, 7 },
3074 { } /* end */
3075};
3076#endif
3077
Takashi Iwaid6815182006-03-23 16:06:23 +01003078/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003079 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003080 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003081
Linus Torvalds1da177e2005-04-16 15:20:36 -07003082static int alc_init(struct hda_codec *codec)
3083{
3084 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003085 unsigned int i;
3086
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003087 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003088 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003089
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003090 for (i = 0; i < spec->num_init_verbs; i++)
3091 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003092
3093 if (spec->init_hook)
3094 spec->init_hook(codec);
3095
Linus Torvalds1da177e2005-04-16 15:20:36 -07003096 return 0;
3097}
3098
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003099static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3100{
3101 struct alc_spec *spec = codec->spec;
3102
3103 if (spec->unsol_event)
3104 spec->unsol_event(codec, res);
3105}
3106
Takashi Iwaicb53c622007-08-10 17:21:45 +02003107#ifdef CONFIG_SND_HDA_POWER_SAVE
3108static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3109{
3110 struct alc_spec *spec = codec->spec;
3111 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3112}
3113#endif
3114
Linus Torvalds1da177e2005-04-16 15:20:36 -07003115/*
3116 * Analog playback callbacks
3117 */
3118static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3119 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003120 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003121{
3122 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003123 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3124 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003125}
3126
3127static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3128 struct hda_codec *codec,
3129 unsigned int stream_tag,
3130 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003131 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003132{
3133 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003134 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3135 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003136}
3137
3138static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3139 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003140 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003141{
3142 struct alc_spec *spec = codec->spec;
3143 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3144}
3145
3146/*
3147 * Digital out
3148 */
3149static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3150 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003151 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003152{
3153 struct alc_spec *spec = codec->spec;
3154 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3155}
3156
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003157static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3158 struct hda_codec *codec,
3159 unsigned int stream_tag,
3160 unsigned int format,
3161 struct snd_pcm_substream *substream)
3162{
3163 struct alc_spec *spec = codec->spec;
3164 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3165 stream_tag, format, substream);
3166}
3167
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003168static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3169 struct hda_codec *codec,
3170 struct snd_pcm_substream *substream)
3171{
3172 struct alc_spec *spec = codec->spec;
3173 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3174}
3175
Linus Torvalds1da177e2005-04-16 15:20:36 -07003176static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3177 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003178 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003179{
3180 struct alc_spec *spec = codec->spec;
3181 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3182}
3183
3184/*
3185 * Analog capture
3186 */
Takashi Iwai63300792008-01-24 15:31:36 +01003187static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003188 struct hda_codec *codec,
3189 unsigned int stream_tag,
3190 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003191 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003192{
3193 struct alc_spec *spec = codec->spec;
3194
Takashi Iwai63300792008-01-24 15:31:36 +01003195 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003196 stream_tag, 0, format);
3197 return 0;
3198}
3199
Takashi Iwai63300792008-01-24 15:31:36 +01003200static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003201 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003202 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003203{
3204 struct alc_spec *spec = codec->spec;
3205
Takashi Iwai888afa12008-03-18 09:57:50 +01003206 snd_hda_codec_cleanup_stream(codec,
3207 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003208 return 0;
3209}
3210
3211
3212/*
3213 */
3214static struct hda_pcm_stream alc880_pcm_analog_playback = {
3215 .substreams = 1,
3216 .channels_min = 2,
3217 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003218 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003219 .ops = {
3220 .open = alc880_playback_pcm_open,
3221 .prepare = alc880_playback_pcm_prepare,
3222 .cleanup = alc880_playback_pcm_cleanup
3223 },
3224};
3225
3226static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003227 .substreams = 1,
3228 .channels_min = 2,
3229 .channels_max = 2,
3230 /* NID is set in alc_build_pcms */
3231};
3232
3233static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3234 .substreams = 1,
3235 .channels_min = 2,
3236 .channels_max = 2,
3237 /* NID is set in alc_build_pcms */
3238};
3239
3240static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3241 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003242 .channels_min = 2,
3243 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003244 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003245 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003246 .prepare = alc880_alt_capture_pcm_prepare,
3247 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003248 },
3249};
3250
3251static struct hda_pcm_stream alc880_pcm_digital_playback = {
3252 .substreams = 1,
3253 .channels_min = 2,
3254 .channels_max = 2,
3255 /* NID is set in alc_build_pcms */
3256 .ops = {
3257 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003258 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003259 .prepare = alc880_dig_playback_pcm_prepare,
3260 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003261 },
3262};
3263
3264static struct hda_pcm_stream alc880_pcm_digital_capture = {
3265 .substreams = 1,
3266 .channels_min = 2,
3267 .channels_max = 2,
3268 /* NID is set in alc_build_pcms */
3269};
3270
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003271/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003272static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003273 .substreams = 0,
3274 .channels_min = 0,
3275 .channels_max = 0,
3276};
3277
Linus Torvalds1da177e2005-04-16 15:20:36 -07003278static int alc_build_pcms(struct hda_codec *codec)
3279{
3280 struct alc_spec *spec = codec->spec;
3281 struct hda_pcm *info = spec->pcm_rec;
3282 int i;
3283
3284 codec->num_pcms = 1;
3285 codec->pcm_info = info;
3286
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003287 if (spec->no_analog)
3288 goto skip_analog;
3289
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003290 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3291 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003292 info->name = spec->stream_name_analog;
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003293
Takashi Iwai4a471b72005-12-07 13:56:29 +01003294 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003295 if (snd_BUG_ON(!spec->multiout.dac_nids))
3296 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003297 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3298 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3299 }
3300 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003301 if (snd_BUG_ON(!spec->adc_nids))
3302 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003303 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3304 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3305 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003306
Takashi Iwai4a471b72005-12-07 13:56:29 +01003307 if (spec->channel_mode) {
3308 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3309 for (i = 0; i < spec->num_channel_mode; i++) {
3310 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3311 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3312 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003313 }
3314 }
3315
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003316 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003317 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003318 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003319 snprintf(spec->stream_name_digital,
3320 sizeof(spec->stream_name_digital),
3321 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003322 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003323 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003324 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003325 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003326 if (spec->dig_out_type)
3327 info->pcm_type = spec->dig_out_type;
3328 else
3329 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003330 if (spec->multiout.dig_out_nid &&
3331 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003332 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3333 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3334 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003335 if (spec->dig_in_nid &&
3336 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003337 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3338 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3339 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003340 /* FIXME: do we need this for all Realtek codec models? */
3341 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003342 }
3343
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003344 if (spec->no_analog)
3345 return 0;
3346
Takashi Iwaie08a0072006-09-07 17:52:14 +02003347 /* If the use of more than one ADC is requested for the current
3348 * model, configure a second analog capture-only PCM.
3349 */
3350 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003351 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3352 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003353 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003354 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003355 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003356 if (spec->alt_dac_nid) {
3357 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3358 *spec->stream_analog_alt_playback;
3359 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3360 spec->alt_dac_nid;
3361 } else {
3362 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3363 alc_pcm_null_stream;
3364 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3365 }
3366 if (spec->num_adc_nids > 1) {
3367 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3368 *spec->stream_analog_alt_capture;
3369 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3370 spec->adc_nids[1];
3371 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3372 spec->num_adc_nids - 1;
3373 } else {
3374 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3375 alc_pcm_null_stream;
3376 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003377 }
3378 }
3379
Linus Torvalds1da177e2005-04-16 15:20:36 -07003380 return 0;
3381}
3382
Takashi Iwai603c4012008-07-30 15:01:44 +02003383static void alc_free_kctls(struct hda_codec *codec)
3384{
3385 struct alc_spec *spec = codec->spec;
3386
3387 if (spec->kctls.list) {
3388 struct snd_kcontrol_new *kctl = spec->kctls.list;
3389 int i;
3390 for (i = 0; i < spec->kctls.used; i++)
3391 kfree(kctl[i].name);
3392 }
3393 snd_array_free(&spec->kctls);
3394}
3395
Linus Torvalds1da177e2005-04-16 15:20:36 -07003396static void alc_free(struct hda_codec *codec)
3397{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003398 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003399
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003400 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003401 return;
3402
Takashi Iwai603c4012008-07-30 15:01:44 +02003403 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003404 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003405 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003406}
3407
Takashi Iwaie044c392008-10-27 16:56:24 +01003408#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003409static int alc_resume(struct hda_codec *codec)
3410{
Takashi Iwaie044c392008-10-27 16:56:24 +01003411 codec->patch_ops.init(codec);
3412 snd_hda_codec_resume_amp(codec);
3413 snd_hda_codec_resume_cache(codec);
3414 return 0;
3415}
Takashi Iwaie044c392008-10-27 16:56:24 +01003416#endif
3417
Linus Torvalds1da177e2005-04-16 15:20:36 -07003418/*
3419 */
3420static struct hda_codec_ops alc_patch_ops = {
3421 .build_controls = alc_build_controls,
3422 .build_pcms = alc_build_pcms,
3423 .init = alc_init,
3424 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003425 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003426#ifdef SND_HDA_NEEDS_RESUME
3427 .resume = alc_resume,
3428#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003429#ifdef CONFIG_SND_HDA_POWER_SAVE
3430 .check_power_status = alc_check_power_status,
3431#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003432};
3433
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003434
3435/*
3436 * Test configuration for debugging
3437 *
3438 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3439 * enum controls.
3440 */
3441#ifdef CONFIG_SND_DEBUG
3442static hda_nid_t alc880_test_dac_nids[4] = {
3443 0x02, 0x03, 0x04, 0x05
3444};
3445
3446static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003447 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003448 .items = {
3449 { "In-1", 0x0 },
3450 { "In-2", 0x1 },
3451 { "In-3", 0x2 },
3452 { "In-4", 0x3 },
3453 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003454 { "Front", 0x5 },
3455 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003456 },
3457};
3458
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003459static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003460 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003461 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003462 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003463 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003464};
3465
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003466static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3467 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003468{
3469 static char *texts[] = {
3470 "N/A", "Line Out", "HP Out",
3471 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3472 };
3473 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3474 uinfo->count = 1;
3475 uinfo->value.enumerated.items = 8;
3476 if (uinfo->value.enumerated.item >= 8)
3477 uinfo->value.enumerated.item = 7;
3478 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3479 return 0;
3480}
3481
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003482static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3483 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003484{
3485 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3486 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3487 unsigned int pin_ctl, item = 0;
3488
3489 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3490 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3491 if (pin_ctl & AC_PINCTL_OUT_EN) {
3492 if (pin_ctl & AC_PINCTL_HP_EN)
3493 item = 2;
3494 else
3495 item = 1;
3496 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3497 switch (pin_ctl & AC_PINCTL_VREFEN) {
3498 case AC_PINCTL_VREF_HIZ: item = 3; break;
3499 case AC_PINCTL_VREF_50: item = 4; break;
3500 case AC_PINCTL_VREF_GRD: item = 5; break;
3501 case AC_PINCTL_VREF_80: item = 6; break;
3502 case AC_PINCTL_VREF_100: item = 7; break;
3503 }
3504 }
3505 ucontrol->value.enumerated.item[0] = item;
3506 return 0;
3507}
3508
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003509static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3510 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003511{
3512 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3513 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3514 static unsigned int ctls[] = {
3515 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3516 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3517 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3518 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3519 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3520 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3521 };
3522 unsigned int old_ctl, new_ctl;
3523
3524 old_ctl = snd_hda_codec_read(codec, nid, 0,
3525 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3526 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3527 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003528 int val;
3529 snd_hda_codec_write_cache(codec, nid, 0,
3530 AC_VERB_SET_PIN_WIDGET_CONTROL,
3531 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003532 val = ucontrol->value.enumerated.item[0] >= 3 ?
3533 HDA_AMP_MUTE : 0;
3534 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3535 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003536 return 1;
3537 }
3538 return 0;
3539}
3540
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003541static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3542 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003543{
3544 static char *texts[] = {
3545 "Front", "Surround", "CLFE", "Side"
3546 };
3547 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3548 uinfo->count = 1;
3549 uinfo->value.enumerated.items = 4;
3550 if (uinfo->value.enumerated.item >= 4)
3551 uinfo->value.enumerated.item = 3;
3552 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3553 return 0;
3554}
3555
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003556static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3557 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003558{
3559 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3560 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3561 unsigned int sel;
3562
3563 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3564 ucontrol->value.enumerated.item[0] = sel & 3;
3565 return 0;
3566}
3567
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003568static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3569 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003570{
3571 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3572 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3573 unsigned int sel;
3574
3575 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3576 if (ucontrol->value.enumerated.item[0] != sel) {
3577 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003578 snd_hda_codec_write_cache(codec, nid, 0,
3579 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003580 return 1;
3581 }
3582 return 0;
3583}
3584
3585#define PIN_CTL_TEST(xname,nid) { \
3586 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3587 .name = xname, \
3588 .info = alc_test_pin_ctl_info, \
3589 .get = alc_test_pin_ctl_get, \
3590 .put = alc_test_pin_ctl_put, \
3591 .private_value = nid \
3592 }
3593
3594#define PIN_SRC_TEST(xname,nid) { \
3595 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3596 .name = xname, \
3597 .info = alc_test_pin_src_info, \
3598 .get = alc_test_pin_src_get, \
3599 .put = alc_test_pin_src_put, \
3600 .private_value = nid \
3601 }
3602
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003603static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003604 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3605 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3606 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3607 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003608 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3609 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3610 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3611 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003612 PIN_CTL_TEST("Front Pin Mode", 0x14),
3613 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3614 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3615 PIN_CTL_TEST("Side Pin Mode", 0x17),
3616 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3617 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3618 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3619 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3620 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3621 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3622 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3623 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3624 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3625 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3626 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3627 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3628 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3629 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3630 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3631 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3632 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3633 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003634 {
3635 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3636 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003637 .info = alc_ch_mode_info,
3638 .get = alc_ch_mode_get,
3639 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003640 },
3641 { } /* end */
3642};
3643
3644static struct hda_verb alc880_test_init_verbs[] = {
3645 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003646 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3647 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3648 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3649 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3650 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3651 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3652 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3653 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003654 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003655 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3656 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3657 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3658 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003659 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003660 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3661 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3662 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3663 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003664 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003665 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3666 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3667 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3668 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003669 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003670 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3671 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003672 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3673 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3674 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003675 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003676 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3677 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3678 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3679 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003680 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003681 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003682 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003683 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003684 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003685 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003686 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003687 /* Analog input/passthru */
3688 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3689 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3690 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3691 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3692 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003693 { }
3694};
3695#endif
3696
Linus Torvalds1da177e2005-04-16 15:20:36 -07003697/*
3698 */
3699
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003700static const char *alc880_models[ALC880_MODEL_LAST] = {
3701 [ALC880_3ST] = "3stack",
3702 [ALC880_TCL_S700] = "tcl",
3703 [ALC880_3ST_DIG] = "3stack-digout",
3704 [ALC880_CLEVO] = "clevo",
3705 [ALC880_5ST] = "5stack",
3706 [ALC880_5ST_DIG] = "5stack-digout",
3707 [ALC880_W810] = "w810",
3708 [ALC880_Z71V] = "z71v",
3709 [ALC880_6ST] = "6stack",
3710 [ALC880_6ST_DIG] = "6stack-digout",
3711 [ALC880_ASUS] = "asus",
3712 [ALC880_ASUS_W1V] = "asus-w1v",
3713 [ALC880_ASUS_DIG] = "asus-dig",
3714 [ALC880_ASUS_DIG2] = "asus-dig2",
3715 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003716 [ALC880_UNIWILL_P53] = "uniwill-p53",
3717 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003718 [ALC880_F1734] = "F1734",
3719 [ALC880_LG] = "lg",
3720 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003721 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003722#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003723 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003724#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003725 [ALC880_AUTO] = "auto",
3726};
3727
3728static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003729 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003730 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3731 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3732 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3733 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3734 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3735 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3736 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3737 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003738 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3739 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003740 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3741 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3742 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3743 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3744 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3745 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3746 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3747 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3748 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3749 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003750 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003751 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3752 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3753 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003754 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003755 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003756 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3757 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003758 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3759 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003760 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3761 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3762 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3763 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003764 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3765 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003766 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003767 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003768 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003769 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003770 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3771 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003772 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003773 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003774 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003775 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003776 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003777 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003778 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003779 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003780 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003781 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3782 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003783 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003784 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3785 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3786 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3787 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003788 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3789 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003790 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003791 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003792 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3793 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003794 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3795 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3796 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003797 /* default Intel */
3798 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003799 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3800 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003801 {}
3802};
3803
Takashi Iwai16ded522005-06-10 19:58:24 +02003804/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003805 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003806 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003807static struct alc_config_preset alc880_presets[] = {
3808 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003809 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003810 .init_verbs = { alc880_volume_init_verbs,
3811 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003812 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003813 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003814 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3815 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003816 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003817 .input_mux = &alc880_capture_source,
3818 },
3819 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003820 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003821 .init_verbs = { alc880_volume_init_verbs,
3822 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003823 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003824 .dac_nids = alc880_dac_nids,
3825 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003826 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3827 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003828 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003829 .input_mux = &alc880_capture_source,
3830 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003831 [ALC880_TCL_S700] = {
3832 .mixers = { alc880_tcl_s700_mixer },
3833 .init_verbs = { alc880_volume_init_verbs,
3834 alc880_pin_tcl_S700_init_verbs,
3835 alc880_gpio2_init_verbs },
3836 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3837 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003838 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3839 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003840 .hp_nid = 0x03,
3841 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3842 .channel_mode = alc880_2_jack_modes,
3843 .input_mux = &alc880_capture_source,
3844 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003845 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003846 .mixers = { alc880_three_stack_mixer,
3847 alc880_five_stack_mixer},
3848 .init_verbs = { alc880_volume_init_verbs,
3849 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003850 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3851 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003852 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3853 .channel_mode = alc880_fivestack_modes,
3854 .input_mux = &alc880_capture_source,
3855 },
3856 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003857 .mixers = { alc880_three_stack_mixer,
3858 alc880_five_stack_mixer },
3859 .init_verbs = { alc880_volume_init_verbs,
3860 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003861 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3862 .dac_nids = alc880_dac_nids,
3863 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003864 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3865 .channel_mode = alc880_fivestack_modes,
3866 .input_mux = &alc880_capture_source,
3867 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003868 [ALC880_6ST] = {
3869 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003870 .init_verbs = { alc880_volume_init_verbs,
3871 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003872 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3873 .dac_nids = alc880_6st_dac_nids,
3874 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3875 .channel_mode = alc880_sixstack_modes,
3876 .input_mux = &alc880_6stack_capture_source,
3877 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003878 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003879 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003880 .init_verbs = { alc880_volume_init_verbs,
3881 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003882 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3883 .dac_nids = alc880_6st_dac_nids,
3884 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003885 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3886 .channel_mode = alc880_sixstack_modes,
3887 .input_mux = &alc880_6stack_capture_source,
3888 },
3889 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003890 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003891 .init_verbs = { alc880_volume_init_verbs,
3892 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003893 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003894 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3895 .dac_nids = alc880_w810_dac_nids,
3896 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003897 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3898 .channel_mode = alc880_w810_modes,
3899 .input_mux = &alc880_capture_source,
3900 },
3901 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003902 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003903 .init_verbs = { alc880_volume_init_verbs,
3904 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003905 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3906 .dac_nids = alc880_z71v_dac_nids,
3907 .dig_out_nid = ALC880_DIGOUT_NID,
3908 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003909 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3910 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003911 .input_mux = &alc880_capture_source,
3912 },
3913 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003914 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003915 .init_verbs = { alc880_volume_init_verbs,
3916 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003917 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3918 .dac_nids = alc880_f1734_dac_nids,
3919 .hp_nid = 0x02,
3920 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3921 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003922 .input_mux = &alc880_f1734_capture_source,
3923 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003924 .init_hook = alc880_uniwill_p53_init_hook,
Takashi Iwai16ded522005-06-10 19:58:24 +02003925 },
3926 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003927 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003928 .init_verbs = { alc880_volume_init_verbs,
3929 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003930 alc880_gpio1_init_verbs },
3931 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3932 .dac_nids = alc880_asus_dac_nids,
3933 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3934 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003935 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003936 .input_mux = &alc880_capture_source,
3937 },
3938 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003939 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003940 .init_verbs = { alc880_volume_init_verbs,
3941 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003942 alc880_gpio1_init_verbs },
3943 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3944 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003945 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003946 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3947 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003948 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003949 .input_mux = &alc880_capture_source,
3950 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003951 [ALC880_ASUS_DIG2] = {
3952 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003953 .init_verbs = { alc880_volume_init_verbs,
3954 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003955 alc880_gpio2_init_verbs }, /* use GPIO2 */
3956 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3957 .dac_nids = alc880_asus_dac_nids,
3958 .dig_out_nid = ALC880_DIGOUT_NID,
3959 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3960 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003961 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003962 .input_mux = &alc880_capture_source,
3963 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003964 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003965 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003966 .init_verbs = { alc880_volume_init_verbs,
3967 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003968 alc880_gpio1_init_verbs },
3969 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3970 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003971 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003972 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3973 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003974 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003975 .input_mux = &alc880_capture_source,
3976 },
3977 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003978 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003979 .init_verbs = { alc880_volume_init_verbs,
3980 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003981 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3982 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003983 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003984 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3985 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003986 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003987 .input_mux = &alc880_capture_source,
3988 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003989 [ALC880_UNIWILL] = {
3990 .mixers = { alc880_uniwill_mixer },
3991 .init_verbs = { alc880_volume_init_verbs,
3992 alc880_uniwill_init_verbs },
3993 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3994 .dac_nids = alc880_asus_dac_nids,
3995 .dig_out_nid = ALC880_DIGOUT_NID,
3996 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3997 .channel_mode = alc880_threestack_modes,
3998 .need_dac_fix = 1,
3999 .input_mux = &alc880_capture_source,
4000 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004001 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004002 },
4003 [ALC880_UNIWILL_P53] = {
4004 .mixers = { alc880_uniwill_p53_mixer },
4005 .init_verbs = { alc880_volume_init_verbs,
4006 alc880_uniwill_p53_init_verbs },
4007 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4008 .dac_nids = alc880_asus_dac_nids,
4009 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004010 .channel_mode = alc880_threestack_modes,
4011 .input_mux = &alc880_capture_source,
4012 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004013 .init_hook = alc880_uniwill_p53_init_hook,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004014 },
4015 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004016 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004017 .init_verbs = { alc880_volume_init_verbs,
4018 alc880_uniwill_p53_init_verbs,
4019 alc880_beep_init_verbs },
4020 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4021 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004022 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004023 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4024 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004025 .input_mux = &alc880_capture_source,
4026 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004027 .init_hook = alc880_uniwill_p53_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004028 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004029 [ALC880_CLEVO] = {
4030 .mixers = { alc880_three_stack_mixer },
4031 .init_verbs = { alc880_volume_init_verbs,
4032 alc880_pin_clevo_init_verbs },
4033 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4034 .dac_nids = alc880_dac_nids,
4035 .hp_nid = 0x03,
4036 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4037 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004038 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004039 .input_mux = &alc880_capture_source,
4040 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004041 [ALC880_LG] = {
4042 .mixers = { alc880_lg_mixer },
4043 .init_verbs = { alc880_volume_init_verbs,
4044 alc880_lg_init_verbs },
4045 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4046 .dac_nids = alc880_lg_dac_nids,
4047 .dig_out_nid = ALC880_DIGOUT_NID,
4048 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4049 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004050 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004051 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004052 .unsol_event = alc_automute_amp_unsol_event,
4053 .init_hook = alc880_lg_init_hook,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004054#ifdef CONFIG_SND_HDA_POWER_SAVE
4055 .loopbacks = alc880_lg_loopbacks,
4056#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004057 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004058 [ALC880_LG_LW] = {
4059 .mixers = { alc880_lg_lw_mixer },
4060 .init_verbs = { alc880_volume_init_verbs,
4061 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004062 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004063 .dac_nids = alc880_dac_nids,
4064 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004065 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4066 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004067 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004068 .unsol_event = alc_automute_amp_unsol_event,
4069 .init_hook = alc880_lg_lw_init_hook,
Takashi Iwaid6815182006-03-23 16:06:23 +01004070 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004071 [ALC880_MEDION_RIM] = {
4072 .mixers = { alc880_medion_rim_mixer },
4073 .init_verbs = { alc880_volume_init_verbs,
4074 alc880_medion_rim_init_verbs,
4075 alc_gpio2_init_verbs },
4076 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4077 .dac_nids = alc880_dac_nids,
4078 .dig_out_nid = ALC880_DIGOUT_NID,
4079 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4080 .channel_mode = alc880_2_jack_modes,
4081 .input_mux = &alc880_medion_rim_capture_source,
4082 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004083 .init_hook = alc880_medion_rim_init_hook,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004084 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004085#ifdef CONFIG_SND_DEBUG
4086 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004087 .mixers = { alc880_test_mixer },
4088 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004089 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4090 .dac_nids = alc880_test_dac_nids,
4091 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004092 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4093 .channel_mode = alc880_test_modes,
4094 .input_mux = &alc880_test_capture_source,
4095 },
4096#endif
4097};
4098
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004099/*
4100 * Automatic parse of I/O pins from the BIOS configuration
4101 */
4102
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004103enum {
4104 ALC_CTL_WIDGET_VOL,
4105 ALC_CTL_WIDGET_MUTE,
4106 ALC_CTL_BIND_MUTE,
4107};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004108static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004109 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4110 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004111 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004112};
4113
4114/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004115static int add_control(struct alc_spec *spec, int type, const char *name,
4116 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004117{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004118 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004119
Takashi Iwai603c4012008-07-30 15:01:44 +02004120 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4121 knew = snd_array_new(&spec->kctls);
4122 if (!knew)
4123 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004124 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004125 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004126 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004127 return -ENOMEM;
4128 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004129 return 0;
4130}
4131
4132#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4133#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4134#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4135#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4136#define alc880_is_input_pin(nid) ((nid) >= 0x18)
4137#define alc880_input_pin_idx(nid) ((nid) - 0x18)
4138#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4139#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4140#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4141#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4142#define ALC880_PIN_CD_NID 0x1c
4143
4144/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004145static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4146 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004147{
4148 hda_nid_t nid;
4149 int assigned[4];
4150 int i, j;
4151
4152 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004153 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004154
4155 /* check the pins hardwired to audio widget */
4156 for (i = 0; i < cfg->line_outs; i++) {
4157 nid = cfg->line_out_pins[i];
4158 if (alc880_is_fixed_pin(nid)) {
4159 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004160 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004161 assigned[idx] = 1;
4162 }
4163 }
4164 /* left pins can be connect to any audio widget */
4165 for (i = 0; i < cfg->line_outs; i++) {
4166 nid = cfg->line_out_pins[i];
4167 if (alc880_is_fixed_pin(nid))
4168 continue;
4169 /* search for an empty channel */
4170 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004171 if (!assigned[j]) {
4172 spec->multiout.dac_nids[i] =
4173 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004174 assigned[j] = 1;
4175 break;
4176 }
4177 }
4178 }
4179 spec->multiout.num_dacs = cfg->line_outs;
4180 return 0;
4181}
4182
4183/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004184static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4185 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004186{
4187 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004188 static const char *chname[4] = {
4189 "Front", "Surround", NULL /*CLFE*/, "Side"
4190 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004191 hda_nid_t nid;
4192 int i, err;
4193
4194 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004195 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004196 continue;
4197 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4198 if (i == 2) {
4199 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004200 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4201 "Center Playback Volume",
4202 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4203 HDA_OUTPUT));
4204 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004205 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004206 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4207 "LFE Playback Volume",
4208 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4209 HDA_OUTPUT));
4210 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004211 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004212 err = add_control(spec, ALC_CTL_BIND_MUTE,
4213 "Center Playback Switch",
4214 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4215 HDA_INPUT));
4216 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004217 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004218 err = add_control(spec, ALC_CTL_BIND_MUTE,
4219 "LFE Playback Switch",
4220 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4221 HDA_INPUT));
4222 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004223 return err;
4224 } else {
4225 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004226 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4227 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4228 HDA_OUTPUT));
4229 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004230 return err;
4231 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004232 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4233 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4234 HDA_INPUT));
4235 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004236 return err;
4237 }
4238 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004239 return 0;
4240}
4241
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004242/* add playback controls for speaker and HP outputs */
4243static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4244 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004245{
4246 hda_nid_t nid;
4247 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004248 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004249
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004250 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004251 return 0;
4252
4253 if (alc880_is_fixed_pin(pin)) {
4254 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004255 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004256 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004257 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004258 else
4259 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004260 /* control HP volume/switch on the output mixer amp */
4261 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004262 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004263 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4264 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4265 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004266 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004267 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004268 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4269 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4270 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004271 return err;
4272 } else if (alc880_is_multi_pin(pin)) {
4273 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004274 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004275 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004276 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4277 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4278 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004279 return err;
4280 }
4281 return 0;
4282}
4283
4284/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004285static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4286 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004287 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004288{
4289 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004290 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004291
4292 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004293 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4294 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4295 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004296 return err;
4297 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004298 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4299 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4300 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004301 return err;
4302 return 0;
4303}
4304
4305/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004306static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4307 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004308{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004309 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004310 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004311
4312 for (i = 0; i < AUTO_PIN_LAST; i++) {
4313 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004314 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004315 err = new_analog_input(spec, cfg->input_pins[i],
4316 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004317 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004318 if (err < 0)
4319 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004320 imux->items[imux->num_items].label =
4321 auto_pin_cfg_labels[i];
4322 imux->items[imux->num_items].index =
4323 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004324 imux->num_items++;
4325 }
4326 }
4327 return 0;
4328}
4329
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004330static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4331 unsigned int pin_type)
4332{
4333 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4334 pin_type);
4335 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004336 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4337 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004338}
4339
Kailang Yangdf694da2005-12-05 19:42:22 +01004340static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4341 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004342 int dac_idx)
4343{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004344 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004345 /* need the manual connection? */
4346 if (alc880_is_multi_pin(nid)) {
4347 struct alc_spec *spec = codec->spec;
4348 int idx = alc880_multi_pin_idx(nid);
4349 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4350 AC_VERB_SET_CONNECT_SEL,
4351 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4352 }
4353}
4354
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004355static int get_pin_type(int line_out_type)
4356{
4357 if (line_out_type == AUTO_PIN_HP_OUT)
4358 return PIN_HP;
4359 else
4360 return PIN_OUT;
4361}
4362
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004363static void alc880_auto_init_multi_out(struct hda_codec *codec)
4364{
4365 struct alc_spec *spec = codec->spec;
4366 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004367
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004368 for (i = 0; i < spec->autocfg.line_outs; i++) {
4369 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004370 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4371 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004372 }
4373}
4374
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004375static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004376{
4377 struct alc_spec *spec = codec->spec;
4378 hda_nid_t pin;
4379
Takashi Iwai82bc9552006-03-21 11:24:42 +01004380 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004381 if (pin) /* connect to front */
4382 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004383 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004384 if (pin) /* connect to front */
4385 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4386}
4387
4388static void alc880_auto_init_analog_input(struct hda_codec *codec)
4389{
4390 struct alc_spec *spec = codec->spec;
4391 int i;
4392
4393 for (i = 0; i < AUTO_PIN_LAST; i++) {
4394 hda_nid_t nid = spec->autocfg.input_pins[i];
4395 if (alc880_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004396 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004397 if (nid != ALC880_PIN_CD_NID &&
4398 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004399 snd_hda_codec_write(codec, nid, 0,
4400 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004401 AMP_OUT_MUTE);
4402 }
4403 }
4404}
4405
4406/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004407/* return 1 if successful, 0 if the proper config is not found,
4408 * or a negative error code
4409 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004410static int alc880_parse_auto_config(struct hda_codec *codec)
4411{
4412 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004413 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004414 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004415
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004416 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4417 alc880_ignore);
4418 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004419 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004420 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004421 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004422
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004423 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4424 if (err < 0)
4425 return err;
4426 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4427 if (err < 0)
4428 return err;
4429 err = alc880_auto_create_extra_out(spec,
4430 spec->autocfg.speaker_pins[0],
4431 "Speaker");
4432 if (err < 0)
4433 return err;
4434 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4435 "Headphone");
4436 if (err < 0)
4437 return err;
4438 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4439 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004440 return err;
4441
4442 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4443
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004444 /* check multiple SPDIF-out (for recent codecs) */
4445 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4446 hda_nid_t dig_nid;
4447 err = snd_hda_get_connections(codec,
4448 spec->autocfg.dig_out_pins[i],
4449 &dig_nid, 1);
4450 if (err < 0)
4451 continue;
4452 if (!i)
4453 spec->multiout.dig_out_nid = dig_nid;
4454 else {
4455 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4456 spec->slave_dig_outs[i - 1] = dig_nid;
4457 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4458 break;
4459 }
4460 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004461 if (spec->autocfg.dig_in_pin)
4462 spec->dig_in_nid = ALC880_DIGIN_NID;
4463
Takashi Iwai603c4012008-07-30 15:01:44 +02004464 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004465 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004466
Takashi Iwaid88897e2008-10-31 15:01:37 +01004467 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004468
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004469 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004470 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004471
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004472 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4473
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004474 return 1;
4475}
4476
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004477/* additional initialization for auto-configuration model */
4478static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004479{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004480 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004481 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004482 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004483 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004484 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004485 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004486}
4487
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004488static void set_capture_mixer(struct alc_spec *spec)
4489{
Takashi Iwaia23b6882009-03-23 15:21:36 +01004490 static struct snd_kcontrol_new *caps[2][3] = {
4491 { alc_capture_mixer_nosrc1,
4492 alc_capture_mixer_nosrc2,
4493 alc_capture_mixer_nosrc3 },
4494 { alc_capture_mixer1,
4495 alc_capture_mixer2,
4496 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004497 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004498 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4499 int mux;
4500 if (spec->input_mux && spec->input_mux->num_items > 1)
4501 mux = 1;
4502 else
4503 mux = 0;
4504 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4505 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004506}
4507
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004508#define set_beep_amp(spec, nid, idx, dir) \
4509 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4510
4511/*
4512 * OK, here we have finally the patch for ALC880
4513 */
4514
Linus Torvalds1da177e2005-04-16 15:20:36 -07004515static int patch_alc880(struct hda_codec *codec)
4516{
4517 struct alc_spec *spec;
4518 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004519 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004520
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004521 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004522 if (spec == NULL)
4523 return -ENOMEM;
4524
4525 codec->spec = spec;
4526
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004527 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4528 alc880_models,
4529 alc880_cfg_tbl);
4530 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +02004531 printk(KERN_INFO "hda_codec: Unknown model for %s, "
4532 "trying auto-probe from BIOS...\n", codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004533 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004534 }
4535
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004536 if (board_config == ALC880_AUTO) {
4537 /* automatic parse from the BIOS config */
4538 err = alc880_parse_auto_config(codec);
4539 if (err < 0) {
4540 alc_free(codec);
4541 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004542 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004543 printk(KERN_INFO
4544 "hda_codec: Cannot set up configuration "
4545 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004546 board_config = ALC880_3ST;
4547 }
4548 }
4549
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004550 err = snd_hda_attach_beep_device(codec, 0x1);
4551 if (err < 0) {
4552 alc_free(codec);
4553 return err;
4554 }
4555
Kailang Yangdf694da2005-12-05 19:42:22 +01004556 if (board_config != ALC880_AUTO)
4557 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004558
Linus Torvalds1da177e2005-04-16 15:20:36 -07004559 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4560 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004561 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004562
Linus Torvalds1da177e2005-04-16 15:20:36 -07004563 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4564 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4565
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004566 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004567 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004568 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004569 /* get type */
4570 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004571 if (wcap != AC_WID_AUD_IN) {
4572 spec->adc_nids = alc880_adc_nids_alt;
4573 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004574 } else {
4575 spec->adc_nids = alc880_adc_nids;
4576 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004577 }
4578 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004579 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004580 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004581
Takashi Iwai2134ea42008-01-10 16:53:55 +01004582 spec->vmaster_nid = 0x0c;
4583
Linus Torvalds1da177e2005-04-16 15:20:36 -07004584 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004585 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004586 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004587#ifdef CONFIG_SND_HDA_POWER_SAVE
4588 if (!spec->loopback.amplist)
4589 spec->loopback.amplist = alc880_loopbacks;
4590#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004591 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004592
4593 return 0;
4594}
4595
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004596
Linus Torvalds1da177e2005-04-16 15:20:36 -07004597/*
4598 * ALC260 support
4599 */
4600
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004601static hda_nid_t alc260_dac_nids[1] = {
4602 /* front */
4603 0x02,
4604};
4605
4606static hda_nid_t alc260_adc_nids[1] = {
4607 /* ADC0 */
4608 0x04,
4609};
4610
Kailang Yangdf694da2005-12-05 19:42:22 +01004611static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004612 /* ADC1 */
4613 0x05,
4614};
4615
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004616/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4617 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4618 */
4619static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004620 /* ADC0, ADC1 */
4621 0x04, 0x05
4622};
4623
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004624#define ALC260_DIGOUT_NID 0x03
4625#define ALC260_DIGIN_NID 0x06
4626
4627static struct hda_input_mux alc260_capture_source = {
4628 .num_items = 4,
4629 .items = {
4630 { "Mic", 0x0 },
4631 { "Front Mic", 0x1 },
4632 { "Line", 0x2 },
4633 { "CD", 0x4 },
4634 },
4635};
4636
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004637/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004638 * headphone jack and the internal CD lines since these are the only pins at
4639 * which audio can appear. For flexibility, also allow the option of
4640 * recording the mixer output on the second ADC (ADC0 doesn't have a
4641 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004642 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004643static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4644 {
4645 .num_items = 3,
4646 .items = {
4647 { "Mic/Line", 0x0 },
4648 { "CD", 0x4 },
4649 { "Headphone", 0x2 },
4650 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004651 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004652 {
4653 .num_items = 4,
4654 .items = {
4655 { "Mic/Line", 0x0 },
4656 { "CD", 0x4 },
4657 { "Headphone", 0x2 },
4658 { "Mixer", 0x5 },
4659 },
4660 },
4661
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004662};
4663
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004664/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4665 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004666 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004667static struct hda_input_mux alc260_acer_capture_sources[2] = {
4668 {
4669 .num_items = 4,
4670 .items = {
4671 { "Mic", 0x0 },
4672 { "Line", 0x2 },
4673 { "CD", 0x4 },
4674 { "Headphone", 0x5 },
4675 },
4676 },
4677 {
4678 .num_items = 5,
4679 .items = {
4680 { "Mic", 0x0 },
4681 { "Line", 0x2 },
4682 { "CD", 0x4 },
4683 { "Headphone", 0x6 },
4684 { "Mixer", 0x5 },
4685 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004686 },
4687};
Michael Schwingencc959482009-02-22 18:58:45 +01004688
4689/* Maxdata Favorit 100XS */
4690static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4691 {
4692 .num_items = 2,
4693 .items = {
4694 { "Line/Mic", 0x0 },
4695 { "CD", 0x4 },
4696 },
4697 },
4698 {
4699 .num_items = 3,
4700 .items = {
4701 { "Line/Mic", 0x0 },
4702 { "CD", 0x4 },
4703 { "Mixer", 0x5 },
4704 },
4705 },
4706};
4707
Linus Torvalds1da177e2005-04-16 15:20:36 -07004708/*
4709 * This is just place-holder, so there's something for alc_build_pcms to look
4710 * at when it calculates the maximum number of channels. ALC260 has no mixer
4711 * element which allows changing the channel mode, so the verb list is
4712 * never used.
4713 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004714static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004715 { 2, NULL },
4716};
4717
Kailang Yangdf694da2005-12-05 19:42:22 +01004718
4719/* Mixer combinations
4720 *
4721 * basic: base_output + input + pc_beep + capture
4722 * HP: base_output + input + capture_alt
4723 * HP_3013: hp_3013 + input + capture
4724 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004725 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004726 */
4727
4728static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004729 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004730 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004731 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4732 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4733 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4734 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4735 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004736};
Kailang Yangdf694da2005-12-05 19:42:22 +01004737
4738static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004739 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4740 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4741 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4742 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4743 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4744 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4745 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4746 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004747 { } /* end */
4748};
4749
Takashi Iwaibec15c32008-01-28 18:16:30 +01004750/* update HP, line and mono out pins according to the master switch */
4751static void alc260_hp_master_update(struct hda_codec *codec,
4752 hda_nid_t hp, hda_nid_t line,
4753 hda_nid_t mono)
4754{
4755 struct alc_spec *spec = codec->spec;
4756 unsigned int val = spec->master_sw ? PIN_HP : 0;
4757 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004758 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004759 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004760 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004761 val);
4762 /* mono (speaker) depending on the HP jack sense */
4763 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004764 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004765 val);
4766}
4767
4768static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4769 struct snd_ctl_elem_value *ucontrol)
4770{
4771 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4772 struct alc_spec *spec = codec->spec;
4773 *ucontrol->value.integer.value = spec->master_sw;
4774 return 0;
4775}
4776
4777static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4778 struct snd_ctl_elem_value *ucontrol)
4779{
4780 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4781 struct alc_spec *spec = codec->spec;
4782 int val = !!*ucontrol->value.integer.value;
4783 hda_nid_t hp, line, mono;
4784
4785 if (val == spec->master_sw)
4786 return 0;
4787 spec->master_sw = val;
4788 hp = (kcontrol->private_value >> 16) & 0xff;
4789 line = (kcontrol->private_value >> 8) & 0xff;
4790 mono = kcontrol->private_value & 0xff;
4791 alc260_hp_master_update(codec, hp, line, mono);
4792 return 1;
4793}
4794
4795static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4796 {
4797 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4798 .name = "Master Playback Switch",
4799 .info = snd_ctl_boolean_mono_info,
4800 .get = alc260_hp_master_sw_get,
4801 .put = alc260_hp_master_sw_put,
4802 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4803 },
4804 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4805 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4806 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4807 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4808 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4809 HDA_OUTPUT),
4810 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4811 { } /* end */
4812};
4813
4814static struct hda_verb alc260_hp_unsol_verbs[] = {
4815 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4816 {},
4817};
4818
4819static void alc260_hp_automute(struct hda_codec *codec)
4820{
4821 struct alc_spec *spec = codec->spec;
4822 unsigned int present;
4823
4824 present = snd_hda_codec_read(codec, 0x10, 0,
4825 AC_VERB_GET_PIN_SENSE, 0);
4826 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4827 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4828}
4829
4830static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4831{
4832 if ((res >> 26) == ALC880_HP_EVENT)
4833 alc260_hp_automute(codec);
4834}
4835
Kailang Yangdf694da2005-12-05 19:42:22 +01004836static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004837 {
4838 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4839 .name = "Master Playback Switch",
4840 .info = snd_ctl_boolean_mono_info,
4841 .get = alc260_hp_master_sw_get,
4842 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004843 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004844 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004845 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4846 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4847 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4848 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4849 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4850 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004851 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4852 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004853 { } /* end */
4854};
4855
Kailang Yang3f878302008-08-26 13:02:23 +02004856static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4857 .ops = &snd_hda_bind_vol,
4858 .values = {
4859 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4860 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4861 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4862 0
4863 },
4864};
4865
4866static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4867 .ops = &snd_hda_bind_sw,
4868 .values = {
4869 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4870 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4871 0
4872 },
4873};
4874
4875static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4876 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4877 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4878 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4879 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4880 { } /* end */
4881};
4882
Takashi Iwaibec15c32008-01-28 18:16:30 +01004883static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4884 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4885 {},
4886};
4887
4888static void alc260_hp_3013_automute(struct hda_codec *codec)
4889{
4890 struct alc_spec *spec = codec->spec;
4891 unsigned int present;
4892
4893 present = snd_hda_codec_read(codec, 0x15, 0,
4894 AC_VERB_GET_PIN_SENSE, 0);
4895 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004896 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004897}
4898
4899static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4900 unsigned int res)
4901{
4902 if ((res >> 26) == ALC880_HP_EVENT)
4903 alc260_hp_3013_automute(codec);
4904}
4905
Kailang Yang3f878302008-08-26 13:02:23 +02004906static void alc260_hp_3012_automute(struct hda_codec *codec)
4907{
4908 unsigned int present, bits;
4909
4910 present = snd_hda_codec_read(codec, 0x10, 0,
4911 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4912
4913 bits = present ? 0 : PIN_OUT;
4914 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4915 bits);
4916 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4917 bits);
4918 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4919 bits);
4920}
4921
4922static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4923 unsigned int res)
4924{
4925 if ((res >> 26) == ALC880_HP_EVENT)
4926 alc260_hp_3012_automute(codec);
4927}
4928
4929/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004930 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4931 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004932static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004933 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004934 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004935 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004936 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4937 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4938 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4939 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004940 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004941 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4942 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004943 { } /* end */
4944};
4945
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004946/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4947 * versions of the ALC260 don't act on requests to enable mic bias from NID
4948 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4949 * datasheet doesn't mention this restriction. At this stage it's not clear
4950 * whether this behaviour is intentional or is a hardware bug in chip
4951 * revisions available in early 2006. Therefore for now allow the
4952 * "Headphone Jack Mode" control to span all choices, but if it turns out
4953 * that the lack of mic bias for this NID is intentional we could change the
4954 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4955 *
4956 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4957 * don't appear to make the mic bias available from the "line" jack, even
4958 * though the NID used for this jack (0x14) can supply it. The theory is
4959 * that perhaps Acer have included blocking capacitors between the ALC260
4960 * and the output jack. If this turns out to be the case for all such
4961 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4962 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004963 *
4964 * The C20x Tablet series have a mono internal speaker which is controlled
4965 * via the chip's Mono sum widget and pin complex, so include the necessary
4966 * controls for such models. On models without a "mono speaker" the control
4967 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004968 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004969static struct snd_kcontrol_new alc260_acer_mixer[] = {
4970 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4971 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004972 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004973 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004974 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004975 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004976 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004977 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4978 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4979 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4980 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4981 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4982 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4983 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4984 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004985 { } /* end */
4986};
4987
Michael Schwingencc959482009-02-22 18:58:45 +01004988/* Maxdata Favorit 100XS: one output and one input (0x12) jack
4989 */
4990static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
4991 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4992 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
4993 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
4994 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4995 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4996 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4997 { } /* end */
4998};
4999
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005000/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5001 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5002 */
5003static struct snd_kcontrol_new alc260_will_mixer[] = {
5004 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5005 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5006 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5007 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5008 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5009 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5010 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5011 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5012 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5013 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005014 { } /* end */
5015};
5016
5017/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5018 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5019 */
5020static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5021 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5022 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5023 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5024 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5025 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5026 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5027 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5028 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5029 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5030 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5031 { } /* end */
5032};
5033
Kailang Yangdf694da2005-12-05 19:42:22 +01005034/*
5035 * initialization verbs
5036 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005037static struct hda_verb alc260_init_verbs[] = {
5038 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005039 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005040 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005041 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005042 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005043 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005044 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005045 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005046 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005047 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005048 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005049 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005050 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005051 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005052 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005053 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005054 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005055 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5056 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005057 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005058 /* set connection select to line in (default select for this ADC) */
5059 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005060 /* mute capture amp left and right */
5061 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5062 /* set connection select to line in (default select for this ADC) */
5063 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005064 /* set vol=0 Line-Out mixer amp left and right */
5065 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5066 /* unmute pin widget amp left and right (no gain on this amp) */
5067 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5068 /* set vol=0 HP mixer amp left and right */
5069 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5070 /* unmute pin widget amp left and right (no gain on this amp) */
5071 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5072 /* set vol=0 Mono mixer amp left and right */
5073 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5074 /* unmute pin widget amp left and right (no gain on this amp) */
5075 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5076 /* unmute LINE-2 out pin */
5077 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005078 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5079 * Line In 2 = 0x03
5080 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005081 /* mute analog inputs */
5082 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5083 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5084 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5085 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5086 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005087 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005088 /* mute Front out path */
5089 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5090 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5091 /* mute Headphone out path */
5092 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5093 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5094 /* mute Mono out path */
5095 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5096 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005097 { }
5098};
5099
Takashi Iwai474167d2006-05-17 17:17:43 +02005100#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005101static struct hda_verb alc260_hp_init_verbs[] = {
5102 /* Headphone and output */
5103 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5104 /* mono output */
5105 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5106 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5107 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5108 /* Mic2 (front panel) pin widget for input and vref at 80% */
5109 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5110 /* Line In pin widget for input */
5111 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5112 /* Line-2 pin widget for output */
5113 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5114 /* CD pin widget for input */
5115 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5116 /* unmute amp left and right */
5117 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5118 /* set connection select to line in (default select for this ADC) */
5119 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5120 /* unmute Line-Out mixer amp left and right (volume = 0) */
5121 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5122 /* mute pin widget amp left and right (no gain on this amp) */
5123 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5124 /* unmute HP mixer amp left and right (volume = 0) */
5125 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5126 /* mute pin widget amp left and right (no gain on this amp) */
5127 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005128 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5129 * Line In 2 = 0x03
5130 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005131 /* mute analog inputs */
5132 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5133 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5134 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5135 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5136 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005137 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5138 /* Unmute Front out path */
5139 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5140 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5141 /* Unmute Headphone out path */
5142 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5143 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5144 /* Unmute Mono out path */
5145 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5146 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5147 { }
5148};
Takashi Iwai474167d2006-05-17 17:17:43 +02005149#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005150
5151static struct hda_verb alc260_hp_3013_init_verbs[] = {
5152 /* Line out and output */
5153 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5154 /* mono output */
5155 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5156 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5157 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5158 /* Mic2 (front panel) pin widget for input and vref at 80% */
5159 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5160 /* Line In pin widget for input */
5161 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5162 /* Headphone pin widget for output */
5163 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5164 /* CD pin widget for input */
5165 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5166 /* unmute amp left and right */
5167 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5168 /* set connection select to line in (default select for this ADC) */
5169 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5170 /* unmute Line-Out mixer amp left and right (volume = 0) */
5171 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5172 /* mute pin widget amp left and right (no gain on this amp) */
5173 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5174 /* unmute HP mixer amp left and right (volume = 0) */
5175 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5176 /* mute pin widget amp left and right (no gain on this amp) */
5177 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005178 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5179 * Line In 2 = 0x03
5180 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005181 /* mute analog inputs */
5182 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5183 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5184 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5185 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5186 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005187 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5188 /* Unmute Front out path */
5189 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5190 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5191 /* Unmute Headphone out path */
5192 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5193 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5194 /* Unmute Mono out path */
5195 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5196 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5197 { }
5198};
5199
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005200/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005201 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5202 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005203 */
5204static struct hda_verb alc260_fujitsu_init_verbs[] = {
5205 /* Disable all GPIOs */
5206 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5207 /* Internal speaker is connected to headphone pin */
5208 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5209 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5210 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005211 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5212 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5213 /* Ensure all other unused pins are disabled and muted. */
5214 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5215 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005216 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005217 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005218 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005219 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5220 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5221 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005222
Jonathan Woithef7ace402006-02-28 11:46:14 +01005223 /* Disable digital (SPDIF) pins */
5224 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5225 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005226
Kailang Yangea1fb292008-08-26 12:58:38 +02005227 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005228 * when acting as an output.
5229 */
5230 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5231
5232 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005233 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5234 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5235 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5236 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5237 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5238 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5239 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5240 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5241 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005242
Jonathan Woithef7ace402006-02-28 11:46:14 +01005243 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5244 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5245 /* Unmute Line1 pin widget output buffer since it starts as an output.
5246 * If the pin mode is changed by the user the pin mode control will
5247 * take care of enabling the pin's input/output buffers as needed.
5248 * Therefore there's no need to enable the input buffer at this
5249 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005250 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005251 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005252 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005253 * mixer ctrl)
5254 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005255 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005256
Jonathan Woithef7ace402006-02-28 11:46:14 +01005257 /* Mute capture amp left and right */
5258 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005259 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005260 * in (on mic1 pin)
5261 */
5262 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005263
Jonathan Woithef7ace402006-02-28 11:46:14 +01005264 /* Do the same for the second ADC: mute capture input amp and
5265 * set ADC connection to line in (on mic1 pin)
5266 */
5267 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5268 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005269
Jonathan Woithef7ace402006-02-28 11:46:14 +01005270 /* Mute all inputs to mixer widget (even unconnected ones) */
5271 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5272 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5273 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5274 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5275 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5276 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5277 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5278 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005279
5280 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005281};
5282
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005283/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5284 * similar laptops (adapted from Fujitsu init verbs).
5285 */
5286static struct hda_verb alc260_acer_init_verbs[] = {
5287 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5288 * the headphone jack. Turn this on and rely on the standard mute
5289 * methods whenever the user wants to turn these outputs off.
5290 */
5291 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5292 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5293 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5294 /* Internal speaker/Headphone jack is connected to Line-out pin */
5295 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5296 /* Internal microphone/Mic jack is connected to Mic1 pin */
5297 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5298 /* Line In jack is connected to Line1 pin */
5299 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005300 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5301 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005302 /* Ensure all other unused pins are disabled and muted. */
5303 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5304 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005305 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5306 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5307 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5308 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5309 /* Disable digital (SPDIF) pins */
5310 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5311 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5312
Kailang Yangea1fb292008-08-26 12:58:38 +02005313 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005314 * bus when acting as outputs.
5315 */
5316 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5317 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5318
5319 /* Start with output sum widgets muted and their output gains at min */
5320 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5321 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5322 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5323 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5324 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5325 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5326 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5327 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5328 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5329
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005330 /* Unmute Line-out pin widget amp left and right
5331 * (no equiv mixer ctrl)
5332 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005333 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005334 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5335 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005336 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5337 * inputs. If the pin mode is changed by the user the pin mode control
5338 * will take care of enabling the pin's input/output buffers as needed.
5339 * Therefore there's no need to enable the input buffer at this
5340 * stage.
5341 */
5342 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5343 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5344
5345 /* Mute capture amp left and right */
5346 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5347 /* Set ADC connection select to match default mixer setting - mic
5348 * (on mic1 pin)
5349 */
5350 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5351
5352 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005353 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005354 */
5355 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005356 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005357
5358 /* Mute all inputs to mixer widget (even unconnected ones) */
5359 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5360 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5361 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5362 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5363 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5364 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5365 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5366 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5367
5368 { }
5369};
5370
Michael Schwingencc959482009-02-22 18:58:45 +01005371/* Initialisation sequence for Maxdata Favorit 100XS
5372 * (adapted from Acer init verbs).
5373 */
5374static struct hda_verb alc260_favorit100_init_verbs[] = {
5375 /* GPIO 0 enables the output jack.
5376 * Turn this on and rely on the standard mute
5377 * methods whenever the user wants to turn these outputs off.
5378 */
5379 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5380 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5381 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5382 /* Line/Mic input jack is connected to Mic1 pin */
5383 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5384 /* Ensure all other unused pins are disabled and muted. */
5385 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5386 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5387 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5388 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5389 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5390 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5391 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5392 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5393 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5394 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5395 /* Disable digital (SPDIF) pins */
5396 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5397 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5398
5399 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5400 * bus when acting as outputs.
5401 */
5402 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5403 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5404
5405 /* Start with output sum widgets muted and their output gains at min */
5406 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5407 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5408 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5409 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5410 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5411 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5412 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5413 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5414 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5415
5416 /* Unmute Line-out pin widget amp left and right
5417 * (no equiv mixer ctrl)
5418 */
5419 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5420 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5421 * inputs. If the pin mode is changed by the user the pin mode control
5422 * will take care of enabling the pin's input/output buffers as needed.
5423 * Therefore there's no need to enable the input buffer at this
5424 * stage.
5425 */
5426 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5427
5428 /* Mute capture amp left and right */
5429 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5430 /* Set ADC connection select to match default mixer setting - mic
5431 * (on mic1 pin)
5432 */
5433 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5434
5435 /* Do similar with the second ADC: mute capture input amp and
5436 * set ADC connection to mic to match ALSA's default state.
5437 */
5438 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5439 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5440
5441 /* Mute all inputs to mixer widget (even unconnected ones) */
5442 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5443 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5444 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5445 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5446 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5447 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5448 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5449 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5450
5451 { }
5452};
5453
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005454static struct hda_verb alc260_will_verbs[] = {
5455 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5456 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5457 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5458 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5459 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5460 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5461 {}
5462};
5463
5464static struct hda_verb alc260_replacer_672v_verbs[] = {
5465 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5466 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5467 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5468
5469 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5470 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5471 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5472
5473 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5474 {}
5475};
5476
5477/* toggle speaker-output according to the hp-jack state */
5478static void alc260_replacer_672v_automute(struct hda_codec *codec)
5479{
5480 unsigned int present;
5481
5482 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5483 present = snd_hda_codec_read(codec, 0x0f, 0,
5484 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5485 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005486 snd_hda_codec_write_cache(codec, 0x01, 0,
5487 AC_VERB_SET_GPIO_DATA, 1);
5488 snd_hda_codec_write_cache(codec, 0x0f, 0,
5489 AC_VERB_SET_PIN_WIDGET_CONTROL,
5490 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005491 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005492 snd_hda_codec_write_cache(codec, 0x01, 0,
5493 AC_VERB_SET_GPIO_DATA, 0);
5494 snd_hda_codec_write_cache(codec, 0x0f, 0,
5495 AC_VERB_SET_PIN_WIDGET_CONTROL,
5496 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005497 }
5498}
5499
5500static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5501 unsigned int res)
5502{
5503 if ((res >> 26) == ALC880_HP_EVENT)
5504 alc260_replacer_672v_automute(codec);
5505}
5506
Kailang Yang3f878302008-08-26 13:02:23 +02005507static struct hda_verb alc260_hp_dc7600_verbs[] = {
5508 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5509 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5510 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5511 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5512 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5513 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5514 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5515 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5516 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5517 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5518 {}
5519};
5520
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005521/* Test configuration for debugging, modelled after the ALC880 test
5522 * configuration.
5523 */
5524#ifdef CONFIG_SND_DEBUG
5525static hda_nid_t alc260_test_dac_nids[1] = {
5526 0x02,
5527};
5528static hda_nid_t alc260_test_adc_nids[2] = {
5529 0x04, 0x05,
5530};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005531/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005532 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005533 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005534 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005535static struct hda_input_mux alc260_test_capture_sources[2] = {
5536 {
5537 .num_items = 7,
5538 .items = {
5539 { "MIC1 pin", 0x0 },
5540 { "MIC2 pin", 0x1 },
5541 { "LINE1 pin", 0x2 },
5542 { "LINE2 pin", 0x3 },
5543 { "CD pin", 0x4 },
5544 { "LINE-OUT pin", 0x5 },
5545 { "HP-OUT pin", 0x6 },
5546 },
5547 },
5548 {
5549 .num_items = 8,
5550 .items = {
5551 { "MIC1 pin", 0x0 },
5552 { "MIC2 pin", 0x1 },
5553 { "LINE1 pin", 0x2 },
5554 { "LINE2 pin", 0x3 },
5555 { "CD pin", 0x4 },
5556 { "Mixer", 0x5 },
5557 { "LINE-OUT pin", 0x6 },
5558 { "HP-OUT pin", 0x7 },
5559 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005560 },
5561};
5562static struct snd_kcontrol_new alc260_test_mixer[] = {
5563 /* Output driver widgets */
5564 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5565 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5566 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5567 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5568 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5569 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5570
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005571 /* Modes for retasking pin widgets
5572 * Note: the ALC260 doesn't seem to act on requests to enable mic
5573 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5574 * mention this restriction. At this stage it's not clear whether
5575 * this behaviour is intentional or is a hardware bug in chip
5576 * revisions available at least up until early 2006. Therefore for
5577 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5578 * choices, but if it turns out that the lack of mic bias for these
5579 * NIDs is intentional we could change their modes from
5580 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5581 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005582 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5583 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5584 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5585 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5586 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5587 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5588
5589 /* Loopback mixer controls */
5590 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5591 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5592 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5593 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5594 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5595 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5596 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5597 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5598 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5599 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005600 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5601 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5602 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5603 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005604
5605 /* Controls for GPIO pins, assuming they are configured as outputs */
5606 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5607 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5608 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5609 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5610
Jonathan Woithe92621f12006-02-28 11:47:47 +01005611 /* Switches to allow the digital IO pins to be enabled. The datasheet
5612 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005613 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005614 */
5615 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5616 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5617
Jonathan Woithef8225f62008-01-08 12:16:54 +01005618 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5619 * this output to turn on an external amplifier.
5620 */
5621 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5622 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5623
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005624 { } /* end */
5625};
5626static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005627 /* Enable all GPIOs as outputs with an initial value of 0 */
5628 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5629 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5630 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5631
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005632 /* Enable retasking pins as output, initially without power amp */
5633 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5634 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5635 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5636 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5637 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5638 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5639
Jonathan Woithe92621f12006-02-28 11:47:47 +01005640 /* Disable digital (SPDIF) pins initially, but users can enable
5641 * them via a mixer switch. In the case of SPDIF-out, this initverb
5642 * payload also sets the generation to 0, output to be in "consumer"
5643 * PCM format, copyright asserted, no pre-emphasis and no validity
5644 * control.
5645 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005646 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5647 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5648
Kailang Yangea1fb292008-08-26 12:58:38 +02005649 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005650 * OUT1 sum bus when acting as an output.
5651 */
5652 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5653 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5654 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5655 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5656
5657 /* Start with output sum widgets muted and their output gains at min */
5658 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5659 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5660 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5661 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5662 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5663 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5664 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5665 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5666 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5667
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005668 /* Unmute retasking pin widget output buffers since the default
5669 * state appears to be output. As the pin mode is changed by the
5670 * user the pin mode control will take care of enabling the pin's
5671 * input/output buffers as needed.
5672 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005673 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5674 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5675 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5676 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5677 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5678 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5679 /* Also unmute the mono-out pin widget */
5680 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5681
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005682 /* Mute capture amp left and right */
5683 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005684 /* Set ADC connection select to match default mixer setting (mic1
5685 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005686 */
5687 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5688
5689 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005690 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005691 */
5692 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5693 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5694
5695 /* Mute all inputs to mixer widget (even unconnected ones) */
5696 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5697 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5698 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5699 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5700 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5701 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5702 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5703 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5704
5705 { }
5706};
5707#endif
5708
Takashi Iwai63300792008-01-24 15:31:36 +01005709#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5710#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005711
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005712#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5713#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5714
Kailang Yangdf694da2005-12-05 19:42:22 +01005715/*
5716 * for BIOS auto-configuration
5717 */
5718
5719static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005720 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005721{
5722 hda_nid_t nid_vol;
5723 unsigned long vol_val, sw_val;
5724 char name[32];
5725 int err;
5726
5727 if (nid >= 0x0f && nid < 0x11) {
5728 nid_vol = nid - 0x7;
5729 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5730 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5731 } else if (nid == 0x11) {
5732 nid_vol = nid - 0x7;
5733 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5734 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5735 } else if (nid >= 0x12 && nid <= 0x15) {
5736 nid_vol = 0x08;
5737 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5738 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5739 } else
5740 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005741
Takashi Iwai863b4512008-10-21 17:01:47 +02005742 if (!(*vol_bits & (1 << nid_vol))) {
5743 /* first control for the volume widget */
5744 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5745 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5746 if (err < 0)
5747 return err;
5748 *vol_bits |= (1 << nid_vol);
5749 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005750 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005751 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5752 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005753 return err;
5754 return 1;
5755}
5756
5757/* add playback controls from the parsed DAC table */
5758static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5759 const struct auto_pin_cfg *cfg)
5760{
5761 hda_nid_t nid;
5762 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005763 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005764
5765 spec->multiout.num_dacs = 1;
5766 spec->multiout.dac_nids = spec->private_dac_nids;
5767 spec->multiout.dac_nids[0] = 0x02;
5768
5769 nid = cfg->line_out_pins[0];
5770 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005771 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005772 if (err < 0)
5773 return err;
5774 }
5775
Takashi Iwai82bc9552006-03-21 11:24:42 +01005776 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005777 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005778 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005779 if (err < 0)
5780 return err;
5781 }
5782
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005783 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005784 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005785 err = alc260_add_playback_controls(spec, nid, "Headphone",
5786 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005787 if (err < 0)
5788 return err;
5789 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005790 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005791}
5792
5793/* create playback/capture controls for input pins */
5794static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5795 const struct auto_pin_cfg *cfg)
5796{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005797 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005798 int i, err, idx;
5799
5800 for (i = 0; i < AUTO_PIN_LAST; i++) {
5801 if (cfg->input_pins[i] >= 0x12) {
5802 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005803 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005804 auto_pin_cfg_labels[i], idx,
5805 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005806 if (err < 0)
5807 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005808 imux->items[imux->num_items].label =
5809 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005810 imux->items[imux->num_items].index = idx;
5811 imux->num_items++;
5812 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005813 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005814 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005815 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005816 auto_pin_cfg_labels[i], idx,
5817 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005818 if (err < 0)
5819 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005820 imux->items[imux->num_items].label =
5821 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005822 imux->items[imux->num_items].index = idx;
5823 imux->num_items++;
5824 }
5825 }
5826 return 0;
5827}
5828
5829static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5830 hda_nid_t nid, int pin_type,
5831 int sel_idx)
5832{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005833 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005834 /* need the manual connection? */
5835 if (nid >= 0x12) {
5836 int idx = nid - 0x12;
5837 snd_hda_codec_write(codec, idx + 0x0b, 0,
5838 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005839 }
5840}
5841
5842static void alc260_auto_init_multi_out(struct hda_codec *codec)
5843{
5844 struct alc_spec *spec = codec->spec;
5845 hda_nid_t nid;
5846
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005847 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005848 if (nid) {
5849 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5850 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5851 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005852
Takashi Iwai82bc9552006-03-21 11:24:42 +01005853 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005854 if (nid)
5855 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5856
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005857 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005858 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005859 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005860}
Kailang Yangdf694da2005-12-05 19:42:22 +01005861
5862#define ALC260_PIN_CD_NID 0x16
5863static void alc260_auto_init_analog_input(struct hda_codec *codec)
5864{
5865 struct alc_spec *spec = codec->spec;
5866 int i;
5867
5868 for (i = 0; i < AUTO_PIN_LAST; i++) {
5869 hda_nid_t nid = spec->autocfg.input_pins[i];
5870 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01005871 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005872 if (nid != ALC260_PIN_CD_NID &&
5873 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005874 snd_hda_codec_write(codec, nid, 0,
5875 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005876 AMP_OUT_MUTE);
5877 }
5878 }
5879}
5880
5881/*
5882 * generic initialization of ADC, input mixers and output mixers
5883 */
5884static struct hda_verb alc260_volume_init_verbs[] = {
5885 /*
5886 * Unmute ADC0-1 and set the default input to mic-in
5887 */
5888 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5889 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5890 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5891 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005892
Kailang Yangdf694da2005-12-05 19:42:22 +01005893 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5894 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005895 * Note: PASD motherboards uses the Line In 2 as the input for
5896 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005897 */
5898 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005899 /* mute analog inputs */
5900 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5901 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5902 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5903 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5904 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005905
5906 /*
5907 * Set up output mixers (0x08 - 0x0a)
5908 */
5909 /* set vol=0 to output mixers */
5910 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5911 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5912 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5913 /* set up input amps for analog loopback */
5914 /* Amp Indices: DAC = 0, mixer = 1 */
5915 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5916 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5917 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5918 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5919 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5920 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005921
Kailang Yangdf694da2005-12-05 19:42:22 +01005922 { }
5923};
5924
5925static int alc260_parse_auto_config(struct hda_codec *codec)
5926{
5927 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005928 int err;
5929 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5930
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005931 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5932 alc260_ignore);
5933 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005934 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005935 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5936 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005937 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005938 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005939 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005940 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5941 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005942 return err;
5943
5944 spec->multiout.max_channels = 2;
5945
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005946 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01005947 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005948 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005949 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005950
Takashi Iwaid88897e2008-10-31 15:01:37 +01005951 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005952
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005953 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005954 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005955
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005956 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
5957
Kailang Yangdf694da2005-12-05 19:42:22 +01005958 return 1;
5959}
5960
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005961/* additional initialization for auto-configuration model */
5962static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005963{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005964 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005965 alc260_auto_init_multi_out(codec);
5966 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005967 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005968 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005969}
5970
Takashi Iwaicb53c622007-08-10 17:21:45 +02005971#ifdef CONFIG_SND_HDA_POWER_SAVE
5972static struct hda_amp_list alc260_loopbacks[] = {
5973 { 0x07, HDA_INPUT, 0 },
5974 { 0x07, HDA_INPUT, 1 },
5975 { 0x07, HDA_INPUT, 2 },
5976 { 0x07, HDA_INPUT, 3 },
5977 { 0x07, HDA_INPUT, 4 },
5978 { } /* end */
5979};
5980#endif
5981
Kailang Yangdf694da2005-12-05 19:42:22 +01005982/*
5983 * ALC260 configurations
5984 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005985static const char *alc260_models[ALC260_MODEL_LAST] = {
5986 [ALC260_BASIC] = "basic",
5987 [ALC260_HP] = "hp",
5988 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005989 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005990 [ALC260_FUJITSU_S702X] = "fujitsu",
5991 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005992 [ALC260_WILL] = "will",
5993 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01005994 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005995#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005996 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005997#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005998 [ALC260_AUTO] = "auto",
5999};
6000
6001static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006002 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006003 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006004 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006005 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01006006 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006007 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006008 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006009 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006010 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6011 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6012 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6013 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6014 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6015 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6016 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6017 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6018 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006019 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006020 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006021 {}
6022};
6023
Kailang Yangdf694da2005-12-05 19:42:22 +01006024static struct alc_config_preset alc260_presets[] = {
6025 [ALC260_BASIC] = {
6026 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006027 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006028 .init_verbs = { alc260_init_verbs },
6029 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6030 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006031 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006032 .adc_nids = alc260_adc_nids,
6033 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6034 .channel_mode = alc260_modes,
6035 .input_mux = &alc260_capture_source,
6036 },
6037 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006038 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006039 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006040 .init_verbs = { alc260_init_verbs,
6041 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006042 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6043 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006044 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6045 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006046 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6047 .channel_mode = alc260_modes,
6048 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006049 .unsol_event = alc260_hp_unsol_event,
6050 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006051 },
Kailang Yang3f878302008-08-26 13:02:23 +02006052 [ALC260_HP_DC7600] = {
6053 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006054 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006055 .init_verbs = { alc260_init_verbs,
6056 alc260_hp_dc7600_verbs },
6057 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6058 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006059 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6060 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006061 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6062 .channel_mode = alc260_modes,
6063 .input_mux = &alc260_capture_source,
6064 .unsol_event = alc260_hp_3012_unsol_event,
6065 .init_hook = alc260_hp_3012_automute,
6066 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006067 [ALC260_HP_3013] = {
6068 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006069 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006070 .init_verbs = { alc260_hp_3013_init_verbs,
6071 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006072 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6073 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006074 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6075 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006076 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6077 .channel_mode = alc260_modes,
6078 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006079 .unsol_event = alc260_hp_3013_unsol_event,
6080 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006081 },
6082 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006083 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006084 .init_verbs = { alc260_fujitsu_init_verbs },
6085 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6086 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006087 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6088 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006089 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6090 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006091 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6092 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006093 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006094 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006095 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006096 .init_verbs = { alc260_acer_init_verbs },
6097 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6098 .dac_nids = alc260_dac_nids,
6099 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6100 .adc_nids = alc260_dual_adc_nids,
6101 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6102 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006103 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6104 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006105 },
Michael Schwingencc959482009-02-22 18:58:45 +01006106 [ALC260_FAVORIT100] = {
6107 .mixers = { alc260_favorit100_mixer },
6108 .init_verbs = { alc260_favorit100_init_verbs },
6109 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6110 .dac_nids = alc260_dac_nids,
6111 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6112 .adc_nids = alc260_dual_adc_nids,
6113 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6114 .channel_mode = alc260_modes,
6115 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6116 .input_mux = alc260_favorit100_capture_sources,
6117 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006118 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006119 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006120 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6121 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6122 .dac_nids = alc260_dac_nids,
6123 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6124 .adc_nids = alc260_adc_nids,
6125 .dig_out_nid = ALC260_DIGOUT_NID,
6126 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6127 .channel_mode = alc260_modes,
6128 .input_mux = &alc260_capture_source,
6129 },
6130 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006131 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006132 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6133 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6134 .dac_nids = alc260_dac_nids,
6135 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6136 .adc_nids = alc260_adc_nids,
6137 .dig_out_nid = ALC260_DIGOUT_NID,
6138 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6139 .channel_mode = alc260_modes,
6140 .input_mux = &alc260_capture_source,
6141 .unsol_event = alc260_replacer_672v_unsol_event,
6142 .init_hook = alc260_replacer_672v_automute,
6143 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006144#ifdef CONFIG_SND_DEBUG
6145 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006146 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006147 .init_verbs = { alc260_test_init_verbs },
6148 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6149 .dac_nids = alc260_test_dac_nids,
6150 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6151 .adc_nids = alc260_test_adc_nids,
6152 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6153 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006154 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6155 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006156 },
6157#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006158};
6159
Linus Torvalds1da177e2005-04-16 15:20:36 -07006160static int patch_alc260(struct hda_codec *codec)
6161{
6162 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006163 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006164
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006165 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006166 if (spec == NULL)
6167 return -ENOMEM;
6168
6169 codec->spec = spec;
6170
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006171 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6172 alc260_models,
6173 alc260_cfg_tbl);
6174 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +02006175 snd_printd(KERN_INFO "hda_codec: Unknown model for %s, "
6176 "trying auto-probe from BIOS...\n",
6177 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006178 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006179 }
6180
Kailang Yangdf694da2005-12-05 19:42:22 +01006181 if (board_config == ALC260_AUTO) {
6182 /* automatic parse from the BIOS config */
6183 err = alc260_parse_auto_config(codec);
6184 if (err < 0) {
6185 alc_free(codec);
6186 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006187 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006188 printk(KERN_INFO
6189 "hda_codec: Cannot set up configuration "
6190 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006191 board_config = ALC260_BASIC;
6192 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006193 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006194
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006195 err = snd_hda_attach_beep_device(codec, 0x1);
6196 if (err < 0) {
6197 alc_free(codec);
6198 return err;
6199 }
6200
Kailang Yangdf694da2005-12-05 19:42:22 +01006201 if (board_config != ALC260_AUTO)
6202 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006203
Linus Torvalds1da177e2005-04-16 15:20:36 -07006204 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6205 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6206
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006207 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6208 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6209
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006210 if (!spec->adc_nids && spec->input_mux) {
6211 /* check whether NID 0x04 is valid */
6212 unsigned int wcap = get_wcaps(codec, 0x04);
6213 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6214 /* get type */
6215 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6216 spec->adc_nids = alc260_adc_nids_alt;
6217 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6218 } else {
6219 spec->adc_nids = alc260_adc_nids;
6220 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6221 }
6222 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006223 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006224 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006225
Takashi Iwai2134ea42008-01-10 16:53:55 +01006226 spec->vmaster_nid = 0x08;
6227
Linus Torvalds1da177e2005-04-16 15:20:36 -07006228 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006229 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006230 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006231#ifdef CONFIG_SND_HDA_POWER_SAVE
6232 if (!spec->loopback.amplist)
6233 spec->loopback.amplist = alc260_loopbacks;
6234#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006235 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006236
6237 return 0;
6238}
6239
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006240
Linus Torvalds1da177e2005-04-16 15:20:36 -07006241/*
6242 * ALC882 support
6243 *
6244 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6245 * configuration. Each pin widget can choose any input DACs and a mixer.
6246 * Each ADC is connected from a mixer of all inputs. This makes possible
6247 * 6-channel independent captures.
6248 *
6249 * In addition, an independent DAC for the multi-playback (not used in this
6250 * driver yet).
6251 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006252#define ALC882_DIGOUT_NID 0x06
6253#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07006254
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006255static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006256 { 8, NULL }
6257};
6258
6259static hda_nid_t alc882_dac_nids[4] = {
6260 /* front, rear, clfe, rear_surr */
6261 0x02, 0x03, 0x04, 0x05
6262};
6263
Kailang Yangdf694da2005-12-05 19:42:22 +01006264/* identical with ALC880 */
6265#define alc882_adc_nids alc880_adc_nids
6266#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07006267
Takashi Iwaie1406342008-02-11 18:32:32 +01006268static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6269static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
6270
Linus Torvalds1da177e2005-04-16 15:20:36 -07006271/* input MUX */
6272/* FIXME: should be a matrix-type input source selection */
6273
6274static struct hda_input_mux alc882_capture_source = {
6275 .num_items = 4,
6276 .items = {
6277 { "Mic", 0x0 },
6278 { "Front Mic", 0x1 },
6279 { "Line", 0x2 },
6280 { "CD", 0x4 },
6281 },
6282};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006283
6284static struct hda_input_mux mb5_capture_source = {
6285 .num_items = 3,
6286 .items = {
6287 { "Mic", 0x1 },
6288 { "Line", 0x2 },
6289 { "CD", 0x4 },
6290 },
6291};
6292
Kailang Yangdf694da2005-12-05 19:42:22 +01006293/*
Kailang Yang272a5272007-05-14 11:00:38 +02006294 * 2ch mode
6295 */
6296static struct hda_verb alc882_3ST_ch2_init[] = {
6297 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6298 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6299 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6300 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6301 { } /* end */
6302};
6303
6304/*
6305 * 6ch mode
6306 */
6307static struct hda_verb alc882_3ST_ch6_init[] = {
6308 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6309 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6310 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6311 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6312 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6313 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6314 { } /* end */
6315};
6316
6317static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
6318 { 2, alc882_3ST_ch2_init },
6319 { 6, alc882_3ST_ch6_init },
6320};
6321
6322/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006323 * 6ch mode
6324 */
6325static struct hda_verb alc882_sixstack_ch6_init[] = {
6326 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6327 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6328 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6329 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6330 { } /* end */
6331};
6332
6333/*
6334 * 8ch mode
6335 */
6336static struct hda_verb alc882_sixstack_ch8_init[] = {
6337 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6338 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6339 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6340 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6341 { } /* end */
6342};
6343
6344static struct hda_channel_mode alc882_sixstack_modes[2] = {
6345 { 6, alc882_sixstack_ch6_init },
6346 { 8, alc882_sixstack_ch8_init },
6347};
6348
Takashi Iwai87350ad2007-08-16 18:19:38 +02006349/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006350 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006351 */
6352
6353/*
6354 * 2ch mode
6355 */
6356static struct hda_verb alc885_mbp_ch2_init[] = {
6357 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6358 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6359 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6360 { } /* end */
6361};
6362
6363/*
6364 * 6ch mode
6365 */
6366static struct hda_verb alc885_mbp_ch6_init[] = {
6367 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6368 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6369 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6370 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6371 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6372 { } /* end */
6373};
6374
6375static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6376 { 2, alc885_mbp_ch2_init },
6377 { 6, alc885_mbp_ch6_init },
6378};
6379
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006380/*
6381 * 2ch
6382 * Speakers/Woofer/HP = Front
6383 * LineIn = Input
6384 */
6385static struct hda_verb alc885_mb5_ch2_init[] = {
6386 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6387 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6388 { } /* end */
6389};
6390
6391/*
6392 * 6ch mode
6393 * Speakers/HP = Front
6394 * Woofer = LFE
6395 * LineIn = Surround
6396 */
6397static struct hda_verb alc885_mb5_ch6_init[] = {
6398 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6399 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6400 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6401 { } /* end */
6402};
6403
6404static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6405 { 2, alc885_mb5_ch2_init },
6406 { 6, alc885_mb5_ch6_init },
6407};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006408
Linus Torvalds1da177e2005-04-16 15:20:36 -07006409/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6410 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6411 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006412static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006413 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006414 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006415 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006416 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006417 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6418 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006419 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6420 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006421 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006422 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006423 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6424 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6425 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6426 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6427 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6428 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006429 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006430 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6431 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006432 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006433 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006434 { } /* end */
6435};
6436
Takashi Iwai87350ad2007-08-16 18:19:38 +02006437static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006438 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6439 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6440 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6441 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6442 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6443 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006444 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6445 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006446 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006447 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6448 { } /* end */
6449};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006450
6451static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006452 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6453 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6454 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6455 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
6456 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
6457 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
6458 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
6459 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006460 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6461 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6462 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6463 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6464 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
6465 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
6466 { } /* end */
6467};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006468
Kailang Yangbdd148a2007-05-08 15:19:08 +02006469static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6470 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6471 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6472 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6473 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6474 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6475 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6476 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6477 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6478 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006479 { } /* end */
6480};
6481
Kailang Yang272a5272007-05-14 11:00:38 +02006482static struct snd_kcontrol_new alc882_targa_mixer[] = {
6483 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6484 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6485 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6486 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6487 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6488 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6489 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6490 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6491 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006492 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006493 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6494 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006495 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006496 { } /* end */
6497};
6498
6499/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6500 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6501 */
6502static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6503 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6504 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6505 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6506 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6507 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6508 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6509 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6510 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6511 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6512 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6513 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6514 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006515 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006516 { } /* end */
6517};
6518
Takashi Iwai914759b2007-09-06 14:52:04 +02006519static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6520 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6521 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6522 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6523 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6524 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6525 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6526 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6527 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6528 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6529 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006530 { } /* end */
6531};
6532
Kailang Yangdf694da2005-12-05 19:42:22 +01006533static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6534 {
6535 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6536 .name = "Channel Mode",
6537 .info = alc_ch_mode_info,
6538 .get = alc_ch_mode_get,
6539 .put = alc_ch_mode_put,
6540 },
6541 { } /* end */
6542};
6543
Linus Torvalds1da177e2005-04-16 15:20:36 -07006544static struct hda_verb alc882_init_verbs[] = {
6545 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006546 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6547 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6548 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006549 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006550 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6551 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6552 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006553 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006554 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6555 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6556 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006557 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006558 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6559 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6560 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006561
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006562 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006563 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006564 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006565 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006566 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006567 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006568 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006569 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006570 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006571 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006572 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006573 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006574 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006575 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006576 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006577 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006578 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006579 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006580 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6581 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006582 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006583 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6584 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006585 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006586 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6587 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6588 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6589 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6590 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006591 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006592 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006593
6594 /* FIXME: use matrix-type input source selection */
6595 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6596 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006597 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6598 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6599 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6600 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006601 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006602 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6603 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6604 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6605 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006606 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006607 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6608 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6609 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6610 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6611 /* ADC1: mute amp left and right */
6612 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006613 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006614 /* ADC2: mute amp left and right */
6615 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006616 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006617 /* ADC3: mute amp left and right */
6618 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006619 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006620
6621 { }
6622};
6623
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006624static struct hda_verb alc882_eapd_verbs[] = {
6625 /* change to EAPD mode */
6626 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006627 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006628 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006629};
6630
Tobin Davis9102cd12006-12-15 10:02:12 +01006631/* Mac Pro test */
6632static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6633 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6634 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6635 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6636 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6637 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006638 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01006639 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6640 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006641 */
Tobin Davis9102cd12006-12-15 10:02:12 +01006642 { } /* end */
6643};
6644
6645static struct hda_verb alc882_macpro_init_verbs[] = {
6646 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6647 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6648 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6649 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6650 /* Front Pin: output 0 (0x0c) */
6651 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6652 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6653 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6654 /* Front Mic pin: input vref at 80% */
6655 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6656 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6657 /* Speaker: output */
6658 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6659 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6660 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6661 /* Headphone output (output 0 - 0x0c) */
6662 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6663 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6664 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6665
6666 /* FIXME: use matrix-type input source selection */
6667 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6668 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6669 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6670 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6671 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6672 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6673 /* Input mixer2 */
6674 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6675 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6676 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6677 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6678 /* Input mixer3 */
6679 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6680 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6681 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6682 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6683 /* ADC1: mute amp left and right */
6684 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6685 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6686 /* ADC2: mute amp left and right */
6687 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6688 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6689 /* ADC3: mute amp left and right */
6690 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6691 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6692
6693 { }
6694};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006695
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006696/* Macbook 5,1 */
6697static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006698 /* DACs */
6699 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6700 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6701 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6702 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006703 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006704 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6705 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6706 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006707 /* Surround mixer */
6708 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6709 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6710 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6711 /* LFE mixer */
6712 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6713 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6714 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6715 /* HP mixer */
6716 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6717 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6718 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6719 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006720 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
6721 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006722 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6723 /* LFE Pin (0x0e) */
6724 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
6725 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6726 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
6727 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006728 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6729 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006730 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006731 /* Front Mic pin: input vref at 80% */
6732 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6733 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6734 /* Line In pin */
6735 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6736 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6737
6738 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6739 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6740 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6741 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6742 { }
6743};
6744
Takashi Iwai87350ad2007-08-16 18:19:38 +02006745/* Macbook Pro rev3 */
6746static struct hda_verb alc885_mbp3_init_verbs[] = {
6747 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6748 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6749 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6750 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6751 /* Rear mixer */
6752 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6753 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6754 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6755 /* Front Pin: output 0 (0x0c) */
6756 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6757 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6758 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6759 /* HP Pin: output 0 (0x0d) */
6760 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6761 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6762 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6763 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6764 /* Mic (rear) pin: input vref at 80% */
6765 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6766 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6767 /* Front Mic pin: input vref at 80% */
6768 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6769 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6770 /* Line In pin: use output 1 when in LineOut mode */
6771 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6772 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6773 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6774
6775 /* FIXME: use matrix-type input source selection */
6776 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6777 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6778 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6779 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6780 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6781 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6782 /* Input mixer2 */
6783 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6784 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6785 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6786 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6787 /* Input mixer3 */
6788 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6789 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6790 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6791 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6792 /* ADC1: mute amp left and right */
6793 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6794 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6795 /* ADC2: mute amp left and right */
6796 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6797 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6798 /* ADC3: mute amp left and right */
6799 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6800 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6801
6802 { }
6803};
6804
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006805/* iMac 24 mixer. */
6806static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6807 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6808 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6809 { } /* end */
6810};
6811
6812/* iMac 24 init verbs. */
6813static struct hda_verb alc885_imac24_init_verbs[] = {
6814 /* Internal speakers: output 0 (0x0c) */
6815 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6816 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6817 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6818 /* Internal speakers: output 0 (0x0c) */
6819 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6820 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6821 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6822 /* Headphone: output 0 (0x0c) */
6823 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6824 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6825 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6826 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6827 /* Front Mic: input vref at 80% */
6828 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6829 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6830 { }
6831};
6832
6833/* Toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006834static void alc885_imac24_automute_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006835{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006836 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006837
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006838 spec->autocfg.hp_pins[0] = 0x14;
6839 spec->autocfg.speaker_pins[0] = 0x18;
6840 spec->autocfg.speaker_pins[1] = 0x1a;
6841 alc_automute_amp(codec);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006842}
6843
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006844static void alc885_mbp3_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006845{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006846 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006847
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006848 spec->autocfg.hp_pins[0] = 0x15;
6849 spec->autocfg.speaker_pins[0] = 0x14;
6850 alc_automute_amp(codec);
Takashi Iwai87350ad2007-08-16 18:19:38 +02006851}
6852
6853
Kailang Yang272a5272007-05-14 11:00:38 +02006854static struct hda_verb alc882_targa_verbs[] = {
6855 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6856 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6857
6858 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6859 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006860
Kailang Yang272a5272007-05-14 11:00:38 +02006861 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6862 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6863 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6864
6865 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6866 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6867 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6868 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6869 { } /* end */
6870};
6871
6872/* toggle speaker-output according to the hp-jack state */
6873static void alc882_targa_automute(struct hda_codec *codec)
6874{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006875 struct alc_spec *spec = codec->spec;
6876 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006877 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006878 spec->jack_present ? 1 : 3);
6879}
6880
6881static void alc882_targa_init_hook(struct hda_codec *codec)
6882{
6883 struct alc_spec *spec = codec->spec;
6884
6885 spec->autocfg.hp_pins[0] = 0x14;
6886 spec->autocfg.speaker_pins[0] = 0x1b;
6887 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006888}
6889
6890static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6891{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006892 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02006893 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006894}
6895
6896static struct hda_verb alc882_asus_a7j_verbs[] = {
6897 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6898 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6899
6900 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6901 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6902 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006903
Kailang Yang272a5272007-05-14 11:00:38 +02006904 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6905 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6906 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6907
6908 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6909 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6910 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6911 { } /* end */
6912};
6913
Takashi Iwai914759b2007-09-06 14:52:04 +02006914static struct hda_verb alc882_asus_a7m_verbs[] = {
6915 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6916 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6917
6918 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6919 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6920 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006921
Takashi Iwai914759b2007-09-06 14:52:04 +02006922 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6923 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6924 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6925
6926 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6927 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6928 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6929 { } /* end */
6930};
6931
Tobin Davis9102cd12006-12-15 10:02:12 +01006932static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6933{
6934 unsigned int gpiostate, gpiomask, gpiodir;
6935
6936 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6937 AC_VERB_GET_GPIO_DATA, 0);
6938
6939 if (!muted)
6940 gpiostate |= (1 << pin);
6941 else
6942 gpiostate &= ~(1 << pin);
6943
6944 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6945 AC_VERB_GET_GPIO_MASK, 0);
6946 gpiomask |= (1 << pin);
6947
6948 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6949 AC_VERB_GET_GPIO_DIRECTION, 0);
6950 gpiodir |= (1 << pin);
6951
6952
6953 snd_hda_codec_write(codec, codec->afg, 0,
6954 AC_VERB_SET_GPIO_MASK, gpiomask);
6955 snd_hda_codec_write(codec, codec->afg, 0,
6956 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6957
6958 msleep(1);
6959
6960 snd_hda_codec_write(codec, codec->afg, 0,
6961 AC_VERB_SET_GPIO_DATA, gpiostate);
6962}
6963
Takashi Iwai7debbe52007-08-16 15:01:03 +02006964/* set up GPIO at initialization */
6965static void alc885_macpro_init_hook(struct hda_codec *codec)
6966{
6967 alc882_gpio_mute(codec, 0, 0);
6968 alc882_gpio_mute(codec, 1, 0);
6969}
6970
6971/* set up GPIO and update auto-muting at initialization */
6972static void alc885_imac24_init_hook(struct hda_codec *codec)
6973{
6974 alc885_macpro_init_hook(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006975 alc885_imac24_automute_init_hook(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02006976}
6977
Kailang Yangdf694da2005-12-05 19:42:22 +01006978/*
6979 * generic initialization of ADC, input mixers and output mixers
6980 */
6981static struct hda_verb alc882_auto_init_verbs[] = {
6982 /*
6983 * Unmute ADC0-2 and set the default input to mic-in
6984 */
6985 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6986 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6987 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6988 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6989 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6990 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6991
Takashi Iwaicb53c622007-08-10 17:21:45 +02006992 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006993 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006994 * Note: PASD motherboards uses the Line In 2 as the input for
6995 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006996 */
6997 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006998 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6999 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7000 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7001 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7002 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007003
7004 /*
7005 * Set up output mixers (0x0c - 0x0f)
7006 */
7007 /* set vol=0 to output mixers */
7008 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7009 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7010 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7011 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7012 /* set up input amps for analog loopback */
7013 /* Amp Indices: DAC = 0, mixer = 1 */
7014 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7015 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7016 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7017 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7018 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7019 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7020 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7021 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7022 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7023 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7024
7025 /* FIXME: use matrix-type input source selection */
7026 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7027 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7028 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7029 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7030 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7031 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7032 /* Input mixer2 */
7033 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7034 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7035 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7036 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7037 /* Input mixer3 */
7038 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7039 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7040 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7041 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7042
7043 { }
7044};
7045
Takashi Iwaicb53c622007-08-10 17:21:45 +02007046#ifdef CONFIG_SND_HDA_POWER_SAVE
7047#define alc882_loopbacks alc880_loopbacks
7048#endif
7049
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007050/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007051#define alc882_pcm_analog_playback alc880_pcm_analog_playback
7052#define alc882_pcm_analog_capture alc880_pcm_analog_capture
7053#define alc882_pcm_digital_playback alc880_pcm_digital_playback
7054#define alc882_pcm_digital_capture alc880_pcm_digital_capture
7055
7056/*
7057 * configuration and preset
7058 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007059static const char *alc882_models[ALC882_MODEL_LAST] = {
7060 [ALC882_3ST_DIG] = "3stack-dig",
7061 [ALC882_6ST_DIG] = "6stack-dig",
7062 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02007063 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02007064 [ALC882_TARGA] = "targa",
7065 [ALC882_ASUS_A7J] = "asus-a7j",
7066 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01007067 [ALC885_MACPRO] = "macpro",
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007068 [ALC885_MB5] = "mb5",
Takashi Iwai87350ad2007-08-16 18:19:38 +02007069 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007070 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007071 [ALC882_AUTO] = "auto",
7072};
7073
7074static struct snd_pci_quirk alc882_cfg_tbl[] = {
7075 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02007076 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02007077 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02007078 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007079 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02007080 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01007081 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007082 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01007083 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007084 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
7085 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
7086 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01007087 {}
7088};
7089
7090static struct alc_config_preset alc882_presets[] = {
7091 [ALC882_3ST_DIG] = {
7092 .mixers = { alc882_base_mixer },
7093 .init_verbs = { alc882_init_verbs },
7094 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7095 .dac_nids = alc882_dac_nids,
7096 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01007097 .dig_in_nid = ALC882_DIGIN_NID,
7098 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7099 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007100 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01007101 .input_mux = &alc882_capture_source,
7102 },
7103 [ALC882_6ST_DIG] = {
7104 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
7105 .init_verbs = { alc882_init_verbs },
7106 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7107 .dac_nids = alc882_dac_nids,
7108 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01007109 .dig_in_nid = ALC882_DIGIN_NID,
7110 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
7111 .channel_mode = alc882_sixstack_modes,
7112 .input_mux = &alc882_capture_source,
7113 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007114 [ALC882_ARIMA] = {
7115 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
7116 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
7117 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7118 .dac_nids = alc882_dac_nids,
7119 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
7120 .channel_mode = alc882_sixstack_modes,
7121 .input_mux = &alc882_capture_source,
7122 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02007123 [ALC882_W2JC] = {
7124 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
7125 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7126 alc880_gpio1_init_verbs },
7127 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7128 .dac_nids = alc882_dac_nids,
7129 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7130 .channel_mode = alc880_threestack_modes,
7131 .need_dac_fix = 1,
7132 .input_mux = &alc882_capture_source,
7133 .dig_out_nid = ALC882_DIGOUT_NID,
7134 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007135 [ALC885_MBP3] = {
7136 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
7137 .init_verbs = { alc885_mbp3_init_verbs,
7138 alc880_gpio1_init_verbs },
7139 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7140 .dac_nids = alc882_dac_nids,
7141 .channel_mode = alc885_mbp_6ch_modes,
7142 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
7143 .input_mux = &alc882_capture_source,
7144 .dig_out_nid = ALC882_DIGOUT_NID,
7145 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007146 .unsol_event = alc_automute_amp_unsol_event,
7147 .init_hook = alc885_mbp3_init_hook,
Takashi Iwai87350ad2007-08-16 18:19:38 +02007148 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007149 [ALC885_MB5] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007150 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007151 .init_verbs = { alc885_mb5_init_verbs,
7152 alc880_gpio1_init_verbs },
7153 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7154 .dac_nids = alc882_dac_nids,
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007155 .channel_mode = alc885_mb5_6ch_modes,
7156 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007157 .input_mux = &mb5_capture_source,
7158 .dig_out_nid = ALC882_DIGOUT_NID,
7159 .dig_in_nid = ALC882_DIGIN_NID,
7160 },
Tobin Davis9102cd12006-12-15 10:02:12 +01007161 [ALC885_MACPRO] = {
7162 .mixers = { alc882_macpro_mixer },
7163 .init_verbs = { alc882_macpro_init_verbs },
7164 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7165 .dac_nids = alc882_dac_nids,
7166 .dig_out_nid = ALC882_DIGOUT_NID,
7167 .dig_in_nid = ALC882_DIGIN_NID,
7168 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7169 .channel_mode = alc882_ch_modes,
7170 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007171 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01007172 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007173 [ALC885_IMAC24] = {
7174 .mixers = { alc885_imac24_mixer },
7175 .init_verbs = { alc885_imac24_init_verbs },
7176 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7177 .dac_nids = alc882_dac_nids,
7178 .dig_out_nid = ALC882_DIGOUT_NID,
7179 .dig_in_nid = ALC882_DIGIN_NID,
7180 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7181 .channel_mode = alc882_ch_modes,
7182 .input_mux = &alc882_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007183 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007184 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007185 },
Kailang Yang272a5272007-05-14 11:00:38 +02007186 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007187 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007188 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
7189 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7190 .dac_nids = alc882_dac_nids,
7191 .dig_out_nid = ALC882_DIGOUT_NID,
7192 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7193 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007194 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007195 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7196 .channel_mode = alc882_3ST_6ch_modes,
7197 .need_dac_fix = 1,
7198 .input_mux = &alc882_capture_source,
7199 .unsol_event = alc882_targa_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007200 .init_hook = alc882_targa_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02007201 },
7202 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007203 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007204 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
7205 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7206 .dac_nids = alc882_dac_nids,
7207 .dig_out_nid = ALC882_DIGOUT_NID,
7208 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7209 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007210 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007211 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7212 .channel_mode = alc882_3ST_6ch_modes,
7213 .need_dac_fix = 1,
7214 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007215 },
Takashi Iwai914759b2007-09-06 14:52:04 +02007216 [ALC882_ASUS_A7M] = {
7217 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
7218 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7219 alc880_gpio1_init_verbs,
7220 alc882_asus_a7m_verbs },
7221 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7222 .dac_nids = alc882_dac_nids,
7223 .dig_out_nid = ALC882_DIGOUT_NID,
7224 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7225 .channel_mode = alc880_threestack_modes,
7226 .need_dac_fix = 1,
7227 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007228 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007229};
7230
7231
7232/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02007233 * Pin config fixes
7234 */
Kailang Yangea1fb292008-08-26 12:58:38 +02007235enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02007236 PINFIX_ABIT_AW9D_MAX
7237};
7238
7239static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
7240 { 0x15, 0x01080104 }, /* side */
7241 { 0x16, 0x01011012 }, /* rear */
7242 { 0x17, 0x01016011 }, /* clfe */
7243 { }
7244};
7245
7246static const struct alc_pincfg *alc882_pin_fixes[] = {
7247 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
7248};
7249
7250static struct snd_pci_quirk alc882_pinfix_tbl[] = {
7251 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
7252 {}
7253};
7254
7255/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007256 * BIOS auto configuration
7257 */
7258static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
7259 hda_nid_t nid, int pin_type,
7260 int dac_idx)
7261{
7262 /* set as output */
7263 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007264 int idx;
7265
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007266 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007267 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7268 idx = 4;
7269 else
7270 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01007271 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7272
7273}
7274
7275static void alc882_auto_init_multi_out(struct hda_codec *codec)
7276{
7277 struct alc_spec *spec = codec->spec;
7278 int i;
7279
7280 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007281 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007282 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007283 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007284 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007285 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01007286 }
7287}
7288
7289static void alc882_auto_init_hp_out(struct hda_codec *codec)
7290{
7291 struct alc_spec *spec = codec->spec;
7292 hda_nid_t pin;
7293
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007294 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007295 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007296 /* use dac 0 */
7297 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007298 pin = spec->autocfg.speaker_pins[0];
7299 if (pin)
7300 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01007301}
7302
7303#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
7304#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
7305
7306static void alc882_auto_init_analog_input(struct hda_codec *codec)
7307{
7308 struct alc_spec *spec = codec->spec;
7309 int i;
7310
7311 for (i = 0; i < AUTO_PIN_LAST; i++) {
7312 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01007313 if (!nid)
7314 continue;
Takashi Iwai23f0c042009-02-26 13:03:58 +01007315 alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/);
Takashi Iwai7194cae2008-03-06 16:58:17 +01007316 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
7317 snd_hda_codec_write(codec, nid, 0,
7318 AC_VERB_SET_AMP_GAIN_MUTE,
7319 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01007320 }
7321}
7322
Takashi Iwaif511b012008-08-15 16:46:42 +02007323static void alc882_auto_init_input_src(struct hda_codec *codec)
7324{
7325 struct alc_spec *spec = codec->spec;
Takashi Iwaif511b012008-08-15 16:46:42 +02007326 int c;
7327
7328 for (c = 0; c < spec->num_adc_nids; c++) {
7329 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
7330 hda_nid_t nid = spec->capsrc_nids[c];
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007331 unsigned int mux_idx;
7332 const struct hda_input_mux *imux;
Takashi Iwaif511b012008-08-15 16:46:42 +02007333 int conns, mute, idx, item;
7334
7335 conns = snd_hda_get_connections(codec, nid, conn_list,
7336 ARRAY_SIZE(conn_list));
7337 if (conns < 0)
7338 continue;
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007339 mux_idx = c >= spec->num_mux_defs ? 0 : c;
7340 imux = &spec->input_mux[mux_idx];
Takashi Iwaif511b012008-08-15 16:46:42 +02007341 for (idx = 0; idx < conns; idx++) {
7342 /* if the current connection is the selected one,
7343 * unmute it as default - otherwise mute it
7344 */
7345 mute = AMP_IN_MUTE(idx);
7346 for (item = 0; item < imux->num_items; item++) {
7347 if (imux->items[item].index == idx) {
7348 if (spec->cur_mux[c] == item)
7349 mute = AMP_IN_UNMUTE(idx);
7350 break;
7351 }
7352 }
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007353 /* check if we have a selector or mixer
7354 * we could check for the widget type instead, but
7355 * just check for Amp-In presence (in case of mixer
7356 * without amp-in there is something wrong, this
7357 * function shouldn't be used or capsrc nid is wrong)
7358 */
7359 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
7360 snd_hda_codec_write(codec, nid, 0,
7361 AC_VERB_SET_AMP_GAIN_MUTE,
7362 mute);
7363 else if (mute != AMP_IN_MUTE(idx))
7364 snd_hda_codec_write(codec, nid, 0,
7365 AC_VERB_SET_CONNECT_SEL,
7366 idx);
Takashi Iwaif511b012008-08-15 16:46:42 +02007367 }
7368 }
7369}
7370
Takashi Iwai776e1842007-08-29 15:07:11 +02007371/* add mic boosts if needed */
7372static int alc_auto_add_mic_boost(struct hda_codec *codec)
7373{
7374 struct alc_spec *spec = codec->spec;
7375 int err;
7376 hda_nid_t nid;
7377
7378 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007379 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007380 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7381 "Mic Boost",
7382 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7383 if (err < 0)
7384 return err;
7385 }
7386 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007387 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007388 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7389 "Front Mic Boost",
7390 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7391 if (err < 0)
7392 return err;
7393 }
7394 return 0;
7395}
7396
Kailang Yangdf694da2005-12-05 19:42:22 +01007397/* almost identical with ALC880 parser... */
7398static int alc882_parse_auto_config(struct hda_codec *codec)
7399{
7400 struct alc_spec *spec = codec->spec;
7401 int err = alc880_parse_auto_config(codec);
7402
7403 if (err < 0)
7404 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007405 else if (!err)
7406 return 0; /* no config found */
7407
7408 err = alc_auto_add_mic_boost(codec);
7409 if (err < 0)
7410 return err;
7411
7412 /* hack - override the init verbs */
7413 spec->init_verbs[0] = alc882_auto_init_verbs;
7414
7415 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01007416}
7417
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007418/* additional initialization for auto-configuration model */
7419static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007420{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007421 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007422 alc882_auto_init_multi_out(codec);
7423 alc882_auto_init_hp_out(codec);
7424 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02007425 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007426 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007427 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007428}
7429
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007430static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7431
Linus Torvalds1da177e2005-04-16 15:20:36 -07007432static int patch_alc882(struct hda_codec *codec)
7433{
7434 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007435 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007436
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007437 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007438 if (spec == NULL)
7439 return -ENOMEM;
7440
Linus Torvalds1da177e2005-04-16 15:20:36 -07007441 codec->spec = spec;
7442
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007443 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7444 alc882_models,
7445 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007446
Kailang Yangdf694da2005-12-05 19:42:22 +01007447 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007448 /* Pick up systems that don't supply PCI SSID */
7449 switch (codec->subsystem_id) {
7450 case 0x106b0c00: /* Mac Pro */
7451 board_config = ALC885_MACPRO;
7452 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007453 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007454 case 0x106b2800: /* AppleTV */
Mark Eggleston3077e442009-01-31 17:57:54 +01007455 case 0x106b3e00: /* iMac 24 Aluminium */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007456 board_config = ALC885_IMAC24;
7457 break;
Luke Yelavich2d466382009-02-23 13:00:33 +11007458 case 0x106b00a0: /* MacBookPro3,1 - Another revision */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007459 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007460 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007461 case 0x106b2c00: /* Macbook Pro rev3 */
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007462 /* Macbook 3.1 (0x106b3600) is handled by patch_alc883() */
Luke Yelavich2a884642009-01-28 15:58:38 +11007463 case 0x106b3800: /* MacbookPro4,1 - latter revision */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007464 board_config = ALC885_MBP3;
7465 break;
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007466 case 0x106b3f00: /* Macbook 5,1 */
Takashi Iwai7442f9d2009-05-14 18:20:33 +02007467 case 0x106b4000: /* Macbook Pro 5,1 - FIXME: HP jack sense
7468 * seems not working, so apparently
7469 * no perfect solution yet
7470 */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007471 board_config = ALC885_MB5;
7472 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007473 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007474 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007475 if (codec->revision_id == 0x100101 ||
7476 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007477 alc_free(codec);
7478 return patch_alc883(codec);
7479 }
Takashi Iwai6c627f32009-05-18 12:33:36 +02007480 printk(KERN_INFO "hda_codec: Unknown model for %s, "
7481 "trying auto-probe from BIOS...\n",
7482 codec->chip_name);
Tobin Davis081d17c2007-02-15 17:46:18 +01007483 board_config = ALC882_AUTO;
7484 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007485 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007486
Takashi Iwaif95474e2007-07-10 00:47:43 +02007487 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7488
Kailang Yangdf694da2005-12-05 19:42:22 +01007489 if (board_config == ALC882_AUTO) {
7490 /* automatic parse from the BIOS config */
7491 err = alc882_parse_auto_config(codec);
7492 if (err < 0) {
7493 alc_free(codec);
7494 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007495 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007496 printk(KERN_INFO
7497 "hda_codec: Cannot set up configuration "
7498 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007499 board_config = ALC882_3ST_DIG;
7500 }
7501 }
7502
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007503 err = snd_hda_attach_beep_device(codec, 0x1);
7504 if (err < 0) {
7505 alc_free(codec);
7506 return err;
7507 }
7508
Kailang Yangdf694da2005-12-05 19:42:22 +01007509 if (board_config != ALC882_AUTO)
7510 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007511
Kailang Yangdf694da2005-12-05 19:42:22 +01007512 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7513 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007514 /* FIXME: setup DAC5 */
7515 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7516 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007517
Kailang Yangdf694da2005-12-05 19:42:22 +01007518 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7519 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007520
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007521 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007522 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007523 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007524 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007525 /* get type */
7526 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007527 if (wcap != AC_WID_AUD_IN) {
7528 spec->adc_nids = alc882_adc_nids_alt;
7529 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007530 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007531 } else {
7532 spec->adc_nids = alc882_adc_nids;
7533 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007534 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007535 }
7536 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007537 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007538 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007539
Takashi Iwai2134ea42008-01-10 16:53:55 +01007540 spec->vmaster_nid = 0x0c;
7541
Linus Torvalds1da177e2005-04-16 15:20:36 -07007542 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007543 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007544 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007545#ifdef CONFIG_SND_HDA_POWER_SAVE
7546 if (!spec->loopback.amplist)
7547 spec->loopback.amplist = alc882_loopbacks;
7548#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007549 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007550
7551 return 0;
7552}
7553
7554/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007555 * ALC883 support
7556 *
7557 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7558 * configuration. Each pin widget can choose any input DACs and a mixer.
7559 * Each ADC is connected from a mixer of all inputs. This makes possible
7560 * 6-channel independent captures.
7561 *
7562 * In addition, an independent DAC for the multi-playback (not used in this
7563 * driver yet).
7564 */
7565#define ALC883_DIGOUT_NID 0x06
7566#define ALC883_DIGIN_NID 0x0a
7567
Wu Fengguang3ab90932008-11-17 09:51:09 +01007568#define ALC1200_DIGOUT_NID 0x10
7569
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007570static hda_nid_t alc883_dac_nids[4] = {
7571 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007572 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007573};
7574
7575static hda_nid_t alc883_adc_nids[2] = {
7576 /* ADC1-2 */
7577 0x08, 0x09,
7578};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007579
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007580static hda_nid_t alc883_adc_nids_alt[1] = {
7581 /* ADC1 */
7582 0x08,
7583};
7584
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007585static hda_nid_t alc883_adc_nids_rev[2] = {
7586 /* ADC2-1 */
7587 0x09, 0x08
7588};
7589
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007590#define alc889_adc_nids alc880_adc_nids
7591
Takashi Iwaie1406342008-02-11 18:32:32 +01007592static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7593
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007594static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7595
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007596#define alc889_capsrc_nids alc882_capsrc_nids
7597
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007598/* input MUX */
7599/* FIXME: should be a matrix-type input source selection */
7600
7601static struct hda_input_mux alc883_capture_source = {
7602 .num_items = 4,
7603 .items = {
7604 { "Mic", 0x0 },
7605 { "Front Mic", 0x1 },
7606 { "Line", 0x2 },
7607 { "CD", 0x4 },
7608 },
7609};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007610
Jiang zhe17bba1b2008-06-04 12:11:07 +02007611static struct hda_input_mux alc883_3stack_6ch_intel = {
7612 .num_items = 4,
7613 .items = {
7614 { "Mic", 0x1 },
7615 { "Front Mic", 0x0 },
7616 { "Line", 0x2 },
7617 { "CD", 0x4 },
7618 },
7619};
7620
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007621static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7622 .num_items = 2,
7623 .items = {
7624 { "Mic", 0x1 },
7625 { "Line", 0x2 },
7626 },
7627};
7628
Kailang Yang272a5272007-05-14 11:00:38 +02007629static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7630 .num_items = 4,
7631 .items = {
7632 { "Mic", 0x0 },
7633 { "iMic", 0x1 },
7634 { "Line", 0x2 },
7635 { "CD", 0x4 },
7636 },
7637};
7638
Jiang zhefb97dc62008-03-06 11:07:11 +01007639static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7640 .num_items = 2,
7641 .items = {
7642 { "Mic", 0x0 },
7643 { "Int Mic", 0x1 },
7644 },
7645};
7646
Kailang Yange2757d52008-08-26 13:17:46 +02007647static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7648 .num_items = 3,
7649 .items = {
7650 { "Mic", 0x0 },
7651 { "Front Mic", 0x1 },
7652 { "Line", 0x4 },
7653 },
7654};
7655
7656static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7657 .num_items = 2,
7658 .items = {
7659 { "Mic", 0x0 },
7660 { "Line", 0x2 },
7661 },
7662};
7663
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007664static struct hda_input_mux alc889A_mb31_capture_source = {
7665 .num_items = 2,
7666 .items = {
7667 { "Mic", 0x0 },
7668 /* Front Mic (0x01) unused */
7669 { "Line", 0x2 },
7670 /* Line 2 (0x03) unused */
7671 /* CD (0x04) unsused? */
7672 },
7673};
7674
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007675/*
7676 * 2ch mode
7677 */
7678static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7679 { 2, NULL }
7680};
7681
7682/*
7683 * 2ch mode
7684 */
7685static struct hda_verb alc883_3ST_ch2_init[] = {
7686 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7687 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7688 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7689 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7690 { } /* end */
7691};
7692
7693/*
Tobin Davisb2011312007-09-17 12:45:11 +02007694 * 4ch mode
7695 */
7696static struct hda_verb alc883_3ST_ch4_init[] = {
7697 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7698 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7699 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7700 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7701 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7702 { } /* end */
7703};
7704
7705/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007706 * 6ch mode
7707 */
7708static struct hda_verb alc883_3ST_ch6_init[] = {
7709 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7710 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7711 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7712 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7713 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7714 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7715 { } /* end */
7716};
7717
Tobin Davisb2011312007-09-17 12:45:11 +02007718static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007719 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007720 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007721 { 6, alc883_3ST_ch6_init },
7722};
7723
David Heidelberger64a8be72009-06-08 16:15:18 +02007724
7725/*
7726 * 2ch mode
7727 */
7728static struct hda_verb alc883_4ST_ch2_init[] = {
Takashi Iwaif03ecf52009-06-08 16:38:17 +02007729 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
David Heidelberger64a8be72009-06-08 16:15:18 +02007730 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7731 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7732 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7733 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7734 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7735 { } /* end */
7736};
7737
7738/*
7739 * 4ch mode
7740 */
7741static struct hda_verb alc883_4ST_ch4_init[] = {
7742 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7743 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7744 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7745 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7746 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7747 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7748 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7749 { } /* end */
7750};
7751
7752/*
7753 * 6ch mode
7754 */
7755static struct hda_verb alc883_4ST_ch6_init[] = {
7756 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7757 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7758 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7759 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7760 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7761 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7762 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7763 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7764 { } /* end */
7765};
7766
7767/*
7768 * 8ch mode
7769 */
7770static struct hda_verb alc883_4ST_ch8_init[] = {
7771 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7772 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7773 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7774 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7775 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7776 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7777 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7778 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7779 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7780 { } /* end */
7781};
7782
7783static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7784 { 2, alc883_4ST_ch2_init },
7785 { 4, alc883_4ST_ch4_init },
7786 { 6, alc883_4ST_ch6_init },
7787 { 8, alc883_4ST_ch8_init },
7788};
7789
7790
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007791/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007792 * 2ch mode
7793 */
7794static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7795 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7796 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7797 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7798 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7799 { } /* end */
7800};
7801
7802/*
7803 * 4ch mode
7804 */
7805static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7806 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7807 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7808 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7809 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7810 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7811 { } /* end */
7812};
7813
7814/*
7815 * 6ch mode
7816 */
7817static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7818 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7819 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7820 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7821 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7822 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7823 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7824 { } /* end */
7825};
7826
7827static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7828 { 2, alc883_3ST_ch2_intel_init },
7829 { 4, alc883_3ST_ch4_intel_init },
7830 { 6, alc883_3ST_ch6_intel_init },
7831};
7832
7833/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007834 * 6ch mode
7835 */
7836static struct hda_verb alc883_sixstack_ch6_init[] = {
7837 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7838 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7839 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7840 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7841 { } /* end */
7842};
7843
7844/*
7845 * 8ch mode
7846 */
7847static struct hda_verb alc883_sixstack_ch8_init[] = {
7848 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7849 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7850 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7851 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7852 { } /* end */
7853};
7854
7855static struct hda_channel_mode alc883_sixstack_modes[2] = {
7856 { 6, alc883_sixstack_ch6_init },
7857 { 8, alc883_sixstack_ch8_init },
7858};
7859
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007860/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7861static struct hda_verb alc889A_mb31_ch2_init[] = {
7862 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7863 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7864 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7865 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7866 { } /* end */
7867};
7868
7869/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7870static struct hda_verb alc889A_mb31_ch4_init[] = {
7871 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7872 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7873 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7874 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7875 { } /* end */
7876};
7877
7878/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7879static struct hda_verb alc889A_mb31_ch5_init[] = {
7880 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7881 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7882 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7883 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7884 { } /* end */
7885};
7886
7887/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7888static struct hda_verb alc889A_mb31_ch6_init[] = {
7889 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7890 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7891 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7892 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7893 { } /* end */
7894};
7895
7896static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7897 { 2, alc889A_mb31_ch2_init },
7898 { 4, alc889A_mb31_ch4_init },
7899 { 5, alc889A_mb31_ch5_init },
7900 { 6, alc889A_mb31_ch6_init },
7901};
7902
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007903static struct hda_verb alc883_medion_eapd_verbs[] = {
7904 /* eanable EAPD on medion laptop */
7905 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7906 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7907 { }
7908};
7909
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007910/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7911 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7912 */
7913
7914static struct snd_kcontrol_new alc883_base_mixer[] = {
7915 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7916 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7917 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7918 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7919 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7920 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7921 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7922 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7923 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7924 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7925 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7926 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7927 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7928 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7929 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7930 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007931 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007932 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7933 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007934 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007935 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007936 { } /* end */
7937};
7938
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007939static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7940 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7941 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7942 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7943 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7944 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7945 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7946 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7947 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7948 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7949 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7950 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7951 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7952 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007953 { } /* end */
7954};
7955
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007956static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007957 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7958 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7959 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7960 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7961 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7962 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7963 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7964 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7965 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7966 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007967 { } /* end */
7968};
7969
Jiang zhefb97dc62008-03-06 11:07:11 +01007970static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7971 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7972 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7973 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7974 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7975 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7976 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7977 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7978 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7979 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7980 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007981 { } /* end */
7982};
7983
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007984static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7985 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7986 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7987 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7988 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7989 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7990 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7991 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7992 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007993 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007994 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7995 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007996 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007997 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007998 { } /* end */
7999};
8000
8001static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8002 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8003 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8004 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8005 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8006 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8007 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8008 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8009 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8010 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8011 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8012 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8013 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8014 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8015 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008016 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008017 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8018 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008019 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008020 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008021 { } /* end */
8022};
8023
Jiang zhe17bba1b2008-06-04 12:11:07 +02008024static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8025 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8026 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8027 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8028 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8029 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8030 HDA_OUTPUT),
8031 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8032 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8033 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8034 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8035 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8036 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8037 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8038 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8039 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8040 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8041 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8042 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8043 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8044 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008045 { } /* end */
8046};
8047
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008048static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008049 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008050 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008051 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008052 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008053 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8054 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008055 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8056 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008057 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8058 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8059 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8060 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8061 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8062 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008063 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008064 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8065 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008066 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008067 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008068 { } /* end */
8069};
8070
Sasha Alexandrc2592492009-06-16 14:52:54 -04008071static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008072 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8073 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8074 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8075 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8076 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8077 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8078 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8079 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8080 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8081 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8082 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8083 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8084 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8085 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008086 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008087 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008088 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008089};
Kailang Yangccc656c2006-10-17 12:32:26 +02008090
Sasha Alexandrc2592492009-06-16 14:52:54 -04008091static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008092 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8093 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8094 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8095 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8096 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8097 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008098 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008099 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008100 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8101 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8102 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008103 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008104};
Kailang Yangccc656c2006-10-17 12:32:26 +02008105
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008106static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8107 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8108 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008109 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8110 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008111 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8112 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8113 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8114 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008115 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008116};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008117
Kailang Yang272a5272007-05-14 11:00:38 +02008118static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8119 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8120 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8121 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8122 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8123 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8124 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8125 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8126 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8127 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008128 { } /* end */
8129};
8130
8131static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8132 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8133 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8134 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8135 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8136 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8137 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8138 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8139 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8140 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008141 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008142};
Kailang Yang272a5272007-05-14 11:00:38 +02008143
Tobin Davis2880a862007-08-07 11:50:26 +02008144static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008145 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8146 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008147 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008148 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8149 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008150 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8151 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8152 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008153 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008154};
Tobin Davis2880a862007-08-07 11:50:26 +02008155
Kailang Yange2757d52008-08-26 13:17:46 +02008156static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8157 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8158 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8159 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8160 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8161 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8162 0x0d, 1, 0x0, HDA_OUTPUT),
8163 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8164 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8165 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8166 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8167 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008168 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8169 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8170 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8171 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8172 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8173 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8174 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8175 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8176 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8177 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008178 { } /* end */
8179};
8180
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008181static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8182 /* Output mixers */
8183 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8184 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8185 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8186 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8187 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8188 HDA_OUTPUT),
8189 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8190 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8191 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8192 /* Output switches */
8193 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8194 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8195 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8196 /* Boost mixers */
8197 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8198 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8199 /* Input mixers */
8200 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8201 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8202 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8203 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8204 { } /* end */
8205};
8206
Guido Günther3e1647c52009-06-05 00:47:26 +02008207static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8208 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8209 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8210 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8211 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8212 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8213 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8214 { } /* end */
8215};
8216
Kailang Yange2757d52008-08-26 13:17:46 +02008217static struct hda_bind_ctls alc883_bind_cap_vol = {
8218 .ops = &snd_hda_bind_vol,
8219 .values = {
8220 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8221 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8222 0
8223 },
8224};
8225
8226static struct hda_bind_ctls alc883_bind_cap_switch = {
8227 .ops = &snd_hda_bind_sw,
8228 .values = {
8229 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8230 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8231 0
8232 },
8233};
8234
8235static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8236 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8237 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8238 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8239 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8240 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8241 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8242 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8243 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008244 { } /* end */
8245};
8246
8247static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008248 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8249 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8250 {
8251 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8252 /* .name = "Capture Source", */
8253 .name = "Input Source",
8254 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008255 .info = alc_mux_enum_info,
8256 .get = alc_mux_enum_get,
8257 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008258 },
8259 { } /* end */
8260};
8261
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008262static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8263 {
8264 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8265 .name = "Channel Mode",
8266 .info = alc_ch_mode_info,
8267 .get = alc_ch_mode_get,
8268 .put = alc_ch_mode_put,
8269 },
8270 { } /* end */
8271};
8272
8273static struct hda_verb alc883_init_verbs[] = {
8274 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02008275 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008276 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8277 /* ADC2: mute amp left and right */
8278 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8279 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8280 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8281 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8282 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8283 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8284 /* Rear mixer */
8285 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8286 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8287 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8288 /* CLFE mixer */
8289 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8290 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8291 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8292 /* Side mixer */
8293 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8294 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8295 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8296
Takashi Iwaicb53c622007-08-10 17:21:45 +02008297 /* mute analog input loopbacks */
8298 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8299 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8300 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8301 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8302 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008303
8304 /* Front Pin: output 0 (0x0c) */
8305 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8306 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8307 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8308 /* Rear Pin: output 1 (0x0d) */
8309 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8310 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8311 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8312 /* CLFE Pin: output 2 (0x0e) */
8313 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8314 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8315 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8316 /* Side Pin: output 3 (0x0f) */
8317 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8318 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8319 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8320 /* Mic (rear) pin: input vref at 80% */
8321 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8322 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8323 /* Front Mic pin: input vref at 80% */
8324 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8325 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8326 /* Line In pin: input */
8327 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8328 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8329 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8330 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8331 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8332 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8333 /* CD pin widget for input */
8334 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8335
8336 /* FIXME: use matrix-type input source selection */
8337 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8338 /* Input mixer2 */
8339 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008340 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8341 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8342 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008343 /* Input mixer3 */
8344 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008345 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8346 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8347 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008348 { }
8349};
8350
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008351/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008352static void alc883_mitac_init_hook(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008353{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008354 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008355
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008356 spec->autocfg.hp_pins[0] = 0x15;
8357 spec->autocfg.speaker_pins[0] = 0x14;
8358 spec->autocfg.speaker_pins[1] = 0x17;
8359 alc_automute_amp(codec);
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008360}
8361
8362/* auto-toggle front mic */
8363/*
8364static void alc883_mitac_mic_automute(struct hda_codec *codec)
8365{
8366 unsigned int present;
8367 unsigned char bits;
8368
8369 present = snd_hda_codec_read(codec, 0x18, 0,
8370 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8371 bits = present ? HDA_AMP_MUTE : 0;
8372 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8373}
8374*/
8375
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008376static struct hda_verb alc883_mitac_verbs[] = {
8377 /* HP */
8378 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8379 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8380 /* Subwoofer */
8381 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8382 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8383
8384 /* enable unsolicited event */
8385 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8386 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8387
8388 { } /* end */
8389};
8390
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008391static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008392 /* HP */
8393 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8394 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8395 /* Int speaker */
8396 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8397 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8398
8399 /* enable unsolicited event */
8400 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008401 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008402
8403 { } /* end */
8404};
8405
Jiang zhefb97dc62008-03-06 11:07:11 +01008406static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8407 /* HP */
8408 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8409 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8410 /* Subwoofer */
8411 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8412 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8413
8414 /* enable unsolicited event */
8415 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8416
8417 { } /* end */
8418};
8419
Sasha Alexandrc2592492009-06-16 14:52:54 -04008420static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008421 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8422 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8423
8424 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8425 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008426
David Heidelberger64a8be72009-06-08 16:15:18 +02008427/* Connect Line-Out side jack (SPDIF) to Side */
8428 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8429 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8430 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8431/* Connect Mic jack to CLFE */
8432 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8433 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8434 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8435/* Connect Line-in jack to Surround */
8436 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8437 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8438 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8439/* Connect HP out jack to Front */
8440 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8441 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8442 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008443
8444 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008445
8446 { } /* end */
8447};
8448
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008449static struct hda_verb alc883_lenovo_101e_verbs[] = {
8450 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8451 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8452 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8453 { } /* end */
8454};
8455
Kailang Yang272a5272007-05-14 11:00:38 +02008456static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8457 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8458 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8459 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8460 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8461 { } /* end */
8462};
8463
8464static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8465 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8466 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8467 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8468 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8469 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8470 { } /* end */
8471};
8472
Kailang Yang189609a2007-08-20 11:31:23 +02008473static struct hda_verb alc883_haier_w66_verbs[] = {
8474 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8475 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8476
8477 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8478
8479 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8480 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8481 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8482 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8483 { } /* end */
8484};
8485
Kailang Yange2757d52008-08-26 13:17:46 +02008486static struct hda_verb alc888_lenovo_sky_verbs[] = {
8487 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8488 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8489 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8490 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8491 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8492 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8493 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8494 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8495 { } /* end */
8496};
8497
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008498static struct hda_verb alc888_6st_dell_verbs[] = {
8499 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8500 { }
8501};
8502
Guido Günther3e1647c52009-06-05 00:47:26 +02008503static struct hda_verb alc883_vaiott_verbs[] = {
8504 /* HP */
8505 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8506 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8507
8508 /* enable unsolicited event */
8509 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8510
8511 { } /* end */
8512};
8513
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008514static void alc888_3st_hp_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008515{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008516 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008517
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008518 spec->autocfg.hp_pins[0] = 0x1b;
8519 spec->autocfg.speaker_pins[0] = 0x14;
8520 spec->autocfg.speaker_pins[1] = 0x16;
8521 spec->autocfg.speaker_pins[2] = 0x18;
8522 alc_automute_amp(codec);
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008523}
8524
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008525static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008526 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008527 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8528 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008529 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008530 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008531};
8532
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008533/*
8534 * 2ch mode
8535 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008536static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008537 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8538 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8539 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8540 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008541 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008542};
8543
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008544/*
8545 * 4ch mode
8546 */
8547static struct hda_verb alc888_3st_hp_4ch_init[] = {
8548 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8549 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8550 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8551 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8552 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8553 { } /* end */
8554};
8555
8556/*
8557 * 6ch mode
8558 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008559static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008560 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8561 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008562 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008563 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8564 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008565 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8566 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008567};
8568
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008569static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008570 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008571 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008572 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008573};
8574
Kailang Yang272a5272007-05-14 11:00:38 +02008575/* toggle front-jack and RCA according to the hp-jack state */
8576static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8577{
8578 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008579
Kailang Yang272a5272007-05-14 11:00:38 +02008580 present = snd_hda_codec_read(codec, 0x1b, 0,
8581 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008582 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8583 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8584 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8585 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008586}
8587
8588/* toggle RCA according to the front-jack state */
8589static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8590{
8591 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008592
Kailang Yang272a5272007-05-14 11:00:38 +02008593 present = snd_hda_codec_read(codec, 0x14, 0,
8594 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008595 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8596 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008597}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008598
Kailang Yang272a5272007-05-14 11:00:38 +02008599static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8600 unsigned int res)
8601{
8602 if ((res >> 26) == ALC880_HP_EVENT)
8603 alc888_lenovo_ms7195_front_automute(codec);
8604 if ((res >> 26) == ALC880_FRONT_EVENT)
8605 alc888_lenovo_ms7195_rca_automute(codec);
8606}
8607
8608static struct hda_verb alc883_medion_md2_verbs[] = {
8609 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8610 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8611
8612 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8613
8614 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8615 { } /* end */
8616};
8617
8618/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008619static void alc883_medion_md2_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008620{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008621 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008622
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008623 spec->autocfg.hp_pins[0] = 0x14;
8624 spec->autocfg.speaker_pins[0] = 0x15;
8625 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008626}
8627
Kailang Yangccc656c2006-10-17 12:32:26 +02008628/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008629#define alc883_targa_init_hook alc882_targa_init_hook
8630#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008631
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008632static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8633{
8634 unsigned int present;
8635
8636 present = snd_hda_codec_read(codec, 0x18, 0,
8637 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8638 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8639 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8640}
8641
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008642static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008643{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008644 struct alc_spec *spec = codec->spec;
8645
8646 spec->autocfg.hp_pins[0] = 0x15;
8647 spec->autocfg.speaker_pins[0] = 0x14;
8648 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008649 alc883_clevo_m720_mic_automute(codec);
8650}
8651
8652static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008653 unsigned int res)
8654{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008655 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008656 case ALC880_MIC_EVENT:
8657 alc883_clevo_m720_mic_automute(codec);
8658 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008659 default:
8660 alc_automute_amp_unsol_event(codec, res);
8661 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008662 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008663}
8664
Jiang zhefb97dc62008-03-06 11:07:11 +01008665/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008666static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008667{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008668 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008669
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008670 spec->autocfg.hp_pins[0] = 0x14;
8671 spec->autocfg.speaker_pins[0] = 0x15;
8672 alc_automute_amp(codec);
Jiang zhefb97dc62008-03-06 11:07:11 +01008673}
8674
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008675static void alc883_haier_w66_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008676{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008677 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008678
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008679 spec->autocfg.hp_pins[0] = 0x1b;
8680 spec->autocfg.speaker_pins[0] = 0x14;
8681 alc_automute_amp(codec);
Kailang Yang189609a2007-08-20 11:31:23 +02008682}
8683
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008684static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8685{
8686 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008687 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008688
David Heidelberger64a8be72009-06-08 16:15:18 +02008689 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8690 & AC_PINSENSE_PRESENCE;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008691 bits = present ? HDA_AMP_MUTE : 0;
8692 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8693 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008694}
8695
8696static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8697{
8698 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008699 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008700
8701 present = snd_hda_codec_read(codec, 0x1b, 0,
8702 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008703 bits = present ? HDA_AMP_MUTE : 0;
8704 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8705 HDA_AMP_MUTE, bits);
8706 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8707 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008708}
8709
8710static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8711 unsigned int res)
8712{
8713 if ((res >> 26) == ALC880_HP_EVENT)
8714 alc883_lenovo_101e_all_automute(codec);
8715 if ((res >> 26) == ALC880_FRONT_EVENT)
8716 alc883_lenovo_101e_ispeaker_automute(codec);
8717}
8718
Takashi Iwai676a9b52007-08-16 15:23:35 +02008719/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008720static void alc883_acer_aspire_init_hook(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008721{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008722 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008723
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008724 spec->autocfg.hp_pins[0] = 0x14;
8725 spec->autocfg.speaker_pins[0] = 0x15;
8726 spec->autocfg.speaker_pins[1] = 0x16;
8727 alc_automute_amp(codec);
Takashi Iwai676a9b52007-08-16 15:23:35 +02008728}
8729
Kailang Yangd1a991a2007-08-15 16:21:59 +02008730static struct hda_verb alc883_acer_eapd_verbs[] = {
8731 /* HP Pin: output 0 (0x0c) */
8732 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8733 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8734 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8735 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008736 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8737 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008738 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008739 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8740 /* eanable EAPD on medion laptop */
8741 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8742 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008743 /* enable unsolicited event */
8744 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008745 { }
8746};
8747
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008748static void alc888_6st_dell_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008749{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008750 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008751
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008752 spec->autocfg.hp_pins[0] = 0x1b;
8753 spec->autocfg.speaker_pins[0] = 0x14;
8754 spec->autocfg.speaker_pins[1] = 0x15;
8755 spec->autocfg.speaker_pins[2] = 0x16;
8756 spec->autocfg.speaker_pins[3] = 0x17;
8757 alc_automute_amp(codec);
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008758}
8759
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008760static void alc888_lenovo_sky_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008761{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008762 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008763
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008764 spec->autocfg.hp_pins[0] = 0x1b;
8765 spec->autocfg.speaker_pins[0] = 0x14;
8766 spec->autocfg.speaker_pins[1] = 0x15;
8767 spec->autocfg.speaker_pins[2] = 0x16;
8768 spec->autocfg.speaker_pins[3] = 0x17;
8769 spec->autocfg.speaker_pins[4] = 0x1a;
8770 alc_automute_amp(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008771}
8772
Guido Günther3e1647c52009-06-05 00:47:26 +02008773static void alc883_vaiott_init_hook(struct hda_codec *codec)
8774{
8775 struct alc_spec *spec = codec->spec;
8776
8777 spec->autocfg.hp_pins[0] = 0x15;
8778 spec->autocfg.speaker_pins[0] = 0x14;
8779 spec->autocfg.speaker_pins[1] = 0x17;
8780 alc_automute_amp(codec);
8781}
8782
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008783/*
8784 * generic initialization of ADC, input mixers and output mixers
8785 */
8786static struct hda_verb alc883_auto_init_verbs[] = {
8787 /*
8788 * Unmute ADC0-2 and set the default input to mic-in
8789 */
8790 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8791 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8792 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8793 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8794
Takashi Iwaicb53c622007-08-10 17:21:45 +02008795 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008796 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008797 * Note: PASD motherboards uses the Line In 2 as the input for
8798 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008799 */
8800 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008801 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8802 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8803 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8804 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8805 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008806
8807 /*
8808 * Set up output mixers (0x0c - 0x0f)
8809 */
8810 /* set vol=0 to output mixers */
8811 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8812 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8813 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8814 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8815 /* set up input amps for analog loopback */
8816 /* Amp Indices: DAC = 0, mixer = 1 */
8817 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8818 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8819 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8820 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8821 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8822 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8823 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8824 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8825 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8826 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8827
8828 /* FIXME: use matrix-type input source selection */
8829 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8830 /* Input mixer1 */
8831 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8832 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8833 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008834 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008835 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8836 /* Input mixer2 */
8837 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8838 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8839 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008840 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008841 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008842
8843 { }
8844};
8845
Kailang Yange2757d52008-08-26 13:17:46 +02008846static struct hda_verb alc888_asus_m90v_verbs[] = {
8847 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8848 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8849 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8850 /* enable unsolicited event */
8851 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8852 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8853 { } /* end */
8854};
8855
8856static void alc883_nb_mic_automute(struct hda_codec *codec)
8857{
8858 unsigned int present;
8859
8860 present = snd_hda_codec_read(codec, 0x18, 0,
8861 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8862 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8863 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8864 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8865 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8866}
8867
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008868static void alc883_M90V_init_hook(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008869{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008870 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008871
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008872 spec->autocfg.hp_pins[0] = 0x1b;
8873 spec->autocfg.speaker_pins[0] = 0x14;
8874 spec->autocfg.speaker_pins[1] = 0x15;
8875 spec->autocfg.speaker_pins[2] = 0x16;
8876 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008877}
8878
8879static void alc883_mode2_unsol_event(struct hda_codec *codec,
8880 unsigned int res)
8881{
8882 switch (res >> 26) {
Kailang Yange2757d52008-08-26 13:17:46 +02008883 case ALC880_MIC_EVENT:
8884 alc883_nb_mic_automute(codec);
8885 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008886 default:
8887 alc_sku_unsol_event(codec, res);
8888 break;
Kailang Yange2757d52008-08-26 13:17:46 +02008889 }
8890}
8891
8892static void alc883_mode2_inithook(struct hda_codec *codec)
8893{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008894 alc883_M90V_init_hook(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008895 alc883_nb_mic_automute(codec);
8896}
8897
8898static struct hda_verb alc888_asus_eee1601_verbs[] = {
8899 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8900 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8901 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8902 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8903 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8904 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8905 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8906 /* enable unsolicited event */
8907 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8908 { } /* end */
8909};
8910
Kailang Yange2757d52008-08-26 13:17:46 +02008911static void alc883_eee1601_inithook(struct hda_codec *codec)
8912{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008913 struct alc_spec *spec = codec->spec;
8914
8915 spec->autocfg.hp_pins[0] = 0x14;
8916 spec->autocfg.speaker_pins[0] = 0x1b;
8917 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008918}
8919
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008920static struct hda_verb alc889A_mb31_verbs[] = {
8921 /* Init rear pin (used as headphone output) */
8922 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8923 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8924 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8925 /* Init line pin (used as output in 4ch and 6ch mode) */
8926 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8927 /* Init line 2 pin (used as headphone out by default) */
8928 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8929 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8930 { } /* end */
8931};
8932
8933/* Mute speakers according to the headphone jack state */
8934static void alc889A_mb31_automute(struct hda_codec *codec)
8935{
8936 unsigned int present;
8937
8938 /* Mute only in 2ch or 4ch mode */
8939 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8940 == 0x00) {
8941 present = snd_hda_codec_read(codec, 0x15, 0,
8942 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
8943 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8944 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8945 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8946 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8947 }
8948}
8949
8950static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8951{
8952 if ((res >> 26) == ALC880_HP_EVENT)
8953 alc889A_mb31_automute(codec);
8954}
8955
Takashi Iwaicb53c622007-08-10 17:21:45 +02008956#ifdef CONFIG_SND_HDA_POWER_SAVE
8957#define alc883_loopbacks alc880_loopbacks
8958#endif
8959
Sasha Alexandrdef319f2009-06-16 16:00:15 -04008960/* pcm configuration: identical with ALC880 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008961#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8962#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008963#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008964#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8965#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8966
8967/*
8968 * configuration and preset
8969 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008970static const char *alc883_models[ALC883_MODEL_LAST] = {
8971 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8972 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8973 [ALC883_3ST_6ch] = "3stack-6ch",
8974 [ALC883_6ST_DIG] = "6stack-dig",
8975 [ALC883_TARGA_DIG] = "targa-dig",
8976 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02008977 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008978 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008979 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008980 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Hector Martin3b315d72009-06-02 10:54:19 +02008981 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008982 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008983 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008984 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008985 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008986 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8987 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008988 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008989 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008990 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008991 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008992 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008993 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008994 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008995 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008996 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008997 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008998 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c52009-06-05 00:47:26 +02008999 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009000 [ALC883_AUTO] = "auto",
9001};
9002
9003static struct snd_pci_quirk alc883_cfg_tbl[] = {
9004 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009005 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009006 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009007 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009008 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9009 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009010 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009011 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9012 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009013 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
9014 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009015 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9016 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009017 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9018 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaib3bdb302009-02-18 13:16:26 +01009019 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
Takashi Iwai94683502009-02-13 09:31:20 +01009020 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009021 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
9022 ALC888_ACER_ASPIRE_4930G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009023 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
9024 ALC888_ACER_ASPIRE_4930G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009025 /* default Acer -- disabled as it causes more problems.
9026 * model=auto should work fine now
9027 */
9028 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009029 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02009030 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009031 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9032 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009033 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009034 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009035 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009036 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009037 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009038 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009039 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009040 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02009041 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009042 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009043 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009044 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9045 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009046 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009047 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02009048 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009049 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9050 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9051 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02009052 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009053 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009054 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009055 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9056 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9057 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9058 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9059 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9060 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
9061 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9062 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9063 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009064 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009065 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9066 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009067 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009068 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009069 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009070 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009071 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009072 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009073 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009074 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009075 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9076 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009077 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009078 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009079 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009080 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009081 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009082 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009083 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009084 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009085 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009086 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9087 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009088 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009089 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009090 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009091 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009092 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02009093 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9094 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009095 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08009096 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009097 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Guido Günther3e1647c52009-06-05 00:47:26 +02009098 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009099 {}
9100};
9101
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009102static hda_nid_t alc883_slave_dig_outs[] = {
9103 ALC1200_DIGOUT_NID, 0,
9104};
9105
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009106static hda_nid_t alc1200_slave_dig_outs[] = {
9107 ALC883_DIGOUT_NID, 0,
9108};
9109
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009110static struct alc_config_preset alc883_presets[] = {
9111 [ALC883_3ST_2ch_DIG] = {
9112 .mixers = { alc883_3ST_2ch_mixer },
9113 .init_verbs = { alc883_init_verbs },
9114 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9115 .dac_nids = alc883_dac_nids,
9116 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009117 .dig_in_nid = ALC883_DIGIN_NID,
9118 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9119 .channel_mode = alc883_3ST_2ch_modes,
9120 .input_mux = &alc883_capture_source,
9121 },
9122 [ALC883_3ST_6ch_DIG] = {
9123 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9124 .init_verbs = { alc883_init_verbs },
9125 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9126 .dac_nids = alc883_dac_nids,
9127 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009128 .dig_in_nid = ALC883_DIGIN_NID,
9129 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9130 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009131 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009132 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009133 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009134 [ALC883_3ST_6ch] = {
9135 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9136 .init_verbs = { alc883_init_verbs },
9137 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9138 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009139 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9140 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009141 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009142 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009143 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009144 [ALC883_3ST_6ch_INTEL] = {
9145 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9146 .init_verbs = { alc883_init_verbs },
9147 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9148 .dac_nids = alc883_dac_nids,
9149 .dig_out_nid = ALC883_DIGOUT_NID,
9150 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009151 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009152 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9153 .channel_mode = alc883_3ST_6ch_intel_modes,
9154 .need_dac_fix = 1,
9155 .input_mux = &alc883_3stack_6ch_intel,
9156 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009157 [ALC883_6ST_DIG] = {
9158 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9159 .init_verbs = { alc883_init_verbs },
9160 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9161 .dac_nids = alc883_dac_nids,
9162 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009163 .dig_in_nid = ALC883_DIGIN_NID,
9164 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9165 .channel_mode = alc883_sixstack_modes,
9166 .input_mux = &alc883_capture_source,
9167 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009168 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009169 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
9170 .init_verbs = { alc883_init_verbs, alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009171 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9172 .dac_nids = alc883_dac_nids,
9173 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009174 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9175 .channel_mode = alc883_3ST_6ch_modes,
9176 .need_dac_fix = 1,
9177 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009178 .unsol_event = alc883_targa_unsol_event,
9179 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02009180 },
9181 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009182 .mixers = { alc883_targa_2ch_mixer},
9183 .init_verbs = { alc883_init_verbs, alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009184 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9185 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009186 .adc_nids = alc883_adc_nids_alt,
9187 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02009188 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009189 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9190 .channel_mode = alc883_3ST_2ch_modes,
9191 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009192 .unsol_event = alc883_targa_unsol_event,
9193 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02009194 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009195 [ALC883_TARGA_8ch_DIG] = {
9196 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9197 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009198 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009199 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9200 .dac_nids = alc883_dac_nids,
9201 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9202 .adc_nids = alc883_adc_nids_rev,
9203 .capsrc_nids = alc883_capsrc_nids_rev,
9204 .dig_out_nid = ALC883_DIGOUT_NID,
9205 .dig_in_nid = ALC883_DIGIN_NID,
9206 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9207 .channel_mode = alc883_4ST_8ch_modes,
9208 .need_dac_fix = 1,
9209 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009210 .unsol_event = alc883_targa_unsol_event,
9211 .init_hook = alc883_targa_init_hook,
David Heidelberger64a8be72009-06-08 16:15:18 +02009212 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009213 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009214 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009215 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9216 * and the headphone jack. Turn this on and rely on the
9217 * standard mute methods whenever the user wants to turn
9218 * these outputs off.
9219 */
9220 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9221 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9222 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009223 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9224 .channel_mode = alc883_3ST_2ch_modes,
9225 .input_mux = &alc883_capture_source,
9226 },
Tobin Davis2880a862007-08-07 11:50:26 +02009227 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009228 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009229 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009230 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9231 .dac_nids = alc883_dac_nids,
9232 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009233 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9234 .channel_mode = alc883_3ST_2ch_modes,
9235 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009236 .unsol_event = alc_automute_amp_unsol_event,
9237 .init_hook = alc883_acer_aspire_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009238 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009239 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009240 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009241 alc883_chmode_mixer },
9242 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9243 alc888_acer_aspire_4930g_verbs },
9244 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9245 .dac_nids = alc883_dac_nids,
9246 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9247 .adc_nids = alc883_adc_nids_rev,
9248 .capsrc_nids = alc883_capsrc_nids_rev,
9249 .dig_out_nid = ALC883_DIGOUT_NID,
9250 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9251 .channel_mode = alc883_3ST_6ch_modes,
9252 .need_dac_fix = 1,
9253 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009254 ARRAY_SIZE(alc888_2_capture_sources),
9255 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009256 .unsol_event = alc_automute_amp_unsol_event,
9257 .init_hook = alc888_acer_aspire_4930g_init_hook,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009258 },
Hector Martin3b315d72009-06-02 10:54:19 +02009259 [ALC888_ACER_ASPIRE_8930G] = {
9260 .mixers = { alc888_base_mixer,
9261 alc883_chmode_mixer },
9262 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin018df412009-06-04 00:13:40 +02009263 alc889_acer_aspire_8930g_verbs },
Hector Martin3b315d72009-06-02 10:54:19 +02009264 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9265 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009266 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9267 .adc_nids = alc889_adc_nids,
9268 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009269 .dig_out_nid = ALC883_DIGOUT_NID,
9270 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9271 .channel_mode = alc883_3ST_6ch_modes,
9272 .need_dac_fix = 1,
9273 .const_channel_count = 6,
9274 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009275 ARRAY_SIZE(alc889_capture_sources),
9276 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009277 .unsol_event = alc_automute_amp_unsol_event,
Hector Martin018df412009-06-04 00:13:40 +02009278 .init_hook = alc889_acer_aspire_8930g_init_hook,
Hector Martin3b315d72009-06-02 10:54:19 +02009279 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009280 [ALC883_MEDION] = {
9281 .mixers = { alc883_fivestack_mixer,
9282 alc883_chmode_mixer },
9283 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009284 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009285 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9286 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009287 .adc_nids = alc883_adc_nids_alt,
9288 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02009289 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9290 .channel_mode = alc883_sixstack_modes,
9291 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009292 },
Kailang Yang272a5272007-05-14 11:00:38 +02009293 [ALC883_MEDION_MD2] = {
9294 .mixers = { alc883_medion_md2_mixer},
9295 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9296 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9297 .dac_nids = alc883_dac_nids,
9298 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009299 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9300 .channel_mode = alc883_3ST_2ch_modes,
9301 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009302 .unsol_event = alc_automute_amp_unsol_event,
9303 .init_hook = alc883_medion_md2_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +02009304 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009305 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009306 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009307 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9308 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9309 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009310 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9311 .channel_mode = alc883_3ST_2ch_modes,
9312 .input_mux = &alc883_capture_source,
9313 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009314 [ALC883_CLEVO_M720] = {
9315 .mixers = { alc883_clevo_m720_mixer },
9316 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009317 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9318 .dac_nids = alc883_dac_nids,
9319 .dig_out_nid = ALC883_DIGOUT_NID,
9320 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9321 .channel_mode = alc883_3ST_2ch_modes,
9322 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009323 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009324 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009325 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009326 [ALC883_LENOVO_101E_2ch] = {
9327 .mixers = { alc883_lenovo_101e_2ch_mixer},
9328 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9329 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9330 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009331 .adc_nids = alc883_adc_nids_alt,
9332 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009333 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9334 .channel_mode = alc883_3ST_2ch_modes,
9335 .input_mux = &alc883_lenovo_101e_capture_source,
9336 .unsol_event = alc883_lenovo_101e_unsol_event,
9337 .init_hook = alc883_lenovo_101e_all_automute,
9338 },
Kailang Yang272a5272007-05-14 11:00:38 +02009339 [ALC883_LENOVO_NB0763] = {
9340 .mixers = { alc883_lenovo_nb0763_mixer },
9341 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9342 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9343 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009344 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9345 .channel_mode = alc883_3ST_2ch_modes,
9346 .need_dac_fix = 1,
9347 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009348 .unsol_event = alc_automute_amp_unsol_event,
9349 .init_hook = alc883_medion_md2_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02009350 },
9351 [ALC888_LENOVO_MS7195_DIG] = {
9352 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9353 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9354 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9355 .dac_nids = alc883_dac_nids,
9356 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009357 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9358 .channel_mode = alc883_3ST_6ch_modes,
9359 .need_dac_fix = 1,
9360 .input_mux = &alc883_capture_source,
9361 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9362 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009363 },
9364 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009365 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009366 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9367 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9368 .dac_nids = alc883_dac_nids,
9369 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009370 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9371 .channel_mode = alc883_3ST_2ch_modes,
9372 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009373 .unsol_event = alc_automute_amp_unsol_event,
9374 .init_hook = alc883_haier_w66_init_hook,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009375 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009376 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009377 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009378 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009379 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9380 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009381 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9382 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009383 .need_dac_fix = 1,
9384 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009385 .unsol_event = alc_automute_amp_unsol_event,
9386 .init_hook = alc888_3st_hp_init_hook,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009387 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009388 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009389 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009390 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9391 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9392 .dac_nids = alc883_dac_nids,
9393 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009394 .dig_in_nid = ALC883_DIGIN_NID,
9395 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9396 .channel_mode = alc883_sixstack_modes,
9397 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009398 .unsol_event = alc_automute_amp_unsol_event,
9399 .init_hook = alc888_6st_dell_init_hook,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009400 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009401 [ALC883_MITAC] = {
9402 .mixers = { alc883_mitac_mixer },
9403 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9404 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9405 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009406 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9407 .channel_mode = alc883_3ST_2ch_modes,
9408 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009409 .unsol_event = alc_automute_amp_unsol_event,
9410 .init_hook = alc883_mitac_init_hook,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009411 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009412 [ALC883_FUJITSU_PI2515] = {
9413 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9414 .init_verbs = { alc883_init_verbs,
9415 alc883_2ch_fujitsu_pi2515_verbs},
9416 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9417 .dac_nids = alc883_dac_nids,
9418 .dig_out_nid = ALC883_DIGOUT_NID,
9419 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9420 .channel_mode = alc883_3ST_2ch_modes,
9421 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009422 .unsol_event = alc_automute_amp_unsol_event,
9423 .init_hook = alc883_2ch_fujitsu_pi2515_init_hook,
Jiang zhefb97dc62008-03-06 11:07:11 +01009424 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009425 [ALC888_FUJITSU_XA3530] = {
9426 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9427 .init_verbs = { alc883_init_verbs,
9428 alc888_fujitsu_xa3530_verbs },
9429 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9430 .dac_nids = alc883_dac_nids,
9431 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9432 .adc_nids = alc883_adc_nids_rev,
9433 .capsrc_nids = alc883_capsrc_nids_rev,
9434 .dig_out_nid = ALC883_DIGOUT_NID,
9435 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9436 .channel_mode = alc888_4ST_8ch_intel_modes,
9437 .num_mux_defs =
9438 ARRAY_SIZE(alc888_2_capture_sources),
9439 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009440 .unsol_event = alc_automute_amp_unsol_event,
9441 .init_hook = alc888_fujitsu_xa3530_init_hook,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009442 },
Kailang Yange2757d52008-08-26 13:17:46 +02009443 [ALC888_LENOVO_SKY] = {
9444 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9445 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9446 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9447 .dac_nids = alc883_dac_nids,
9448 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009449 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9450 .channel_mode = alc883_sixstack_modes,
9451 .need_dac_fix = 1,
9452 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009453 .unsol_event = alc_automute_amp_unsol_event,
9454 .init_hook = alc888_lenovo_sky_init_hook,
Kailang Yange2757d52008-08-26 13:17:46 +02009455 },
9456 [ALC888_ASUS_M90V] = {
9457 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9458 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9459 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9460 .dac_nids = alc883_dac_nids,
9461 .dig_out_nid = ALC883_DIGOUT_NID,
9462 .dig_in_nid = ALC883_DIGIN_NID,
9463 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9464 .channel_mode = alc883_3ST_6ch_modes,
9465 .need_dac_fix = 1,
9466 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9467 .unsol_event = alc883_mode2_unsol_event,
9468 .init_hook = alc883_mode2_inithook,
9469 },
9470 [ALC888_ASUS_EEE1601] = {
9471 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009472 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009473 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9474 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9475 .dac_nids = alc883_dac_nids,
9476 .dig_out_nid = ALC883_DIGOUT_NID,
9477 .dig_in_nid = ALC883_DIGIN_NID,
9478 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9479 .channel_mode = alc883_3ST_2ch_modes,
9480 .need_dac_fix = 1,
9481 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009482 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009483 .init_hook = alc883_eee1601_inithook,
9484 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009485 [ALC1200_ASUS_P5Q] = {
9486 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9487 .init_verbs = { alc883_init_verbs },
9488 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9489 .dac_nids = alc883_dac_nids,
9490 .dig_out_nid = ALC1200_DIGOUT_NID,
9491 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009492 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009493 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9494 .channel_mode = alc883_sixstack_modes,
9495 .input_mux = &alc883_capture_source,
9496 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009497 [ALC889A_MB31] = {
9498 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9499 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9500 alc880_gpio1_init_verbs },
9501 .adc_nids = alc883_adc_nids,
9502 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9503 .dac_nids = alc883_dac_nids,
9504 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9505 .channel_mode = alc889A_mb31_6ch_modes,
9506 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9507 .input_mux = &alc889A_mb31_capture_source,
9508 .dig_out_nid = ALC883_DIGOUT_NID,
9509 .unsol_event = alc889A_mb31_unsol_event,
9510 .init_hook = alc889A_mb31_automute,
9511 },
Guido Günther3e1647c52009-06-05 00:47:26 +02009512 [ALC883_SONY_VAIO_TT] = {
9513 .mixers = { alc883_vaiott_mixer },
9514 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9515 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9516 .dac_nids = alc883_dac_nids,
9517 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9518 .channel_mode = alc883_3ST_2ch_modes,
9519 .input_mux = &alc883_capture_source,
9520 .unsol_event = alc_automute_amp_unsol_event,
9521 .init_hook = alc883_vaiott_init_hook,
9522 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009523};
9524
9525
9526/*
9527 * BIOS auto configuration
9528 */
9529static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
9530 hda_nid_t nid, int pin_type,
9531 int dac_idx)
9532{
9533 /* set as output */
9534 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009535 int idx;
9536
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009537 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009538 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9539 idx = 4;
9540 else
9541 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009542 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9543
9544}
9545
9546static void alc883_auto_init_multi_out(struct hda_codec *codec)
9547{
9548 struct alc_spec *spec = codec->spec;
9549 int i;
9550
9551 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009552 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009553 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009554 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009555 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009556 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009557 }
9558}
9559
9560static void alc883_auto_init_hp_out(struct hda_codec *codec)
9561{
9562 struct alc_spec *spec = codec->spec;
9563 hda_nid_t pin;
9564
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009565 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009566 if (pin) /* connect to front */
9567 /* use dac 0 */
9568 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009569 pin = spec->autocfg.speaker_pins[0];
9570 if (pin)
9571 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009572}
9573
9574#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
9575#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9576
9577static void alc883_auto_init_analog_input(struct hda_codec *codec)
9578{
9579 struct alc_spec *spec = codec->spec;
9580 int i;
9581
9582 for (i = 0; i < AUTO_PIN_LAST; i++) {
9583 hda_nid_t nid = spec->autocfg.input_pins[i];
9584 if (alc883_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01009585 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01009586 if (nid != ALC883_PIN_CD_NID &&
9587 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009588 snd_hda_codec_write(codec, nid, 0,
9589 AC_VERB_SET_AMP_GAIN_MUTE,
9590 AMP_OUT_MUTE);
9591 }
9592 }
9593}
9594
Takashi Iwaif511b012008-08-15 16:46:42 +02009595#define alc883_auto_init_input_src alc882_auto_init_input_src
9596
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009597/* almost identical with ALC880 parser... */
9598static int alc883_parse_auto_config(struct hda_codec *codec)
9599{
9600 struct alc_spec *spec = codec->spec;
9601 int err = alc880_parse_auto_config(codec);
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009602 struct auto_pin_cfg *cfg = &spec->autocfg;
9603 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009604
9605 if (err < 0)
9606 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009607 else if (!err)
9608 return 0; /* no config found */
9609
9610 err = alc_auto_add_mic_boost(codec);
9611 if (err < 0)
9612 return err;
9613
9614 /* hack - override the init verbs */
9615 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02009616
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009617 /* setup input_mux for ALC889 */
9618 if (codec->vendor_id == 0x10ec0889) {
9619 /* digital-mic input pin is excluded in alc880_auto_create..()
9620 * because it's under 0x18
9621 */
9622 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9623 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9624 struct hda_input_mux *imux = &spec->private_imux[0];
9625 for (i = 1; i < 3; i++)
9626 memcpy(&spec->private_imux[i],
9627 &spec->private_imux[0],
9628 sizeof(spec->private_imux[0]));
9629 imux->items[imux->num_items].label = "Int DMic";
9630 imux->items[imux->num_items].index = 0x0b;
9631 imux->num_items++;
9632 spec->num_mux_defs = 3;
9633 spec->input_mux = spec->private_imux;
9634 }
9635 }
9636
Takashi Iwai776e1842007-08-29 15:07:11 +02009637 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009638}
9639
9640/* additional initialization for auto-configuration model */
9641static void alc883_auto_init(struct hda_codec *codec)
9642{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009643 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009644 alc883_auto_init_multi_out(codec);
9645 alc883_auto_init_hp_out(codec);
9646 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009647 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009648 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009649 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009650}
9651
9652static int patch_alc883(struct hda_codec *codec)
9653{
9654 struct alc_spec *spec;
9655 int err, board_config;
9656
9657 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9658 if (spec == NULL)
9659 return -ENOMEM;
9660
9661 codec->spec = spec;
9662
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009663 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9664
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009665 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9666 alc883_models,
9667 alc883_cfg_tbl);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009668 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
9669 /* Pick up systems that don't supply PCI SSID */
9670 switch (codec->subsystem_id) {
9671 case 0x106b3600: /* Macbook 3.1 */
9672 board_config = ALC889A_MB31;
9673 break;
9674 default:
9675 printk(KERN_INFO
9676 "hda_codec: Unknown model for %s, trying "
9677 "auto-probe from BIOS...\n", codec->chip_name);
9678 board_config = ALC883_AUTO;
9679 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009680 }
9681
9682 if (board_config == ALC883_AUTO) {
9683 /* automatic parse from the BIOS config */
9684 err = alc883_parse_auto_config(codec);
9685 if (err < 0) {
9686 alc_free(codec);
9687 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009688 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009689 printk(KERN_INFO
9690 "hda_codec: Cannot set up configuration "
9691 "from BIOS. Using base mode...\n");
9692 board_config = ALC883_3ST_2ch_DIG;
9693 }
9694 }
9695
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009696 err = snd_hda_attach_beep_device(codec, 0x1);
9697 if (err < 0) {
9698 alc_free(codec);
9699 return err;
9700 }
9701
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009702 if (board_config != ALC883_AUTO)
9703 setup_preset(spec, &alc883_presets[board_config]);
9704
Kailang Yang2f893282008-05-27 12:14:47 +02009705 switch (codec->vendor_id) {
9706 case 0x10ec0888:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009707 if (!spec->num_adc_nids) {
9708 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9709 spec->adc_nids = alc883_adc_nids;
9710 }
9711 if (!spec->capsrc_nids)
9712 spec->capsrc_nids = alc883_capsrc_nids;
9713 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009714 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Kailang Yang2f893282008-05-27 12:14:47 +02009715 break;
9716 case 0x10ec0889:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009717 if (!spec->num_adc_nids) {
9718 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9719 spec->adc_nids = alc889_adc_nids;
9720 }
9721 if (!spec->capsrc_nids)
9722 spec->capsrc_nids = alc889_capsrc_nids;
9723 spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style
9724 capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009725 break;
9726 default:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009727 if (!spec->num_adc_nids) {
9728 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9729 spec->adc_nids = alc883_adc_nids;
9730 }
9731 if (!spec->capsrc_nids)
9732 spec->capsrc_nids = alc883_capsrc_nids;
9733 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009734 break;
9735 }
9736
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009737 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9738 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009739 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009740
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009741 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9742 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9743
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009744 if (!spec->cap_mixer)
9745 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009746 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009747
Takashi Iwai2134ea42008-01-10 16:53:55 +01009748 spec->vmaster_nid = 0x0c;
9749
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009750 codec->patch_ops = alc_patch_ops;
9751 if (board_config == ALC883_AUTO)
9752 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009753
Takashi Iwaicb53c622007-08-10 17:21:45 +02009754#ifdef CONFIG_SND_HDA_POWER_SAVE
9755 if (!spec->loopback.amplist)
9756 spec->loopback.amplist = alc883_loopbacks;
9757#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009758 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009759
9760 return 0;
9761}
9762
9763/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009764 * ALC262 support
9765 */
9766
9767#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9768#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9769
9770#define alc262_dac_nids alc260_dac_nids
9771#define alc262_adc_nids alc882_adc_nids
9772#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009773#define alc262_capsrc_nids alc882_capsrc_nids
9774#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009775
9776#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009777#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009778
Kailang Yang4e555fe2008-08-26 13:05:55 +02009779static hda_nid_t alc262_dmic_adc_nids[1] = {
9780 /* ADC0 */
9781 0x09
9782};
9783
9784static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9785
Kailang Yangdf694da2005-12-05 19:42:22 +01009786static struct snd_kcontrol_new alc262_base_mixer[] = {
9787 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9788 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9789 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9790 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9791 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9792 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9793 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9794 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009795 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009796 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9797 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009798 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009799 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9800 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9801 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9802 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009803 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009804};
9805
Takashi Iwaice875f02008-01-28 18:17:43 +01009806/* update HP, line and mono-out pins according to the master switch */
9807static void alc262_hp_master_update(struct hda_codec *codec)
9808{
9809 struct alc_spec *spec = codec->spec;
9810 int val = spec->master_sw;
9811
9812 /* HP & line-out */
9813 snd_hda_codec_write_cache(codec, 0x1b, 0,
9814 AC_VERB_SET_PIN_WIDGET_CONTROL,
9815 val ? PIN_HP : 0);
9816 snd_hda_codec_write_cache(codec, 0x15, 0,
9817 AC_VERB_SET_PIN_WIDGET_CONTROL,
9818 val ? PIN_HP : 0);
9819 /* mono (speaker) depending on the HP jack sense */
9820 val = val && !spec->jack_present;
9821 snd_hda_codec_write_cache(codec, 0x16, 0,
9822 AC_VERB_SET_PIN_WIDGET_CONTROL,
9823 val ? PIN_OUT : 0);
9824}
9825
9826static void alc262_hp_bpc_automute(struct hda_codec *codec)
9827{
9828 struct alc_spec *spec = codec->spec;
9829 unsigned int presence;
9830 presence = snd_hda_codec_read(codec, 0x1b, 0,
9831 AC_VERB_GET_PIN_SENSE, 0);
9832 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9833 alc262_hp_master_update(codec);
9834}
9835
9836static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9837{
9838 if ((res >> 26) != ALC880_HP_EVENT)
9839 return;
9840 alc262_hp_bpc_automute(codec);
9841}
9842
9843static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9844{
9845 struct alc_spec *spec = codec->spec;
9846 unsigned int presence;
9847 presence = snd_hda_codec_read(codec, 0x15, 0,
9848 AC_VERB_GET_PIN_SENSE, 0);
9849 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9850 alc262_hp_master_update(codec);
9851}
9852
9853static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9854 unsigned int res)
9855{
9856 if ((res >> 26) != ALC880_HP_EVENT)
9857 return;
9858 alc262_hp_wildwest_automute(codec);
9859}
9860
Takashi Iwaib72519b2009-05-08 14:31:55 +02009861#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +01009862
9863static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9864 struct snd_ctl_elem_value *ucontrol)
9865{
9866 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9867 struct alc_spec *spec = codec->spec;
9868 int val = !!*ucontrol->value.integer.value;
9869
9870 if (val == spec->master_sw)
9871 return 0;
9872 spec->master_sw = val;
9873 alc262_hp_master_update(codec);
9874 return 1;
9875}
9876
Takashi Iwaib72519b2009-05-08 14:31:55 +02009877#define ALC262_HP_MASTER_SWITCH \
9878 { \
9879 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9880 .name = "Master Playback Switch", \
9881 .info = snd_ctl_boolean_mono_info, \
9882 .get = alc262_hp_master_sw_get, \
9883 .put = alc262_hp_master_sw_put, \
9884 }
9885
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009886static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009887 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009888 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9889 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9890 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009891 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9892 HDA_OUTPUT),
9893 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9894 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009895 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9896 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009897 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009898 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9899 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009900 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009901 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9902 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9903 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9904 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009905 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9906 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9907 { } /* end */
9908};
9909
Kailang Yangcd7509a2007-01-26 18:33:17 +01009910static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009911 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +01009912 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9913 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9914 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9915 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009916 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9917 HDA_OUTPUT),
9918 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9919 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009920 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9921 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009922 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009923 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9924 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9925 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9926 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009927 { } /* end */
9928};
9929
9930static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9931 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9932 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009933 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009934 { } /* end */
9935};
9936
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009937/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009938static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009939{
9940 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009941
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009942 spec->autocfg.hp_pins[0] = 0x15;
9943 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
9944 alc_automute_amp(codec);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009945}
9946
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009947static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009948 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9949 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009950 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9951 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9952 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9953 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9954 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9955 { } /* end */
9956};
9957
9958static struct hda_verb alc262_hp_t5735_verbs[] = {
9959 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9960 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9961
9962 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9963 { }
9964};
9965
Kailang Yang8c427222008-01-10 13:03:59 +01009966static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009967 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9968 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009969 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9970 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009971 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9972 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9973 { } /* end */
9974};
9975
9976static struct hda_verb alc262_hp_rp5700_verbs[] = {
9977 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9978 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9979 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9980 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9981 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9982 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9983 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9984 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9985 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9986 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9987 {}
9988};
9989
9990static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9991 .num_items = 1,
9992 .items = {
9993 { "Line", 0x1 },
9994 },
9995};
9996
Takashi Iwai42171c12009-05-08 14:11:43 +02009997/* bind hp and internal speaker mute (with plug check) as master switch */
9998static void alc262_hippo_master_update(struct hda_codec *codec)
9999{
10000 struct alc_spec *spec = codec->spec;
10001 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10002 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10003 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10004 unsigned int mute;
10005
10006 /* HP */
10007 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10008 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10009 HDA_AMP_MUTE, mute);
10010 /* mute internal speaker per jack sense */
10011 if (spec->jack_present)
10012 mute = HDA_AMP_MUTE;
10013 if (line_nid)
10014 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10015 HDA_AMP_MUTE, mute);
10016 if (speaker_nid && speaker_nid != line_nid)
10017 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10018 HDA_AMP_MUTE, mute);
10019}
10020
10021#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10022
10023static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10024 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010025{
10026 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010027 struct alc_spec *spec = codec->spec;
10028 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010029
Takashi Iwai42171c12009-05-08 14:11:43 +020010030 if (val == spec->master_sw)
10031 return 0;
10032 spec->master_sw = val;
10033 alc262_hippo_master_update(codec);
10034 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010035}
Takashi Iwai5b319542007-07-26 11:49:22 +020010036
Takashi Iwai42171c12009-05-08 14:11:43 +020010037#define ALC262_HIPPO_MASTER_SWITCH \
10038 { \
10039 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10040 .name = "Master Playback Switch", \
10041 .info = snd_ctl_boolean_mono_info, \
10042 .get = alc262_hippo_master_sw_get, \
10043 .put = alc262_hippo_master_sw_put, \
10044 }
10045
10046static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10047 ALC262_HIPPO_MASTER_SWITCH,
10048 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10049 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10050 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10051 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10052 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10053 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10054 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10055 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10056 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10057 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10058 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10059 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10060 { } /* end */
10061};
10062
10063static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10064 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10065 ALC262_HIPPO_MASTER_SWITCH,
10066 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10067 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10068 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10069 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10070 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10071 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10072 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10073 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10074 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10075 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10076 { } /* end */
10077};
10078
10079/* mute/unmute internal speaker according to the hp jack and mute state */
10080static void alc262_hippo_automute(struct hda_codec *codec)
10081{
10082 struct alc_spec *spec = codec->spec;
10083 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10084 unsigned int present;
10085
10086 /* need to execute and sync at first */
10087 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
10088 present = snd_hda_codec_read(codec, hp_nid, 0,
10089 AC_VERB_GET_PIN_SENSE, 0);
10090 spec->jack_present = (present & 0x80000000) != 0;
10091 alc262_hippo_master_update(codec);
10092}
10093
10094static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10095{
10096 if ((res >> 26) != ALC880_HP_EVENT)
10097 return;
10098 alc262_hippo_automute(codec);
10099}
10100
10101static void alc262_hippo_init_hook(struct hda_codec *codec)
10102{
10103 struct alc_spec *spec = codec->spec;
10104
10105 spec->autocfg.hp_pins[0] = 0x15;
10106 spec->autocfg.speaker_pins[0] = 0x14;
10107 alc262_hippo_automute(codec);
10108}
10109
10110static void alc262_hippo1_init_hook(struct hda_codec *codec)
10111{
10112 struct alc_spec *spec = codec->spec;
10113
10114 spec->autocfg.hp_pins[0] = 0x1b;
10115 spec->autocfg.speaker_pins[0] = 0x14;
10116 alc262_hippo_automute(codec);
10117}
10118
10119
Kailang Yang272a5272007-05-14 11:00:38 +020010120static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010121 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010122 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010123 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10124 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10125 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10126 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10127 { } /* end */
10128};
10129
Kailang Yang83c34212007-07-05 11:43:05 +020010130static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010131 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10132 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010133 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10134 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10135 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10136 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10137 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10138 { } /* end */
10139};
Kailang Yang272a5272007-05-14 11:00:38 +020010140
Tony Vroonba340e82009-02-02 19:01:30 +000010141static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10142 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10143 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10144 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10145 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10146 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10147 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10148 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10149 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10150 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10151 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10152 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10153 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10154 { } /* end */
10155};
10156
10157static struct hda_verb alc262_tyan_verbs[] = {
10158 /* Headphone automute */
10159 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10160 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10161 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10162
10163 /* P11 AUX_IN, white 4-pin connector */
10164 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10165 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10166 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10167 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10168
10169 {}
10170};
10171
10172/* unsolicited event for HP jack sensing */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010173static void alc262_tyan_init_hook(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010174{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010175 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010176
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010177 spec->autocfg.hp_pins[0] = 0x1b;
10178 spec->autocfg.speaker_pins[0] = 0x15;
10179 alc_automute_amp(codec);
Tony Vroonba340e82009-02-02 19:01:30 +000010180}
10181
Tony Vroonba340e82009-02-02 19:01:30 +000010182
Kailang Yangdf694da2005-12-05 19:42:22 +010010183#define alc262_capture_mixer alc882_capture_mixer
10184#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10185
10186/*
10187 * generic initialization of ADC, input mixers and output mixers
10188 */
10189static struct hda_verb alc262_init_verbs[] = {
10190 /*
10191 * Unmute ADC0-2 and set the default input to mic-in
10192 */
10193 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10194 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10195 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10196 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10197 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10198 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10199
Takashi Iwaicb53c622007-08-10 17:21:45 +020010200 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010201 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010202 * Note: PASD motherboards uses the Line In 2 as the input for
10203 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010204 */
10205 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010206 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10207 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10208 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10209 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10210 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010211
10212 /*
10213 * Set up output mixers (0x0c - 0x0e)
10214 */
10215 /* set vol=0 to output mixers */
10216 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10217 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10218 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10219 /* set up input amps for analog loopback */
10220 /* Amp Indices: DAC = 0, mixer = 1 */
10221 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10222 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10223 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10224 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10225 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10226 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10227
10228 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10229 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10230 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10231 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10232 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10233 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10234
10235 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10236 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10237 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10238 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10239 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010240
Kailang Yangdf694da2005-12-05 19:42:22 +010010241 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10242 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010243
Kailang Yangdf694da2005-12-05 19:42:22 +010010244 /* FIXME: use matrix-type input source selection */
10245 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10246 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10247 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10248 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10249 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10250 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10251 /* Input mixer2 */
10252 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10253 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10254 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10255 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10256 /* Input mixer3 */
10257 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10258 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10259 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010260 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010261
10262 { }
10263};
10264
Kailang Yang4e555fe2008-08-26 13:05:55 +020010265static struct hda_verb alc262_eapd_verbs[] = {
10266 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10267 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10268 { }
10269};
10270
Kailang Yangccc656c2006-10-17 12:32:26 +020010271static struct hda_verb alc262_hippo_unsol_verbs[] = {
10272 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10273 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10274 {}
10275};
10276
10277static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10278 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10279 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10280 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10281
10282 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10283 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10284 {}
10285};
10286
Kailang Yang272a5272007-05-14 11:00:38 +020010287static struct hda_verb alc262_sony_unsol_verbs[] = {
10288 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10289 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10290 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10291
10292 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10293 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010294 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010295};
10296
Kailang Yang4e555fe2008-08-26 13:05:55 +020010297static struct hda_input_mux alc262_dmic_capture_source = {
10298 .num_items = 2,
10299 .items = {
10300 { "Int DMic", 0x9 },
10301 { "Mic", 0x0 },
10302 },
10303};
10304
10305static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10306 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10307 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10308 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10309 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10310 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010311 { } /* end */
10312};
10313
10314static struct hda_verb alc262_toshiba_s06_verbs[] = {
10315 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10316 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10317 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10318 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10319 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10320 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10321 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10322 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10323 {}
10324};
10325
10326static void alc262_dmic_automute(struct hda_codec *codec)
10327{
10328 unsigned int present;
10329
10330 present = snd_hda_codec_read(codec, 0x18, 0,
10331 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10332 snd_hda_codec_write(codec, 0x22, 0,
10333 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
10334}
10335
Kailang Yang4e555fe2008-08-26 13:05:55 +020010336
10337/* unsolicited event for HP jack sensing */
10338static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
10339 unsigned int res)
10340{
Kailang Yang4e555fe2008-08-26 13:05:55 +020010341 if ((res >> 26) == ALC880_MIC_EVENT)
10342 alc262_dmic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010343 else
10344 alc_sku_unsol_event(codec, res);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010345}
10346
10347static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
10348{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010349 struct alc_spec *spec = codec->spec;
10350
10351 spec->autocfg.hp_pins[0] = 0x15;
10352 spec->autocfg.speaker_pins[0] = 0x14;
10353 alc_automute_pin(codec);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010354 alc262_dmic_automute(codec);
10355}
10356
Takashi Iwai834be882006-03-01 14:16:17 +010010357/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010358 * nec model
10359 * 0x15 = headphone
10360 * 0x16 = internal speaker
10361 * 0x18 = external mic
10362 */
10363
10364static struct snd_kcontrol_new alc262_nec_mixer[] = {
10365 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10366 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10367
10368 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10369 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10370 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10371
10372 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10373 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10374 { } /* end */
10375};
10376
10377static struct hda_verb alc262_nec_verbs[] = {
10378 /* Unmute Speaker */
10379 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10380
10381 /* Headphone */
10382 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10383 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10384
10385 /* External mic to headphone */
10386 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10387 /* External mic to speaker */
10388 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10389 {}
10390};
10391
10392/*
Takashi Iwai834be882006-03-01 14:16:17 +010010393 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010394 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10395 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010396 */
10397
10398#define ALC_HP_EVENT 0x37
10399
10400static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10401 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10402 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010403 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10404 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010405 {}
10406};
10407
Jiang zhe0e31daf2008-03-20 12:12:39 +010010408static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10409 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10410 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10411 {}
10412};
10413
Takashi Iwai834be882006-03-01 14:16:17 +010010414static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010415 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010416 .items = {
10417 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010418 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010419 { "CD", 0x4 },
10420 },
10421};
10422
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010423static struct hda_input_mux alc262_HP_capture_source = {
10424 .num_items = 5,
10425 .items = {
10426 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010427 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010428 { "Line", 0x2 },
10429 { "CD", 0x4 },
10430 { "AUX IN", 0x6 },
10431 },
10432};
10433
zhejiangaccbe492007-08-31 12:36:05 +020010434static struct hda_input_mux alc262_HP_D7000_capture_source = {
10435 .num_items = 4,
10436 .items = {
10437 { "Mic", 0x0 },
10438 { "Front Mic", 0x2 },
10439 { "Line", 0x1 },
10440 { "CD", 0x4 },
10441 },
10442};
10443
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010444/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010445static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10446{
10447 struct alc_spec *spec = codec->spec;
10448 unsigned int mute;
10449
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010450 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010451 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010452 /* need to execute and sync at first */
10453 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010454 /* check laptop HP jack */
10455 present = snd_hda_codec_read(codec, 0x14, 0,
10456 AC_VERB_GET_PIN_SENSE, 0);
10457 /* need to execute and sync at first */
10458 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10459 /* check docking HP jack */
10460 present |= snd_hda_codec_read(codec, 0x1b, 0,
10461 AC_VERB_GET_PIN_SENSE, 0);
10462 if (present & AC_PINSENSE_PRESENCE)
10463 spec->jack_present = 1;
10464 else
10465 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010466 spec->sense_updated = 1;
10467 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010468 /* unmute internal speaker only if both HPs are unplugged and
10469 * master switch is on
10470 */
10471 if (spec->jack_present)
10472 mute = HDA_AMP_MUTE;
10473 else
Takashi Iwai834be882006-03-01 14:16:17 +010010474 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010475 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10476 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010477}
10478
10479/* unsolicited event for HP jack sensing */
10480static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10481 unsigned int res)
10482{
10483 if ((res >> 26) != ALC_HP_EVENT)
10484 return;
10485 alc262_fujitsu_automute(codec, 1);
10486}
10487
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010488static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10489{
10490 alc262_fujitsu_automute(codec, 1);
10491}
10492
Takashi Iwai834be882006-03-01 14:16:17 +010010493/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010494static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10495 .ops = &snd_hda_bind_vol,
10496 .values = {
10497 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10498 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10499 0
10500 },
10501};
Takashi Iwai834be882006-03-01 14:16:17 +010010502
Jiang zhe0e31daf2008-03-20 12:12:39 +010010503/* mute/unmute internal speaker according to the hp jack and mute state */
10504static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10505{
10506 struct alc_spec *spec = codec->spec;
10507 unsigned int mute;
10508
10509 if (force || !spec->sense_updated) {
10510 unsigned int present_int_hp;
10511 /* need to execute and sync at first */
10512 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10513 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10514 AC_VERB_GET_PIN_SENSE, 0);
10515 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10516 spec->sense_updated = 1;
10517 }
10518 if (spec->jack_present) {
10519 /* mute internal speaker */
10520 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10521 HDA_AMP_MUTE, HDA_AMP_MUTE);
10522 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10523 HDA_AMP_MUTE, HDA_AMP_MUTE);
10524 } else {
10525 /* unmute internal speaker if necessary */
10526 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10527 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10528 HDA_AMP_MUTE, mute);
10529 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10530 HDA_AMP_MUTE, mute);
10531 }
10532}
10533
10534/* unsolicited event for HP jack sensing */
10535static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10536 unsigned int res)
10537{
10538 if ((res >> 26) != ALC_HP_EVENT)
10539 return;
10540 alc262_lenovo_3000_automute(codec, 1);
10541}
10542
Takashi Iwai834be882006-03-01 14:16:17 +010010543/* bind hp and internal speaker mute (with plug check) */
10544static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10545 struct snd_ctl_elem_value *ucontrol)
10546{
10547 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10548 long *valp = ucontrol->value.integer.value;
10549 int change;
10550
Tony Vroon5d9fab22008-03-14 17:09:18 +010010551 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10552 HDA_AMP_MUTE,
10553 valp ? 0 : HDA_AMP_MUTE);
10554 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10555 HDA_AMP_MUTE,
10556 valp ? 0 : HDA_AMP_MUTE);
10557
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010558 if (change)
10559 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010560 return change;
10561}
10562
10563static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010564 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010565 {
10566 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10567 .name = "Master Playback Switch",
10568 .info = snd_hda_mixer_amp_switch_info,
10569 .get = snd_hda_mixer_amp_switch_get,
10570 .put = alc262_fujitsu_master_sw_put,
10571 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10572 },
10573 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10574 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10575 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10576 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10577 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010578 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10579 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10580 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010581 { } /* end */
10582};
10583
Jiang zhe0e31daf2008-03-20 12:12:39 +010010584/* bind hp and internal speaker mute (with plug check) */
10585static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10586 struct snd_ctl_elem_value *ucontrol)
10587{
10588 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10589 long *valp = ucontrol->value.integer.value;
10590 int change;
10591
10592 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10593 HDA_AMP_MUTE,
10594 valp ? 0 : HDA_AMP_MUTE);
10595
10596 if (change)
10597 alc262_lenovo_3000_automute(codec, 0);
10598 return change;
10599}
10600
10601static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10602 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10603 {
10604 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10605 .name = "Master Playback Switch",
10606 .info = snd_hda_mixer_amp_switch_info,
10607 .get = snd_hda_mixer_amp_switch_get,
10608 .put = alc262_lenovo_3000_master_sw_put,
10609 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10610 },
10611 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10612 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10613 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10614 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10615 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10616 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10617 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10618 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10619 { } /* end */
10620};
10621
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010622static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10623 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010624 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010625 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10626 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10627 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10628 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10629 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10630 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10631 { } /* end */
10632};
10633
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010634/* additional init verbs for Benq laptops */
10635static struct hda_verb alc262_EAPD_verbs[] = {
10636 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10637 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10638 {}
10639};
10640
Kailang Yang83c34212007-07-05 11:43:05 +020010641static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10642 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10643 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10644
10645 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10646 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10647 {}
10648};
10649
Tobin Davisf651b502007-10-26 12:40:47 +020010650/* Samsung Q1 Ultra Vista model setup */
10651static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010652 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10653 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010654 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10655 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10656 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010657 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010658 { } /* end */
10659};
10660
10661static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010662 /* output mixer */
10663 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10664 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10665 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10666 /* speaker */
10667 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10668 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10669 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10670 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10671 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010672 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010673 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10674 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10675 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10676 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10677 /* internal mic */
10678 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10679 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10680 /* ADC, choose mic */
10681 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10682 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10683 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10684 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10685 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10686 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10687 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10688 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10689 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10690 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010691 {}
10692};
10693
Tobin Davisf651b502007-10-26 12:40:47 +020010694/* mute/unmute internal speaker according to the hp jack and mute state */
10695static void alc262_ultra_automute(struct hda_codec *codec)
10696{
10697 struct alc_spec *spec = codec->spec;
10698 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010699
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010700 mute = 0;
10701 /* auto-mute only when HP is used as HP */
10702 if (!spec->cur_mux[0]) {
10703 unsigned int present;
10704 /* need to execute and sync at first */
10705 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10706 present = snd_hda_codec_read(codec, 0x15, 0,
10707 AC_VERB_GET_PIN_SENSE, 0);
10708 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10709 if (spec->jack_present)
10710 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010711 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010712 /* mute/unmute internal speaker */
10713 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10714 HDA_AMP_MUTE, mute);
10715 /* mute/unmute HP */
10716 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10717 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010718}
10719
10720/* unsolicited event for HP jack sensing */
10721static void alc262_ultra_unsol_event(struct hda_codec *codec,
10722 unsigned int res)
10723{
10724 if ((res >> 26) != ALC880_HP_EVENT)
10725 return;
10726 alc262_ultra_automute(codec);
10727}
10728
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010729static struct hda_input_mux alc262_ultra_capture_source = {
10730 .num_items = 2,
10731 .items = {
10732 { "Mic", 0x1 },
10733 { "Headphone", 0x7 },
10734 },
10735};
10736
10737static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10738 struct snd_ctl_elem_value *ucontrol)
10739{
10740 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10741 struct alc_spec *spec = codec->spec;
10742 int ret;
10743
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010744 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010745 if (!ret)
10746 return 0;
10747 /* reprogram the HP pin as mic or HP according to the input source */
10748 snd_hda_codec_write_cache(codec, 0x15, 0,
10749 AC_VERB_SET_PIN_WIDGET_CONTROL,
10750 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10751 alc262_ultra_automute(codec); /* mute/unmute HP */
10752 return ret;
10753}
10754
10755static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10756 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10757 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10758 {
10759 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10760 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010761 .info = alc_mux_enum_info,
10762 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010763 .put = alc262_ultra_mux_enum_put,
10764 },
10765 { } /* end */
10766};
10767
Kailang Yangdf694da2005-12-05 19:42:22 +010010768/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010769static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10770 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010771{
10772 hda_nid_t nid;
10773 int err;
10774
10775 spec->multiout.num_dacs = 1; /* only use one dac */
10776 spec->multiout.dac_nids = spec->private_dac_nids;
10777 spec->multiout.dac_nids[0] = 2;
10778
10779 nid = cfg->line_out_pins[0];
10780 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010781 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10782 "Front Playback Volume",
10783 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10784 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010785 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010786 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10787 "Front Playback Switch",
10788 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10789 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010790 return err;
10791 }
10792
Takashi Iwai82bc9552006-03-21 11:24:42 +010010793 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010794 if (nid) {
10795 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010796 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10797 "Speaker Playback Volume",
10798 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10799 HDA_OUTPUT));
10800 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010801 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010802 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10803 "Speaker Playback Switch",
10804 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10805 HDA_OUTPUT));
10806 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010807 return err;
10808 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010809 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10810 "Speaker Playback Switch",
10811 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10812 HDA_OUTPUT));
10813 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010814 return err;
10815 }
10816 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010817 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010818 if (nid) {
10819 /* spec->multiout.hp_nid = 2; */
10820 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010821 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10822 "Headphone Playback Volume",
10823 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10824 HDA_OUTPUT));
10825 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010826 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010827 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10828 "Headphone Playback Switch",
10829 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10830 HDA_OUTPUT));
10831 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010832 return err;
10833 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010834 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10835 "Headphone Playback Switch",
10836 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10837 HDA_OUTPUT));
10838 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010839 return err;
10840 }
10841 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010842 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010843}
10844
10845/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010846#define alc262_auto_create_analog_input_ctls \
10847 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010848
10849/*
10850 * generic initialization of ADC, input mixers and output mixers
10851 */
10852static struct hda_verb alc262_volume_init_verbs[] = {
10853 /*
10854 * Unmute ADC0-2 and set the default input to mic-in
10855 */
10856 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10857 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10858 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10859 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10860 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10861 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10862
Takashi Iwaicb53c622007-08-10 17:21:45 +020010863 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010864 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010865 * Note: PASD motherboards uses the Line In 2 as the input for
10866 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010867 */
10868 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010869 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10870 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10871 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10872 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10873 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010874
10875 /*
10876 * Set up output mixers (0x0c - 0x0f)
10877 */
10878 /* set vol=0 to output mixers */
10879 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10880 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10881 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010882
Kailang Yangdf694da2005-12-05 19:42:22 +010010883 /* set up input amps for analog loopback */
10884 /* Amp Indices: DAC = 0, mixer = 1 */
10885 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10886 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10887 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10888 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10889 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10890 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10891
10892 /* FIXME: use matrix-type input source selection */
10893 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10894 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10895 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10896 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10897 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10898 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10899 /* Input mixer2 */
10900 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10901 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10902 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10903 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10904 /* Input mixer3 */
10905 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10906 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10907 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10908 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10909
10910 { }
10911};
10912
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010913static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10914 /*
10915 * Unmute ADC0-2 and set the default input to mic-in
10916 */
10917 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10918 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10919 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10920 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10921 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10922 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10923
Takashi Iwaicb53c622007-08-10 17:21:45 +020010924 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010925 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010926 * Note: PASD motherboards uses the Line In 2 as the input for
10927 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010928 */
10929 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010930 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10931 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10932 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10933 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10934 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10935 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10936 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010937
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010938 /*
10939 * Set up output mixers (0x0c - 0x0e)
10940 */
10941 /* set vol=0 to output mixers */
10942 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10943 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10944 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10945
10946 /* set up input amps for analog loopback */
10947 /* Amp Indices: DAC = 0, mixer = 1 */
10948 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10949 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10950 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10951 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10952 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10953 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10954
Takashi Iwaice875f02008-01-28 18:17:43 +010010955 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010956 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10957 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10958
10959 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10960 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10961
10962 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10963 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10964
10965 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10966 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10967 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10968 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10969 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10970
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010971 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010972 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10973 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010974 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010975 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10976 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10977
10978
10979 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010980 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
10981 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010982 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010983 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10984 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10985 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10986 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10987 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
10988 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
10989 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
10990 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010991 /* Input mixer2 */
10992 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010993 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10994 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10995 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10996 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10997 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
10998 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
10999 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11000 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011001 /* Input mixer3 */
11002 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011003 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11004 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11005 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11006 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11007 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11008 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11009 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11010 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011011
Takashi Iwaice875f02008-01-28 18:17:43 +010011012 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11013
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011014 { }
11015};
11016
Kailang Yangcd7509a2007-01-26 18:33:17 +010011017static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11018 /*
11019 * Unmute ADC0-2 and set the default input to mic-in
11020 */
11021 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11022 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11023 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11024 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11025 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11026 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11027
Takashi Iwaicb53c622007-08-10 17:21:45 +020011028 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011029 * mixer widget
11030 * Note: PASD motherboards uses the Line In 2 as the input for front
11031 * panel mic (mic 2)
11032 */
11033 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011034 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11035 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11036 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11037 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11038 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11039 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11040 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11041 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011042 /*
11043 * Set up output mixers (0x0c - 0x0e)
11044 */
11045 /* set vol=0 to output mixers */
11046 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11047 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11048 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11049
11050 /* set up input amps for analog loopback */
11051 /* Amp Indices: DAC = 0, mixer = 1 */
11052 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11053 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11054 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11055 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11056 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11057 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11058
11059
11060 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11061 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11062 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11063 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11064 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11065 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11066 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11067
11068 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11069 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11070
11071 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11072 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11073
11074 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11075 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11076 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11077 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11078 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11079 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11080
11081 /* FIXME: use matrix-type input source selection */
11082 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11083 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11084 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11085 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11086 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11087 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11088 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11089 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11090 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11091 /* Input mixer2 */
11092 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11093 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11094 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11095 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11096 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11097 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11098 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11099 /* Input mixer3 */
11100 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11101 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11102 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11103 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11104 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11105 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11106 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11107
Takashi Iwaice875f02008-01-28 18:17:43 +010011108 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11109
Kailang Yangcd7509a2007-01-26 18:33:17 +010011110 { }
11111};
11112
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011113static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11114
11115 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11116 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11117 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11118
11119 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11120 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11121 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11122 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11123
11124 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11125 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11126 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11127 {}
11128};
11129
11130
Takashi Iwaicb53c622007-08-10 17:21:45 +020011131#ifdef CONFIG_SND_HDA_POWER_SAVE
11132#define alc262_loopbacks alc880_loopbacks
11133#endif
11134
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011135/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011136#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11137#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11138#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11139#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11140
11141/*
11142 * BIOS auto configuration
11143 */
11144static int alc262_parse_auto_config(struct hda_codec *codec)
11145{
11146 struct alc_spec *spec = codec->spec;
11147 int err;
11148 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11149
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011150 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11151 alc262_ignore);
11152 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011153 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011154 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011155 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011156 spec->multiout.max_channels = 2;
11157 spec->no_analog = 1;
11158 goto dig_only;
11159 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011160 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011161 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011162 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11163 if (err < 0)
11164 return err;
11165 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
11166 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011167 return err;
11168
11169 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11170
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011171 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011172 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011173 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011174 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011175 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011176 if (spec->autocfg.dig_in_pin)
11177 spec->dig_in_nid = ALC262_DIGIN_NID;
11178
Takashi Iwai603c4012008-07-30 15:01:44 +020011179 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011180 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011181
Takashi Iwaid88897e2008-10-31 15:01:37 +010011182 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011183 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011184 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011185
Takashi Iwai776e1842007-08-29 15:07:11 +020011186 err = alc_auto_add_mic_boost(codec);
11187 if (err < 0)
11188 return err;
11189
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011190 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11191
Kailang Yangdf694da2005-12-05 19:42:22 +010011192 return 1;
11193}
11194
11195#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11196#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11197#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011198#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011199
11200
11201/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011202static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011203{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011204 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011205 alc262_auto_init_multi_out(codec);
11206 alc262_auto_init_hp_out(codec);
11207 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011208 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011209 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011210 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011211}
11212
11213/*
11214 * configuration and preset
11215 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011216static const char *alc262_models[ALC262_MODEL_LAST] = {
11217 [ALC262_BASIC] = "basic",
11218 [ALC262_HIPPO] = "hippo",
11219 [ALC262_HIPPO_1] = "hippo_1",
11220 [ALC262_FUJITSU] = "fujitsu",
11221 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011222 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011223 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011224 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011225 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011226 [ALC262_BENQ_T31] = "benq-t31",
11227 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011228 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011229 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011230 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011231 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011232 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011233 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011234 [ALC262_AUTO] = "auto",
11235};
11236
11237static struct snd_pci_quirk alc262_cfg_tbl[] = {
11238 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011239 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011240 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11241 ALC262_HP_BPC),
11242 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11243 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011244 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11245 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011246 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011247 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011248 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011249 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011250 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011251 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011252 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011253 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011254 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11255 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11256 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011257 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11258 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011259 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011260 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011261 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011262 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011263 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwaif872a912009-02-26 00:57:01 +010011264 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11265 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090011266 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011267 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011268 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011269 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011270 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011271 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011272 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11273 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011274 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011275 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011276 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011277 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011278 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011279 {}
11280};
11281
11282static struct alc_config_preset alc262_presets[] = {
11283 [ALC262_BASIC] = {
11284 .mixers = { alc262_base_mixer },
11285 .init_verbs = { alc262_init_verbs },
11286 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11287 .dac_nids = alc262_dac_nids,
11288 .hp_nid = 0x03,
11289 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11290 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011291 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011292 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011293 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011294 .mixers = { alc262_hippo_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +020011295 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
11296 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11297 .dac_nids = alc262_dac_nids,
11298 .hp_nid = 0x03,
11299 .dig_out_nid = ALC262_DIGOUT_NID,
11300 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11301 .channel_mode = alc262_modes,
11302 .input_mux = &alc262_capture_source,
11303 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011304 .init_hook = alc262_hippo_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011305 },
11306 [ALC262_HIPPO_1] = {
11307 .mixers = { alc262_hippo1_mixer },
11308 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11309 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11310 .dac_nids = alc262_dac_nids,
11311 .hp_nid = 0x02,
11312 .dig_out_nid = ALC262_DIGOUT_NID,
11313 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11314 .channel_mode = alc262_modes,
11315 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011316 .unsol_event = alc262_hippo_unsol_event,
11317 .init_hook = alc262_hippo1_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011318 },
Takashi Iwai834be882006-03-01 14:16:17 +010011319 [ALC262_FUJITSU] = {
11320 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011321 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11322 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011323 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11324 .dac_nids = alc262_dac_nids,
11325 .hp_nid = 0x03,
11326 .dig_out_nid = ALC262_DIGOUT_NID,
11327 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11328 .channel_mode = alc262_modes,
11329 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011330 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011331 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011332 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011333 [ALC262_HP_BPC] = {
11334 .mixers = { alc262_HP_BPC_mixer },
11335 .init_verbs = { alc262_HP_BPC_init_verbs },
11336 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11337 .dac_nids = alc262_dac_nids,
11338 .hp_nid = 0x03,
11339 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11340 .channel_mode = alc262_modes,
11341 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011342 .unsol_event = alc262_hp_bpc_unsol_event,
11343 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011344 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011345 [ALC262_HP_BPC_D7000_WF] = {
11346 .mixers = { alc262_HP_BPC_WildWest_mixer },
11347 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11348 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11349 .dac_nids = alc262_dac_nids,
11350 .hp_nid = 0x03,
11351 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11352 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011353 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011354 .unsol_event = alc262_hp_wildwest_unsol_event,
11355 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011356 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011357 [ALC262_HP_BPC_D7000_WL] = {
11358 .mixers = { alc262_HP_BPC_WildWest_mixer,
11359 alc262_HP_BPC_WildWest_option_mixer },
11360 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11361 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11362 .dac_nids = alc262_dac_nids,
11363 .hp_nid = 0x03,
11364 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11365 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011366 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011367 .unsol_event = alc262_hp_wildwest_unsol_event,
11368 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011369 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011370 [ALC262_HP_TC_T5735] = {
11371 .mixers = { alc262_hp_t5735_mixer },
11372 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11373 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11374 .dac_nids = alc262_dac_nids,
11375 .hp_nid = 0x03,
11376 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11377 .channel_mode = alc262_modes,
11378 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011379 .unsol_event = alc_automute_amp_unsol_event,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011380 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010011381 },
11382 [ALC262_HP_RP5700] = {
11383 .mixers = { alc262_hp_rp5700_mixer },
11384 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11385 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11386 .dac_nids = alc262_dac_nids,
11387 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11388 .channel_mode = alc262_modes,
11389 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011390 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011391 [ALC262_BENQ_ED8] = {
11392 .mixers = { alc262_base_mixer },
11393 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11394 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11395 .dac_nids = alc262_dac_nids,
11396 .hp_nid = 0x03,
11397 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11398 .channel_mode = alc262_modes,
11399 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011400 },
Kailang Yang272a5272007-05-14 11:00:38 +020011401 [ALC262_SONY_ASSAMD] = {
11402 .mixers = { alc262_sony_mixer },
11403 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11404 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11405 .dac_nids = alc262_dac_nids,
11406 .hp_nid = 0x02,
11407 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11408 .channel_mode = alc262_modes,
11409 .input_mux = &alc262_capture_source,
11410 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011411 .init_hook = alc262_hippo_init_hook,
Kailang Yang83c34212007-07-05 11:43:05 +020011412 },
11413 [ALC262_BENQ_T31] = {
11414 .mixers = { alc262_benq_t31_mixer },
11415 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
11416 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11417 .dac_nids = alc262_dac_nids,
11418 .hp_nid = 0x03,
11419 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11420 .channel_mode = alc262_modes,
11421 .input_mux = &alc262_capture_source,
11422 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011423 .init_hook = alc262_hippo_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020011424 },
Tobin Davisf651b502007-10-26 12:40:47 +020011425 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011426 .mixers = { alc262_ultra_mixer },
11427 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011428 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011429 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11430 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011431 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11432 .channel_mode = alc262_modes,
11433 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011434 .adc_nids = alc262_adc_nids, /* ADC0 */
11435 .capsrc_nids = alc262_capsrc_nids,
11436 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011437 .unsol_event = alc262_ultra_unsol_event,
11438 .init_hook = alc262_ultra_automute,
11439 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011440 [ALC262_LENOVO_3000] = {
11441 .mixers = { alc262_lenovo_3000_mixer },
11442 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11443 alc262_lenovo_3000_unsol_verbs },
11444 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11445 .dac_nids = alc262_dac_nids,
11446 .hp_nid = 0x03,
11447 .dig_out_nid = ALC262_DIGOUT_NID,
11448 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11449 .channel_mode = alc262_modes,
11450 .input_mux = &alc262_fujitsu_capture_source,
11451 .unsol_event = alc262_lenovo_3000_unsol_event,
11452 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011453 [ALC262_NEC] = {
11454 .mixers = { alc262_nec_mixer },
11455 .init_verbs = { alc262_nec_verbs },
11456 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11457 .dac_nids = alc262_dac_nids,
11458 .hp_nid = 0x03,
11459 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11460 .channel_mode = alc262_modes,
11461 .input_mux = &alc262_capture_source,
11462 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011463 [ALC262_TOSHIBA_S06] = {
11464 .mixers = { alc262_toshiba_s06_mixer },
11465 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11466 alc262_eapd_verbs },
11467 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11468 .capsrc_nids = alc262_dmic_capsrc_nids,
11469 .dac_nids = alc262_dac_nids,
11470 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
11471 .dig_out_nid = ALC262_DIGOUT_NID,
11472 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11473 .channel_mode = alc262_modes,
11474 .input_mux = &alc262_dmic_capture_source,
11475 .unsol_event = alc262_toshiba_s06_unsol_event,
11476 .init_hook = alc262_toshiba_s06_init_hook,
11477 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011478 [ALC262_TOSHIBA_RX1] = {
11479 .mixers = { alc262_toshiba_rx1_mixer },
11480 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11481 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11482 .dac_nids = alc262_dac_nids,
11483 .hp_nid = 0x03,
11484 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11485 .channel_mode = alc262_modes,
11486 .input_mux = &alc262_capture_source,
11487 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011488 .init_hook = alc262_hippo_init_hook,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011489 },
Tony Vroonba340e82009-02-02 19:01:30 +000011490 [ALC262_TYAN] = {
11491 .mixers = { alc262_tyan_mixer },
11492 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11493 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11494 .dac_nids = alc262_dac_nids,
11495 .hp_nid = 0x02,
11496 .dig_out_nid = ALC262_DIGOUT_NID,
11497 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11498 .channel_mode = alc262_modes,
11499 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011500 .unsol_event = alc_automute_amp_unsol_event,
11501 .init_hook = alc262_tyan_init_hook,
Tony Vroonba340e82009-02-02 19:01:30 +000011502 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011503};
11504
11505static int patch_alc262(struct hda_codec *codec)
11506{
11507 struct alc_spec *spec;
11508 int board_config;
11509 int err;
11510
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011511 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011512 if (spec == NULL)
11513 return -ENOMEM;
11514
11515 codec->spec = spec;
11516#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011517 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11518 * under-run
11519 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011520 {
11521 int tmp;
11522 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11523 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11524 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11525 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11526 }
11527#endif
11528
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011529 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11530
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011531 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11532 alc262_models,
11533 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011534
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011535 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020011536 printk(KERN_INFO "hda_codec: Unknown model for %s, "
11537 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011538 board_config = ALC262_AUTO;
11539 }
11540
11541 if (board_config == ALC262_AUTO) {
11542 /* automatic parse from the BIOS config */
11543 err = alc262_parse_auto_config(codec);
11544 if (err < 0) {
11545 alc_free(codec);
11546 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011547 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011548 printk(KERN_INFO
11549 "hda_codec: Cannot set up configuration "
11550 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011551 board_config = ALC262_BASIC;
11552 }
11553 }
11554
Takashi Iwai07eba612009-02-19 08:06:35 +010011555 if (!spec->no_analog) {
11556 err = snd_hda_attach_beep_device(codec, 0x1);
11557 if (err < 0) {
11558 alc_free(codec);
11559 return err;
11560 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011561 }
11562
Kailang Yangdf694da2005-12-05 19:42:22 +010011563 if (board_config != ALC262_AUTO)
11564 setup_preset(spec, &alc262_presets[board_config]);
11565
Kailang Yangdf694da2005-12-05 19:42:22 +010011566 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11567 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011568
Kailang Yangdf694da2005-12-05 19:42:22 +010011569 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11570 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11571
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011572 spec->capture_style = CAPT_MIX;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011573 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011574 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010011575 unsigned int wcap = get_wcaps(codec, 0x07);
11576
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011577 /* get type */
11578 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010011579 if (wcap != AC_WID_AUD_IN) {
11580 spec->adc_nids = alc262_adc_nids_alt;
11581 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011582 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010011583 } else {
11584 spec->adc_nids = alc262_adc_nids;
11585 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011586 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011587 }
11588 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011589 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011590 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011591 if (!spec->no_analog)
11592 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011593
Takashi Iwai2134ea42008-01-10 16:53:55 +010011594 spec->vmaster_nid = 0x0c;
11595
Kailang Yangdf694da2005-12-05 19:42:22 +010011596 codec->patch_ops = alc_patch_ops;
11597 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011598 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011599#ifdef CONFIG_SND_HDA_POWER_SAVE
11600 if (!spec->loopback.amplist)
11601 spec->loopback.amplist = alc262_loopbacks;
11602#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011603 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011604
Kailang Yangdf694da2005-12-05 19:42:22 +010011605 return 0;
11606}
11607
Kailang Yangdf694da2005-12-05 19:42:22 +010011608/*
Kailang Yanga361d842007-06-05 12:30:55 +020011609 * ALC268 channel source setting (2 channel)
11610 */
11611#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11612#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011613
Kailang Yanga361d842007-06-05 12:30:55 +020011614static hda_nid_t alc268_dac_nids[2] = {
11615 /* front, hp */
11616 0x02, 0x03
11617};
11618
11619static hda_nid_t alc268_adc_nids[2] = {
11620 /* ADC0-1 */
11621 0x08, 0x07
11622};
11623
11624static hda_nid_t alc268_adc_nids_alt[1] = {
11625 /* ADC0 */
11626 0x08
11627};
11628
Takashi Iwaie1406342008-02-11 18:32:32 +010011629static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11630
Kailang Yanga361d842007-06-05 12:30:55 +020011631static struct snd_kcontrol_new alc268_base_mixer[] = {
11632 /* output mixer control */
11633 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11634 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11635 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11636 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011637 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11638 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11639 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011640 { }
11641};
11642
Takashi Iwai42171c12009-05-08 14:11:43 +020011643static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11644 /* output mixer control */
11645 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11646 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11647 ALC262_HIPPO_MASTER_SWITCH,
11648 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11649 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11650 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11651 { }
11652};
11653
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011654/* bind Beep switches of both NID 0x0f and 0x10 */
11655static struct hda_bind_ctls alc268_bind_beep_sw = {
11656 .ops = &snd_hda_bind_sw,
11657 .values = {
11658 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11659 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11660 0
11661 },
11662};
11663
11664static struct snd_kcontrol_new alc268_beep_mixer[] = {
11665 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11666 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11667 { }
11668};
11669
Kailang Yangd1a991a2007-08-15 16:21:59 +020011670static struct hda_verb alc268_eapd_verbs[] = {
11671 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11672 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11673 { }
11674};
11675
Takashi Iwaid2738092007-08-16 14:59:45 +020011676/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011677static struct hda_verb alc268_toshiba_verbs[] = {
11678 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11679 { } /* end */
11680};
11681
Kailang Yang8ef355d2008-08-26 13:10:22 +020011682static struct hda_input_mux alc268_acer_lc_capture_source = {
11683 .num_items = 2,
11684 .items = {
11685 { "i-Mic", 0x6 },
11686 { "E-Mic", 0x0 },
11687 },
11688};
11689
Takashi Iwaid2738092007-08-16 14:59:45 +020011690/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011691/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011692static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11693 .ops = &snd_hda_bind_vol,
11694 .values = {
11695 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11696 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11697 0
11698 },
11699};
11700
Takashi Iwai889c4392007-08-23 18:56:52 +020011701/* mute/unmute internal speaker according to the hp jack and mute state */
11702static void alc268_acer_automute(struct hda_codec *codec, int force)
11703{
11704 struct alc_spec *spec = codec->spec;
11705 unsigned int mute;
11706
11707 if (force || !spec->sense_updated) {
11708 unsigned int present;
11709 present = snd_hda_codec_read(codec, 0x14, 0,
11710 AC_VERB_GET_PIN_SENSE, 0);
11711 spec->jack_present = (present & 0x80000000) != 0;
11712 spec->sense_updated = 1;
11713 }
11714 if (spec->jack_present)
11715 mute = HDA_AMP_MUTE; /* mute internal speaker */
11716 else /* unmute internal speaker if necessary */
11717 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11718 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11719 HDA_AMP_MUTE, mute);
11720}
11721
11722
11723/* bind hp and internal speaker mute (with plug check) */
11724static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11725 struct snd_ctl_elem_value *ucontrol)
11726{
11727 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11728 long *valp = ucontrol->value.integer.value;
11729 int change;
11730
11731 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11732 HDA_AMP_MUTE,
11733 valp[0] ? 0 : HDA_AMP_MUTE);
11734 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11735 HDA_AMP_MUTE,
11736 valp[1] ? 0 : HDA_AMP_MUTE);
11737 if (change)
11738 alc268_acer_automute(codec, 0);
11739 return change;
11740}
Takashi Iwaid2738092007-08-16 14:59:45 +020011741
Kailang Yang8ef355d2008-08-26 13:10:22 +020011742static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11743 /* output mixer control */
11744 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11745 {
11746 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11747 .name = "Master Playback Switch",
11748 .info = snd_hda_mixer_amp_switch_info,
11749 .get = snd_hda_mixer_amp_switch_get,
11750 .put = alc268_acer_master_sw_put,
11751 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11752 },
11753 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11754 { }
11755};
11756
Takashi Iwaid2738092007-08-16 14:59:45 +020011757static struct snd_kcontrol_new alc268_acer_mixer[] = {
11758 /* output mixer control */
11759 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11760 {
11761 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11762 .name = "Master Playback Switch",
11763 .info = snd_hda_mixer_amp_switch_info,
11764 .get = snd_hda_mixer_amp_switch_get,
11765 .put = alc268_acer_master_sw_put,
11766 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11767 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011768 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11769 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11770 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011771 { }
11772};
11773
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011774static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11775 /* output mixer control */
11776 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11777 {
11778 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11779 .name = "Master Playback Switch",
11780 .info = snd_hda_mixer_amp_switch_info,
11781 .get = snd_hda_mixer_amp_switch_get,
11782 .put = alc268_acer_master_sw_put,
11783 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11784 },
11785 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11786 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11787 { }
11788};
11789
Kailang Yang8ef355d2008-08-26 13:10:22 +020011790static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11791 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11792 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11793 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11794 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11795 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11796 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11797 { }
11798};
11799
Takashi Iwaid2738092007-08-16 14:59:45 +020011800static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011801 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11802 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011803 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11804 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011805 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11806 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011807 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11808 { }
11809};
11810
11811/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011812#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11813#define alc268_toshiba_init_hook alc262_hippo_init_hook
Takashi Iwaid2738092007-08-16 14:59:45 +020011814
11815static void alc268_acer_unsol_event(struct hda_codec *codec,
11816 unsigned int res)
11817{
Takashi Iwai889c4392007-08-23 18:56:52 +020011818 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011819 return;
11820 alc268_acer_automute(codec, 1);
11821}
11822
Takashi Iwai889c4392007-08-23 18:56:52 +020011823static void alc268_acer_init_hook(struct hda_codec *codec)
11824{
11825 alc268_acer_automute(codec, 1);
11826}
11827
Kailang Yang8ef355d2008-08-26 13:10:22 +020011828/* toggle speaker-output according to the hp-jack state */
11829static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11830{
11831 unsigned int present;
11832 unsigned char bits;
11833
11834 present = snd_hda_codec_read(codec, 0x15, 0,
11835 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11836 bits = present ? AMP_IN_MUTE(0) : 0;
11837 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11838 AMP_IN_MUTE(0), bits);
11839 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11840 AMP_IN_MUTE(0), bits);
11841}
11842
11843
11844static void alc268_acer_mic_automute(struct hda_codec *codec)
11845{
11846 unsigned int present;
11847
11848 present = snd_hda_codec_read(codec, 0x18, 0,
11849 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11850 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11851 present ? 0x0 : 0x6);
11852}
11853
11854static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11855 unsigned int res)
11856{
11857 if ((res >> 26) == ALC880_HP_EVENT)
11858 alc268_aspire_one_speaker_automute(codec);
11859 if ((res >> 26) == ALC880_MIC_EVENT)
11860 alc268_acer_mic_automute(codec);
11861}
11862
11863static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11864{
11865 alc268_aspire_one_speaker_automute(codec);
11866 alc268_acer_mic_automute(codec);
11867}
11868
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011869static struct snd_kcontrol_new alc268_dell_mixer[] = {
11870 /* output mixer control */
11871 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11872 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11873 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11874 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11875 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11876 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11877 { }
11878};
11879
11880static struct hda_verb alc268_dell_verbs[] = {
11881 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11882 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11883 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11884 { }
11885};
11886
11887/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011888static void alc268_dell_init_hook(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011889{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011890 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011891
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011892 spec->autocfg.hp_pins[0] = 0x15;
11893 spec->autocfg.speaker_pins[0] = 0x14;
11894 alc_automute_pin(codec);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011895}
11896
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011897static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11898 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11899 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11900 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11901 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11902 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11903 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11904 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11905 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11906 { }
11907};
11908
11909static struct hda_verb alc267_quanta_il1_verbs[] = {
11910 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11911 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11912 { }
11913};
11914
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011915static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11916{
11917 unsigned int present;
11918
11919 present = snd_hda_codec_read(codec, 0x18, 0,
11920 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11921 snd_hda_codec_write(codec, 0x23, 0,
11922 AC_VERB_SET_CONNECT_SEL,
11923 present ? 0x00 : 0x01);
11924}
11925
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011926static void alc267_quanta_il1_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011927{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011928 struct alc_spec *spec = codec->spec;
11929
11930 spec->autocfg.hp_pins[0] = 0x15;
11931 spec->autocfg.speaker_pins[0] = 0x14;
11932 alc_automute_pin(codec);
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011933 alc267_quanta_il1_mic_automute(codec);
11934}
11935
11936static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11937 unsigned int res)
11938{
11939 switch (res >> 26) {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011940 case ALC880_MIC_EVENT:
11941 alc267_quanta_il1_mic_automute(codec);
11942 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011943 default:
11944 alc_sku_unsol_event(codec, res);
11945 break;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011946 }
11947}
11948
Kailang Yanga361d842007-06-05 12:30:55 +020011949/*
11950 * generic initialization of ADC, input mixers and output mixers
11951 */
11952static struct hda_verb alc268_base_init_verbs[] = {
11953 /* Unmute DAC0-1 and set vol = 0 */
11954 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011955 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011956
11957 /*
11958 * Set up output mixers (0x0c - 0x0e)
11959 */
11960 /* set vol=0 to output mixers */
11961 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011962 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11963
11964 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11965 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11966
11967 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11968 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11969 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11970 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11971 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11972 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11973 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11974 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11975
11976 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11977 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11978 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11979 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011980 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011981
11982 /* set PCBEEP vol = 0, mute connections */
11983 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11984 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11985 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011986
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011987 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011988
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011989 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11990 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11991 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11992 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011993
Kailang Yanga361d842007-06-05 12:30:55 +020011994 { }
11995};
11996
11997/*
11998 * generic initialization of ADC, input mixers and output mixers
11999 */
12000static struct hda_verb alc268_volume_init_verbs[] = {
12001 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012002 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12003 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012004
12005 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12006 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12007 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12008 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12009 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12010
Kailang Yanga361d842007-06-05 12:30:55 +020012011 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012012 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12013 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12014
12015 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012016 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012017
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012018 /* set PCBEEP vol = 0, mute connections */
12019 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12020 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12021 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012022
12023 { }
12024};
12025
Kailang Yanga361d842007-06-05 12:30:55 +020012026static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12027 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12028 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12029 {
12030 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12031 /* The multiple "Capture Source" controls confuse alsamixer
12032 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020012033 */
12034 /* .name = "Capture Source", */
12035 .name = "Input Source",
12036 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012037 .info = alc_mux_enum_info,
12038 .get = alc_mux_enum_get,
12039 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020012040 },
12041 { } /* end */
12042};
12043
12044static struct snd_kcontrol_new alc268_capture_mixer[] = {
12045 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12046 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12047 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12048 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
12049 {
12050 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12051 /* The multiple "Capture Source" controls confuse alsamixer
12052 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020012053 */
12054 /* .name = "Capture Source", */
12055 .name = "Input Source",
12056 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012057 .info = alc_mux_enum_info,
12058 .get = alc_mux_enum_get,
12059 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020012060 },
12061 { } /* end */
12062};
12063
12064static struct hda_input_mux alc268_capture_source = {
12065 .num_items = 4,
12066 .items = {
12067 { "Mic", 0x0 },
12068 { "Front Mic", 0x1 },
12069 { "Line", 0x2 },
12070 { "CD", 0x3 },
12071 },
12072};
12073
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012074static struct hda_input_mux alc268_acer_capture_source = {
12075 .num_items = 3,
12076 .items = {
12077 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012078 { "Internal Mic", 0x1 },
12079 { "Line", 0x2 },
12080 },
12081};
12082
12083static struct hda_input_mux alc268_acer_dmic_capture_source = {
12084 .num_items = 3,
12085 .items = {
12086 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012087 { "Internal Mic", 0x6 },
12088 { "Line", 0x2 },
12089 },
12090};
12091
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012092#ifdef CONFIG_SND_DEBUG
12093static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012094 /* Volume widgets */
12095 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12096 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12097 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12098 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12099 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12100 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12101 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12102 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12103 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12104 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12105 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12106 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12107 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012108 /* The below appears problematic on some hardwares */
12109 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012110 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12111 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12112 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12113 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12114
12115 /* Modes for retasking pin widgets */
12116 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12117 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12118 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12119 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12120
12121 /* Controls for GPIO pins, assuming they are configured as outputs */
12122 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12123 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12124 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12125 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12126
12127 /* Switches to allow the digital SPDIF output pin to be enabled.
12128 * The ALC268 does not have an SPDIF input.
12129 */
12130 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12131
12132 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12133 * this output to turn on an external amplifier.
12134 */
12135 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12136 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12137
12138 { } /* end */
12139};
12140#endif
12141
Kailang Yanga361d842007-06-05 12:30:55 +020012142/* create input playback/capture controls for the given pin */
12143static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12144 const char *ctlname, int idx)
12145{
12146 char name[32];
12147 int err;
12148
12149 sprintf(name, "%s Playback Volume", ctlname);
12150 if (nid == 0x14) {
12151 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12152 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
12153 HDA_OUTPUT));
12154 if (err < 0)
12155 return err;
12156 } else if (nid == 0x15) {
12157 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12158 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
12159 HDA_OUTPUT));
12160 if (err < 0)
12161 return err;
12162 } else
12163 return -1;
12164 sprintf(name, "%s Playback Switch", ctlname);
12165 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12166 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
12167 if (err < 0)
12168 return err;
12169 return 0;
12170}
12171
12172/* add playback controls from the parsed DAC table */
12173static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12174 const struct auto_pin_cfg *cfg)
12175{
12176 hda_nid_t nid;
12177 int err;
12178
12179 spec->multiout.num_dacs = 2; /* only use one dac */
12180 spec->multiout.dac_nids = spec->private_dac_nids;
12181 spec->multiout.dac_nids[0] = 2;
12182 spec->multiout.dac_nids[1] = 3;
12183
12184 nid = cfg->line_out_pins[0];
12185 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020012186 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020012187
12188 nid = cfg->speaker_pins[0];
12189 if (nid == 0x1d) {
12190 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12191 "Speaker Playback Volume",
12192 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12193 if (err < 0)
12194 return err;
12195 }
12196 nid = cfg->hp_pins[0];
12197 if (nid)
12198 alc268_new_analog_output(spec, nid, "Headphone", 0);
12199
12200 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12201 if (nid == 0x16) {
12202 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12203 "Mono Playback Switch",
12204 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
12205 if (err < 0)
12206 return err;
12207 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012208 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012209}
12210
12211/* create playback/capture controls for input pins */
12212static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
12213 const struct auto_pin_cfg *cfg)
12214{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012215 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012216 int i, idx1;
12217
12218 for (i = 0; i < AUTO_PIN_LAST; i++) {
12219 switch(cfg->input_pins[i]) {
12220 case 0x18:
12221 idx1 = 0; /* Mic 1 */
12222 break;
12223 case 0x19:
12224 idx1 = 1; /* Mic 2 */
12225 break;
12226 case 0x1a:
12227 idx1 = 2; /* Line In */
12228 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020012229 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020012230 idx1 = 3; /* CD */
12231 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010012232 case 0x12:
12233 case 0x13:
12234 idx1 = 6; /* digital mics */
12235 break;
Kailang Yanga361d842007-06-05 12:30:55 +020012236 default:
12237 continue;
12238 }
12239 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
12240 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020012241 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020012242 }
12243 return 0;
12244}
12245
12246static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12247{
12248 struct alc_spec *spec = codec->spec;
12249 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12250 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12251 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12252 unsigned int dac_vol1, dac_vol2;
12253
12254 if (speaker_nid) {
12255 snd_hda_codec_write(codec, speaker_nid, 0,
12256 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
12257 snd_hda_codec_write(codec, 0x0f, 0,
12258 AC_VERB_SET_AMP_GAIN_MUTE,
12259 AMP_IN_UNMUTE(1));
12260 snd_hda_codec_write(codec, 0x10, 0,
12261 AC_VERB_SET_AMP_GAIN_MUTE,
12262 AMP_IN_UNMUTE(1));
12263 } else {
12264 snd_hda_codec_write(codec, 0x0f, 0,
12265 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12266 snd_hda_codec_write(codec, 0x10, 0,
12267 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12268 }
12269
12270 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012271 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012272 dac_vol2 = AMP_OUT_ZERO;
12273 else if (line_nid == 0x15)
12274 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012275 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012276 dac_vol2 = AMP_OUT_ZERO;
12277 else if (hp_nid == 0x15)
12278 dac_vol1 = AMP_OUT_ZERO;
12279 if (line_nid != 0x16 || hp_nid != 0x16 ||
12280 spec->autocfg.line_out_pins[1] != 0x16 ||
12281 spec->autocfg.line_out_pins[2] != 0x16)
12282 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12283
12284 snd_hda_codec_write(codec, 0x02, 0,
12285 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12286 snd_hda_codec_write(codec, 0x03, 0,
12287 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12288}
12289
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012290/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012291#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12292#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012293#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012294#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12295
12296/*
12297 * BIOS auto configuration
12298 */
12299static int alc268_parse_auto_config(struct hda_codec *codec)
12300{
12301 struct alc_spec *spec = codec->spec;
12302 int err;
12303 static hda_nid_t alc268_ignore[] = { 0 };
12304
12305 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12306 alc268_ignore);
12307 if (err < 0)
12308 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012309 if (!spec->autocfg.line_outs) {
12310 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12311 spec->multiout.max_channels = 2;
12312 spec->no_analog = 1;
12313 goto dig_only;
12314 }
Kailang Yanga361d842007-06-05 12:30:55 +020012315 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012316 }
Kailang Yanga361d842007-06-05 12:30:55 +020012317 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12318 if (err < 0)
12319 return err;
12320 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
12321 if (err < 0)
12322 return err;
12323
12324 spec->multiout.max_channels = 2;
12325
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012326 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012327 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012328 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012329 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012330 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12331 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012332 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012333 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012334
Takashi Iwai892981f2009-03-02 08:04:35 +010012335 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012336 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012337
Takashi Iwaid88897e2008-10-31 15:01:37 +010012338 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020012339 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012340 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012341
Takashi Iwai776e1842007-08-29 15:07:11 +020012342 err = alc_auto_add_mic_boost(codec);
12343 if (err < 0)
12344 return err;
12345
Kailang Yanga361d842007-06-05 12:30:55 +020012346 return 1;
12347}
12348
12349#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12350#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12351#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12352
12353/* init callback for auto-configuration model -- overriding the default init */
12354static void alc268_auto_init(struct hda_codec *codec)
12355{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012356 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012357 alc268_auto_init_multi_out(codec);
12358 alc268_auto_init_hp_out(codec);
12359 alc268_auto_init_mono_speaker_out(codec);
12360 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012361 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012362 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012363}
12364
12365/*
12366 * configuration and preset
12367 */
12368static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012369 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012370 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012371 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012372 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012373 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012374 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012375 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012376 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012377#ifdef CONFIG_SND_DEBUG
12378 [ALC268_TEST] = "test",
12379#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012380 [ALC268_AUTO] = "auto",
12381};
12382
12383static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012384 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012385 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012386 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012387 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012388 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012389 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12390 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012391 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012392 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012393 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
12394 ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012395 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012396 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
12397 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12398 ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012399 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012400 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012401 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012402 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012403 {}
12404};
12405
12406static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012407 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010012408 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012409 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12410 alc267_quanta_il1_verbs },
12411 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12412 .dac_nids = alc268_dac_nids,
12413 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12414 .adc_nids = alc268_adc_nids_alt,
12415 .hp_nid = 0x03,
12416 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12417 .channel_mode = alc268_modes,
12418 .input_mux = &alc268_capture_source,
12419 .unsol_event = alc267_quanta_il1_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012420 .init_hook = alc267_quanta_il1_init_hook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012421 },
Kailang Yanga361d842007-06-05 12:30:55 +020012422 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012423 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12424 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012425 .init_verbs = { alc268_base_init_verbs },
12426 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12427 .dac_nids = alc268_dac_nids,
12428 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12429 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012430 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012431 .hp_nid = 0x03,
12432 .dig_out_nid = ALC268_DIGOUT_NID,
12433 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12434 .channel_mode = alc268_modes,
12435 .input_mux = &alc268_capture_source,
12436 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012437 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012438 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012439 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012440 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12441 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012442 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12443 .dac_nids = alc268_dac_nids,
12444 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12445 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012446 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012447 .hp_nid = 0x03,
12448 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12449 .channel_mode = alc268_modes,
12450 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012451 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012452 .init_hook = alc268_toshiba_init_hook,
Takashi Iwaid2738092007-08-16 14:59:45 +020012453 },
12454 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012455 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12456 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012457 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12458 alc268_acer_verbs },
12459 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12460 .dac_nids = alc268_dac_nids,
12461 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12462 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012463 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012464 .hp_nid = 0x02,
12465 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12466 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012467 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012468 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012469 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012470 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012471 [ALC268_ACER_DMIC] = {
12472 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12473 alc268_beep_mixer },
12474 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12475 alc268_acer_verbs },
12476 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12477 .dac_nids = alc268_dac_nids,
12478 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12479 .adc_nids = alc268_adc_nids_alt,
12480 .capsrc_nids = alc268_capsrc_nids,
12481 .hp_nid = 0x02,
12482 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12483 .channel_mode = alc268_modes,
12484 .input_mux = &alc268_acer_dmic_capture_source,
12485 .unsol_event = alc268_acer_unsol_event,
12486 .init_hook = alc268_acer_init_hook,
12487 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012488 [ALC268_ACER_ASPIRE_ONE] = {
12489 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012490 alc268_beep_mixer,
12491 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012492 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12493 alc268_acer_aspire_one_verbs },
12494 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12495 .dac_nids = alc268_dac_nids,
12496 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12497 .adc_nids = alc268_adc_nids_alt,
12498 .capsrc_nids = alc268_capsrc_nids,
12499 .hp_nid = 0x03,
12500 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12501 .channel_mode = alc268_modes,
12502 .input_mux = &alc268_acer_lc_capture_source,
12503 .unsol_event = alc268_acer_lc_unsol_event,
12504 .init_hook = alc268_acer_lc_init_hook,
12505 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012506 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012507 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012508 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12509 alc268_dell_verbs },
12510 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12511 .dac_nids = alc268_dac_nids,
12512 .hp_nid = 0x02,
12513 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12514 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012515 .unsol_event = alc_sku_unsol_event,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012516 .init_hook = alc268_dell_init_hook,
12517 .input_mux = &alc268_capture_source,
12518 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012519 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012520 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12521 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012522 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12523 alc268_toshiba_verbs },
12524 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12525 .dac_nids = alc268_dac_nids,
12526 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12527 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012528 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012529 .hp_nid = 0x03,
12530 .dig_out_nid = ALC268_DIGOUT_NID,
12531 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12532 .channel_mode = alc268_modes,
12533 .input_mux = &alc268_capture_source,
12534 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012535 .init_hook = alc268_toshiba_init_hook
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012536 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012537#ifdef CONFIG_SND_DEBUG
12538 [ALC268_TEST] = {
12539 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12540 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12541 alc268_volume_init_verbs },
12542 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12543 .dac_nids = alc268_dac_nids,
12544 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12545 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012546 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012547 .hp_nid = 0x03,
12548 .dig_out_nid = ALC268_DIGOUT_NID,
12549 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12550 .channel_mode = alc268_modes,
12551 .input_mux = &alc268_capture_source,
12552 },
12553#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012554};
12555
12556static int patch_alc268(struct hda_codec *codec)
12557{
12558 struct alc_spec *spec;
12559 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012560 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012561
12562 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12563 if (spec == NULL)
12564 return -ENOMEM;
12565
12566 codec->spec = spec;
12567
12568 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12569 alc268_models,
12570 alc268_cfg_tbl);
12571
12572 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020012573 printk(KERN_INFO "hda_codec: Unknown model for %s, "
12574 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012575 board_config = ALC268_AUTO;
12576 }
12577
12578 if (board_config == ALC268_AUTO) {
12579 /* automatic parse from the BIOS config */
12580 err = alc268_parse_auto_config(codec);
12581 if (err < 0) {
12582 alc_free(codec);
12583 return err;
12584 } else if (!err) {
12585 printk(KERN_INFO
12586 "hda_codec: Cannot set up configuration "
12587 "from BIOS. Using base mode...\n");
12588 board_config = ALC268_3ST;
12589 }
12590 }
12591
12592 if (board_config != ALC268_AUTO)
12593 setup_preset(spec, &alc268_presets[board_config]);
12594
Kailang Yanga361d842007-06-05 12:30:55 +020012595 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12596 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012597 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012598
Kailang Yanga361d842007-06-05 12:30:55 +020012599 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12600
Takashi Iwai22971e32009-02-10 11:56:44 +010012601 has_beep = 0;
12602 for (i = 0; i < spec->num_mixers; i++) {
12603 if (spec->mixers[i] == alc268_beep_mixer) {
12604 has_beep = 1;
12605 break;
12606 }
12607 }
12608
12609 if (has_beep) {
12610 err = snd_hda_attach_beep_device(codec, 0x1);
12611 if (err < 0) {
12612 alc_free(codec);
12613 return err;
12614 }
12615 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12616 /* override the amp caps for beep generator */
12617 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012618 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12619 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12620 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12621 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012622 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012623
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012624 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012625 /* check whether NID 0x07 is valid */
12626 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012627 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012628
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012629 /* get type */
12630 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012631 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012632 spec->adc_nids = alc268_adc_nids_alt;
12633 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012634 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012635 } else {
12636 spec->adc_nids = alc268_adc_nids;
12637 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012638 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012639 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012640 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012641 /* set default input source */
12642 for (i = 0; i < spec->num_adc_nids; i++)
12643 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12644 0, AC_VERB_SET_CONNECT_SEL,
12645 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012646 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012647
12648 spec->vmaster_nid = 0x02;
12649
Kailang Yanga361d842007-06-05 12:30:55 +020012650 codec->patch_ops = alc_patch_ops;
12651 if (board_config == ALC268_AUTO)
12652 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012653
Takashi Iwaidaead532008-11-28 12:55:36 +010012654 codec->proc_widget_hook = print_realtek_coef;
12655
Kailang Yanga361d842007-06-05 12:30:55 +020012656 return 0;
12657}
12658
12659/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012660 * ALC269 channel source setting (2 channel)
12661 */
12662#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12663
12664#define alc269_dac_nids alc260_dac_nids
12665
12666static hda_nid_t alc269_adc_nids[1] = {
12667 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012668 0x08,
12669};
12670
Takashi Iwaie01bf502008-08-21 16:25:07 +020012671static hda_nid_t alc269_capsrc_nids[1] = {
12672 0x23,
12673};
12674
12675/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12676 * not a mux!
12677 */
12678
Kailang Yangf53281e2008-07-18 12:36:43 +020012679static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12680 .num_items = 2,
12681 .items = {
12682 { "i-Mic", 0x5 },
12683 { "e-Mic", 0x0 },
12684 },
12685};
12686
12687static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12688 .num_items = 2,
12689 .items = {
12690 { "i-Mic", 0x1 },
12691 { "e-Mic", 0x0 },
12692 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012693};
12694
12695#define alc269_modes alc260_modes
12696#define alc269_capture_source alc880_lg_lw_capture_source
12697
12698static struct snd_kcontrol_new alc269_base_mixer[] = {
12699 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12700 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12701 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12702 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12703 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12704 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12705 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12706 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12707 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12708 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12709 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12710 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12711 { } /* end */
12712};
12713
Kailang Yang60db6b52008-08-26 13:13:00 +020012714static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12715 /* output mixer control */
12716 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12717 {
12718 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12719 .name = "Master Playback Switch",
12720 .info = snd_hda_mixer_amp_switch_info,
12721 .get = snd_hda_mixer_amp_switch_get,
12722 .put = alc268_acer_master_sw_put,
12723 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12724 },
12725 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12726 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12727 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12728 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12729 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12730 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012731 { }
12732};
12733
Tony Vroon64154832008-11-06 15:08:49 +000012734static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12735 /* output mixer control */
12736 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12737 {
12738 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12739 .name = "Master Playback Switch",
12740 .info = snd_hda_mixer_amp_switch_info,
12741 .get = snd_hda_mixer_amp_switch_get,
12742 .put = alc268_acer_master_sw_put,
12743 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12744 },
12745 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12746 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12747 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12748 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12749 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12750 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12751 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12752 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12753 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012754 { }
12755};
12756
Kailang Yangf53281e2008-07-18 12:36:43 +020012757/* bind volumes of both NID 0x0c and 0x0d */
12758static struct hda_bind_ctls alc269_epc_bind_vol = {
12759 .ops = &snd_hda_bind_vol,
12760 .values = {
12761 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12762 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12763 0
12764 },
12765};
12766
12767static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12768 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12769 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12770 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12771 { } /* end */
12772};
12773
Kailang Yangf6a92242007-12-13 16:52:54 +010012774/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012775static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12776 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12777 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012778 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12779 { } /* end */
12780};
12781
12782/* FSC amilo */
12783static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12784 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12785 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12786 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012787 { } /* end */
12788};
12789
Kailang Yang60db6b52008-08-26 13:13:00 +020012790static struct hda_verb alc269_quanta_fl1_verbs[] = {
12791 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12792 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12793 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12794 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12795 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12796 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12797 { }
12798};
12799
Tony Vroon64154832008-11-06 15:08:49 +000012800static struct hda_verb alc269_lifebook_verbs[] = {
12801 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12802 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12803 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12804 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12805 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12806 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12807 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12808 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12809 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12810 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12811 { }
12812};
12813
Kailang Yang60db6b52008-08-26 13:13:00 +020012814/* toggle speaker-output according to the hp-jack state */
12815static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12816{
12817 unsigned int present;
12818 unsigned char bits;
12819
12820 present = snd_hda_codec_read(codec, 0x15, 0,
12821 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12822 bits = present ? AMP_IN_MUTE(0) : 0;
12823 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12824 AMP_IN_MUTE(0), bits);
12825 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12826 AMP_IN_MUTE(0), bits);
12827
12828 snd_hda_codec_write(codec, 0x20, 0,
12829 AC_VERB_SET_COEF_INDEX, 0x0c);
12830 snd_hda_codec_write(codec, 0x20, 0,
12831 AC_VERB_SET_PROC_COEF, 0x680);
12832
12833 snd_hda_codec_write(codec, 0x20, 0,
12834 AC_VERB_SET_COEF_INDEX, 0x0c);
12835 snd_hda_codec_write(codec, 0x20, 0,
12836 AC_VERB_SET_PROC_COEF, 0x480);
12837}
12838
Tony Vroon64154832008-11-06 15:08:49 +000012839/* toggle speaker-output according to the hp-jacks state */
12840static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12841{
12842 unsigned int present;
12843 unsigned char bits;
12844
12845 /* Check laptop headphone socket */
12846 present = snd_hda_codec_read(codec, 0x15, 0,
12847 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12848
12849 /* Check port replicator headphone socket */
12850 present |= snd_hda_codec_read(codec, 0x1a, 0,
12851 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12852
12853 bits = present ? AMP_IN_MUTE(0) : 0;
12854 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12855 AMP_IN_MUTE(0), bits);
12856 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12857 AMP_IN_MUTE(0), bits);
12858
12859 snd_hda_codec_write(codec, 0x20, 0,
12860 AC_VERB_SET_COEF_INDEX, 0x0c);
12861 snd_hda_codec_write(codec, 0x20, 0,
12862 AC_VERB_SET_PROC_COEF, 0x680);
12863
12864 snd_hda_codec_write(codec, 0x20, 0,
12865 AC_VERB_SET_COEF_INDEX, 0x0c);
12866 snd_hda_codec_write(codec, 0x20, 0,
12867 AC_VERB_SET_PROC_COEF, 0x480);
12868}
12869
Kailang Yang60db6b52008-08-26 13:13:00 +020012870static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12871{
12872 unsigned int present;
12873
12874 present = snd_hda_codec_read(codec, 0x18, 0,
12875 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12876 snd_hda_codec_write(codec, 0x23, 0,
12877 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12878}
12879
Tony Vroon64154832008-11-06 15:08:49 +000012880static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12881{
12882 unsigned int present_laptop;
12883 unsigned int present_dock;
12884
12885 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12886 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12887
12888 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12889 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12890
12891 /* Laptop mic port overrides dock mic port, design decision */
12892 if (present_dock)
12893 snd_hda_codec_write(codec, 0x23, 0,
12894 AC_VERB_SET_CONNECT_SEL, 0x3);
12895 if (present_laptop)
12896 snd_hda_codec_write(codec, 0x23, 0,
12897 AC_VERB_SET_CONNECT_SEL, 0x0);
12898 if (!present_dock && !present_laptop)
12899 snd_hda_codec_write(codec, 0x23, 0,
12900 AC_VERB_SET_CONNECT_SEL, 0x1);
12901}
12902
Kailang Yang60db6b52008-08-26 13:13:00 +020012903static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12904 unsigned int res)
12905{
12906 if ((res >> 26) == ALC880_HP_EVENT)
12907 alc269_quanta_fl1_speaker_automute(codec);
12908 if ((res >> 26) == ALC880_MIC_EVENT)
12909 alc269_quanta_fl1_mic_automute(codec);
12910}
12911
Tony Vroon64154832008-11-06 15:08:49 +000012912static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12913 unsigned int res)
12914{
12915 if ((res >> 26) == ALC880_HP_EVENT)
12916 alc269_lifebook_speaker_automute(codec);
12917 if ((res >> 26) == ALC880_MIC_EVENT)
12918 alc269_lifebook_mic_autoswitch(codec);
12919}
12920
Kailang Yang60db6b52008-08-26 13:13:00 +020012921static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12922{
12923 alc269_quanta_fl1_speaker_automute(codec);
12924 alc269_quanta_fl1_mic_automute(codec);
12925}
12926
Tony Vroon64154832008-11-06 15:08:49 +000012927static void alc269_lifebook_init_hook(struct hda_codec *codec)
12928{
12929 alc269_lifebook_speaker_automute(codec);
12930 alc269_lifebook_mic_autoswitch(codec);
12931}
12932
Kailang Yang60db6b52008-08-26 13:13:00 +020012933static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12934 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12935 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12936 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12937 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12938 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12939 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12940 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12941 {}
12942};
12943
12944static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12945 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12946 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12947 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12948 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12949 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12950 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12951 {}
12952};
12953
12954/* toggle speaker-output according to the hp-jack state */
12955static void alc269_speaker_automute(struct hda_codec *codec)
12956{
12957 unsigned int present;
12958 unsigned char bits;
12959
12960 present = snd_hda_codec_read(codec, 0x15, 0,
12961 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12962 bits = present ? AMP_IN_MUTE(0) : 0;
12963 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12964 AMP_IN_MUTE(0), bits);
12965 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12966 AMP_IN_MUTE(0), bits);
12967}
12968
12969static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12970{
12971 unsigned int present;
12972
12973 present = snd_hda_codec_read(codec, 0x18, 0,
12974 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12975 snd_hda_codec_write(codec, 0x23, 0,
12976 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12977}
12978
12979static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12980{
12981 unsigned int present;
12982
12983 present = snd_hda_codec_read(codec, 0x18, 0,
12984 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12985 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12986 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12987 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12988 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12989}
12990
12991/* unsolicited event for HP jack sensing */
12992static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12993 unsigned int res)
12994{
12995 if ((res >> 26) == ALC880_HP_EVENT)
12996 alc269_speaker_automute(codec);
12997
12998 if ((res >> 26) == ALC880_MIC_EVENT)
12999 alc269_eeepc_dmic_automute(codec);
13000}
13001
13002static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
13003{
13004 alc269_speaker_automute(codec);
13005 alc269_eeepc_dmic_automute(codec);
13006}
13007
13008/* unsolicited event for HP jack sensing */
13009static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
13010 unsigned int res)
13011{
13012 if ((res >> 26) == ALC880_HP_EVENT)
13013 alc269_speaker_automute(codec);
13014
13015 if ((res >> 26) == ALC880_MIC_EVENT)
13016 alc269_eeepc_amic_automute(codec);
13017}
13018
13019static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
13020{
13021 alc269_speaker_automute(codec);
13022 alc269_eeepc_amic_automute(codec);
13023}
13024
Kailang Yangf6a92242007-12-13 16:52:54 +010013025/*
13026 * generic initialization of ADC, input mixers and output mixers
13027 */
13028static struct hda_verb alc269_init_verbs[] = {
13029 /*
13030 * Unmute ADC0 and set the default input to mic-in
13031 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013032 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013033
13034 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13035 * analog-loopback mixer widget
13036 * Note: PASD motherboards uses the Line In 2 as the input for
13037 * front panel mic (mic 2)
13038 */
13039 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13040 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13041 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13042 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13043 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13044 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13045
13046 /*
13047 * Set up output mixers (0x0c - 0x0e)
13048 */
13049 /* set vol=0 to output mixers */
13050 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13051 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13052
13053 /* set up input amps for analog loopback */
13054 /* Amp Indices: DAC = 0, mixer = 1 */
13055 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13056 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13057 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13058 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13059 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13060 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13061
13062 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13063 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13064 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13065 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13066 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13067 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13068 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13069
13070 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13071 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13072 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13073 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13074 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13075 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13076 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13077
13078 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13079 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13080
13081 /* FIXME: use matrix-type input source selection */
13082 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13083 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013084 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13085 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013086 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13087 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13088
13089 /* set EAPD */
13090 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13091 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13092 { }
13093};
13094
13095/* add playback controls from the parsed DAC table */
13096static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
13097 const struct auto_pin_cfg *cfg)
13098{
13099 hda_nid_t nid;
13100 int err;
13101
13102 spec->multiout.num_dacs = 1; /* only use one dac */
13103 spec->multiout.dac_nids = spec->private_dac_nids;
13104 spec->multiout.dac_nids[0] = 2;
13105
13106 nid = cfg->line_out_pins[0];
13107 if (nid) {
13108 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13109 "Front Playback Volume",
13110 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
13111 if (err < 0)
13112 return err;
13113 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13114 "Front Playback Switch",
13115 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13116 if (err < 0)
13117 return err;
13118 }
13119
13120 nid = cfg->speaker_pins[0];
13121 if (nid) {
13122 if (!cfg->line_out_pins[0]) {
13123 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13124 "Speaker Playback Volume",
13125 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13126 HDA_OUTPUT));
13127 if (err < 0)
13128 return err;
13129 }
13130 if (nid == 0x16) {
13131 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13132 "Speaker Playback Switch",
13133 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13134 HDA_OUTPUT));
13135 if (err < 0)
13136 return err;
13137 } else {
13138 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13139 "Speaker Playback Switch",
13140 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13141 HDA_OUTPUT));
13142 if (err < 0)
13143 return err;
13144 }
13145 }
13146 nid = cfg->hp_pins[0];
13147 if (nid) {
13148 /* spec->multiout.hp_nid = 2; */
13149 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
13150 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13151 "Headphone Playback Volume",
13152 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13153 HDA_OUTPUT));
13154 if (err < 0)
13155 return err;
13156 }
13157 if (nid == 0x16) {
13158 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13159 "Headphone Playback Switch",
13160 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13161 HDA_OUTPUT));
13162 if (err < 0)
13163 return err;
13164 } else {
13165 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13166 "Headphone Playback Switch",
13167 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13168 HDA_OUTPUT));
13169 if (err < 0)
13170 return err;
13171 }
13172 }
13173 return 0;
13174}
13175
Takashi Iwaiee956e02008-10-31 17:16:31 +010013176static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
13177 const struct auto_pin_cfg *cfg)
13178{
13179 int err;
13180
13181 err = alc880_auto_create_analog_input_ctls(spec, cfg);
13182 if (err < 0)
13183 return err;
13184 /* digital-mic input pin is excluded in alc880_auto_create..()
13185 * because it's under 0x18
13186 */
13187 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
13188 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013189 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwaiee956e02008-10-31 17:16:31 +010013190 imux->items[imux->num_items].label = "Int Mic";
13191 imux->items[imux->num_items].index = 0x05;
13192 imux->num_items++;
13193 }
13194 return 0;
13195}
Kailang Yangf6a92242007-12-13 16:52:54 +010013196
13197#ifdef CONFIG_SND_HDA_POWER_SAVE
13198#define alc269_loopbacks alc880_loopbacks
13199#endif
13200
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013201/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013202#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13203#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13204#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13205#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13206
Takashi Iwaif03d3112009-03-05 14:18:16 +010013207static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13208 .substreams = 1,
13209 .channels_min = 2,
13210 .channels_max = 8,
13211 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13212 /* NID is set in alc_build_pcms */
13213 .ops = {
13214 .open = alc880_playback_pcm_open,
13215 .prepare = alc880_playback_pcm_prepare,
13216 .cleanup = alc880_playback_pcm_cleanup
13217 },
13218};
13219
13220static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13221 .substreams = 1,
13222 .channels_min = 2,
13223 .channels_max = 2,
13224 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13225 /* NID is set in alc_build_pcms */
13226};
13227
Kailang Yangf6a92242007-12-13 16:52:54 +010013228/*
13229 * BIOS auto configuration
13230 */
13231static int alc269_parse_auto_config(struct hda_codec *codec)
13232{
13233 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013234 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013235 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13236
13237 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13238 alc269_ignore);
13239 if (err < 0)
13240 return err;
13241
13242 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13243 if (err < 0)
13244 return err;
13245 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
13246 if (err < 0)
13247 return err;
13248
13249 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13250
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013251 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013252 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13253
Takashi Iwai603c4012008-07-30 15:01:44 +020013254 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013255 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013256
Takashi Iwaid88897e2008-10-31 15:01:37 +010013257 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013258 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013259 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013260 /* set default input source */
13261 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13262 0, AC_VERB_SET_CONNECT_SEL,
13263 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013264
13265 err = alc_auto_add_mic_boost(codec);
13266 if (err < 0)
13267 return err;
13268
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013269 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013270 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013271
Kailang Yangf6a92242007-12-13 16:52:54 +010013272 return 1;
13273}
13274
13275#define alc269_auto_init_multi_out alc882_auto_init_multi_out
13276#define alc269_auto_init_hp_out alc882_auto_init_hp_out
13277#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13278
13279
13280/* init callback for auto-configuration model -- overriding the default init */
13281static void alc269_auto_init(struct hda_codec *codec)
13282{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013283 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013284 alc269_auto_init_multi_out(codec);
13285 alc269_auto_init_hp_out(codec);
13286 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013287 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013288 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013289}
13290
13291/*
13292 * configuration and preset
13293 */
13294static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013295 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013296 [ALC269_QUANTA_FL1] = "quanta",
13297 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013298 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013299 [ALC269_FUJITSU] = "fujitsu",
13300 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010013301};
13302
13303static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013304 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013305 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13306 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013307 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13308 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13309 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13310 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13311 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13312 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013313 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13314 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013315 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13316 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013317 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013318 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013319 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013320 {}
13321};
13322
13323static struct alc_config_preset alc269_presets[] = {
13324 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013325 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013326 .init_verbs = { alc269_init_verbs },
13327 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13328 .dac_nids = alc269_dac_nids,
13329 .hp_nid = 0x03,
13330 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13331 .channel_mode = alc269_modes,
13332 .input_mux = &alc269_capture_source,
13333 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013334 [ALC269_QUANTA_FL1] = {
13335 .mixers = { alc269_quanta_fl1_mixer },
13336 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13337 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13338 .dac_nids = alc269_dac_nids,
13339 .hp_nid = 0x03,
13340 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13341 .channel_mode = alc269_modes,
13342 .input_mux = &alc269_capture_source,
13343 .unsol_event = alc269_quanta_fl1_unsol_event,
13344 .init_hook = alc269_quanta_fl1_init_hook,
13345 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013346 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013347 .mixers = { alc269_eeepc_mixer },
13348 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013349 .init_verbs = { alc269_init_verbs,
13350 alc269_eeepc_amic_init_verbs },
13351 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13352 .dac_nids = alc269_dac_nids,
13353 .hp_nid = 0x03,
13354 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13355 .channel_mode = alc269_modes,
13356 .input_mux = &alc269_eeepc_amic_capture_source,
13357 .unsol_event = alc269_eeepc_amic_unsol_event,
13358 .init_hook = alc269_eeepc_amic_inithook,
13359 },
13360 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013361 .mixers = { alc269_eeepc_mixer },
13362 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013363 .init_verbs = { alc269_init_verbs,
13364 alc269_eeepc_dmic_init_verbs },
13365 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13366 .dac_nids = alc269_dac_nids,
13367 .hp_nid = 0x03,
13368 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13369 .channel_mode = alc269_modes,
13370 .input_mux = &alc269_eeepc_dmic_capture_source,
13371 .unsol_event = alc269_eeepc_dmic_unsol_event,
13372 .init_hook = alc269_eeepc_dmic_inithook,
13373 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013374 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013375 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013376 .cap_mixer = alc269_epc_capture_mixer,
13377 .init_verbs = { alc269_init_verbs,
13378 alc269_eeepc_dmic_init_verbs },
13379 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13380 .dac_nids = alc269_dac_nids,
13381 .hp_nid = 0x03,
13382 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13383 .channel_mode = alc269_modes,
13384 .input_mux = &alc269_eeepc_dmic_capture_source,
13385 .unsol_event = alc269_eeepc_dmic_unsol_event,
13386 .init_hook = alc269_eeepc_dmic_inithook,
13387 },
Tony Vroon64154832008-11-06 15:08:49 +000013388 [ALC269_LIFEBOOK] = {
13389 .mixers = { alc269_lifebook_mixer },
13390 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13391 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13392 .dac_nids = alc269_dac_nids,
13393 .hp_nid = 0x03,
13394 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13395 .channel_mode = alc269_modes,
13396 .input_mux = &alc269_capture_source,
13397 .unsol_event = alc269_lifebook_unsol_event,
13398 .init_hook = alc269_lifebook_init_hook,
13399 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013400};
13401
13402static int patch_alc269(struct hda_codec *codec)
13403{
13404 struct alc_spec *spec;
13405 int board_config;
13406 int err;
13407
13408 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13409 if (spec == NULL)
13410 return -ENOMEM;
13411
13412 codec->spec = spec;
13413
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013414 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13415
Kailang Yangf6a92242007-12-13 16:52:54 +010013416 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13417 alc269_models,
13418 alc269_cfg_tbl);
13419
13420 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020013421 printk(KERN_INFO "hda_codec: Unknown model for %s, "
13422 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013423 board_config = ALC269_AUTO;
13424 }
13425
13426 if (board_config == ALC269_AUTO) {
13427 /* automatic parse from the BIOS config */
13428 err = alc269_parse_auto_config(codec);
13429 if (err < 0) {
13430 alc_free(codec);
13431 return err;
13432 } else if (!err) {
13433 printk(KERN_INFO
13434 "hda_codec: Cannot set up configuration "
13435 "from BIOS. Using base mode...\n");
13436 board_config = ALC269_BASIC;
13437 }
13438 }
13439
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013440 err = snd_hda_attach_beep_device(codec, 0x1);
13441 if (err < 0) {
13442 alc_free(codec);
13443 return err;
13444 }
13445
Kailang Yangf6a92242007-12-13 16:52:54 +010013446 if (board_config != ALC269_AUTO)
13447 setup_preset(spec, &alc269_presets[board_config]);
13448
Takashi Iwaif03d3112009-03-05 14:18:16 +010013449 if (codec->subsystem_id == 0x17aa3bf8) {
13450 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13451 * fix the sample rate of analog I/O to 44.1kHz
13452 */
13453 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13454 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13455 } else {
13456 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13457 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13458 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013459 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13460 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13461
13462 spec->adc_nids = alc269_adc_nids;
13463 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013464 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013465 if (!spec->cap_mixer)
13466 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013467 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013468
13469 codec->patch_ops = alc_patch_ops;
13470 if (board_config == ALC269_AUTO)
13471 spec->init_hook = alc269_auto_init;
13472#ifdef CONFIG_SND_HDA_POWER_SAVE
13473 if (!spec->loopback.amplist)
13474 spec->loopback.amplist = alc269_loopbacks;
13475#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013476 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013477
13478 return 0;
13479}
13480
13481/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013482 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13483 */
13484
13485/*
13486 * set the path ways for 2 channel output
13487 * need to set the codec line out and mic 1 pin widgets to inputs
13488 */
13489static struct hda_verb alc861_threestack_ch2_init[] = {
13490 /* set pin widget 1Ah (line in) for input */
13491 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013492 /* set pin widget 18h (mic1/2) for input, for mic also enable
13493 * the vref
13494 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013495 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13496
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013497 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13498#if 0
13499 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13500 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13501#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013502 { } /* end */
13503};
13504/*
13505 * 6ch mode
13506 * need to set the codec line out and mic 1 pin widgets to outputs
13507 */
13508static struct hda_verb alc861_threestack_ch6_init[] = {
13509 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13510 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13511 /* set pin widget 18h (mic1) for output (CLFE)*/
13512 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13513
13514 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013515 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013516
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013517 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13518#if 0
13519 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13520 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13521#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013522 { } /* end */
13523};
13524
13525static struct hda_channel_mode alc861_threestack_modes[2] = {
13526 { 2, alc861_threestack_ch2_init },
13527 { 6, alc861_threestack_ch6_init },
13528};
Takashi Iwai22309c32006-08-09 16:57:28 +020013529/* Set mic1 as input and unmute the mixer */
13530static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13531 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13532 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13533 { } /* end */
13534};
13535/* Set mic1 as output and mute mixer */
13536static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13537 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13538 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13539 { } /* end */
13540};
13541
13542static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13543 { 2, alc861_uniwill_m31_ch2_init },
13544 { 4, alc861_uniwill_m31_ch4_init },
13545};
Kailang Yangdf694da2005-12-05 19:42:22 +010013546
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013547/* Set mic1 and line-in as input and unmute the mixer */
13548static struct hda_verb alc861_asus_ch2_init[] = {
13549 /* set pin widget 1Ah (line in) for input */
13550 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013551 /* set pin widget 18h (mic1/2) for input, for mic also enable
13552 * the vref
13553 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013554 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13555
13556 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13557#if 0
13558 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13559 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13560#endif
13561 { } /* end */
13562};
13563/* Set mic1 nad line-in as output and mute mixer */
13564static struct hda_verb alc861_asus_ch6_init[] = {
13565 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13566 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13567 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13568 /* set pin widget 18h (mic1) for output (CLFE)*/
13569 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13570 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13571 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13572 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13573
13574 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13575#if 0
13576 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13577 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13578#endif
13579 { } /* end */
13580};
13581
13582static struct hda_channel_mode alc861_asus_modes[2] = {
13583 { 2, alc861_asus_ch2_init },
13584 { 6, alc861_asus_ch6_init },
13585};
13586
Kailang Yangdf694da2005-12-05 19:42:22 +010013587/* patch-ALC861 */
13588
13589static struct snd_kcontrol_new alc861_base_mixer[] = {
13590 /* output mixer control */
13591 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13592 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13593 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13594 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13595 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13596
13597 /*Input mixer control */
13598 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13599 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13600 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13601 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13602 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13603 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13604 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13605 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13606 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13607 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013608
Kailang Yangdf694da2005-12-05 19:42:22 +010013609 { } /* end */
13610};
13611
13612static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13613 /* output mixer control */
13614 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13615 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13616 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13617 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13618 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13619
13620 /* Input mixer control */
13621 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13622 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13623 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13624 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13625 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13626 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13627 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13628 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13629 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13630 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013631
Kailang Yangdf694da2005-12-05 19:42:22 +010013632 {
13633 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13634 .name = "Channel Mode",
13635 .info = alc_ch_mode_info,
13636 .get = alc_ch_mode_get,
13637 .put = alc_ch_mode_put,
13638 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13639 },
13640 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013641};
13642
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013643static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013644 /* output mixer control */
13645 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13646 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13647 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013648
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013649 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013650};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013651
Takashi Iwai22309c32006-08-09 16:57:28 +020013652static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13653 /* output mixer control */
13654 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13655 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13656 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13657 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13658 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13659
13660 /* Input mixer control */
13661 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13662 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13663 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13664 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13665 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13666 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13667 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13668 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13669 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13670 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013671
Takashi Iwai22309c32006-08-09 16:57:28 +020013672 {
13673 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13674 .name = "Channel Mode",
13675 .info = alc_ch_mode_info,
13676 .get = alc_ch_mode_get,
13677 .put = alc_ch_mode_put,
13678 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13679 },
13680 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013681};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013682
13683static struct snd_kcontrol_new alc861_asus_mixer[] = {
13684 /* output mixer control */
13685 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13686 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13687 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13688 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13689 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13690
13691 /* Input mixer control */
13692 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13693 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13694 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13695 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13696 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13697 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13698 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13699 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13700 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013701 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13702
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013703 {
13704 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13705 .name = "Channel Mode",
13706 .info = alc_ch_mode_info,
13707 .get = alc_ch_mode_get,
13708 .put = alc_ch_mode_put,
13709 .private_value = ARRAY_SIZE(alc861_asus_modes),
13710 },
13711 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013712};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013713
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013714/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013715static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013716 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13717 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013718 { }
13719};
13720
Kailang Yangdf694da2005-12-05 19:42:22 +010013721/*
13722 * generic initialization of ADC, input mixers and output mixers
13723 */
13724static struct hda_verb alc861_base_init_verbs[] = {
13725 /*
13726 * Unmute ADC0 and set the default input to mic-in
13727 */
13728 /* port-A for surround (rear panel) */
13729 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13730 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13731 /* port-B for mic-in (rear panel) with vref */
13732 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13733 /* port-C for line-in (rear panel) */
13734 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13735 /* port-D for Front */
13736 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13737 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13738 /* port-E for HP out (front panel) */
13739 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13740 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013741 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013742 /* port-F for mic-in (front panel) with vref */
13743 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13744 /* port-G for CLFE (rear panel) */
13745 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13746 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13747 /* port-H for side (rear panel) */
13748 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13749 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13750 /* CD-in */
13751 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13752 /* route front mic to ADC1*/
13753 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13754 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013755
Kailang Yangdf694da2005-12-05 19:42:22 +010013756 /* Unmute DAC0~3 & spdif out*/
13757 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13758 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13759 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13760 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13761 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013762
Kailang Yangdf694da2005-12-05 19:42:22 +010013763 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13764 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13765 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13766 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13767 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013768
Kailang Yangdf694da2005-12-05 19:42:22 +010013769 /* Unmute Stereo Mixer 15 */
13770 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13771 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13772 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013773 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013774
13775 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13776 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13777 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13778 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13779 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13780 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13781 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13782 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013783 /* hp used DAC 3 (Front) */
13784 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013785 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13786
13787 { }
13788};
13789
13790static struct hda_verb alc861_threestack_init_verbs[] = {
13791 /*
13792 * Unmute ADC0 and set the default input to mic-in
13793 */
13794 /* port-A for surround (rear panel) */
13795 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13796 /* port-B for mic-in (rear panel) with vref */
13797 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13798 /* port-C for line-in (rear panel) */
13799 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13800 /* port-D for Front */
13801 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13802 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13803 /* port-E for HP out (front panel) */
13804 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13805 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013806 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013807 /* port-F for mic-in (front panel) with vref */
13808 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13809 /* port-G for CLFE (rear panel) */
13810 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13811 /* port-H for side (rear panel) */
13812 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13813 /* CD-in */
13814 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13815 /* route front mic to ADC1*/
13816 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13817 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13818 /* Unmute DAC0~3 & spdif out*/
13819 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13820 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13821 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13822 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13823 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013824
Kailang Yangdf694da2005-12-05 19:42:22 +010013825 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13826 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13827 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13828 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13829 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013830
Kailang Yangdf694da2005-12-05 19:42:22 +010013831 /* Unmute Stereo Mixer 15 */
13832 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13833 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13834 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013835 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013836
13837 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13838 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13839 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13840 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13841 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13842 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13843 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13844 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013845 /* hp used DAC 3 (Front) */
13846 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013847 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13848 { }
13849};
Takashi Iwai22309c32006-08-09 16:57:28 +020013850
13851static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13852 /*
13853 * Unmute ADC0 and set the default input to mic-in
13854 */
13855 /* port-A for surround (rear panel) */
13856 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13857 /* port-B for mic-in (rear panel) with vref */
13858 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13859 /* port-C for line-in (rear panel) */
13860 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13861 /* port-D for Front */
13862 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13863 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13864 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013865 /* this has to be set to VREF80 */
13866 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013867 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013868 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013869 /* port-F for mic-in (front panel) with vref */
13870 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13871 /* port-G for CLFE (rear panel) */
13872 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13873 /* port-H for side (rear panel) */
13874 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13875 /* CD-in */
13876 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13877 /* route front mic to ADC1*/
13878 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13879 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13880 /* Unmute DAC0~3 & spdif out*/
13881 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13882 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13883 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13884 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13885 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013886
Takashi Iwai22309c32006-08-09 16:57:28 +020013887 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13888 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13889 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13890 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13891 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013892
Takashi Iwai22309c32006-08-09 16:57:28 +020013893 /* Unmute Stereo Mixer 15 */
13894 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13895 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13896 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013897 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013898
13899 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13900 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13901 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13902 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13903 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13904 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13905 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13906 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013907 /* hp used DAC 3 (Front) */
13908 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013909 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13910 { }
13911};
13912
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013913static struct hda_verb alc861_asus_init_verbs[] = {
13914 /*
13915 * Unmute ADC0 and set the default input to mic-in
13916 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013917 /* port-A for surround (rear panel)
13918 * according to codec#0 this is the HP jack
13919 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013920 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13921 /* route front PCM to HP */
13922 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13923 /* port-B for mic-in (rear panel) with vref */
13924 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13925 /* port-C for line-in (rear panel) */
13926 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13927 /* port-D for Front */
13928 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13929 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13930 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013931 /* this has to be set to VREF80 */
13932 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013933 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013934 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013935 /* port-F for mic-in (front panel) with vref */
13936 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13937 /* port-G for CLFE (rear panel) */
13938 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13939 /* port-H for side (rear panel) */
13940 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13941 /* CD-in */
13942 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13943 /* route front mic to ADC1*/
13944 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13945 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13946 /* Unmute DAC0~3 & spdif out*/
13947 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13948 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13949 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13950 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13951 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13952 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13953 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13954 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13955 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13956 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013957
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013958 /* Unmute Stereo Mixer 15 */
13959 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13960 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13961 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013962 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013963
13964 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13965 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13966 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13967 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13968 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13969 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13970 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13971 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013972 /* hp used DAC 3 (Front) */
13973 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013974 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13975 { }
13976};
13977
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013978/* additional init verbs for ASUS laptops */
13979static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13980 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13981 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13982 { }
13983};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013984
Kailang Yangdf694da2005-12-05 19:42:22 +010013985/*
13986 * generic initialization of ADC, input mixers and output mixers
13987 */
13988static struct hda_verb alc861_auto_init_verbs[] = {
13989 /*
13990 * Unmute ADC0 and set the default input to mic-in
13991 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013992 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013993 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013994
Kailang Yangdf694da2005-12-05 19:42:22 +010013995 /* Unmute DAC0~3 & spdif out*/
13996 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13997 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13998 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13999 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14000 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014001
Kailang Yangdf694da2005-12-05 19:42:22 +010014002 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14003 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14004 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14005 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14006 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014007
Kailang Yangdf694da2005-12-05 19:42:22 +010014008 /* Unmute Stereo Mixer 15 */
14009 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14010 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14011 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14012 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14013
14014 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14015 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14016 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14017 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14018 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14019 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14020 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14021 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14022
14023 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14024 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014025 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14026 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014027 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14028 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014029 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14030 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014031
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014032 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014033
14034 { }
14035};
14036
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014037static struct hda_verb alc861_toshiba_init_verbs[] = {
14038 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014039
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014040 { }
14041};
14042
14043/* toggle speaker-output according to the hp-jack state */
14044static void alc861_toshiba_automute(struct hda_codec *codec)
14045{
14046 unsigned int present;
14047
14048 present = snd_hda_codec_read(codec, 0x0f, 0,
14049 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014050 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14051 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14052 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14053 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014054}
14055
14056static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14057 unsigned int res)
14058{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014059 if ((res >> 26) == ALC880_HP_EVENT)
14060 alc861_toshiba_automute(codec);
14061}
14062
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014063/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014064#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14065#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14066#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14067#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14068
14069
14070#define ALC861_DIGOUT_NID 0x07
14071
14072static struct hda_channel_mode alc861_8ch_modes[1] = {
14073 { 8, NULL }
14074};
14075
14076static hda_nid_t alc861_dac_nids[4] = {
14077 /* front, surround, clfe, side */
14078 0x03, 0x06, 0x05, 0x04
14079};
14080
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014081static hda_nid_t alc660_dac_nids[3] = {
14082 /* front, clfe, surround */
14083 0x03, 0x05, 0x06
14084};
14085
Kailang Yangdf694da2005-12-05 19:42:22 +010014086static hda_nid_t alc861_adc_nids[1] = {
14087 /* ADC0-2 */
14088 0x08,
14089};
14090
14091static struct hda_input_mux alc861_capture_source = {
14092 .num_items = 5,
14093 .items = {
14094 { "Mic", 0x0 },
14095 { "Front Mic", 0x3 },
14096 { "Line", 0x1 },
14097 { "CD", 0x4 },
14098 { "Mixer", 0x5 },
14099 },
14100};
14101
14102/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014103static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
14104 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014105{
14106 int i;
14107 hda_nid_t nid;
14108
14109 spec->multiout.dac_nids = spec->private_dac_nids;
14110 for (i = 0; i < cfg->line_outs; i++) {
14111 nid = cfg->line_out_pins[i];
14112 if (nid) {
14113 if (i >= ARRAY_SIZE(alc861_dac_nids))
14114 continue;
14115 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
14116 }
14117 }
14118 spec->multiout.num_dacs = cfg->line_outs;
14119 return 0;
14120}
14121
14122/* add playback controls from the parsed DAC table */
14123static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
14124 const struct auto_pin_cfg *cfg)
14125{
14126 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014127 static const char *chname[4] = {
14128 "Front", "Surround", NULL /*CLFE*/, "Side"
14129 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014130 hda_nid_t nid;
14131 int i, idx, err;
14132
14133 for (i = 0; i < cfg->line_outs; i++) {
14134 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014135 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014136 continue;
14137 if (nid == 0x05) {
14138 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014139 err = add_control(spec, ALC_CTL_BIND_MUTE,
14140 "Center Playback Switch",
14141 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
14142 HDA_OUTPUT));
14143 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014144 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014145 err = add_control(spec, ALC_CTL_BIND_MUTE,
14146 "LFE Playback Switch",
14147 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
14148 HDA_OUTPUT));
14149 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014150 return err;
14151 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014152 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
14153 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010014154 if (nid == alc861_dac_nids[idx])
14155 break;
14156 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014157 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14158 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
14159 HDA_OUTPUT));
14160 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014161 return err;
14162 }
14163 }
14164 return 0;
14165}
14166
14167static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
14168{
14169 int err;
14170 hda_nid_t nid;
14171
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014172 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014173 return 0;
14174
14175 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
14176 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014177 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
14178 "Headphone Playback Switch",
14179 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
14180 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014181 return err;
14182 spec->multiout.hp_nid = nid;
14183 }
14184 return 0;
14185}
14186
14187/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014188static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
14189 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014190{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014191 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014192 int i, err, idx, idx1;
14193
14194 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014195 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014196 case 0x0c:
14197 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014198 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014199 break;
14200 case 0x0f:
14201 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014202 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014203 break;
14204 case 0x0d:
14205 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014206 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014207 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014208 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010014209 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014210 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014211 break;
14212 case 0x11:
14213 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014214 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010014215 break;
14216 default:
14217 continue;
14218 }
14219
Takashi Iwai4a471b72005-12-07 13:56:29 +010014220 err = new_analog_input(spec, cfg->input_pins[i],
14221 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010014222 if (err < 0)
14223 return err;
14224
Takashi Iwai4a471b72005-12-07 13:56:29 +010014225 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010014226 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014227 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010014228 }
14229 return 0;
14230}
14231
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014232static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14233 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010014234 int pin_type, int dac_idx)
14235{
Jacek Luczak564c5be2008-05-03 18:41:23 +020014236 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14237 pin_type);
14238 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14239 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010014240}
14241
14242static void alc861_auto_init_multi_out(struct hda_codec *codec)
14243{
14244 struct alc_spec *spec = codec->spec;
14245 int i;
14246
14247 for (i = 0; i < spec->autocfg.line_outs; i++) {
14248 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014249 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014250 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014251 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014252 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014253 }
14254}
14255
14256static void alc861_auto_init_hp_out(struct hda_codec *codec)
14257{
14258 struct alc_spec *spec = codec->spec;
14259 hda_nid_t pin;
14260
Takashi Iwaieb06ed82006-09-20 17:10:27 +020014261 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014262 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014263 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
14264 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014265 pin = spec->autocfg.speaker_pins[0];
14266 if (pin)
14267 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014268}
14269
14270static void alc861_auto_init_analog_input(struct hda_codec *codec)
14271{
14272 struct alc_spec *spec = codec->spec;
14273 int i;
14274
14275 for (i = 0; i < AUTO_PIN_LAST; i++) {
14276 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014277 if (nid >= 0x0c && nid <= 0x11)
14278 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014279 }
14280}
14281
14282/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014283/* return 1 if successful, 0 if the proper config is not found,
14284 * or a negative error code
14285 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014286static int alc861_parse_auto_config(struct hda_codec *codec)
14287{
14288 struct alc_spec *spec = codec->spec;
14289 int err;
14290 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14291
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014292 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14293 alc861_ignore);
14294 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014295 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014296 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014297 return 0; /* can't find valid BIOS pin config */
14298
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014299 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
14300 if (err < 0)
14301 return err;
14302 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
14303 if (err < 0)
14304 return err;
14305 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
14306 if (err < 0)
14307 return err;
14308 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
14309 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014310 return err;
14311
14312 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14313
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014314 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014315 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14316
Takashi Iwai603c4012008-07-30 15:01:44 +020014317 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014318 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014319
Takashi Iwaid88897e2008-10-31 15:01:37 +010014320 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014321
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014322 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014323 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014324
14325 spec->adc_nids = alc861_adc_nids;
14326 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014327 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014328
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014329 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14330
Kailang Yangdf694da2005-12-05 19:42:22 +010014331 return 1;
14332}
14333
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014334/* additional initialization for auto-configuration model */
14335static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014336{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014337 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014338 alc861_auto_init_multi_out(codec);
14339 alc861_auto_init_hp_out(codec);
14340 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014341 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014342 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014343}
14344
Takashi Iwaicb53c622007-08-10 17:21:45 +020014345#ifdef CONFIG_SND_HDA_POWER_SAVE
14346static struct hda_amp_list alc861_loopbacks[] = {
14347 { 0x15, HDA_INPUT, 0 },
14348 { 0x15, HDA_INPUT, 1 },
14349 { 0x15, HDA_INPUT, 2 },
14350 { 0x15, HDA_INPUT, 3 },
14351 { } /* end */
14352};
14353#endif
14354
Kailang Yangdf694da2005-12-05 19:42:22 +010014355
14356/*
14357 * configuration and preset
14358 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014359static const char *alc861_models[ALC861_MODEL_LAST] = {
14360 [ALC861_3ST] = "3stack",
14361 [ALC660_3ST] = "3stack-660",
14362 [ALC861_3ST_DIG] = "3stack-dig",
14363 [ALC861_6ST_DIG] = "6stack-dig",
14364 [ALC861_UNIWILL_M31] = "uniwill-m31",
14365 [ALC861_TOSHIBA] = "toshiba",
14366 [ALC861_ASUS] = "asus",
14367 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14368 [ALC861_AUTO] = "auto",
14369};
14370
14371static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014372 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014373 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14374 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14375 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014376 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014377 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014378 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014379 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14380 * Any other models that need this preset?
14381 */
14382 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014383 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14384 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014385 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14386 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14387 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14388 /* FIXME: the below seems conflict */
14389 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14390 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14391 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014392 {}
14393};
14394
14395static struct alc_config_preset alc861_presets[] = {
14396 [ALC861_3ST] = {
14397 .mixers = { alc861_3ST_mixer },
14398 .init_verbs = { alc861_threestack_init_verbs },
14399 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14400 .dac_nids = alc861_dac_nids,
14401 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14402 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014403 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014404 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14405 .adc_nids = alc861_adc_nids,
14406 .input_mux = &alc861_capture_source,
14407 },
14408 [ALC861_3ST_DIG] = {
14409 .mixers = { alc861_base_mixer },
14410 .init_verbs = { alc861_threestack_init_verbs },
14411 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14412 .dac_nids = alc861_dac_nids,
14413 .dig_out_nid = ALC861_DIGOUT_NID,
14414 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14415 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014416 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014417 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14418 .adc_nids = alc861_adc_nids,
14419 .input_mux = &alc861_capture_source,
14420 },
14421 [ALC861_6ST_DIG] = {
14422 .mixers = { alc861_base_mixer },
14423 .init_verbs = { alc861_base_init_verbs },
14424 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14425 .dac_nids = alc861_dac_nids,
14426 .dig_out_nid = ALC861_DIGOUT_NID,
14427 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14428 .channel_mode = alc861_8ch_modes,
14429 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14430 .adc_nids = alc861_adc_nids,
14431 .input_mux = &alc861_capture_source,
14432 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014433 [ALC660_3ST] = {
14434 .mixers = { alc861_3ST_mixer },
14435 .init_verbs = { alc861_threestack_init_verbs },
14436 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14437 .dac_nids = alc660_dac_nids,
14438 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14439 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014440 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014441 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14442 .adc_nids = alc861_adc_nids,
14443 .input_mux = &alc861_capture_source,
14444 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014445 [ALC861_UNIWILL_M31] = {
14446 .mixers = { alc861_uniwill_m31_mixer },
14447 .init_verbs = { alc861_uniwill_m31_init_verbs },
14448 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14449 .dac_nids = alc861_dac_nids,
14450 .dig_out_nid = ALC861_DIGOUT_NID,
14451 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14452 .channel_mode = alc861_uniwill_m31_modes,
14453 .need_dac_fix = 1,
14454 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14455 .adc_nids = alc861_adc_nids,
14456 .input_mux = &alc861_capture_source,
14457 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014458 [ALC861_TOSHIBA] = {
14459 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014460 .init_verbs = { alc861_base_init_verbs,
14461 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014462 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14463 .dac_nids = alc861_dac_nids,
14464 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14465 .channel_mode = alc883_3ST_2ch_modes,
14466 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14467 .adc_nids = alc861_adc_nids,
14468 .input_mux = &alc861_capture_source,
14469 .unsol_event = alc861_toshiba_unsol_event,
14470 .init_hook = alc861_toshiba_automute,
14471 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014472 [ALC861_ASUS] = {
14473 .mixers = { alc861_asus_mixer },
14474 .init_verbs = { alc861_asus_init_verbs },
14475 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14476 .dac_nids = alc861_dac_nids,
14477 .dig_out_nid = ALC861_DIGOUT_NID,
14478 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14479 .channel_mode = alc861_asus_modes,
14480 .need_dac_fix = 1,
14481 .hp_nid = 0x06,
14482 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14483 .adc_nids = alc861_adc_nids,
14484 .input_mux = &alc861_capture_source,
14485 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014486 [ALC861_ASUS_LAPTOP] = {
14487 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14488 .init_verbs = { alc861_asus_init_verbs,
14489 alc861_asus_laptop_init_verbs },
14490 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14491 .dac_nids = alc861_dac_nids,
14492 .dig_out_nid = ALC861_DIGOUT_NID,
14493 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14494 .channel_mode = alc883_3ST_2ch_modes,
14495 .need_dac_fix = 1,
14496 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14497 .adc_nids = alc861_adc_nids,
14498 .input_mux = &alc861_capture_source,
14499 },
14500};
Kailang Yangdf694da2005-12-05 19:42:22 +010014501
14502
14503static int patch_alc861(struct hda_codec *codec)
14504{
14505 struct alc_spec *spec;
14506 int board_config;
14507 int err;
14508
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014509 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014510 if (spec == NULL)
14511 return -ENOMEM;
14512
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014513 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014514
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014515 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14516 alc861_models,
14517 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014518
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014519 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020014520 printk(KERN_INFO "hda_codec: Unknown model for %s, "
14521 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014522 board_config = ALC861_AUTO;
14523 }
14524
14525 if (board_config == ALC861_AUTO) {
14526 /* automatic parse from the BIOS config */
14527 err = alc861_parse_auto_config(codec);
14528 if (err < 0) {
14529 alc_free(codec);
14530 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014531 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014532 printk(KERN_INFO
14533 "hda_codec: Cannot set up configuration "
14534 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014535 board_config = ALC861_3ST_DIG;
14536 }
14537 }
14538
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014539 err = snd_hda_attach_beep_device(codec, 0x23);
14540 if (err < 0) {
14541 alc_free(codec);
14542 return err;
14543 }
14544
Kailang Yangdf694da2005-12-05 19:42:22 +010014545 if (board_config != ALC861_AUTO)
14546 setup_preset(spec, &alc861_presets[board_config]);
14547
Kailang Yangdf694da2005-12-05 19:42:22 +010014548 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14549 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14550
Kailang Yangdf694da2005-12-05 19:42:22 +010014551 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14552 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14553
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014554 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14555
Takashi Iwai2134ea42008-01-10 16:53:55 +010014556 spec->vmaster_nid = 0x03;
14557
Kailang Yangdf694da2005-12-05 19:42:22 +010014558 codec->patch_ops = alc_patch_ops;
14559 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014560 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014561#ifdef CONFIG_SND_HDA_POWER_SAVE
14562 if (!spec->loopback.amplist)
14563 spec->loopback.amplist = alc861_loopbacks;
14564#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014565 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014566
Kailang Yangdf694da2005-12-05 19:42:22 +010014567 return 0;
14568}
14569
14570/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014571 * ALC861-VD support
14572 *
14573 * Based on ALC882
14574 *
14575 * In addition, an independent DAC
14576 */
14577#define ALC861VD_DIGOUT_NID 0x06
14578
14579static hda_nid_t alc861vd_dac_nids[4] = {
14580 /* front, surr, clfe, side surr */
14581 0x02, 0x03, 0x04, 0x05
14582};
14583
14584/* dac_nids for ALC660vd are in a different order - according to
14585 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014586 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014587 * of ALC660vd codecs, but for now there is only 3stack mixer
14588 * - and it is the same as in 861vd.
14589 * adc_nids in ALC660vd are (is) the same as in 861vd
14590 */
14591static hda_nid_t alc660vd_dac_nids[3] = {
14592 /* front, rear, clfe, rear_surr */
14593 0x02, 0x04, 0x03
14594};
14595
14596static hda_nid_t alc861vd_adc_nids[1] = {
14597 /* ADC0 */
14598 0x09,
14599};
14600
Takashi Iwaie1406342008-02-11 18:32:32 +010014601static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14602
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014603/* input MUX */
14604/* FIXME: should be a matrix-type input source selection */
14605static struct hda_input_mux alc861vd_capture_source = {
14606 .num_items = 4,
14607 .items = {
14608 { "Mic", 0x0 },
14609 { "Front Mic", 0x1 },
14610 { "Line", 0x2 },
14611 { "CD", 0x4 },
14612 },
14613};
14614
Kailang Yang272a5272007-05-14 11:00:38 +020014615static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014616 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014617 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014618 { "Ext Mic", 0x0 },
14619 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014620 },
14621};
14622
Kailang Yangd1a991a2007-08-15 16:21:59 +020014623static struct hda_input_mux alc861vd_hp_capture_source = {
14624 .num_items = 2,
14625 .items = {
14626 { "Front Mic", 0x0 },
14627 { "ATAPI Mic", 0x1 },
14628 },
14629};
14630
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014631/*
14632 * 2ch mode
14633 */
14634static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14635 { 2, NULL }
14636};
14637
14638/*
14639 * 6ch mode
14640 */
14641static struct hda_verb alc861vd_6stack_ch6_init[] = {
14642 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14643 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14644 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14645 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14646 { } /* end */
14647};
14648
14649/*
14650 * 8ch mode
14651 */
14652static struct hda_verb alc861vd_6stack_ch8_init[] = {
14653 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14654 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14655 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14656 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14657 { } /* end */
14658};
14659
14660static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14661 { 6, alc861vd_6stack_ch6_init },
14662 { 8, alc861vd_6stack_ch8_init },
14663};
14664
14665static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14666 {
14667 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14668 .name = "Channel Mode",
14669 .info = alc_ch_mode_info,
14670 .get = alc_ch_mode_get,
14671 .put = alc_ch_mode_put,
14672 },
14673 { } /* end */
14674};
14675
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014676/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14677 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14678 */
14679static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14680 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14681 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14682
14683 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14684 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14685
14686 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14687 HDA_OUTPUT),
14688 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14689 HDA_OUTPUT),
14690 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14691 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14692
14693 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14694 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14695
14696 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14697
14698 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14699 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14700 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14701
14702 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14703 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14704 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14705
14706 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14707 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14708
14709 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14710 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14711
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014712 { } /* end */
14713};
14714
14715static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14716 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14717 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14718
14719 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14720
14721 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14722 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14723 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14724
14725 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14726 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14727 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14728
14729 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14730 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14731
14732 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14733 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14734
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014735 { } /* end */
14736};
14737
Kailang Yangbdd148a2007-05-08 15:19:08 +020014738static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14739 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14740 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14741 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14742
14743 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14744
14745 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14746 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14747 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14748
14749 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14750 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14751 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14752
14753 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14754 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14755
14756 { } /* end */
14757};
14758
Tobin Davisb419f342008-03-07 11:57:51 +010014759/* Pin assignment: Speaker=0x14, HP = 0x15,
14760 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014761 */
14762static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014763 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14764 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014765 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14766 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014767 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14768 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14769 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14770 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14771 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14772 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014773 { } /* end */
14774};
14775
Kailang Yangd1a991a2007-08-15 16:21:59 +020014776/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14777 * Front Mic=0x18, ATAPI Mic = 0x19,
14778 */
14779static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14780 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14781 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14782 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14783 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14784 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14785 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14786 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14787 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014788
Kailang Yangd1a991a2007-08-15 16:21:59 +020014789 { } /* end */
14790};
14791
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014792/*
14793 * generic initialization of ADC, input mixers and output mixers
14794 */
14795static struct hda_verb alc861vd_volume_init_verbs[] = {
14796 /*
14797 * Unmute ADC0 and set the default input to mic-in
14798 */
14799 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14800 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14801
14802 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14803 * the analog-loopback mixer widget
14804 */
14805 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014806 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14807 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14808 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14809 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14810 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014811
14812 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014813 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14814 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14815 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014816 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014817
14818 /*
14819 * Set up output mixers (0x02 - 0x05)
14820 */
14821 /* set vol=0 to output mixers */
14822 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14823 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14824 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14825 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14826
14827 /* set up input amps for analog loopback */
14828 /* Amp Indices: DAC = 0, mixer = 1 */
14829 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14830 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14831 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14832 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14833 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14834 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14835 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14836 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14837
14838 { }
14839};
14840
14841/*
14842 * 3-stack pin configuration:
14843 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14844 */
14845static struct hda_verb alc861vd_3stack_init_verbs[] = {
14846 /*
14847 * Set pin mode and muting
14848 */
14849 /* set front pin widgets 0x14 for output */
14850 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14851 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14852 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14853
14854 /* Mic (rear) pin: input vref at 80% */
14855 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14856 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14857 /* Front Mic pin: input vref at 80% */
14858 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14859 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14860 /* Line In pin: input */
14861 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14862 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14863 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14864 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14865 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14866 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14867 /* CD pin widget for input */
14868 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14869
14870 { }
14871};
14872
14873/*
14874 * 6-stack pin configuration:
14875 */
14876static struct hda_verb alc861vd_6stack_init_verbs[] = {
14877 /*
14878 * Set pin mode and muting
14879 */
14880 /* set front pin widgets 0x14 for output */
14881 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14882 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14883 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14884
14885 /* Rear Pin: output 1 (0x0d) */
14886 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14887 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14888 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14889 /* CLFE Pin: output 2 (0x0e) */
14890 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14891 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14892 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14893 /* Side Pin: output 3 (0x0f) */
14894 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14895 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14896 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14897
14898 /* Mic (rear) pin: input vref at 80% */
14899 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14900 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14901 /* Front Mic pin: input vref at 80% */
14902 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14903 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14904 /* Line In pin: input */
14905 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14906 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14907 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14908 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14909 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14910 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14911 /* CD pin widget for input */
14912 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14913
14914 { }
14915};
14916
Kailang Yangbdd148a2007-05-08 15:19:08 +020014917static struct hda_verb alc861vd_eapd_verbs[] = {
14918 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14919 { }
14920};
14921
Kailang Yangf9423e72008-05-27 12:32:25 +020014922static struct hda_verb alc660vd_eapd_verbs[] = {
14923 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14924 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14925 { }
14926};
14927
Kailang Yangbdd148a2007-05-08 15:19:08 +020014928static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14929 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14930 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14931 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14932 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014933 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014934 {}
14935};
14936
Kailang Yangbdd148a2007-05-08 15:19:08 +020014937static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14938{
14939 unsigned int present;
14940 unsigned char bits;
14941
14942 present = snd_hda_codec_read(codec, 0x18, 0,
14943 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014944 bits = present ? HDA_AMP_MUTE : 0;
14945 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14946 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014947}
14948
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014949static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020014950{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014951 struct alc_spec *spec = codec->spec;
14952
14953 spec->autocfg.hp_pins[0] = 0x1b;
14954 spec->autocfg.speaker_pins[0] = 0x14;
14955 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014956 alc861vd_lenovo_mic_automute(codec);
14957}
14958
14959static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14960 unsigned int res)
14961{
14962 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020014963 case ALC880_MIC_EVENT:
14964 alc861vd_lenovo_mic_automute(codec);
14965 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014966 default:
14967 alc_automute_amp_unsol_event(codec, res);
14968 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020014969 }
14970}
14971
Kailang Yang272a5272007-05-14 11:00:38 +020014972static struct hda_verb alc861vd_dallas_verbs[] = {
14973 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14974 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14975 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14976 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14977
14978 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14979 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14980 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14981 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14982 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14983 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14984 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14985 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014986
Kailang Yang272a5272007-05-14 11:00:38 +020014987 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14988 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14989 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14990 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14991 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14992 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14993 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14994 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14995
14996 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14997 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14998 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14999 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15000 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15001 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15002 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15003 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15004
15005 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15006 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15007 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15008 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15009
15010 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015011 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015012 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15013
15014 { } /* end */
15015};
15016
15017/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015018static void alc861vd_dallas_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015019{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015020 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015021
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015022 spec->autocfg.hp_pins[0] = 0x15;
15023 spec->autocfg.speaker_pins[0] = 0x14;
15024 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +020015025}
15026
Takashi Iwaicb53c622007-08-10 17:21:45 +020015027#ifdef CONFIG_SND_HDA_POWER_SAVE
15028#define alc861vd_loopbacks alc880_loopbacks
15029#endif
15030
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015031/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015032#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15033#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15034#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15035#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15036
15037/*
15038 * configuration and preset
15039 */
15040static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15041 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015042 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015043 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015044 [ALC861VD_3ST] = "3stack",
15045 [ALC861VD_3ST_DIG] = "3stack-digout",
15046 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015047 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015048 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015049 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015050 [ALC861VD_AUTO] = "auto",
15051};
15052
15053static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015054 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15055 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015056 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015057 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010015058 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015059 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015060 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015061 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015062 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020015063 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015064 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015065 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015066 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015067 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015068 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015069 {}
15070};
15071
15072static struct alc_config_preset alc861vd_presets[] = {
15073 [ALC660VD_3ST] = {
15074 .mixers = { alc861vd_3st_mixer },
15075 .init_verbs = { alc861vd_volume_init_verbs,
15076 alc861vd_3stack_init_verbs },
15077 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15078 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015079 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15080 .channel_mode = alc861vd_3stack_2ch_modes,
15081 .input_mux = &alc861vd_capture_source,
15082 },
Mike Crash6963f842007-06-25 12:12:51 +020015083 [ALC660VD_3ST_DIG] = {
15084 .mixers = { alc861vd_3st_mixer },
15085 .init_verbs = { alc861vd_volume_init_verbs,
15086 alc861vd_3stack_init_verbs },
15087 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15088 .dac_nids = alc660vd_dac_nids,
15089 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015090 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15091 .channel_mode = alc861vd_3stack_2ch_modes,
15092 .input_mux = &alc861vd_capture_source,
15093 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015094 [ALC861VD_3ST] = {
15095 .mixers = { alc861vd_3st_mixer },
15096 .init_verbs = { alc861vd_volume_init_verbs,
15097 alc861vd_3stack_init_verbs },
15098 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15099 .dac_nids = alc861vd_dac_nids,
15100 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15101 .channel_mode = alc861vd_3stack_2ch_modes,
15102 .input_mux = &alc861vd_capture_source,
15103 },
15104 [ALC861VD_3ST_DIG] = {
15105 .mixers = { alc861vd_3st_mixer },
15106 .init_verbs = { alc861vd_volume_init_verbs,
15107 alc861vd_3stack_init_verbs },
15108 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15109 .dac_nids = alc861vd_dac_nids,
15110 .dig_out_nid = ALC861VD_DIGOUT_NID,
15111 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15112 .channel_mode = alc861vd_3stack_2ch_modes,
15113 .input_mux = &alc861vd_capture_source,
15114 },
15115 [ALC861VD_6ST_DIG] = {
15116 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15117 .init_verbs = { alc861vd_volume_init_verbs,
15118 alc861vd_6stack_init_verbs },
15119 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15120 .dac_nids = alc861vd_dac_nids,
15121 .dig_out_nid = ALC861VD_DIGOUT_NID,
15122 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15123 .channel_mode = alc861vd_6stack_modes,
15124 .input_mux = &alc861vd_capture_source,
15125 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015126 [ALC861VD_LENOVO] = {
15127 .mixers = { alc861vd_lenovo_mixer },
15128 .init_verbs = { alc861vd_volume_init_verbs,
15129 alc861vd_3stack_init_verbs,
15130 alc861vd_eapd_verbs,
15131 alc861vd_lenovo_unsol_verbs },
15132 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15133 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015134 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15135 .channel_mode = alc861vd_3stack_2ch_modes,
15136 .input_mux = &alc861vd_capture_source,
15137 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015138 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015139 },
Kailang Yang272a5272007-05-14 11:00:38 +020015140 [ALC861VD_DALLAS] = {
15141 .mixers = { alc861vd_dallas_mixer },
15142 .init_verbs = { alc861vd_dallas_verbs },
15143 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15144 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015145 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15146 .channel_mode = alc861vd_3stack_2ch_modes,
15147 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015148 .unsol_event = alc_automute_amp_unsol_event,
15149 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015150 },
15151 [ALC861VD_HP] = {
15152 .mixers = { alc861vd_hp_mixer },
15153 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15154 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15155 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015156 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015157 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15158 .channel_mode = alc861vd_3stack_2ch_modes,
15159 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015160 .unsol_event = alc_automute_amp_unsol_event,
15161 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020015162 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015163 [ALC660VD_ASUS_V1S] = {
15164 .mixers = { alc861vd_lenovo_mixer },
15165 .init_verbs = { alc861vd_volume_init_verbs,
15166 alc861vd_3stack_init_verbs,
15167 alc861vd_eapd_verbs,
15168 alc861vd_lenovo_unsol_verbs },
15169 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15170 .dac_nids = alc660vd_dac_nids,
15171 .dig_out_nid = ALC861VD_DIGOUT_NID,
15172 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15173 .channel_mode = alc861vd_3stack_2ch_modes,
15174 .input_mux = &alc861vd_capture_source,
15175 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015176 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015177 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015178};
15179
15180/*
15181 * BIOS auto configuration
15182 */
15183static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15184 hda_nid_t nid, int pin_type, int dac_idx)
15185{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015186 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015187}
15188
15189static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15190{
15191 struct alc_spec *spec = codec->spec;
15192 int i;
15193
15194 for (i = 0; i <= HDA_SIDE; i++) {
15195 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015196 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015197 if (nid)
15198 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015199 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015200 }
15201}
15202
15203
15204static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15205{
15206 struct alc_spec *spec = codec->spec;
15207 hda_nid_t pin;
15208
15209 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015210 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015211 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015212 pin = spec->autocfg.speaker_pins[0];
15213 if (pin)
15214 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015215}
15216
15217#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
15218#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15219
15220static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15221{
15222 struct alc_spec *spec = codec->spec;
15223 int i;
15224
15225 for (i = 0; i < AUTO_PIN_LAST; i++) {
15226 hda_nid_t nid = spec->autocfg.input_pins[i];
15227 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015228 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015229 if (nid != ALC861VD_PIN_CD_NID &&
15230 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015231 snd_hda_codec_write(codec, nid, 0,
15232 AC_VERB_SET_AMP_GAIN_MUTE,
15233 AMP_OUT_MUTE);
15234 }
15235 }
15236}
15237
Takashi Iwaif511b012008-08-15 16:46:42 +020015238#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15239
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015240#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15241#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15242
15243/* add playback controls from the parsed DAC table */
15244/* Based on ALC880 version. But ALC861VD has separate,
15245 * different NIDs for mute/unmute switch and volume control */
15246static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15247 const struct auto_pin_cfg *cfg)
15248{
15249 char name[32];
15250 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15251 hda_nid_t nid_v, nid_s;
15252 int i, err;
15253
15254 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015255 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015256 continue;
15257 nid_v = alc861vd_idx_to_mixer_vol(
15258 alc880_dac_to_idx(
15259 spec->multiout.dac_nids[i]));
15260 nid_s = alc861vd_idx_to_mixer_switch(
15261 alc880_dac_to_idx(
15262 spec->multiout.dac_nids[i]));
15263
15264 if (i == 2) {
15265 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015266 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15267 "Center Playback Volume",
15268 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15269 HDA_OUTPUT));
15270 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015271 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015272 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15273 "LFE Playback Volume",
15274 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15275 HDA_OUTPUT));
15276 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015277 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015278 err = add_control(spec, ALC_CTL_BIND_MUTE,
15279 "Center Playback Switch",
15280 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15281 HDA_INPUT));
15282 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015283 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015284 err = add_control(spec, ALC_CTL_BIND_MUTE,
15285 "LFE Playback Switch",
15286 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15287 HDA_INPUT));
15288 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015289 return err;
15290 } else {
15291 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015292 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15293 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15294 HDA_OUTPUT));
15295 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015296 return err;
15297 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015298 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015299 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015300 HDA_INPUT));
15301 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015302 return err;
15303 }
15304 }
15305 return 0;
15306}
15307
15308/* add playback controls for speaker and HP outputs */
15309/* Based on ALC880 version. But ALC861VD has separate,
15310 * different NIDs for mute/unmute switch and volume control */
15311static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15312 hda_nid_t pin, const char *pfx)
15313{
15314 hda_nid_t nid_v, nid_s;
15315 int err;
15316 char name[32];
15317
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015318 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015319 return 0;
15320
15321 if (alc880_is_fixed_pin(pin)) {
15322 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15323 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015324 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015325 spec->multiout.hp_nid = nid_v;
15326 else
15327 spec->multiout.extra_out_nid[0] = nid_v;
15328 /* control HP volume/switch on the output mixer amp */
15329 nid_v = alc861vd_idx_to_mixer_vol(
15330 alc880_fixed_pin_idx(pin));
15331 nid_s = alc861vd_idx_to_mixer_switch(
15332 alc880_fixed_pin_idx(pin));
15333
15334 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015335 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15336 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15337 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015338 return err;
15339 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015340 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15341 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15342 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015343 return err;
15344 } else if (alc880_is_multi_pin(pin)) {
15345 /* set manual connection */
15346 /* we have only a switch on HP-out PIN */
15347 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015348 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15349 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15350 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015351 return err;
15352 }
15353 return 0;
15354}
15355
15356/* parse the BIOS configuration and set up the alc_spec
15357 * return 1 if successful, 0 if the proper config is not found,
15358 * or a negative error code
15359 * Based on ALC880 version - had to change it to override
15360 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15361static int alc861vd_parse_auto_config(struct hda_codec *codec)
15362{
15363 struct alc_spec *spec = codec->spec;
15364 int err;
15365 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15366
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015367 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15368 alc861vd_ignore);
15369 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015370 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015371 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015372 return 0; /* can't find valid BIOS pin config */
15373
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015374 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15375 if (err < 0)
15376 return err;
15377 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15378 if (err < 0)
15379 return err;
15380 err = alc861vd_auto_create_extra_out(spec,
15381 spec->autocfg.speaker_pins[0],
15382 "Speaker");
15383 if (err < 0)
15384 return err;
15385 err = alc861vd_auto_create_extra_out(spec,
15386 spec->autocfg.hp_pins[0],
15387 "Headphone");
15388 if (err < 0)
15389 return err;
15390 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15391 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015392 return err;
15393
15394 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15395
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015396 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015397 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15398
Takashi Iwai603c4012008-07-30 15:01:44 +020015399 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015400 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015401
Takashi Iwaid88897e2008-10-31 15:01:37 +010015402 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015403
15404 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015405 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015406
Takashi Iwai776e1842007-08-29 15:07:11 +020015407 err = alc_auto_add_mic_boost(codec);
15408 if (err < 0)
15409 return err;
15410
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015411 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15412
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015413 return 1;
15414}
15415
15416/* additional initialization for auto-configuration model */
15417static void alc861vd_auto_init(struct hda_codec *codec)
15418{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015419 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015420 alc861vd_auto_init_multi_out(codec);
15421 alc861vd_auto_init_hp_out(codec);
15422 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015423 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015424 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015425 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015426}
15427
15428static int patch_alc861vd(struct hda_codec *codec)
15429{
15430 struct alc_spec *spec;
15431 int err, board_config;
15432
15433 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15434 if (spec == NULL)
15435 return -ENOMEM;
15436
15437 codec->spec = spec;
15438
15439 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15440 alc861vd_models,
15441 alc861vd_cfg_tbl);
15442
15443 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020015444 printk(KERN_INFO "hda_codec: Unknown model for %s, "
15445 "trying auto-probe from BIOS...\n", codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015446 board_config = ALC861VD_AUTO;
15447 }
15448
15449 if (board_config == ALC861VD_AUTO) {
15450 /* automatic parse from the BIOS config */
15451 err = alc861vd_parse_auto_config(codec);
15452 if (err < 0) {
15453 alc_free(codec);
15454 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015455 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015456 printk(KERN_INFO
15457 "hda_codec: Cannot set up configuration "
15458 "from BIOS. Using base mode...\n");
15459 board_config = ALC861VD_3ST;
15460 }
15461 }
15462
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015463 err = snd_hda_attach_beep_device(codec, 0x23);
15464 if (err < 0) {
15465 alc_free(codec);
15466 return err;
15467 }
15468
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015469 if (board_config != ALC861VD_AUTO)
15470 setup_preset(spec, &alc861vd_presets[board_config]);
15471
Kailang Yang2f893282008-05-27 12:14:47 +020015472 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015473 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015474 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015475 }
15476
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015477 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15478 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15479
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015480 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15481 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15482
15483 spec->adc_nids = alc861vd_adc_nids;
15484 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010015485 spec->capsrc_nids = alc861vd_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015486 spec->capture_style = CAPT_MIX;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015487
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015488 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015489 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015490
Takashi Iwai2134ea42008-01-10 16:53:55 +010015491 spec->vmaster_nid = 0x02;
15492
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015493 codec->patch_ops = alc_patch_ops;
15494
15495 if (board_config == ALC861VD_AUTO)
15496 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015497#ifdef CONFIG_SND_HDA_POWER_SAVE
15498 if (!spec->loopback.amplist)
15499 spec->loopback.amplist = alc861vd_loopbacks;
15500#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015501 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015502
15503 return 0;
15504}
15505
15506/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015507 * ALC662 support
15508 *
15509 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15510 * configuration. Each pin widget can choose any input DACs and a mixer.
15511 * Each ADC is connected from a mixer of all inputs. This makes possible
15512 * 6-channel independent captures.
15513 *
15514 * In addition, an independent DAC for the multi-playback (not used in this
15515 * driver yet).
15516 */
15517#define ALC662_DIGOUT_NID 0x06
15518#define ALC662_DIGIN_NID 0x0a
15519
15520static hda_nid_t alc662_dac_nids[4] = {
15521 /* front, rear, clfe, rear_surr */
15522 0x02, 0x03, 0x04
15523};
15524
Kailang Yang622e84c2009-04-21 07:39:04 +020015525static hda_nid_t alc272_dac_nids[2] = {
15526 0x02, 0x03
15527};
15528
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015529static hda_nid_t alc662_adc_nids[1] = {
15530 /* ADC1-2 */
15531 0x09,
15532};
Takashi Iwaie1406342008-02-11 18:32:32 +010015533
Kailang Yang622e84c2009-04-21 07:39:04 +020015534static hda_nid_t alc272_adc_nids[1] = {
15535 /* ADC1-2 */
15536 0x08,
15537};
15538
Kailang Yang77a261b2008-02-19 11:38:05 +010015539static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015540static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15541
Takashi Iwaie1406342008-02-11 18:32:32 +010015542
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015543/* input MUX */
15544/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015545static struct hda_input_mux alc662_capture_source = {
15546 .num_items = 4,
15547 .items = {
15548 { "Mic", 0x0 },
15549 { "Front Mic", 0x1 },
15550 { "Line", 0x2 },
15551 { "CD", 0x4 },
15552 },
15553};
15554
15555static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15556 .num_items = 2,
15557 .items = {
15558 { "Mic", 0x1 },
15559 { "Line", 0x2 },
15560 },
15561};
Kailang Yang291702f2007-10-16 14:28:03 +020015562
15563static struct hda_input_mux alc662_eeepc_capture_source = {
15564 .num_items = 2,
15565 .items = {
15566 { "i-Mic", 0x1 },
15567 { "e-Mic", 0x0 },
15568 },
15569};
15570
Kailang Yang6dda9f42008-05-27 12:05:31 +020015571static struct hda_input_mux alc663_capture_source = {
15572 .num_items = 3,
15573 .items = {
15574 { "Mic", 0x0 },
15575 { "Front Mic", 0x1 },
15576 { "Line", 0x2 },
15577 },
15578};
15579
15580static struct hda_input_mux alc663_m51va_capture_source = {
15581 .num_items = 2,
15582 .items = {
15583 { "Ext-Mic", 0x0 },
15584 { "D-Mic", 0x9 },
15585 },
15586};
15587
Chris Pockelé9541ba12009-05-12 08:08:53 +020015588#if 1 /* set to 0 for testing other input sources below */
15589static struct hda_input_mux alc272_nc10_capture_source = {
15590 .num_items = 2,
15591 .items = {
15592 { "Autoselect Mic", 0x0 },
15593 { "Internal Mic", 0x1 },
15594 },
15595};
15596#else
15597static struct hda_input_mux alc272_nc10_capture_source = {
15598 .num_items = 16,
15599 .items = {
15600 { "Autoselect Mic", 0x0 },
15601 { "Internal Mic", 0x1 },
15602 { "In-0x02", 0x2 },
15603 { "In-0x03", 0x3 },
15604 { "In-0x04", 0x4 },
15605 { "In-0x05", 0x5 },
15606 { "In-0x06", 0x6 },
15607 { "In-0x07", 0x7 },
15608 { "In-0x08", 0x8 },
15609 { "In-0x09", 0x9 },
15610 { "In-0x0a", 0x0a },
15611 { "In-0x0b", 0x0b },
15612 { "In-0x0c", 0x0c },
15613 { "In-0x0d", 0x0d },
15614 { "In-0x0e", 0x0e },
15615 { "In-0x0f", 0x0f },
15616 },
15617};
15618#endif
15619
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015620/*
15621 * 2ch mode
15622 */
15623static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15624 { 2, NULL }
15625};
15626
15627/*
15628 * 2ch mode
15629 */
15630static struct hda_verb alc662_3ST_ch2_init[] = {
15631 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15632 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15633 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15634 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15635 { } /* end */
15636};
15637
15638/*
15639 * 6ch mode
15640 */
15641static struct hda_verb alc662_3ST_ch6_init[] = {
15642 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15643 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15644 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15645 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15646 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15647 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15648 { } /* end */
15649};
15650
15651static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15652 { 2, alc662_3ST_ch2_init },
15653 { 6, alc662_3ST_ch6_init },
15654};
15655
15656/*
15657 * 2ch mode
15658 */
15659static struct hda_verb alc662_sixstack_ch6_init[] = {
15660 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15661 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15662 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15663 { } /* end */
15664};
15665
15666/*
15667 * 6ch mode
15668 */
15669static struct hda_verb alc662_sixstack_ch8_init[] = {
15670 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15671 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15672 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15673 { } /* end */
15674};
15675
15676static struct hda_channel_mode alc662_5stack_modes[2] = {
15677 { 2, alc662_sixstack_ch6_init },
15678 { 6, alc662_sixstack_ch8_init },
15679};
15680
15681/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15682 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15683 */
15684
15685static struct snd_kcontrol_new alc662_base_mixer[] = {
15686 /* output mixer control */
15687 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015688 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015689 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015690 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015691 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15692 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015693 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15694 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015695 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15696
15697 /*Input mixer control */
15698 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15699 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15700 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15701 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15702 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15703 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15704 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15705 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015706 { } /* end */
15707};
15708
15709static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15710 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015711 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015712 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15713 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15714 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15715 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15716 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15717 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15718 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15719 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15720 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015721 { } /* end */
15722};
15723
15724static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15725 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015726 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015727 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015728 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015729 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15730 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015731 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15732 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015733 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15734 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15735 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15736 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15737 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15738 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15739 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15740 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15741 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015742 { } /* end */
15743};
15744
15745static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15746 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15747 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015748 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15749 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015750 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15751 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15752 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15753 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15754 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015755 { } /* end */
15756};
15757
Kailang Yang291702f2007-10-16 14:28:03 +020015758static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015759 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15760 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015761
15762 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15763 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15764 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15765
15766 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15767 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15768 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15769 { } /* end */
15770};
15771
Kailang Yang8c427222008-01-10 13:03:59 +010015772static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015773 ALC262_HIPPO_MASTER_SWITCH,
15774 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015775 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015776 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15777 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015778 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15779 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15780 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15781 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15782 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15783 { } /* end */
15784};
15785
Kailang Yangf1d4e282008-08-26 14:03:29 +020015786static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15787 .ops = &snd_hda_bind_vol,
15788 .values = {
15789 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15790 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15791 0
15792 },
15793};
15794
15795static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15796 .ops = &snd_hda_bind_sw,
15797 .values = {
15798 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15799 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15800 0
15801 },
15802};
15803
Kailang Yang6dda9f42008-05-27 12:05:31 +020015804static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015805 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15806 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15807 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15808 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15809 { } /* end */
15810};
15811
15812static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15813 .ops = &snd_hda_bind_sw,
15814 .values = {
15815 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15816 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15817 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15818 0
15819 },
15820};
15821
15822static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15823 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15824 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15825 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15826 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15827 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15828 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15829
15830 { } /* end */
15831};
15832
15833static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15834 .ops = &snd_hda_bind_sw,
15835 .values = {
15836 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15837 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15838 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15839 0
15840 },
15841};
15842
15843static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15844 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15845 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15846 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15847 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15848 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15849 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15850 { } /* end */
15851};
15852
15853static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015854 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15855 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015856 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15857 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15858 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15859 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15860 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15861 { } /* end */
15862};
15863
15864static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15865 .ops = &snd_hda_bind_vol,
15866 .values = {
15867 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15868 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15869 0
15870 },
15871};
15872
15873static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15874 .ops = &snd_hda_bind_sw,
15875 .values = {
15876 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15877 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15878 0
15879 },
15880};
15881
15882static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15883 HDA_BIND_VOL("Master Playback Volume",
15884 &alc663_asus_two_bind_master_vol),
15885 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15886 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015887 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15888 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15889 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015890 { } /* end */
15891};
15892
15893static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15894 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15895 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15896 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15897 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15898 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15899 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015900 { } /* end */
15901};
15902
15903static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15904 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15905 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15906 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15907 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15908 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15909
15910 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15911 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15912 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15913 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15914 { } /* end */
15915};
15916
15917static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15918 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15919 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15920 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15921
15922 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15923 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15924 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15925 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15926 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15927 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15928 { } /* end */
15929};
15930
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015931static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15932 {
15933 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15934 .name = "Channel Mode",
15935 .info = alc_ch_mode_info,
15936 .get = alc_ch_mode_get,
15937 .put = alc_ch_mode_put,
15938 },
15939 { } /* end */
15940};
15941
15942static struct hda_verb alc662_init_verbs[] = {
15943 /* ADC: mute amp left and right */
15944 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15945 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15946 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15947
Takashi Iwaicb53c622007-08-10 17:21:45 +020015948 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15949 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15950 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15951 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15952 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015953
Kailang Yangb60dd392007-09-20 12:50:29 +020015954 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15955 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15956 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15957 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15958 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15959 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015960
15961 /* Front Pin: output 0 (0x0c) */
15962 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15963 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15964
15965 /* Rear Pin: output 1 (0x0d) */
15966 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15967 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15968
15969 /* CLFE Pin: output 2 (0x0e) */
15970 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15971 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15972
15973 /* Mic (rear) pin: input vref at 80% */
15974 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15975 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15976 /* Front Mic pin: input vref at 80% */
15977 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15978 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15979 /* Line In pin: input */
15980 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15981 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15982 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15983 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15984 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15985 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15986 /* CD pin widget for input */
15987 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15988
15989 /* FIXME: use matrix-type input source selection */
15990 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15991 /* Input mixer */
15992 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020015993 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015994
15995 /* always trun on EAPD */
15996 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15997 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15998
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015999 { }
16000};
16001
16002static struct hda_verb alc662_sue_init_verbs[] = {
16003 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16004 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016005 {}
16006};
16007
16008static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16009 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16010 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16011 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016012};
16013
Kailang Yang8c427222008-01-10 13:03:59 +010016014/* Set Unsolicited Event*/
16015static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16016 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16017 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16018 {}
16019};
16020
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016021/*
16022 * generic initialization of ADC, input mixers and output mixers
16023 */
16024static struct hda_verb alc662_auto_init_verbs[] = {
16025 /*
16026 * Unmute ADC and set the default input to mic-in
16027 */
16028 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16029 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16030
16031 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16032 * mixer widget
16033 * Note: PASD motherboards uses the Line In 2 as the input for front
16034 * panel mic (mic 2)
16035 */
16036 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016037 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16038 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16039 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16040 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16041 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016042
16043 /*
16044 * Set up output mixers (0x0c - 0x0f)
16045 */
16046 /* set vol=0 to output mixers */
16047 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16048 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16049 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16050
16051 /* set up input amps for analog loopback */
16052 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020016053 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16054 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16055 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16056 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16057 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16058 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016059
16060
16061 /* FIXME: use matrix-type input source selection */
16062 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16063 /* Input mixer */
16064 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016065 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016066 { }
16067};
16068
Takashi Iwai24fb9172008-09-02 14:48:20 +020016069/* additional verbs for ALC663 */
16070static struct hda_verb alc663_auto_init_verbs[] = {
16071 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16072 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16073 { }
16074};
16075
Kailang Yang6dda9f42008-05-27 12:05:31 +020016076static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016077 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16078 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016079 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16080 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016081 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16082 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16083 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016084 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16085 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16086 {}
16087};
16088
Kailang Yangf1d4e282008-08-26 14:03:29 +020016089static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16090 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16091 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16092 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16093 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16094 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16095 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16096 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16097 {}
16098};
16099
16100static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16101 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16102 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16103 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16104 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16105 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16106 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16107 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16108 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16109 {}
16110};
16111
16112static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16113 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16114 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16115 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16116 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16117 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16118 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16119 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16120 {}
16121};
16122
16123static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16124 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16125 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16126 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16127 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16128 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16129 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16130 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16131 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16132 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16133 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16134 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16135 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16136 {}
16137};
16138
16139static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16140 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16141 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16142 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16143 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16144 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16145 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16146 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16147 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16148 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16149 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16150 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16151 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16152 {}
16153};
16154
Kailang Yang6dda9f42008-05-27 12:05:31 +020016155static struct hda_verb alc663_g71v_init_verbs[] = {
16156 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16157 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16158 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16159
16160 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16161 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16162 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16163
16164 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16165 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16166 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16167 {}
16168};
16169
16170static struct hda_verb alc663_g50v_init_verbs[] = {
16171 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16172 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16173 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16174
16175 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16176 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16177 {}
16178};
16179
Kailang Yangf1d4e282008-08-26 14:03:29 +020016180static struct hda_verb alc662_ecs_init_verbs[] = {
16181 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16182 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16183 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16184 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16185 {}
16186};
16187
Kailang Yang622e84c2009-04-21 07:39:04 +020016188static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16189 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16190 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16191 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16192 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16193 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16194 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16195 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16196 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16197 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16198 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16199 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16200 {}
16201};
16202
16203static struct hda_verb alc272_dell_init_verbs[] = {
16204 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16205 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16206 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16207 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16208 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16209 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16210 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16211 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16212 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16213 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16214 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16215 {}
16216};
16217
Kailang Yangf1d4e282008-08-26 14:03:29 +020016218static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16219 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16220 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16221 { } /* end */
16222};
16223
Kailang Yang622e84c2009-04-21 07:39:04 +020016224static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16225 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16226 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16227 { } /* end */
16228};
16229
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016230static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16231{
16232 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016233 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016234
16235 present = snd_hda_codec_read(codec, 0x14, 0,
16236 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016237 bits = present ? HDA_AMP_MUTE : 0;
16238 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16239 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016240}
16241
16242static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16243{
16244 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016245 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016246
16247 present = snd_hda_codec_read(codec, 0x1b, 0,
16248 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016249 bits = present ? HDA_AMP_MUTE : 0;
16250 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16251 HDA_AMP_MUTE, bits);
16252 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16253 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016254}
16255
16256static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16257 unsigned int res)
16258{
16259 if ((res >> 26) == ALC880_HP_EVENT)
16260 alc662_lenovo_101e_all_automute(codec);
16261 if ((res >> 26) == ALC880_FRONT_EVENT)
16262 alc662_lenovo_101e_ispeaker_automute(codec);
16263}
16264
Kailang Yang291702f2007-10-16 14:28:03 +020016265static void alc662_eeepc_mic_automute(struct hda_codec *codec)
16266{
16267 unsigned int present;
16268
16269 present = snd_hda_codec_read(codec, 0x18, 0,
16270 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
16271 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16272 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16273 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16274 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16275 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16276 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16277 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16278 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16279}
16280
16281/* unsolicited event for HP jack sensing */
16282static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16283 unsigned int res)
16284{
Kailang Yang291702f2007-10-16 14:28:03 +020016285 if ((res >> 26) == ALC880_MIC_EVENT)
16286 alc662_eeepc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016287 else
16288 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016289}
16290
16291static void alc662_eeepc_inithook(struct hda_codec *codec)
16292{
Takashi Iwai42171c12009-05-08 14:11:43 +020016293 alc262_hippo1_init_hook(codec);
Kailang Yang291702f2007-10-16 14:28:03 +020016294 alc662_eeepc_mic_automute(codec);
16295}
16296
Kailang Yang8c427222008-01-10 13:03:59 +010016297static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
16298{
Takashi Iwai42171c12009-05-08 14:11:43 +020016299 struct alc_spec *spec = codec->spec;
16300
16301 spec->autocfg.hp_pins[0] = 0x14;
16302 spec->autocfg.speaker_pins[0] = 0x1b;
16303 alc262_hippo_master_update(codec);
Kailang Yang8c427222008-01-10 13:03:59 +010016304}
16305
Kailang Yang6dda9f42008-05-27 12:05:31 +020016306static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16307{
16308 unsigned int present;
16309 unsigned char bits;
16310
16311 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016312 AC_VERB_GET_PIN_SENSE, 0)
16313 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016314 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016315 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16316 AMP_IN_MUTE(0), bits);
16317 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16318 AMP_IN_MUTE(0), bits);
16319}
16320
16321static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16322{
16323 unsigned int present;
16324 unsigned char bits;
16325
16326 present = snd_hda_codec_read(codec, 0x21, 0,
16327 AC_VERB_GET_PIN_SENSE, 0)
16328 & AC_PINSENSE_PRESENCE;
16329 bits = present ? HDA_AMP_MUTE : 0;
16330 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16331 AMP_IN_MUTE(0), bits);
16332 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16333 AMP_IN_MUTE(0), bits);
16334 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16335 AMP_IN_MUTE(0), bits);
16336 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16337 AMP_IN_MUTE(0), bits);
16338}
16339
16340static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16341{
16342 unsigned int present;
16343 unsigned char bits;
16344
16345 present = snd_hda_codec_read(codec, 0x15, 0,
16346 AC_VERB_GET_PIN_SENSE, 0)
16347 & AC_PINSENSE_PRESENCE;
16348 bits = present ? HDA_AMP_MUTE : 0;
16349 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16350 AMP_IN_MUTE(0), bits);
16351 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16352 AMP_IN_MUTE(0), bits);
16353 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16354 AMP_IN_MUTE(0), bits);
16355 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16356 AMP_IN_MUTE(0), bits);
16357}
16358
16359static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16360{
16361 unsigned int present;
16362 unsigned char bits;
16363
16364 present = snd_hda_codec_read(codec, 0x1b, 0,
16365 AC_VERB_GET_PIN_SENSE, 0)
16366 & AC_PINSENSE_PRESENCE;
16367 bits = present ? 0 : PIN_OUT;
16368 snd_hda_codec_write(codec, 0x14, 0,
16369 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16370}
16371
16372static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16373{
16374 unsigned int present1, present2;
16375
16376 present1 = snd_hda_codec_read(codec, 0x21, 0,
16377 AC_VERB_GET_PIN_SENSE, 0)
16378 & AC_PINSENSE_PRESENCE;
16379 present2 = snd_hda_codec_read(codec, 0x15, 0,
16380 AC_VERB_GET_PIN_SENSE, 0)
16381 & AC_PINSENSE_PRESENCE;
16382
16383 if (present1 || present2) {
16384 snd_hda_codec_write_cache(codec, 0x14, 0,
16385 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16386 } else {
16387 snd_hda_codec_write_cache(codec, 0x14, 0,
16388 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16389 }
16390}
16391
16392static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16393{
16394 unsigned int present1, present2;
16395
16396 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16397 AC_VERB_GET_PIN_SENSE, 0)
16398 & AC_PINSENSE_PRESENCE;
16399 present2 = snd_hda_codec_read(codec, 0x15, 0,
16400 AC_VERB_GET_PIN_SENSE, 0)
16401 & AC_PINSENSE_PRESENCE;
16402
16403 if (present1 || present2) {
16404 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16405 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16406 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16407 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16408 } else {
16409 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16410 AMP_IN_MUTE(0), 0);
16411 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16412 AMP_IN_MUTE(0), 0);
16413 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016414}
16415
16416static void alc663_m51va_mic_automute(struct hda_codec *codec)
16417{
16418 unsigned int present;
16419
16420 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016421 AC_VERB_GET_PIN_SENSE, 0)
16422 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016423 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016424 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016425 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016426 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016427 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016428 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016429 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016430 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016431}
16432
16433static void alc663_m51va_unsol_event(struct hda_codec *codec,
16434 unsigned int res)
16435{
16436 switch (res >> 26) {
16437 case ALC880_HP_EVENT:
16438 alc663_m51va_speaker_automute(codec);
16439 break;
16440 case ALC880_MIC_EVENT:
16441 alc663_m51va_mic_automute(codec);
16442 break;
16443 }
16444}
16445
16446static void alc663_m51va_inithook(struct hda_codec *codec)
16447{
16448 alc663_m51va_speaker_automute(codec);
16449 alc663_m51va_mic_automute(codec);
16450}
16451
Kailang Yangf1d4e282008-08-26 14:03:29 +020016452/* ***************** Mode1 ******************************/
16453static void alc663_mode1_unsol_event(struct hda_codec *codec,
16454 unsigned int res)
16455{
16456 switch (res >> 26) {
16457 case ALC880_HP_EVENT:
16458 alc663_m51va_speaker_automute(codec);
16459 break;
16460 case ALC880_MIC_EVENT:
16461 alc662_eeepc_mic_automute(codec);
16462 break;
16463 }
16464}
16465
16466static void alc663_mode1_inithook(struct hda_codec *codec)
16467{
16468 alc663_m51va_speaker_automute(codec);
16469 alc662_eeepc_mic_automute(codec);
16470}
16471/* ***************** Mode2 ******************************/
16472static void alc662_mode2_unsol_event(struct hda_codec *codec,
16473 unsigned int res)
16474{
16475 switch (res >> 26) {
16476 case ALC880_HP_EVENT:
16477 alc662_f5z_speaker_automute(codec);
16478 break;
16479 case ALC880_MIC_EVENT:
16480 alc662_eeepc_mic_automute(codec);
16481 break;
16482 }
16483}
16484
16485static void alc662_mode2_inithook(struct hda_codec *codec)
16486{
16487 alc662_f5z_speaker_automute(codec);
16488 alc662_eeepc_mic_automute(codec);
16489}
16490/* ***************** Mode3 ******************************/
16491static void alc663_mode3_unsol_event(struct hda_codec *codec,
16492 unsigned int res)
16493{
16494 switch (res >> 26) {
16495 case ALC880_HP_EVENT:
16496 alc663_two_hp_m1_speaker_automute(codec);
16497 break;
16498 case ALC880_MIC_EVENT:
16499 alc662_eeepc_mic_automute(codec);
16500 break;
16501 }
16502}
16503
16504static void alc663_mode3_inithook(struct hda_codec *codec)
16505{
16506 alc663_two_hp_m1_speaker_automute(codec);
16507 alc662_eeepc_mic_automute(codec);
16508}
16509/* ***************** Mode4 ******************************/
16510static void alc663_mode4_unsol_event(struct hda_codec *codec,
16511 unsigned int res)
16512{
16513 switch (res >> 26) {
16514 case ALC880_HP_EVENT:
16515 alc663_21jd_two_speaker_automute(codec);
16516 break;
16517 case ALC880_MIC_EVENT:
16518 alc662_eeepc_mic_automute(codec);
16519 break;
16520 }
16521}
16522
16523static void alc663_mode4_inithook(struct hda_codec *codec)
16524{
16525 alc663_21jd_two_speaker_automute(codec);
16526 alc662_eeepc_mic_automute(codec);
16527}
16528/* ***************** Mode5 ******************************/
16529static void alc663_mode5_unsol_event(struct hda_codec *codec,
16530 unsigned int res)
16531{
16532 switch (res >> 26) {
16533 case ALC880_HP_EVENT:
16534 alc663_15jd_two_speaker_automute(codec);
16535 break;
16536 case ALC880_MIC_EVENT:
16537 alc662_eeepc_mic_automute(codec);
16538 break;
16539 }
16540}
16541
16542static void alc663_mode5_inithook(struct hda_codec *codec)
16543{
16544 alc663_15jd_two_speaker_automute(codec);
16545 alc662_eeepc_mic_automute(codec);
16546}
16547/* ***************** Mode6 ******************************/
16548static void alc663_mode6_unsol_event(struct hda_codec *codec,
16549 unsigned int res)
16550{
16551 switch (res >> 26) {
16552 case ALC880_HP_EVENT:
16553 alc663_two_hp_m2_speaker_automute(codec);
16554 break;
16555 case ALC880_MIC_EVENT:
16556 alc662_eeepc_mic_automute(codec);
16557 break;
16558 }
16559}
16560
16561static void alc663_mode6_inithook(struct hda_codec *codec)
16562{
16563 alc663_two_hp_m2_speaker_automute(codec);
16564 alc662_eeepc_mic_automute(codec);
16565}
16566
Kailang Yang6dda9f42008-05-27 12:05:31 +020016567static void alc663_g71v_hp_automute(struct hda_codec *codec)
16568{
16569 unsigned int present;
16570 unsigned char bits;
16571
16572 present = snd_hda_codec_read(codec, 0x21, 0,
16573 AC_VERB_GET_PIN_SENSE, 0)
16574 & AC_PINSENSE_PRESENCE;
16575 bits = present ? HDA_AMP_MUTE : 0;
16576 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16577 HDA_AMP_MUTE, bits);
16578 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16579 HDA_AMP_MUTE, bits);
16580}
16581
16582static void alc663_g71v_front_automute(struct hda_codec *codec)
16583{
16584 unsigned int present;
16585 unsigned char bits;
16586
16587 present = snd_hda_codec_read(codec, 0x15, 0,
16588 AC_VERB_GET_PIN_SENSE, 0)
16589 & AC_PINSENSE_PRESENCE;
16590 bits = present ? HDA_AMP_MUTE : 0;
16591 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16592 HDA_AMP_MUTE, bits);
16593}
16594
16595static void alc663_g71v_unsol_event(struct hda_codec *codec,
16596 unsigned int res)
16597{
16598 switch (res >> 26) {
16599 case ALC880_HP_EVENT:
16600 alc663_g71v_hp_automute(codec);
16601 break;
16602 case ALC880_FRONT_EVENT:
16603 alc663_g71v_front_automute(codec);
16604 break;
16605 case ALC880_MIC_EVENT:
16606 alc662_eeepc_mic_automute(codec);
16607 break;
16608 }
16609}
16610
16611static void alc663_g71v_inithook(struct hda_codec *codec)
16612{
16613 alc663_g71v_front_automute(codec);
16614 alc663_g71v_hp_automute(codec);
16615 alc662_eeepc_mic_automute(codec);
16616}
16617
16618static void alc663_g50v_unsol_event(struct hda_codec *codec,
16619 unsigned int res)
16620{
16621 switch (res >> 26) {
16622 case ALC880_HP_EVENT:
16623 alc663_m51va_speaker_automute(codec);
16624 break;
16625 case ALC880_MIC_EVENT:
16626 alc662_eeepc_mic_automute(codec);
16627 break;
16628 }
16629}
16630
16631static void alc663_g50v_inithook(struct hda_codec *codec)
16632{
16633 alc663_m51va_speaker_automute(codec);
16634 alc662_eeepc_mic_automute(codec);
16635}
16636
Kailang Yangf1d4e282008-08-26 14:03:29 +020016637static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16638 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016639 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016640
16641 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16642 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16643 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16644
16645 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16646 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16647 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16648 { } /* end */
16649};
16650
Chris Pockelé9541ba12009-05-12 08:08:53 +020016651static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16652 /* Master Playback automatically created from Speaker and Headphone */
16653 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16654 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16655 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16656 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16657
16658 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16659 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16660 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16661
16662 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16663 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16664 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16665 { } /* end */
16666};
16667
Takashi Iwaicb53c622007-08-10 17:21:45 +020016668#ifdef CONFIG_SND_HDA_POWER_SAVE
16669#define alc662_loopbacks alc880_loopbacks
16670#endif
16671
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016672
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016673/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016674#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16675#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16676#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16677#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16678
16679/*
16680 * configuration and preset
16681 */
16682static const char *alc662_models[ALC662_MODEL_LAST] = {
16683 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16684 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16685 [ALC662_3ST_6ch] = "3stack-6ch",
16686 [ALC662_5ST_DIG] = "6stack-dig",
16687 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016688 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016689 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016690 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016691 [ALC663_ASUS_M51VA] = "m51va",
16692 [ALC663_ASUS_G71V] = "g71v",
16693 [ALC663_ASUS_H13] = "h13",
16694 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016695 [ALC663_ASUS_MODE1] = "asus-mode1",
16696 [ALC662_ASUS_MODE2] = "asus-mode2",
16697 [ALC663_ASUS_MODE3] = "asus-mode3",
16698 [ALC663_ASUS_MODE4] = "asus-mode4",
16699 [ALC663_ASUS_MODE5] = "asus-mode5",
16700 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016701 [ALC272_DELL] = "dell",
16702 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016703 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016704 [ALC662_AUTO] = "auto",
16705};
16706
16707static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016708 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016709 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16710 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016711 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16712 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16713 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16714 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16715 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16716 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16717 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16718 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16719 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16720 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16721 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16722 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016723 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16724 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16725 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016726 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16727 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16728 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16729 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016730 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016731 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16732 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016733 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016734 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16735 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16736 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016737 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16738 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16739 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016740 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16741 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16742 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016743 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016744 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16745 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016746 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016747 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016748 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016749 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16750 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16751 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016752 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016753 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16754 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016755 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016756 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016757 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016758 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016759 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16760 ALC662_3ST_6ch_DIG),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016761 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016762 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16763 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016764 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016765 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016766 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016767 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016768 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016769 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16770 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016771 {}
16772};
16773
16774static struct alc_config_preset alc662_presets[] = {
16775 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016776 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016777 .init_verbs = { alc662_init_verbs },
16778 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16779 .dac_nids = alc662_dac_nids,
16780 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016781 .dig_in_nid = ALC662_DIGIN_NID,
16782 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16783 .channel_mode = alc662_3ST_2ch_modes,
16784 .input_mux = &alc662_capture_source,
16785 },
16786 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016787 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016788 .init_verbs = { alc662_init_verbs },
16789 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16790 .dac_nids = alc662_dac_nids,
16791 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016792 .dig_in_nid = ALC662_DIGIN_NID,
16793 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16794 .channel_mode = alc662_3ST_6ch_modes,
16795 .need_dac_fix = 1,
16796 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016797 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016798 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016799 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016800 .init_verbs = { alc662_init_verbs },
16801 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16802 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016803 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16804 .channel_mode = alc662_3ST_6ch_modes,
16805 .need_dac_fix = 1,
16806 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016807 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016808 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016809 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016810 .init_verbs = { alc662_init_verbs },
16811 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16812 .dac_nids = alc662_dac_nids,
16813 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016814 .dig_in_nid = ALC662_DIGIN_NID,
16815 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16816 .channel_mode = alc662_5stack_modes,
16817 .input_mux = &alc662_capture_source,
16818 },
16819 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016820 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016821 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16822 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16823 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016824 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16825 .channel_mode = alc662_3ST_2ch_modes,
16826 .input_mux = &alc662_lenovo_101e_capture_source,
16827 .unsol_event = alc662_lenovo_101e_unsol_event,
16828 .init_hook = alc662_lenovo_101e_all_automute,
16829 },
Kailang Yang291702f2007-10-16 14:28:03 +020016830 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016831 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016832 .init_verbs = { alc662_init_verbs,
16833 alc662_eeepc_sue_init_verbs },
16834 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16835 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016836 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16837 .channel_mode = alc662_3ST_2ch_modes,
16838 .input_mux = &alc662_eeepc_capture_source,
16839 .unsol_event = alc662_eeepc_unsol_event,
16840 .init_hook = alc662_eeepc_inithook,
16841 },
Kailang Yang8c427222008-01-10 13:03:59 +010016842 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016843 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016844 alc662_chmode_mixer },
16845 .init_verbs = { alc662_init_verbs,
16846 alc662_eeepc_ep20_sue_init_verbs },
16847 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16848 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016849 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16850 .channel_mode = alc662_3ST_6ch_modes,
16851 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016852 .unsol_event = alc662_eeepc_unsol_event,
Kailang Yang8c427222008-01-10 13:03:59 +010016853 .init_hook = alc662_eeepc_ep20_inithook,
16854 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016855 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016856 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016857 .init_verbs = { alc662_init_verbs,
16858 alc662_ecs_init_verbs },
16859 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16860 .dac_nids = alc662_dac_nids,
16861 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16862 .channel_mode = alc662_3ST_2ch_modes,
16863 .input_mux = &alc662_eeepc_capture_source,
16864 .unsol_event = alc662_eeepc_unsol_event,
16865 .init_hook = alc662_eeepc_inithook,
16866 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016867 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016868 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016869 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16870 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16871 .dac_nids = alc662_dac_nids,
16872 .dig_out_nid = ALC662_DIGOUT_NID,
16873 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16874 .channel_mode = alc662_3ST_2ch_modes,
16875 .input_mux = &alc663_m51va_capture_source,
16876 .unsol_event = alc663_m51va_unsol_event,
16877 .init_hook = alc663_m51va_inithook,
16878 },
16879 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016880 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016881 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16882 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16883 .dac_nids = alc662_dac_nids,
16884 .dig_out_nid = ALC662_DIGOUT_NID,
16885 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16886 .channel_mode = alc662_3ST_2ch_modes,
16887 .input_mux = &alc662_eeepc_capture_source,
16888 .unsol_event = alc663_g71v_unsol_event,
16889 .init_hook = alc663_g71v_inithook,
16890 },
16891 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016892 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016893 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16894 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16895 .dac_nids = alc662_dac_nids,
16896 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16897 .channel_mode = alc662_3ST_2ch_modes,
16898 .input_mux = &alc663_m51va_capture_source,
16899 .unsol_event = alc663_m51va_unsol_event,
16900 .init_hook = alc663_m51va_inithook,
16901 },
16902 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016903 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016904 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16905 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16906 .dac_nids = alc662_dac_nids,
16907 .dig_out_nid = ALC662_DIGOUT_NID,
16908 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16909 .channel_mode = alc662_3ST_6ch_modes,
16910 .input_mux = &alc663_capture_source,
16911 .unsol_event = alc663_g50v_unsol_event,
16912 .init_hook = alc663_g50v_inithook,
16913 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016914 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016915 .mixers = { alc663_m51va_mixer },
16916 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016917 .init_verbs = { alc662_init_verbs,
16918 alc663_21jd_amic_init_verbs },
16919 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16920 .hp_nid = 0x03,
16921 .dac_nids = alc662_dac_nids,
16922 .dig_out_nid = ALC662_DIGOUT_NID,
16923 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16924 .channel_mode = alc662_3ST_2ch_modes,
16925 .input_mux = &alc662_eeepc_capture_source,
16926 .unsol_event = alc663_mode1_unsol_event,
16927 .init_hook = alc663_mode1_inithook,
16928 },
16929 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016930 .mixers = { alc662_1bjd_mixer },
16931 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016932 .init_verbs = { alc662_init_verbs,
16933 alc662_1bjd_amic_init_verbs },
16934 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16935 .dac_nids = alc662_dac_nids,
16936 .dig_out_nid = ALC662_DIGOUT_NID,
16937 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16938 .channel_mode = alc662_3ST_2ch_modes,
16939 .input_mux = &alc662_eeepc_capture_source,
16940 .unsol_event = alc662_mode2_unsol_event,
16941 .init_hook = alc662_mode2_inithook,
16942 },
16943 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016944 .mixers = { alc663_two_hp_m1_mixer },
16945 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016946 .init_verbs = { alc662_init_verbs,
16947 alc663_two_hp_amic_m1_init_verbs },
16948 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16949 .hp_nid = 0x03,
16950 .dac_nids = alc662_dac_nids,
16951 .dig_out_nid = ALC662_DIGOUT_NID,
16952 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16953 .channel_mode = alc662_3ST_2ch_modes,
16954 .input_mux = &alc662_eeepc_capture_source,
16955 .unsol_event = alc663_mode3_unsol_event,
16956 .init_hook = alc663_mode3_inithook,
16957 },
16958 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016959 .mixers = { alc663_asus_21jd_clfe_mixer },
16960 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016961 .init_verbs = { alc662_init_verbs,
16962 alc663_21jd_amic_init_verbs},
16963 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16964 .hp_nid = 0x03,
16965 .dac_nids = alc662_dac_nids,
16966 .dig_out_nid = ALC662_DIGOUT_NID,
16967 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16968 .channel_mode = alc662_3ST_2ch_modes,
16969 .input_mux = &alc662_eeepc_capture_source,
16970 .unsol_event = alc663_mode4_unsol_event,
16971 .init_hook = alc663_mode4_inithook,
16972 },
16973 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016974 .mixers = { alc663_asus_15jd_clfe_mixer },
16975 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016976 .init_verbs = { alc662_init_verbs,
16977 alc663_15jd_amic_init_verbs },
16978 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16979 .hp_nid = 0x03,
16980 .dac_nids = alc662_dac_nids,
16981 .dig_out_nid = ALC662_DIGOUT_NID,
16982 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16983 .channel_mode = alc662_3ST_2ch_modes,
16984 .input_mux = &alc662_eeepc_capture_source,
16985 .unsol_event = alc663_mode5_unsol_event,
16986 .init_hook = alc663_mode5_inithook,
16987 },
16988 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016989 .mixers = { alc663_two_hp_m2_mixer },
16990 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016991 .init_verbs = { alc662_init_verbs,
16992 alc663_two_hp_amic_m2_init_verbs },
16993 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16994 .hp_nid = 0x03,
16995 .dac_nids = alc662_dac_nids,
16996 .dig_out_nid = ALC662_DIGOUT_NID,
16997 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16998 .channel_mode = alc662_3ST_2ch_modes,
16999 .input_mux = &alc662_eeepc_capture_source,
17000 .unsol_event = alc663_mode6_unsol_event,
17001 .init_hook = alc663_mode6_inithook,
17002 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017003 [ALC272_DELL] = {
17004 .mixers = { alc663_m51va_mixer },
17005 .cap_mixer = alc272_auto_capture_mixer,
17006 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17007 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17008 .dac_nids = alc662_dac_nids,
17009 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17010 .adc_nids = alc272_adc_nids,
17011 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17012 .capsrc_nids = alc272_capsrc_nids,
17013 .channel_mode = alc662_3ST_2ch_modes,
17014 .input_mux = &alc663_m51va_capture_source,
17015 .unsol_event = alc663_m51va_unsol_event,
17016 .init_hook = alc663_m51va_inithook,
17017 },
17018 [ALC272_DELL_ZM1] = {
17019 .mixers = { alc663_m51va_mixer },
17020 .cap_mixer = alc662_auto_capture_mixer,
17021 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17022 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17023 .dac_nids = alc662_dac_nids,
17024 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17025 .adc_nids = alc662_adc_nids,
17026 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
17027 .capsrc_nids = alc662_capsrc_nids,
17028 .channel_mode = alc662_3ST_2ch_modes,
17029 .input_mux = &alc663_m51va_capture_source,
17030 .unsol_event = alc663_m51va_unsol_event,
17031 .init_hook = alc663_m51va_inithook,
17032 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017033 [ALC272_SAMSUNG_NC10] = {
17034 .mixers = { alc272_nc10_mixer },
17035 .init_verbs = { alc662_init_verbs,
17036 alc663_21jd_amic_init_verbs },
17037 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17038 .dac_nids = alc272_dac_nids,
17039 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17040 .channel_mode = alc662_3ST_2ch_modes,
17041 .input_mux = &alc272_nc10_capture_source,
17042 .unsol_event = alc663_mode4_unsol_event,
17043 .init_hook = alc663_mode4_inithook,
17044 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017045};
17046
17047
17048/*
17049 * BIOS auto configuration
17050 */
17051
17052/* add playback controls from the parsed DAC table */
17053static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
17054 const struct auto_pin_cfg *cfg)
17055{
17056 char name[32];
17057 static const char *chname[4] = {
17058 "Front", "Surround", NULL /*CLFE*/, "Side"
17059 };
17060 hda_nid_t nid;
17061 int i, err;
17062
17063 for (i = 0; i < cfg->line_outs; i++) {
17064 if (!spec->multiout.dac_nids[i])
17065 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020017066 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017067 if (i == 2) {
17068 /* Center/LFE */
17069 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17070 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017071 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
17072 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017073 if (err < 0)
17074 return err;
17075 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17076 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017077 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
17078 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017079 if (err < 0)
17080 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017081 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017082 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017083 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017084 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017085 if (err < 0)
17086 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017087 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017088 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017089 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017090 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017091 if (err < 0)
17092 return err;
17093 } else {
17094 sprintf(name, "%s Playback Volume", chname[i]);
17095 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017096 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
17097 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017098 if (err < 0)
17099 return err;
17100 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017101 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17102 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
17103 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017104 if (err < 0)
17105 return err;
17106 }
17107 }
17108 return 0;
17109}
17110
17111/* add playback controls for speaker and HP outputs */
17112static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
17113 const char *pfx)
17114{
17115 hda_nid_t nid;
17116 int err;
17117 char name[32];
17118
17119 if (!pin)
17120 return 0;
17121
Takashi Iwai24fb9172008-09-02 14:48:20 +020017122 if (pin == 0x17) {
17123 /* ALC663 has a mono output pin on 0x17 */
17124 sprintf(name, "%s Playback Switch", pfx);
17125 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17126 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
17127 return err;
17128 }
17129
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017130 if (alc880_is_fixed_pin(pin)) {
17131 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010017132 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017133 /* specify the DAC as the extra output */
17134 if (!spec->multiout.hp_nid)
17135 spec->multiout.hp_nid = nid;
17136 else
17137 spec->multiout.extra_out_nid[0] = nid;
17138 /* control HP volume/switch on the output mixer amp */
17139 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17140 sprintf(name, "%s Playback Volume", pfx);
17141 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
17142 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
17143 if (err < 0)
17144 return err;
17145 sprintf(name, "%s Playback Switch", pfx);
17146 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
17147 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
17148 if (err < 0)
17149 return err;
17150 } else if (alc880_is_multi_pin(pin)) {
17151 /* set manual connection */
17152 /* we have only a switch on HP-out PIN */
17153 sprintf(name, "%s Playback Switch", pfx);
17154 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17155 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17156 if (err < 0)
17157 return err;
17158 }
17159 return 0;
17160}
17161
Takashi Iwai2d864c42009-03-20 12:52:47 +010017162/* return the index of the src widget from the connection list of the nid.
17163 * return -1 if not found
17164 */
17165static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
17166 hda_nid_t src)
17167{
17168 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
17169 int i, conns;
17170
17171 conns = snd_hda_get_connections(codec, nid, conn_list,
17172 ARRAY_SIZE(conn_list));
17173 if (conns < 0)
17174 return -1;
17175 for (i = 0; i < conns; i++)
17176 if (conn_list[i] == src)
17177 return i;
17178 return -1;
17179}
17180
17181static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
17182{
Takashi Iwai1327a322009-03-23 13:07:47 +010017183 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010017184 return (pincap & AC_PINCAP_IN) != 0;
17185}
17186
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017187/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010017188static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017189 const struct auto_pin_cfg *cfg)
17190{
Takashi Iwai2d864c42009-03-20 12:52:47 +010017191 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017192 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017193 int i, err, idx;
17194
17195 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010017196 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
17197 idx = alc662_input_pin_idx(codec, 0x0b,
17198 cfg->input_pins[i]);
17199 if (idx >= 0) {
17200 err = new_analog_input(spec, cfg->input_pins[i],
17201 auto_pin_cfg_labels[i],
17202 idx, 0x0b);
17203 if (err < 0)
17204 return err;
17205 }
17206 idx = alc662_input_pin_idx(codec, 0x22,
17207 cfg->input_pins[i]);
17208 if (idx >= 0) {
17209 imux->items[imux->num_items].label =
17210 auto_pin_cfg_labels[i];
17211 imux->items[imux->num_items].index = idx;
17212 imux->num_items++;
17213 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017214 }
17215 }
17216 return 0;
17217}
17218
17219static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17220 hda_nid_t nid, int pin_type,
17221 int dac_idx)
17222{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017223 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017224 /* need the manual connection? */
17225 if (alc880_is_multi_pin(nid)) {
17226 struct alc_spec *spec = codec->spec;
17227 int idx = alc880_multi_pin_idx(nid);
17228 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
17229 AC_VERB_SET_CONNECT_SEL,
17230 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
17231 }
17232}
17233
17234static void alc662_auto_init_multi_out(struct hda_codec *codec)
17235{
17236 struct alc_spec *spec = codec->spec;
17237 int i;
17238
17239 for (i = 0; i <= HDA_SIDE; i++) {
17240 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017241 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017242 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017243 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017244 i);
17245 }
17246}
17247
17248static void alc662_auto_init_hp_out(struct hda_codec *codec)
17249{
17250 struct alc_spec *spec = codec->spec;
17251 hda_nid_t pin;
17252
17253 pin = spec->autocfg.hp_pins[0];
17254 if (pin) /* connect to front */
17255 /* use dac 0 */
17256 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017257 pin = spec->autocfg.speaker_pins[0];
17258 if (pin)
17259 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017260}
17261
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017262#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17263
17264static void alc662_auto_init_analog_input(struct hda_codec *codec)
17265{
17266 struct alc_spec *spec = codec->spec;
17267 int i;
17268
17269 for (i = 0; i < AUTO_PIN_LAST; i++) {
17270 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010017271 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017272 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017273 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017274 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017275 snd_hda_codec_write(codec, nid, 0,
17276 AC_VERB_SET_AMP_GAIN_MUTE,
17277 AMP_OUT_MUTE);
17278 }
17279 }
17280}
17281
Takashi Iwaif511b012008-08-15 16:46:42 +020017282#define alc662_auto_init_input_src alc882_auto_init_input_src
17283
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017284static int alc662_parse_auto_config(struct hda_codec *codec)
17285{
17286 struct alc_spec *spec = codec->spec;
17287 int err;
17288 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17289
17290 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17291 alc662_ignore);
17292 if (err < 0)
17293 return err;
17294 if (!spec->autocfg.line_outs)
17295 return 0; /* can't find valid BIOS pin config */
17296
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017297 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17298 if (err < 0)
17299 return err;
17300 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
17301 if (err < 0)
17302 return err;
17303 err = alc662_auto_create_extra_out(spec,
17304 spec->autocfg.speaker_pins[0],
17305 "Speaker");
17306 if (err < 0)
17307 return err;
17308 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
17309 "Headphone");
17310 if (err < 0)
17311 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010017312 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017313 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017314 return err;
17315
17316 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17317
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017318 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017319 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17320
Takashi Iwai603c4012008-07-30 15:01:44 +020017321 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017322 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017323
17324 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017325 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017326
Takashi Iwaid88897e2008-10-31 15:01:37 +010017327 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017328 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017329 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017330
17331 err = alc_auto_add_mic_boost(codec);
17332 if (err < 0)
17333 return err;
17334
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017335 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17336
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017337 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017338}
17339
17340/* additional initialization for auto-configuration model */
17341static void alc662_auto_init(struct hda_codec *codec)
17342{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017343 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017344 alc662_auto_init_multi_out(codec);
17345 alc662_auto_init_hp_out(codec);
17346 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017347 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017348 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017349 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017350}
17351
17352static int patch_alc662(struct hda_codec *codec)
17353{
17354 struct alc_spec *spec;
17355 int err, board_config;
17356
17357 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17358 if (!spec)
17359 return -ENOMEM;
17360
17361 codec->spec = spec;
17362
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017363 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17364
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017365 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17366 alc662_models,
17367 alc662_cfg_tbl);
17368 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020017369 printk(KERN_INFO "hda_codec: Unknown model for %s, "
17370 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017371 board_config = ALC662_AUTO;
17372 }
17373
17374 if (board_config == ALC662_AUTO) {
17375 /* automatic parse from the BIOS config */
17376 err = alc662_parse_auto_config(codec);
17377 if (err < 0) {
17378 alc_free(codec);
17379 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017380 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017381 printk(KERN_INFO
17382 "hda_codec: Cannot set up configuration "
17383 "from BIOS. Using base mode...\n");
17384 board_config = ALC662_3ST_2ch_DIG;
17385 }
17386 }
17387
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017388 err = snd_hda_attach_beep_device(codec, 0x1);
17389 if (err < 0) {
17390 alc_free(codec);
17391 return err;
17392 }
17393
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017394 if (board_config != ALC662_AUTO)
17395 setup_preset(spec, &alc662_presets[board_config]);
17396
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017397 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17398 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17399
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017400 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17401 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17402
Takashi Iwaie1406342008-02-11 18:32:32 +010017403 spec->adc_nids = alc662_adc_nids;
17404 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17405 spec->capsrc_nids = alc662_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017406 spec->capture_style = CAPT_MIX;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017407
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017408 if (!spec->cap_mixer)
17409 set_capture_mixer(spec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017410 if (codec->vendor_id == 0x10ec0662)
17411 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17412 else
17413 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017414
Takashi Iwai2134ea42008-01-10 16:53:55 +010017415 spec->vmaster_nid = 0x02;
17416
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017417 codec->patch_ops = alc_patch_ops;
17418 if (board_config == ALC662_AUTO)
17419 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017420#ifdef CONFIG_SND_HDA_POWER_SAVE
17421 if (!spec->loopback.amplist)
17422 spec->loopback.amplist = alc662_loopbacks;
17423#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017424 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017425
17426 return 0;
17427}
17428
17429/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017430 * patch entries
17431 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017432static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017433 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017434 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017435 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017436 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017437 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017438 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017439 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017440 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017441 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17442 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17443 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017444 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
17445 .patch = patch_alc883 },
17446 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17447 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017448 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017449 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017450 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020017451 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020017452 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
17453 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020017454 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020017455 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010017456 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020017457 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020017458 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
17459 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080017460 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017461 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017462 {} /* terminator */
17463};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017464
17465MODULE_ALIAS("snd-hda-codec-id:10ec*");
17466
17467MODULE_LICENSE("GPL");
17468MODULE_DESCRIPTION("Realtek HD-audio codec");
17469
17470static struct hda_codec_preset_list realtek_list = {
17471 .preset = snd_hda_preset_realtek,
17472 .owner = THIS_MODULE,
17473};
17474
17475static int __init patch_realtek_init(void)
17476{
17477 return snd_hda_add_codec_preset(&realtek_list);
17478}
17479
17480static void __exit patch_realtek_exit(void)
17481{
17482 snd_hda_delete_codec_preset(&realtek_list);
17483}
17484
17485module_init(patch_realtek_init)
17486module_exit(patch_realtek_exit)